Clean up HALs / FastIO (#14082)
This commit is contained in:
parent
4ef364a073
commit
a74aad3b4a
21 changed files with 17 additions and 187 deletions
|
@ -81,9 +81,8 @@
|
||||||
#define _SET_INPUT(IO) CBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
#define _SET_INPUT(IO) CBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
||||||
#define _SET_OUTPUT(IO) SBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
#define _SET_OUTPUT(IO) SBI(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
||||||
|
|
||||||
#define _IS_INPUT(IO) !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
#define _IS_INPUT(IO) !TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
||||||
#define _IS_OUTPUT(IO) TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
#define _IS_OUTPUT(IO) TEST(DIO ## IO ## _DDR, DIO ## IO ## _PIN)
|
||||||
#define _HAS_TIMER(IO) bool(DIO ## IO ## _PWM)
|
|
||||||
|
|
||||||
// digitalRead/Write wrappers
|
// digitalRead/Write wrappers
|
||||||
#ifdef FASTIO_EXT_START
|
#ifdef FASTIO_EXT_START
|
||||||
|
@ -106,7 +105,6 @@
|
||||||
|
|
||||||
#define IS_INPUT(IO) _IS_INPUT(IO)
|
#define IS_INPUT(IO) _IS_INPUT(IO)
|
||||||
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
||||||
#define HAS_TIMER(IO) _HAS_TIMER(IO)
|
|
||||||
|
|
||||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||||
|
|
||||||
|
@ -353,5 +351,3 @@ enum ClockSource2 : char {
|
||||||
#else
|
#else
|
||||||
#error "unknown CPU"
|
#error "unknown CPU"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USEABLE_HARDWARE_PWM(P) (PWM_PIN(P) && !PWM_CHK(P))
|
|
||||||
|
|
|
@ -78,14 +78,6 @@
|
||||||
#undef pgm_read_word
|
#undef pgm_read_word
|
||||||
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
|
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
|
||||||
|
|
||||||
#define RST_POWER_ON 1
|
|
||||||
#define RST_EXTERNAL 2
|
|
||||||
#define RST_BROWN_OUT 4
|
|
||||||
#define RST_WATCHDOG 8
|
|
||||||
#define RST_JTAG 16
|
|
||||||
#define RST_SOFTWARE 32
|
|
||||||
#define RST_BACKUP 64
|
|
||||||
|
|
||||||
typedef int8_t pin_t;
|
typedef int8_t pin_t;
|
||||||
|
|
||||||
#define HAL_SERVO_LIB Servo
|
#define HAL_SERVO_LIB Servo
|
||||||
|
@ -143,13 +135,6 @@ inline void HAL_adc_init(void) {}//todo
|
||||||
|
|
||||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||||
uint16_t HAL_adc_get_result(void);
|
uint16_t HAL_adc_get_result(void);
|
||||||
uint16_t HAL_getAdcReading(uint8_t chan);
|
|
||||||
void HAL_startAdcConversion(uint8_t chan);
|
|
||||||
uint8_t HAL_pinToAdcChannel(int pin);
|
|
||||||
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
|
|
||||||
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
|
|
||||||
void HAL_enable_AdcFreerun(void);
|
|
||||||
//void HAL_disable_AdcFreerun(uint8_t chan);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pin Map
|
// Pin Map
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
// Due has 12 PWMs assigned to logical pins 2-13.
|
// Due has 12 PWMs assigned to logical pins 2-13.
|
||||||
// 6, 7, 8 & 9 come from the PWM controller. The others come from the timers.
|
// 6, 7, 8 & 9 come from the PWM controller. The others come from the timers.
|
||||||
#define PWM_PIN(P) WITHIN(P, 2, 13)
|
#define PWM_PIN(P) WITHIN(P, 2, 13)
|
||||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
|
||||||
|
|
||||||
#ifndef MASK
|
#ifndef MASK
|
||||||
#define MASK(PIN) (1 << PIN)
|
#define MASK(PIN) (1 << PIN)
|
||||||
|
@ -180,8 +179,6 @@
|
||||||
#define IS_INPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
|
#define IS_INPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
|
||||||
// Check if pin is an output
|
// Check if pin is an output
|
||||||
#define IS_OUTPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
|
#define IS_OUTPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
|
||||||
// Check if pin is a timer - Must be a constexpr
|
|
||||||
#define HAS_TIMER(IO) ((IO) >= 2 && (IO) <= 13)
|
|
||||||
|
|
||||||
// Shorthand
|
// Shorthand
|
||||||
#define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); }
|
#define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); }
|
||||||
|
|
|
@ -67,7 +67,6 @@
|
||||||
|
|
||||||
// PWM outputs
|
// PWM outputs
|
||||||
#define PWM_PIN(P) (P < 34) // NOTE Pins >= 34 are input only on ESP32, so they can't be used for output.
|
#define PWM_PIN(P) (P < 34) // NOTE Pins >= 34 are input only on ESP32, so they can't be used for output.
|
||||||
#define USEABLE_HARDWARE_PWM(P) (!IS_I2S_EXPANDER_PIN(P) && PWM_PIN(P))
|
|
||||||
|
|
||||||
// Toggle pin value
|
// Toggle pin value
|
||||||
#define TOGGLE(IO) WRITE(IO, !READ(IO))
|
#define TOGGLE(IO) WRITE(IO, !READ(IO))
|
||||||
|
|
|
@ -80,16 +80,6 @@
|
||||||
/// check if pin is an output
|
/// check if pin is an output
|
||||||
#define _IS_OUTPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
|
#define _IS_OUTPUT(IO) (LPC1768_PIN_PIN(IO) >= 0)
|
||||||
|
|
||||||
// hg42: HAS_TIMER is used only to check if it's a PWM pin
|
|
||||||
// hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically
|
|
||||||
// hg42: instead use PWM bit from the #define
|
|
||||||
|
|
||||||
/// check if pin is a timer
|
|
||||||
#define _HAS_TIMER(IO) true // could be LPC1768_PIN_PWM(IO), but there
|
|
||||||
// hg42: could be this:
|
|
||||||
// #define _HAS_TIMER(IO) LPC1768_PIN_PWM(IO)
|
|
||||||
// but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
|
|
||||||
|
|
||||||
/// Read a pin wrapper
|
/// Read a pin wrapper
|
||||||
#define READ(IO) _READ(IO)
|
#define READ(IO) _READ(IO)
|
||||||
|
|
||||||
|
@ -116,14 +106,9 @@
|
||||||
/// check if pin is an output wrapper
|
/// check if pin is an output wrapper
|
||||||
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
||||||
|
|
||||||
/// check if pin is a timer (wrapper)
|
|
||||||
#define HAS_TIMER(IO) _HAS_TIMER(IO)
|
|
||||||
|
|
||||||
// Shorthand
|
// Shorthand
|
||||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||||
|
|
||||||
// digitalRead/Write wrappers
|
// digitalRead/Write wrappers
|
||||||
#define extDigitalRead(IO) digitalRead(IO)
|
#define extDigitalRead(IO) digitalRead(IO)
|
||||||
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
||||||
|
|
||||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
|
||||||
|
|
|
@ -21,11 +21,6 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define RST_POWER_ON 1
|
|
||||||
#define RST_EXTERNAL 2
|
|
||||||
#define RST_BROWN_OUT 4
|
|
||||||
#define RST_WATCHDOG 8
|
|
||||||
|
|
||||||
#define WDT_TIMEOUT 4000000 // 4 second timeout
|
#define WDT_TIMEOUT 4000000 // 4 second timeout
|
||||||
|
|
||||||
void watchdog_init(void);
|
void watchdog_init(void);
|
||||||
|
|
|
@ -35,8 +35,7 @@
|
||||||
|
|
||||||
#include "../shared/Marduino.h"
|
#include "../shared/Marduino.h"
|
||||||
|
|
||||||
#define PWM_PIN(P) true // all pins are PWM capable
|
#define PWM_PIN(P) true // all pins are PWM capable
|
||||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
|
||||||
|
|
||||||
#define LPC_PIN(pin) gpio_pin(pin)
|
#define LPC_PIN(pin) gpio_pin(pin)
|
||||||
#define LPC_GPIO(port) gpio_port(port)
|
#define LPC_GPIO(port) gpio_port(port)
|
||||||
|
@ -89,10 +88,6 @@
|
||||||
/// check if pin is an output
|
/// check if pin is an output
|
||||||
#define _IS_OUTPUT(IO) (gpio_get_dir(IO))
|
#define _IS_OUTPUT(IO) (gpio_get_dir(IO))
|
||||||
|
|
||||||
/// check if pin is a timer
|
|
||||||
/// all gpio pins are pwm capable, either interrupt or hardware pwm controlled
|
|
||||||
#define _HAS_TIMER(IO) true
|
|
||||||
|
|
||||||
/// Read a pin wrapper
|
/// Read a pin wrapper
|
||||||
#define READ(IO) _READ(IO)
|
#define READ(IO) _READ(IO)
|
||||||
|
|
||||||
|
@ -119,9 +114,6 @@
|
||||||
/// check if pin is an output wrapper
|
/// check if pin is an output wrapper
|
||||||
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
#define IS_OUTPUT(IO) _IS_OUTPUT(IO)
|
||||||
|
|
||||||
/// check if pin is a timer (wrapper)
|
|
||||||
#define HAS_TIMER(IO) _HAS_TIMER(IO)
|
|
||||||
|
|
||||||
// Shorthand
|
// Shorthand
|
||||||
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,6 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define RST_POWER_ON 1
|
|
||||||
#define RST_EXTERNAL 2
|
|
||||||
#define RST_BROWN_OUT 4
|
|
||||||
#define RST_WATCHDOG 8
|
|
||||||
|
|
||||||
#define WDT_TIMEOUT 4000000 // 4 second timeout
|
#define WDT_TIMEOUT 4000000 // 4 second timeout
|
||||||
|
|
||||||
void watchdog_init(void);
|
void watchdog_init(void);
|
||||||
|
|
|
@ -127,14 +127,6 @@
|
||||||
#undef pgm_read_ptr
|
#undef pgm_read_ptr
|
||||||
#define pgm_read_ptr(addr) (*(addr))
|
#define pgm_read_ptr(addr) (*(addr))
|
||||||
|
|
||||||
#define RST_POWER_ON 1
|
|
||||||
#define RST_EXTERNAL 2
|
|
||||||
#define RST_BROWN_OUT 4
|
|
||||||
#define RST_WATCHDOG 8
|
|
||||||
#define RST_JTAG 16
|
|
||||||
#define RST_SOFTWARE 32
|
|
||||||
#define RST_BACKUP 64
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// Types
|
// Types
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
|
@ -80,10 +80,8 @@ void FastIO_init(); // Must be called before using fast io macros
|
||||||
|
|
||||||
#define IS_INPUT(IO)
|
#define IS_INPUT(IO)
|
||||||
#define IS_OUTPUT(IO)
|
#define IS_OUTPUT(IO)
|
||||||
#define HAS_TIMER(IO) digitalPinHasPWM(IO)
|
|
||||||
|
|
||||||
#define PWM_PIN(P) HAS_TIMER(P)
|
#define PWM_PIN(P) digitalPinHasPWM(P)
|
||||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
|
||||||
|
|
||||||
// digitalRead/Write wrappers
|
// digitalRead/Write wrappers
|
||||||
#define extDigitalRead(IO) digitalRead(IO)
|
#define extDigitalRead(IO) digitalRead(IO)
|
||||||
|
|
|
@ -253,23 +253,8 @@ void HAL_adc_init(void);
|
||||||
#define HAL_ADC_READY() true
|
#define HAL_ADC_READY() true
|
||||||
|
|
||||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||||
|
|
||||||
uint16_t HAL_adc_get_result(void);
|
uint16_t HAL_adc_get_result(void);
|
||||||
|
|
||||||
/* Todo: Confirm none of this is needed.
|
|
||||||
uint16_t HAL_getAdcReading(uint8_t chan);
|
|
||||||
|
|
||||||
void HAL_startAdcConversion(uint8_t chan);
|
|
||||||
uint8_t HAL_pinToAdcChannel(int pin);
|
|
||||||
|
|
||||||
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
|
|
||||||
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
|
|
||||||
|
|
||||||
void HAL_enable_AdcFreerun(void);
|
|
||||||
//void HAL_disable_AdcFreerun(uint8_t chan);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define GET_PIN_MAP_PIN(index) index
|
#define GET_PIN_MAP_PIN(index) index
|
||||||
#define GET_PIN_MAP_INDEX(pin) pin
|
#define GET_PIN_MAP_INDEX(pin) pin
|
||||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||||
|
|
|
@ -50,10 +50,8 @@
|
||||||
|
|
||||||
#define IS_INPUT(IO) (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
|
#define IS_INPUT(IO) (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
|
||||||
#define IS_OUTPUT(IO) (_GET_MODE(IO) == GPIO_OUTPUT_PP)
|
#define IS_OUTPUT(IO) (_GET_MODE(IO) == GPIO_OUTPUT_PP)
|
||||||
#define HAS_TIMER(IO) (PIN_MAP[IO].timer_device != nullptr)
|
|
||||||
|
|
||||||
#define PWM_PIN(P) HAS_TIMER(P)
|
#define PWM_PIN(P) (PIN_MAP[IO].timer_device != nullptr)
|
||||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
|
||||||
|
|
||||||
// digitalRead/Write wrappers
|
// digitalRead/Write wrappers
|
||||||
#define extDigitalRead(IO) digitalRead(IO)
|
#define extDigitalRead(IO) digitalRead(IO)
|
||||||
|
|
|
@ -136,14 +136,6 @@
|
||||||
#undef pgm_read_ptr
|
#undef pgm_read_ptr
|
||||||
#define pgm_read_ptr(addr) (*(addr))
|
#define pgm_read_ptr(addr) (*(addr))
|
||||||
|
|
||||||
#define RST_POWER_ON 1
|
|
||||||
#define RST_EXTERNAL 2
|
|
||||||
#define RST_BROWN_OUT 4
|
|
||||||
#define RST_WATCHDOG 8
|
|
||||||
#define RST_JTAG 16
|
|
||||||
#define RST_SOFTWARE 32
|
|
||||||
#define RST_BACKUP 64
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// Types
|
// Types
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -232,23 +224,8 @@ inline void HAL_adc_init(void) {}
|
||||||
#define HAL_ADC_READY() true
|
#define HAL_ADC_READY() true
|
||||||
|
|
||||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||||
|
|
||||||
uint16_t HAL_adc_get_result(void);
|
uint16_t HAL_adc_get_result(void);
|
||||||
|
|
||||||
/* Todo: Confirm none of this is needed.
|
|
||||||
uint16_t HAL_getAdcReading(uint8_t chan);
|
|
||||||
|
|
||||||
void HAL_startAdcConversion(uint8_t chan);
|
|
||||||
uint8_t HAL_pinToAdcChannel(int pin);
|
|
||||||
|
|
||||||
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
|
|
||||||
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
|
|
||||||
|
|
||||||
void HAL_enable_AdcFreerun(void);
|
|
||||||
//void HAL_disable_AdcFreerun(uint8_t chan);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define GET_PIN_MAP_PIN(index) index
|
#define GET_PIN_MAP_PIN(index) index
|
||||||
#define GET_PIN_MAP_INDEX(pin) pin
|
#define GET_PIN_MAP_INDEX(pin) pin
|
||||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||||
|
|
|
@ -50,10 +50,8 @@
|
||||||
|
|
||||||
#define IS_INPUT(IO)
|
#define IS_INPUT(IO)
|
||||||
#define IS_OUTPUT(IO)
|
#define IS_OUTPUT(IO)
|
||||||
#define HAS_TIMER(IO) true
|
|
||||||
|
|
||||||
#define PWM_PIN(P) HAS_TIMER(P)
|
#define PWM_PIN(P) true
|
||||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
|
||||||
|
|
||||||
// digitalRead/Write wrappers
|
// digitalRead/Write wrappers
|
||||||
#define extDigitalRead(IO) digitalRead(IO)
|
#define extDigitalRead(IO) digitalRead(IO)
|
||||||
|
|
|
@ -125,14 +125,6 @@
|
||||||
#undef pgm_read_ptr
|
#undef pgm_read_ptr
|
||||||
#define pgm_read_ptr(addr) (*(addr))
|
#define pgm_read_ptr(addr) (*(addr))
|
||||||
|
|
||||||
#define RST_POWER_ON 1
|
|
||||||
#define RST_EXTERNAL 2
|
|
||||||
#define RST_BROWN_OUT 4
|
|
||||||
#define RST_WATCHDOG 8
|
|
||||||
#define RST_JTAG 16
|
|
||||||
#define RST_SOFTWARE 32
|
|
||||||
#define RST_BACKUP 64
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// Types
|
// Types
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -211,23 +203,8 @@ inline void HAL_adc_init(void) {}
|
||||||
#define HAL_ADC_READY() true
|
#define HAL_ADC_READY() true
|
||||||
|
|
||||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||||
|
|
||||||
uint16_t HAL_adc_get_result(void);
|
uint16_t HAL_adc_get_result(void);
|
||||||
|
|
||||||
/* Todo: Confirm none of this is needed.
|
|
||||||
uint16_t HAL_getAdcReading(uint8_t chan);
|
|
||||||
|
|
||||||
void HAL_startAdcConversion(uint8_t chan);
|
|
||||||
uint8_t HAL_pinToAdcChannel(int pin);
|
|
||||||
|
|
||||||
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
|
|
||||||
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
|
|
||||||
|
|
||||||
void HAL_enable_AdcFreerun(void);
|
|
||||||
//void HAL_disable_AdcFreerun(uint8_t chan);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define GET_PIN_MAP_PIN(index) index
|
#define GET_PIN_MAP_PIN(index) index
|
||||||
#define GET_PIN_MAP_INDEX(pin) pin
|
#define GET_PIN_MAP_INDEX(pin) pin
|
||||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||||
|
|
|
@ -49,10 +49,8 @@
|
||||||
|
|
||||||
#define IS_INPUT(IO)
|
#define IS_INPUT(IO)
|
||||||
#define IS_OUTPUT(IO)
|
#define IS_OUTPUT(IO)
|
||||||
#define HAS_TIMER(IO) true
|
|
||||||
|
|
||||||
#define PWM_PIN(P) HAS_TIMER(P)
|
#define PWM_PIN(P) true
|
||||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
|
||||||
|
|
||||||
// digitalRead/Write wrappers
|
// digitalRead/Write wrappers
|
||||||
#define extDigitalRead(IO) digitalRead(IO)
|
#define extDigitalRead(IO) digitalRead(IO)
|
||||||
|
|
|
@ -89,14 +89,6 @@ typedef int8_t pin_t;
|
||||||
#undef pgm_read_word
|
#undef pgm_read_word
|
||||||
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
|
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
|
||||||
|
|
||||||
#define RST_POWER_ON 1
|
|
||||||
#define RST_EXTERNAL 2
|
|
||||||
#define RST_BROWN_OUT 4
|
|
||||||
#define RST_WATCHDOG 8
|
|
||||||
#define RST_JTAG 16
|
|
||||||
#define RST_SOFTWARE 32
|
|
||||||
#define RST_BACKUP 64
|
|
||||||
|
|
||||||
// Clear the reset reason
|
// Clear the reset reason
|
||||||
void HAL_clear_reset_source(void);
|
void HAL_clear_reset_source(void);
|
||||||
|
|
||||||
|
@ -128,25 +120,11 @@ void HAL_adc_init();
|
||||||
#define HAL_READ_ADC() HAL_adc_get_result()
|
#define HAL_READ_ADC() HAL_adc_get_result()
|
||||||
#define HAL_ADC_READY() true
|
#define HAL_ADC_READY() true
|
||||||
|
|
||||||
#define HAL_ANALOG_SELECT(pin) NOOP;
|
#define HAL_ANALOG_SELECT(pin)
|
||||||
|
|
||||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||||
|
|
||||||
uint16_t HAL_adc_get_result(void);
|
uint16_t HAL_adc_get_result(void);
|
||||||
|
|
||||||
/*
|
|
||||||
uint16_t HAL_getAdcReading(uint8_t chan);
|
|
||||||
|
|
||||||
void HAL_startAdcConversion(uint8_t chan);
|
|
||||||
uint8_t HAL_pinToAdcChannel(int pin);
|
|
||||||
|
|
||||||
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
|
|
||||||
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
|
|
||||||
|
|
||||||
void HAL_enable_AdcFreerun(void);
|
|
||||||
//void HAL_disable_AdcFreerun(uint8_t chan);
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define GET_PIN_MAP_PIN(index) index
|
#define GET_PIN_MAP_PIN(index) index
|
||||||
#define GET_PIN_MAP_INDEX(pin) pin
|
#define GET_PIN_MAP_INDEX(pin) pin
|
||||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||||
|
|
|
@ -91,7 +91,6 @@
|
||||||
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
||||||
|
|
||||||
#define PWM_PIN(P) digitalPinHasPWM(P)
|
#define PWM_PIN(P) digitalPinHasPWM(P)
|
||||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ports, functions, and pins
|
* Ports, functions, and pins
|
||||||
|
|
|
@ -97,14 +97,6 @@ typedef int8_t pin_t;
|
||||||
#undef pgm_read_word
|
#undef pgm_read_word
|
||||||
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
|
#define pgm_read_word(addr) (*((uint16_t*)(addr)))
|
||||||
|
|
||||||
#define RST_POWER_ON 1
|
|
||||||
#define RST_EXTERNAL 2
|
|
||||||
#define RST_BROWN_OUT 4
|
|
||||||
#define RST_WATCHDOG 8
|
|
||||||
#define RST_JTAG 16
|
|
||||||
#define RST_SOFTWARE 32
|
|
||||||
#define RST_BACKUP 64
|
|
||||||
|
|
||||||
/** clear reset reason */
|
/** clear reset reason */
|
||||||
void HAL_clear_reset_source(void);
|
void HAL_clear_reset_source(void);
|
||||||
|
|
||||||
|
@ -133,25 +125,11 @@ void HAL_adc_init();
|
||||||
#define HAL_READ_ADC() HAL_adc_get_result()
|
#define HAL_READ_ADC() HAL_adc_get_result()
|
||||||
#define HAL_ADC_READY() true
|
#define HAL_ADC_READY() true
|
||||||
|
|
||||||
#define HAL_ANALOG_SELECT(pin) NOOP;
|
#define HAL_ANALOG_SELECT(pin)
|
||||||
|
|
||||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||||
|
|
||||||
uint16_t HAL_adc_get_result(void);
|
uint16_t HAL_adc_get_result(void);
|
||||||
|
|
||||||
/*
|
|
||||||
uint16_t HAL_getAdcReading(uint8_t chan);
|
|
||||||
|
|
||||||
void HAL_startAdcConversion(uint8_t chan);
|
|
||||||
uint8_t HAL_pinToAdcChannel(int pin);
|
|
||||||
|
|
||||||
uint16_t HAL_getAdcFreerun(uint8_t chan, bool wait_for_conversion = false);
|
|
||||||
//uint16_t HAL_getAdcSuperSample(uint8_t chan);
|
|
||||||
|
|
||||||
void HAL_enable_AdcFreerun(void);
|
|
||||||
//void HAL_disable_AdcFreerun(uint8_t chan);
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define GET_PIN_MAP_PIN(index) index
|
#define GET_PIN_MAP_PIN(index) index
|
||||||
#define GET_PIN_MAP_INDEX(pin) pin
|
#define GET_PIN_MAP_INDEX(pin) pin
|
||||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||||
|
|
|
@ -90,7 +90,6 @@
|
||||||
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
#define extDigitalWrite(IO,V) digitalWrite(IO,V)
|
||||||
|
|
||||||
#define PWM_PIN(P) digitalPinHasPWM(P)
|
#define PWM_PIN(P) digitalPinHasPWM(P)
|
||||||
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ports, functions, and pins
|
* Ports, functions, and pins
|
||||||
|
|
|
@ -55,3 +55,12 @@
|
||||||
//#define strchr_P(s,c) strchr(s,c)
|
//#define strchr_P(s,c) strchr(s,c)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Restart causes
|
||||||
|
#define RST_POWER_ON 1
|
||||||
|
#define RST_EXTERNAL 2
|
||||||
|
#define RST_BROWN_OUT 4
|
||||||
|
#define RST_WATCHDOG 8
|
||||||
|
#define RST_JTAG 16
|
||||||
|
#define RST_SOFTWARE 32
|
||||||
|
#define RST_BACKUP 64
|
||||||
|
|
Reference in a new issue