🎨 Misc. tweaks to HALs
This commit is contained in:
parent
5859ff0280
commit
4e1bfc4e0d
|
@ -109,7 +109,7 @@ void PRINT_ARRAY_NAME(uint8_t x) {
|
||||||
* Print a pin's PWM status.
|
* Print a pin's PWM status.
|
||||||
* Return true if it's currently a PWM pin.
|
* Return true if it's currently a PWM pin.
|
||||||
*/
|
*/
|
||||||
static bool pwm_status(uint8_t pin) {
|
bool pwm_status(uint8_t pin) {
|
||||||
char buffer[20]; // for the sprintf statements
|
char buffer[20]; // for the sprintf statements
|
||||||
|
|
||||||
switch (digitalPinToTimer_DEBUG(pin)) {
|
switch (digitalPinToTimer_DEBUG(pin)) {
|
||||||
|
@ -232,12 +232,12 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
|
||||||
|
|
||||||
#define OCR_VAL(T, L) pgm_read_word(&PWM_OCR[T][L])
|
#define OCR_VAL(T, L) pgm_read_word(&PWM_OCR[T][L])
|
||||||
|
|
||||||
static void err_is_counter() { SERIAL_ECHOPGM(" non-standard PWM mode"); }
|
void err_is_counter() { SERIAL_ECHOPGM(" non-standard PWM mode"); }
|
||||||
static void err_is_interrupt() { SERIAL_ECHOPGM(" compare interrupt enabled"); }
|
void err_is_interrupt() { SERIAL_ECHOPGM(" compare interrupt enabled"); }
|
||||||
static void err_prob_interrupt() { SERIAL_ECHOPGM(" overflow interrupt enabled"); }
|
void err_prob_interrupt() { SERIAL_ECHOPGM(" overflow interrupt enabled"); }
|
||||||
static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin"); SERIAL_ECHO_SP(14); }
|
void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin"); SERIAL_ECHO_SP(14); }
|
||||||
|
|
||||||
inline void com_print(const uint8_t N, const uint8_t Z) {
|
void com_print(const uint8_t N, const uint8_t Z) {
|
||||||
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
|
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
|
||||||
SERIAL_ECHOPGM(" COM", AS_DIGIT(N));
|
SERIAL_ECHOPGM(" COM", AS_DIGIT(N));
|
||||||
SERIAL_CHAR(Z);
|
SERIAL_CHAR(Z);
|
||||||
|
@ -279,7 +279,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
|
||||||
if (TEST(*TMSK, TOIE)) err_prob_interrupt();
|
if (TEST(*TMSK, TOIE)) err_prob_interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pwm_details(uint8_t pin) {
|
void pwm_details(uint8_t pin) {
|
||||||
switch (digitalPinToTimer_DEBUG(pin)) {
|
switch (digitalPinToTimer_DEBUG(pin)) {
|
||||||
|
|
||||||
#if ABTEST(0)
|
#if ABTEST(0)
|
||||||
|
@ -353,47 +353,41 @@ static void pwm_details(uint8_t pin) {
|
||||||
} // pwm_details
|
} // pwm_details
|
||||||
|
|
||||||
#ifndef digitalRead_mod // Use Teensyduino's version of digitalRead - it doesn't disable the PWMs
|
#ifndef digitalRead_mod // Use Teensyduino's version of digitalRead - it doesn't disable the PWMs
|
||||||
int digitalRead_mod(const int8_t pin) { // same as digitalRead except the PWM stop section has been removed
|
int digitalRead_mod(const pin_t pin) { // same as digitalRead except the PWM stop section has been removed
|
||||||
const uint8_t port = digitalPinToPort_DEBUG(pin);
|
const uint8_t port = digitalPinToPort_DEBUG(pin);
|
||||||
return (port != NOT_A_PIN) && (*portInputRegister(port) & digitalPinToBitMask_DEBUG(pin)) ? HIGH : LOW;
|
return (port != NOT_A_PIN) && (*portInputRegister(port) & digitalPinToBitMask_DEBUG(pin)) ? HIGH : LOW;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PRINT_PORT
|
void print_port(const pin_t pin) { // print port number
|
||||||
|
#ifdef digitalPinToPort_DEBUG
|
||||||
|
uint8_t x;
|
||||||
|
SERIAL_ECHOPGM(" Port: ");
|
||||||
|
#if AVR_AT90USB1286_FAMILY
|
||||||
|
x = (pin == 46 || pin == 47) ? 'E' : digitalPinToPort_DEBUG(pin) + 64;
|
||||||
|
#else
|
||||||
|
x = digitalPinToPort_DEBUG(pin) + 64;
|
||||||
|
#endif
|
||||||
|
SERIAL_CHAR(x);
|
||||||
|
|
||||||
void print_port(int8_t pin) { // print port number
|
#if AVR_AT90USB1286_FAMILY
|
||||||
#ifdef digitalPinToPort_DEBUG
|
if (pin == 46)
|
||||||
uint8_t x;
|
x = '2';
|
||||||
SERIAL_ECHOPGM(" Port: ");
|
else if (pin == 47)
|
||||||
#if AVR_AT90USB1286_FAMILY
|
x = '3';
|
||||||
x = (pin == 46 || pin == 47) ? 'E' : digitalPinToPort_DEBUG(pin) + 64;
|
else {
|
||||||
#else
|
|
||||||
x = digitalPinToPort_DEBUG(pin) + 64;
|
|
||||||
#endif
|
|
||||||
SERIAL_CHAR(x);
|
|
||||||
|
|
||||||
#if AVR_AT90USB1286_FAMILY
|
|
||||||
if (pin == 46)
|
|
||||||
x = '2';
|
|
||||||
else if (pin == 47)
|
|
||||||
x = '3';
|
|
||||||
else {
|
|
||||||
uint8_t temp = digitalPinToBitMask_DEBUG(pin);
|
|
||||||
for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
uint8_t temp = digitalPinToBitMask_DEBUG(pin);
|
uint8_t temp = digitalPinToBitMask_DEBUG(pin);
|
||||||
for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
|
for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
|
||||||
#endif
|
}
|
||||||
SERIAL_CHAR(x);
|
|
||||||
#else
|
#else
|
||||||
SERIAL_ECHO_SP(10);
|
uint8_t temp = digitalPinToBitMask_DEBUG(pin);
|
||||||
|
for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
SERIAL_CHAR(x);
|
||||||
|
#else
|
||||||
#define PRINT_PORT(p) print_port(p)
|
SERIAL_ECHO_SP(10);
|
||||||
|
#endif
|
||||||
#endif
|
}
|
||||||
|
|
||||||
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
|
|
|
@ -22,11 +22,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
//
|
//
|
||||||
// some of the pin mapping functions of the Teensduino extension to the Arduino IDE
|
// Some of the pin mapping functions of the Arduino IDE Teensduino extension
|
||||||
// do not function the same as the other Arduino extensions
|
// function differently from other Arduino extensions.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#define TEENSYDUINO_IDE
|
#define TEENSYDUINO_IDE
|
||||||
|
|
||||||
//digitalPinToTimer(pin) function works like Arduino but Timers are not defined
|
//digitalPinToTimer(pin) function works like Arduino but Timers are not defined
|
||||||
|
@ -48,8 +47,6 @@
|
||||||
#define PE 5
|
#define PE 5
|
||||||
#define PF 6
|
#define PF 6
|
||||||
|
|
||||||
#undef digitalPinToPort
|
|
||||||
|
|
||||||
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
||||||
PD, // 0 - PD0 - INT0 - PWM
|
PD, // 0 - PD0 - INT0 - PWM
|
||||||
PD, // 1 - PD1 - INT1 - PWM
|
PD, // 1 - PD1 - INT1 - PWM
|
||||||
|
@ -101,7 +98,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
||||||
PE, // 47 - PE3 (not defined in teensyduino)
|
PE, // 47 - PE3 (not defined in teensyduino)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
|
#define digitalPinToPort(P) pgm_read_byte(digital_pin_to_port_PGM[P])
|
||||||
|
|
||||||
// digitalPinToBitMask(pin) is OK
|
// digitalPinToBitMask(pin) is OK
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,6 @@
|
||||||
#define NUMBER_PINS_TOTAL PINS_COUNT
|
#define NUMBER_PINS_TOTAL PINS_COUNT
|
||||||
|
|
||||||
#define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin
|
#define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin
|
||||||
#define PRINT_PORT(p)
|
|
||||||
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
|
@ -93,6 +92,8 @@ void pwm_details(int32_t pin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_port(const pin_t) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DUE Board pin | PORT | Label
|
* DUE Board pin | PORT | Label
|
||||||
* ----------------+--------+-------
|
* ----------------+--------+-------
|
||||||
|
|
|
@ -52,8 +52,7 @@ uint8_t MarlinHAL::active_ch = 0;
|
||||||
uint16_t MarlinHAL::adc_value() {
|
uint16_t MarlinHAL::adc_value() {
|
||||||
const pin_t pin = analogInputToDigitalPin(active_ch);
|
const pin_t pin = analogInputToDigitalPin(active_ch);
|
||||||
if (!VALID_PIN(pin)) return 0;
|
if (!VALID_PIN(pin)) return 0;
|
||||||
const uint16_t data = ((Gpio::get(pin) >> 2) & 0x3FF);
|
return uint16_t((Gpio::get(pin) >> 2) & 0x3FF); // return 10bit value as Marlin expects
|
||||||
return data; // return 10bit value as Marlin expects
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarlinHAL::reboot() { /* Reset the application state and GPIO */ }
|
void MarlinHAL::reboot() { /* Reset the application state and GPIO */ }
|
||||||
|
|
|
@ -28,36 +28,33 @@
|
||||||
* Translation of routines & variables used by pinsDebug.h
|
* Translation of routines & variables used by pinsDebug.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
||||||
#define pwm_details(pin) NOOP // (do nothing)
|
|
||||||
#define pwm_status(pin) false // Print a pin's PWM status. Return true if it's currently a PWM pin.
|
|
||||||
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
|
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
|
||||||
#define digitalRead_mod(p) digitalRead(p)
|
#define digitalRead_mod(p) digitalRead(p)
|
||||||
#define PRINT_PORT(p)
|
|
||||||
#define GET_ARRAY_PIN(p) pin_array[p].pin
|
#define GET_ARRAY_PIN(p) pin_array[p].pin
|
||||||
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
// active ADC function/mode/code values for PINSEL registers
|
// active ADC function/mode/code values for PINSEL registers
|
||||||
constexpr int8_t ADC_pin_mode(pin_t pin) {
|
constexpr int8_t ADC_pin_mode(pin_t pin) { return -1; }
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t get_pin_mode(pin_t pin) {
|
int8_t get_pin_mode(const pin_t pin) { return VALID_PIN(pin) ? 0 : -1; }
|
||||||
if (!VALID_PIN(pin)) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GET_PINMODE(pin_t pin) {
|
bool GET_PINMODE(const pin_t pin) {
|
||||||
int8_t pin_mode = get_pin_mode(pin);
|
const int8_t pin_mode = get_pin_mode(pin);
|
||||||
if (pin_mode == -1 || pin_mode == ADC_pin_mode(pin)) // found an invalid pin or active analog pin
|
if (pin_mode == -1 || pin_mode == ADC_pin_mode(pin)) // Invalid pin or active analog pin
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (Gpio::getMode(pin) != 0); //input/output state
|
return (Gpio::getMode(pin) != 0); // Input/output state
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GET_ARRAY_IS_DIGITAL(pin_t pin) {
|
bool GET_ARRAY_IS_DIGITAL(const pin_t pin) {
|
||||||
return (!IS_ANALOG(pin) || get_pin_mode(pin) != ADC_pin_mode(pin));
|
return (!IS_ANALOG(pin) || get_pin_mode(pin) != ADC_pin_mode(pin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pwm_details(const pin_t pin) {}
|
||||||
|
bool pwm_status(const pin_t) { return false; }
|
||||||
|
|
||||||
|
void print_port(const pin_t) {}
|
||||||
|
|
|
@ -29,11 +29,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
||||||
#define pwm_details(pin) pin = pin // do nothing // print PWM details
|
|
||||||
#define pwm_status(pin) false //Print a pin's PWM status. Return true if it's currently a PWM pin.
|
|
||||||
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
|
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
|
||||||
#define digitalRead_mod(p) extDigitalRead(p)
|
#define digitalRead_mod(p) extDigitalRead(p)
|
||||||
#define PRINT_PORT(p)
|
|
||||||
#define GET_ARRAY_PIN(p) pin_array[p].pin
|
#define GET_ARRAY_PIN(p) pin_array[p].pin
|
||||||
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("P%d_%02d"), LPC176x::pin_port(p), LPC176x::pin_bit(p)); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("P%d_%02d"), LPC176x::pin_port(p), LPC176x::pin_bit(p)); SERIAL_ECHO(buffer); }while(0)
|
||||||
|
@ -46,10 +43,14 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool GET_PINMODE(const pin_t pin) {
|
bool GET_PINMODE(const pin_t pin) {
|
||||||
if (!LPC176x::pin_is_valid(pin) || LPC176x::pin_adc_enabled(pin)) // found an invalid pin or active analog pin
|
if (!LPC176x::pin_is_valid(pin) || LPC176x::pin_adc_enabled(pin)) // Invalid pin or active analog pin
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return LPC176x::gpio_direction(pin);
|
return LPC176x::gpio_direction(pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital)
|
#define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital)
|
||||||
|
|
||||||
|
void print_port(const pin_t) {}
|
||||||
|
void pwm_details(const pin_t) {}
|
||||||
|
bool pwm_status(const pin_t) { return false; }
|
||||||
|
|
|
@ -27,35 +27,31 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
||||||
#define pwm_details(pin) pin = pin // do nothing // print PWM details
|
|
||||||
#define pwm_status(pin) false //Print a pin's PWM status. Return true if it's currently a PWM pin.
|
|
||||||
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
|
#define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0)
|
||||||
#define digitalRead_mod(p) digitalRead(p)
|
#define digitalRead_mod(p) digitalRead(p)
|
||||||
#define PRINT_PORT(p)
|
|
||||||
#define GET_ARRAY_PIN(p) pin_array[p].pin
|
#define GET_ARRAY_PIN(p) pin_array[p].pin
|
||||||
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
// active ADC function/mode/code values for PINSEL registers
|
// Active ADC function/mode/code values for PINSEL registers
|
||||||
inline constexpr int8_t ADC_pin_mode(pin_t pin) {
|
constexpr int8_t ADC_pin_mode(pin_t pin) { return -1; }
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int8_t get_pin_mode(pin_t pin) {
|
int8_t get_pin_mode(const pin_t pin) { return VALID_PIN(pin) 0 : -1; }
|
||||||
if (!VALID_PIN(pin)) return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool GET_PINMODE(pin_t pin) {
|
bool GET_PINMODE(const pin_t pin) {
|
||||||
int8_t pin_mode = get_pin_mode(pin);
|
const int8_t pin_mode = get_pin_mode(pin);
|
||||||
if (pin_mode == -1 || pin_mode == ADC_pin_mode(pin)) // found an invalid pin or active analog pin
|
if (pin_mode == -1 || pin_mode == ADC_pin_mode(pin)) // Invalid pin or active analog pin
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (Gpio::getMode(pin) != 0); //input/output state
|
return (Gpio::getMode(pin) != 0); // Input/output state
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool GET_ARRAY_IS_DIGITAL(pin_t pin) {
|
bool GET_ARRAY_IS_DIGITAL(const pin_t pin) {
|
||||||
return (!IS_ANALOG(pin) || get_pin_mode(pin) != ADC_pin_mode(pin));
|
return !IS_ANALOG(pin) || get_pin_mode(pin) != ADC_pin_mode(pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_port(const pin_t) {}
|
||||||
|
void pwm_details(const pin_t) {}
|
||||||
|
bool pwm_status(const pin_t) { return false; }
|
||||||
|
|
|
@ -119,7 +119,6 @@ const XrefInfo pin_xref[] PROGMEM = {
|
||||||
#define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads
|
#define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads
|
||||||
#define PRINT_PIN(Q)
|
#define PRINT_PIN(Q)
|
||||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PORT(ANUM) port_print(ANUM)
|
|
||||||
#define DIGITAL_PIN_TO_ANALOG_PIN(ANUM) -1 // will report analog pin number in the print port routine
|
#define DIGITAL_PIN_TO_ANALOG_PIN(ANUM) -1 // will report analog pin number in the print port routine
|
||||||
|
|
||||||
// x is a variable used to search pin_array
|
// x is a variable used to search pin_array
|
||||||
|
@ -187,7 +186,7 @@ bool is_digital(const pin_t Ard_num) {
|
||||||
return pin_mode == MODE_PIN_INPUT || pin_mode == MODE_PIN_OUTPUT;
|
return pin_mode == MODE_PIN_INPUT || pin_mode == MODE_PIN_OUTPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void port_print(const pin_t Ard_num) {
|
void print_port(const pin_t Ard_num) {
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
pin_t Index;
|
pin_t Index;
|
||||||
for (Index = 0; Index < NUMBER_PINS_TOTAL; Index++)
|
for (Index = 0; Index < NUMBER_PINS_TOTAL; Index++)
|
||||||
|
|
|
@ -41,11 +41,9 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS];
|
||||||
#define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS
|
#define NUMBER_PINS_TOTAL BOARD_NR_GPIO_PINS
|
||||||
#define VALID_PIN(pin) (pin >= 0 && pin < BOARD_NR_GPIO_PINS)
|
#define VALID_PIN(pin) (pin >= 0 && pin < BOARD_NR_GPIO_PINS)
|
||||||
#define GET_ARRAY_PIN(p) pin_t(pin_array[p].pin)
|
#define GET_ARRAY_PIN(p) pin_t(pin_array[p].pin)
|
||||||
#define pwm_status(pin) PWM_PIN(pin)
|
|
||||||
#define digitalRead_mod(p) extDigitalRead(p)
|
#define digitalRead_mod(p) extDigitalRead(p)
|
||||||
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3hd "), int16_t(p)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PORT(p) print_port(p)
|
|
||||||
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define MULTI_NAME_PAD 21 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 21 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
|
@ -54,20 +52,18 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS];
|
||||||
#define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX)
|
#define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int8_t get_pin_mode(pin_t pin) {
|
int8_t get_pin_mode(const pin_t pin) { return VALID_PIN(pin) ? _GET_MODE(pin) : -1; }
|
||||||
return VALID_PIN(pin) ? _GET_MODE(pin) : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) {
|
pin_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t pin) {
|
||||||
if (!VALID_PIN(pin)) return -1;
|
if (!VALID_PIN(pin)) return -1;
|
||||||
int8_t adc_channel = int8_t(PIN_MAP[pin].adc_channel);
|
pin_t adc_channel = pin_t(PIN_MAP[pin].adc_channel);
|
||||||
#ifdef NUM_ANALOG_INPUTS
|
#ifdef NUM_ANALOG_INPUTS
|
||||||
if (adc_channel >= NUM_ANALOG_INPUTS) adc_channel = ADCx;
|
if (adc_channel >= NUM_ANALOG_INPUTS) adc_channel = (pin_t)ADCx;
|
||||||
#endif
|
#endif
|
||||||
return pin_t(adc_channel);
|
return adc_channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IS_ANALOG(pin_t pin) {
|
bool IS_ANALOG(const pin_t pin) {
|
||||||
if (!VALID_PIN(pin)) return false;
|
if (!VALID_PIN(pin)) return false;
|
||||||
if (PIN_MAP[pin].adc_channel != ADCx) {
|
if (PIN_MAP[pin].adc_channel != ADCx) {
|
||||||
#ifdef NUM_ANALOG_INPUTS
|
#ifdef NUM_ANALOG_INPUTS
|
||||||
|
@ -78,11 +74,11 @@ static bool IS_ANALOG(pin_t pin) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool GET_PINMODE(const pin_t pin) {
|
bool GET_PINMODE(const pin_t pin) {
|
||||||
return VALID_PIN(pin) && !IS_INPUT(pin);
|
return VALID_PIN(pin) && !IS_INPUT(pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) {
|
bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) {
|
||||||
const pin_t pin = GET_ARRAY_PIN(array_pin);
|
const pin_t pin = GET_ARRAY_PIN(array_pin);
|
||||||
return (!IS_ANALOG(pin)
|
return (!IS_ANALOG(pin)
|
||||||
#ifdef NUM_ANALOG_INPUTS
|
#ifdef NUM_ANALOG_INPUTS
|
||||||
|
@ -93,7 +89,7 @@ static bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) {
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
|
#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
|
||||||
|
|
||||||
static void pwm_details(const pin_t pin) {
|
void pwm_details(const pin_t pin) {
|
||||||
if (PWM_PIN(pin)) {
|
if (PWM_PIN(pin)) {
|
||||||
timer_dev * const tdev = PIN_MAP[pin].timer_device;
|
timer_dev * const tdev = PIN_MAP[pin].timer_device;
|
||||||
const uint8_t channel = PIN_MAP[pin].timer_channel;
|
const uint8_t channel = PIN_MAP[pin].timer_channel;
|
||||||
|
@ -113,7 +109,9 @@ static void pwm_details(const pin_t pin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_port(pin_t pin) {
|
bool pwm_status(const pin_t pin) { return PWM_PIN(pin); }
|
||||||
|
|
||||||
|
void print_port(const pin_t pin) {
|
||||||
const char port = 'A' + char(pin >> 4); // pin div 16
|
const char port = 'A' + char(pin >> 4); // pin div 16
|
||||||
const int16_t gbit = PIN_MAP[pin].gpio_bit;
|
const int16_t gbit = PIN_MAP[pin].gpio_bit;
|
||||||
char buffer[8];
|
char buffer[8];
|
||||||
|
|
|
@ -55,12 +55,12 @@
|
||||||
|
|
||||||
#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(9)) || ((P) >= analogInputToDigitalPin(12) && (P) <= analogInputToDigitalPin(20))
|
#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(9)) || ((P) >= analogInputToDigitalPin(12) && (P) <= analogInputToDigitalPin(20))
|
||||||
|
|
||||||
void HAL_print_analog_pin(char buffer[], int8_t pin) {
|
void print_analog_pin(char buffer[], int8_t pin) {
|
||||||
if (pin <= 23) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 14));
|
if (pin <= 23) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 14));
|
||||||
else if (pin <= 39) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 19));
|
else if (pin <= 39) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 19));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_analog_pin_state(char buffer[], int8_t pin) {
|
void analog_pin_state(char buffer[], int8_t pin) {
|
||||||
if (pin <= 23) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 14));
|
if (pin <= 23) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 14));
|
||||||
else if (pin <= 39) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 19));
|
else if (pin <= 39) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 19));
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ void HAL_analog_pin_state(char buffer[], int8_t pin) {
|
||||||
* Print a pin's PWM status.
|
* Print a pin's PWM status.
|
||||||
* Return true if it's currently a PWM pin.
|
* Return true if it's currently a PWM pin.
|
||||||
*/
|
*/
|
||||||
bool HAL_pwm_status(const int8_t pin) {
|
bool pwm_status(int8_t pin) {
|
||||||
char buffer[20]; // for the sprintf statements
|
char buffer[20]; // for the sprintf statements
|
||||||
switch (pin) {
|
switch (pin) {
|
||||||
FTM_CASE(0,0);
|
FTM_CASE(0,0);
|
||||||
|
@ -108,4 +108,4 @@ bool HAL_pwm_status(const int8_t pin) {
|
||||||
SERIAL_ECHOPGM(" ");
|
SERIAL_ECHOPGM(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HAL_pwm_details(uint8_t pin) { /* TODO */ }
|
void pwm_details(uint8_t pin) { /* TODO */ }
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS
|
||||||
|
|
||||||
#define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin
|
#define digitalRead_mod(p) extDigitalRead(p) // AVR digitalRead disabled PWM before it read the pin
|
||||||
#define PRINT_PORT(p)
|
|
||||||
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%02d"), p); SERIAL_ECHO(buffer); }while(0)
|
||||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||||
|
@ -39,7 +38,6 @@
|
||||||
#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL))
|
#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL))
|
||||||
#define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
|
#define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0))
|
||||||
#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(13)) || ((P) >= analogInputToDigitalPin(14) && (P) <= analogInputToDigitalPin(17))
|
#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(13)) || ((P) >= analogInputToDigitalPin(14) && (P) <= analogInputToDigitalPin(17))
|
||||||
#define pwm_status(pin) HAL_pwm_status(pin)
|
|
||||||
#define GET_PINMODE(PIN) (VALID_PIN(pin) && IS_OUTPUT(pin))
|
#define GET_PINMODE(PIN) (VALID_PIN(pin) && IS_OUTPUT(pin))
|
||||||
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
#define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
|
||||||
|
|
||||||
|
@ -120,12 +118,12 @@ const struct pwm_pin_info_struct pwm_pin_info[] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
void HAL_print_analog_pin(char buffer[], int8_t pin) {
|
void print_analog_pin(char buffer[], const pin_t pin) {
|
||||||
if (pin <= 23) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 14));
|
if (pin <= 23) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 14));
|
||||||
else if (pin <= 41) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 24));
|
else if (pin <= 41) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 24));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_analog_pin_state(char buffer[], int8_t pin) {
|
void analog_pin_state(char buffer[], const pin_t pin) {
|
||||||
if (pin <= 23) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 14));
|
if (pin <= 23) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 14));
|
||||||
else if (pin <= 41) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 24));
|
else if (pin <= 41) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 24));
|
||||||
}
|
}
|
||||||
|
@ -136,14 +134,14 @@ void HAL_analog_pin_state(char buffer[], int8_t pin) {
|
||||||
* Print a pin's PWM status.
|
* Print a pin's PWM status.
|
||||||
* Return true if it's currently a PWM pin.
|
* Return true if it's currently a PWM pin.
|
||||||
*/
|
*/
|
||||||
bool HAL_pwm_status(const int8_t pin) {
|
bool pwm_status(const pin_t pin) {
|
||||||
char buffer[20]; // for the sprintf statements
|
char buffer[20]; // for the sprintf statements
|
||||||
const struct pwm_pin_info_struct *info;
|
const struct pwm_pin_info_struct *info;
|
||||||
|
|
||||||
if (pin >= CORE_NUM_DIGITAL) return 0;
|
if (pin >= CORE_NUM_DIGITAL) return false;
|
||||||
info = pwm_pin_info + pin;
|
|
||||||
|
|
||||||
if (info->type == 0) return 0;
|
info = pwm_pin_info + pin;
|
||||||
|
if (info->type == 0) return false;
|
||||||
|
|
||||||
/* TODO decode pwm value from timers */
|
/* TODO decode pwm value from timers */
|
||||||
// for now just indicate if output is set as pwm
|
// for now just indicate if output is set as pwm
|
||||||
|
@ -151,4 +149,6 @@ bool HAL_pwm_status(const int8_t pin) {
|
||||||
return (*(portConfigRegister(pin)) == info->muxval);
|
return (*(portConfigRegister(pin)) == info->muxval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pwm_details(uint8_t pin) { /* TODO */ }
|
void pwm_details(const pin_t) { /* TODO */ }
|
||||||
|
|
||||||
|
void print_port(const pin_t) {}
|
||||||
|
|
|
@ -206,7 +206,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e
|
||||||
if (start_string) SERIAL_ECHOF(start_string);
|
if (start_string) SERIAL_ECHOF(start_string);
|
||||||
SERIAL_ECHOPGM("PIN: ");
|
SERIAL_ECHOPGM("PIN: ");
|
||||||
PRINT_PIN(pin);
|
PRINT_PIN(pin);
|
||||||
PRINT_PORT(pin);
|
print_port(pin);
|
||||||
if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) PRINT_PIN_ANALOG(pin); // analog pin number
|
if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) PRINT_PIN_ANALOG(pin); // analog pin number
|
||||||
else SERIAL_ECHO_SP(8); // add padding if not an analog pin
|
else SERIAL_ECHO_SP(8); // add padding if not an analog pin
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e
|
||||||
if (start_string) SERIAL_ECHOF(start_string);
|
if (start_string) SERIAL_ECHOF(start_string);
|
||||||
SERIAL_ECHOPGM("PIN: ");
|
SERIAL_ECHOPGM("PIN: ");
|
||||||
PRINT_PIN(pin);
|
PRINT_PIN(pin);
|
||||||
PRINT_PORT(pin);
|
print_port(pin);
|
||||||
if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) PRINT_PIN_ANALOG(pin); // analog pin number
|
if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) PRINT_PIN_ANALOG(pin); // analog pin number
|
||||||
else SERIAL_ECHO_SP(8); // add padding if not an analog pin
|
else SERIAL_ECHO_SP(8); // add padding if not an analog pin
|
||||||
SERIAL_ECHOPGM("<unused/unknown>");
|
SERIAL_ECHOPGM("<unused/unknown>");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Build tests for AT90USB1286 ARMED
|
# Build tests for AT90USB1286 (CDC)
|
||||||
#
|
#
|
||||||
|
|
||||||
# exit on first failure
|
# exit on first failure
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Build tests for AT90USB1286 ARMED
|
# Build tests for AT90USB1286 (DFU)
|
||||||
#
|
#
|
||||||
|
|
||||||
# exit on first failure
|
# exit on first failure
|
||||||
|
|
Loading…
Reference in a new issue