LPC1768: updates to use the new pin_t typedef
This commit is contained in:
@ -90,7 +90,7 @@ typedef struct { // holds all data needed to control/init one of the
|
||||
|
||||
#define MICRO_MAX 0xffffffff
|
||||
|
||||
#define PWM_MAP_INIT_ROW {0, 0xff, 0, 0, 0, 0, MICRO_MAX, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define PWM_MAP_INIT_ROW {0, P_NC, 0, 0, 0, 0, MICRO_MAX, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define PWM_MAP_INIT {PWM_MAP_INIT_ROW,\
|
||||
PWM_MAP_INIT_ROW,\
|
||||
PWM_MAP_INIT_ROW,\
|
||||
@ -234,12 +234,12 @@ typedef struct { // status of PWM1 channel
|
||||
MR_map map_MR[NUM_PWMS];
|
||||
|
||||
void LPC1768_PWM_update_map_MR(void) {
|
||||
map_MR[0] = {0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + pin_4_PWM_channel) ? 1 : 0), 4, &LPC_PWM1->MR1, 0, 0};
|
||||
map_MR[1] = {0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + pin_11_PWM_channel) ? 1 : 0), 11, &LPC_PWM1->MR2, 0, 0};
|
||||
map_MR[2] = {0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + pin_6_PWM_channel) ? 1 : 0), 6, &LPC_PWM1->MR3, 0, 0};
|
||||
map_MR[3] = {0, 0, 0, &LPC_PWM1->MR4, 0, 0};
|
||||
map_MR[4] = {0, 0, 0, &LPC_PWM1->MR5, 0, 0};
|
||||
map_MR[5] = {0, 0, 0, &LPC_PWM1->MR6, 0, 0};
|
||||
map_MR[0] = {0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + pin_4_PWM_channel) ? 1 : 0), P1_18, &LPC_PWM1->MR1, 0, 0};
|
||||
map_MR[1] = {0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + pin_11_PWM_channel) ? 1 : 0), P1_20, &LPC_PWM1->MR2, 0, 0};
|
||||
map_MR[2] = {0, (uint8_t) (LPC_PWM1->PCR & _BV(8 + pin_6_PWM_channel) ? 1 : 0), P1_21, &LPC_PWM1->MR3, 0, 0};
|
||||
map_MR[3] = {0, 0, P_NC, &LPC_PWM1->MR4, 0, 0};
|
||||
map_MR[4] = {0, 0, P_NC, &LPC_PWM1->MR5, 0, 0};
|
||||
map_MR[5] = {0, 0, P_NC, &LPC_PWM1->MR6, 0, 0};
|
||||
}
|
||||
|
||||
|
||||
@ -384,6 +384,8 @@ bool LPC1768_PWM_detach_pin(pin_t pin) {
|
||||
map_MR[pin_4_PWM_channel - 1].PINSEL3_bits = 0;
|
||||
map_MR[pin_4_PWM_channel - 1].map_PWM_INT = 0; // 0 - available for interrupts, 1 - in use by PWM
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
pinMode(pin, INPUT);
|
||||
@ -506,4 +508,3 @@ return;
|
||||
* NOTE - PCR must be set before PINSEL
|
||||
* sets the pins controlled by the ISR to their active states
|
||||
*/
|
||||
|
||||
|
@ -212,7 +212,7 @@ extern "C" void intWrapper() {
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic /* = false */) :
|
||||
SoftwareSerial::SoftwareSerial(pin_t receivePin, pin_t transmitPin, bool inverse_logic /* = false */) :
|
||||
_rx_delay_centering(0),
|
||||
_rx_delay_intrabit(0),
|
||||
_rx_delay_stopbit(0),
|
||||
@ -233,7 +233,7 @@ SoftwareSerial::~SoftwareSerial()
|
||||
end();
|
||||
}
|
||||
|
||||
void SoftwareSerial::setTX(uint8_t tx)
|
||||
void SoftwareSerial::setTX(pin_t tx)
|
||||
{
|
||||
// First write, then set output. If we do this the other way around,
|
||||
// the pin would be output low for a short while before switching to
|
||||
@ -246,7 +246,7 @@ void SoftwareSerial::setTX(uint8_t tx)
|
||||
|
||||
}
|
||||
|
||||
void SoftwareSerial::setRX(uint8_t rx)
|
||||
void SoftwareSerial::setRX(pin_t rx)
|
||||
{
|
||||
pinMode(rx, INPUT_PULLUP); // pullup for normal logic!
|
||||
//if (!_inverse_logic)
|
||||
|
@ -48,8 +48,8 @@ class SoftwareSerial : public Stream
|
||||
{
|
||||
private:
|
||||
// per object data
|
||||
uint8_t _receivePin;
|
||||
uint8_t _transmitPin;
|
||||
pin_t _receivePin;
|
||||
pin_t _transmitPin;
|
||||
// uint32_t _receiveBitMask; // for rx interrupts
|
||||
uint32_t _receivePort;
|
||||
uint32_t _receivePortPin;
|
||||
@ -74,8 +74,8 @@ private:
|
||||
void recv();
|
||||
uint32_t rx_pin_read();
|
||||
void tx_pin_write(uint8_t pin_state);
|
||||
void setTX(uint8_t transmitPin);
|
||||
void setRX(uint8_t receivePin);
|
||||
void setTX(pin_t transmitPin);
|
||||
void setRX(pin_t receivePin);
|
||||
void setRxIntMsk(bool enable);
|
||||
|
||||
// private static method for timing
|
||||
@ -84,7 +84,7 @@ private:
|
||||
public:
|
||||
// public methods
|
||||
|
||||
SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false);
|
||||
SoftwareSerial(pin_t receivePin, pin_t transmitPin, bool inverse_logic = false);
|
||||
~SoftwareSerial();
|
||||
void begin(long speed);
|
||||
bool listen();
|
||||
|
@ -45,7 +45,7 @@ static void __initialize() {
|
||||
NVIC_EnableIRQ(EINT3_IRQn);
|
||||
}
|
||||
|
||||
void attachInterrupt(const uint32_t pin, void (*callback)(void), uint32_t mode) {
|
||||
void attachInterrupt(const pin_t pin, void (*callback)(void), uint32_t mode) {
|
||||
static int enabled = 0;
|
||||
|
||||
if (!INTERRUPT_PIN(pin)) return;
|
||||
@ -66,7 +66,7 @@ void attachInterrupt(const uint32_t pin, void (*callback)(void), uint32_t mode)
|
||||
GpioEnableInt(myport,mypin,mode);
|
||||
}
|
||||
|
||||
void detachInterrupt(const uint32_t pin) {
|
||||
void detachInterrupt(const pin_t pin) {
|
||||
if (!INTERRUPT_PIN(pin)) return;
|
||||
|
||||
const uint8_t myport = LPC1768_PIN_PORT(pin),
|
||||
|
@ -103,6 +103,8 @@ constexpr int8_t LPC1768_PIN_ADC(const pin_t pin) { return (int8_t)((pin >> 10)
|
||||
// ******************
|
||||
// Runtime pinmapping
|
||||
// ******************
|
||||
#define P_NC -1
|
||||
|
||||
#if SERIAL_PORT != 3
|
||||
#define P0_0 LPC1768_PIN(PORT(0), PIN(0), INTERRUPT(1), PWM(0), ADC_NONE)
|
||||
#define P0_1 LPC1768_PIN(PORT(0), PIN(1), INTERRUPT(1), PWM(0), ADC_NONE)
|
||||
@ -231,7 +233,7 @@ constexpr pin_t adc_pin_table[] = {
|
||||
};
|
||||
|
||||
constexpr pin_t analogInputToDigitalPin(const uint8_t p) {
|
||||
return (p < COUNT(adc_pin_table) ? adc_pin_table[p] : -1);
|
||||
return (p < COUNT(adc_pin_table) ? adc_pin_table[p] : P_NC);
|
||||
}
|
||||
|
||||
constexpr int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p) {
|
||||
|
@ -43,7 +43,9 @@ uint8_t HAL_get_reset_source(void) {
|
||||
|
||||
void watchdog_reset() {
|
||||
WDT_Feed();
|
||||
TOGGLE(13); // heart beat indicator on Pin13
|
||||
#if PIN_EXISTS(LED)
|
||||
TOGGLE(LED_PIN); // heart beat indicator
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // TARGET_LPC1768
|
||||
|
Reference in New Issue
Block a user