diff --git a/source/shoh/src/peripherals/I2C.cpp b/source/shoh/src/peripherals/I2C.cpp index 5f9c753..10ccbd0 100644 --- a/source/shoh/src/peripherals/I2C.cpp +++ b/source/shoh/src/peripherals/I2C.cpp @@ -57,8 +57,12 @@ I2C::I2C (const I2C_config &cfg) : device (nullptr) */ //Manual: Table 83 & 90 Chip_SYSCTL_PeriphReset(RESET_I2C0); - Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 4, IOCON_FUNC1 | IOCON_DIGMODE_EN | cfg.i2c_mode); - Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 5, IOCON_FUNC1 | IOCON_DIGMODE_EN | cfg.i2c_mode); + Chip_IOCON_PinMuxSet(LPC_IOCON, ThreadCommon::PORT_I2C_SCL, + ThreadCommon::PIN_I2C_SCL, IOCON_FUNC1 | + IOCON_DIGMODE_EN | cfg.i2c_mode); + Chip_IOCON_PinMuxSet(LPC_IOCON, ThreadCommon::PORT_I2C_SDA, + ThreadCommon::PIN_I2C_SDA, IOCON_FUNC1 | + IOCON_DIGMODE_EN | cfg.i2c_mode); //} // else { // currently we support only I2C number 0 diff --git a/source/shoh/src/peripherals/I2C.h b/source/shoh/src/peripherals/I2C.h index 6bf5016..28c4c86 100644 --- a/source/shoh/src/peripherals/I2C.h +++ b/source/shoh/src/peripherals/I2C.h @@ -10,6 +10,7 @@ #include "chip.h" #include "board.h" +#include "pinportmap.h" struct I2C_config { unsigned int device_number; diff --git a/source/shoh/src/threads/common/ThreadCommon.h b/source/shoh/src/threads/common/ThreadCommon.h index 0aa05c0..b6b3eea 100644 --- a/source/shoh/src/threads/common/ThreadCommon.h +++ b/source/shoh/src/threads/common/ThreadCommon.h @@ -13,12 +13,12 @@ #include #include #include "queue.h" +#include "pinportmap.h" #include "task.h" #include namespace ThreadCommon { - enum RotaryAction { Right, diff --git a/source/shoh/src/threads/common/pinportmap.h b/source/shoh/src/threads/common/pinportmap.h new file mode 100644 index 0000000..7ae3d6d --- /dev/null +++ b/source/shoh/src/threads/common/pinportmap.h @@ -0,0 +1,49 @@ +/* + * pinportmap.h + * + * Created on: 17 Jun 2023 + * Author: dave + */ + +#ifndef THREADS_COMMON_PINPORTMAP_H_ +#define THREADS_COMMON_PINPORTMAP_H_ + +namespace ThreadCommon +{ + + enum PINMAP + { + PIN_LCD_RS = 24, + PIN_LCD_EN = 26, + PIN_LCD_D4 = 27, + PIN_LCD_D5 = 25, + PIN_LCD_D6 = 28, + PIN_LCD_D7 = 3, + PIN_I2C_SCL = 4, + PIN_I2C_SDA = 5, + PIN_ROTARY_SIG_A = 18, + PIN_ROTARY_SIG_B = 12, + PIN_ROTARY_PRESS = 2, + PIN_BOARD_SW1 = 1 + }; + + enum PORTMAP + { + PORT_LCD_RS = 1, + PORT_LCD_EN = 1, + PORT_LCD_D4 = 1, + PORT_LCD_D5 = 1, + PORT_LCD_D6 = 1, + PORT_LCD_D7 = 2, + PORT_I2C_SCL = 0, + PORT_I2C_SDA = 0, + PORT_ROTARY_SIG_A = 1, + PORT_ROTARY_SIG_B = 2, + PORT_ROTARY_PRESS = 0, + PORT_BOARD_SW1 = 0 + }; +} + + + +#endif /* THREADS_COMMON_PINPORTMAP_H_ */ diff --git a/source/shoh/src/threads/rotary/Rotary.h b/source/shoh/src/threads/rotary/Rotary.h index e21077b..b99965f 100644 --- a/source/shoh/src/threads/rotary/Rotary.h +++ b/source/shoh/src/threads/rotary/Rotary.h @@ -20,9 +20,15 @@ public: private: Event* message; ThreadCommon::QueueManager* _qm; - DigitalIoPin signal[3] = { { 1, 18, true, true, false, true, PIN_INT0_IRQn}, //sigA - { 2, 12, true, true, false}, //sigB - { 0, 2, true, true, false, true, PIN_INT1_IRQn} }; //Press, sw //2 11 (pin without interrupt) //0 1 (board button) + DigitalIoPin signal[3] = { { ThreadCommon::PORT_ROTARY_SIG_A, + ThreadCommon::PIN_ROTARY_SIG_A, + true, true, false, true, PIN_INT0_IRQn}, + { ThreadCommon::PORT_ROTARY_SIG_B, + ThreadCommon::PIN_ROTARY_SIG_A, + true, true, false}, + { ThreadCommon::PORT_ROTARY_PRESS, + ThreadCommon::PIN_ROTARY_SIG_A, + true, true, false, true, PIN_INT1_IRQn} }; }; void thread_rotary(void* pvParams); diff --git a/source/shoh/src/threads/user_interface/UserInterface.cpp b/source/shoh/src/threads/user_interface/UserInterface.cpp index 9bcc0fd..0195380 100644 --- a/source/shoh/src/threads/user_interface/UserInterface.cpp +++ b/source/shoh/src/threads/user_interface/UserInterface.cpp @@ -75,12 +75,18 @@ void UserInterface::handleLCD(LiquidCrystal *lcd, const char *str) void UserInterface::initLCD1() { - this->lcd1_rs = new DigitalIoPin(1, 24, false);//(1, 18, false); - this->lcd1_en = new DigitalIoPin(1, 26, false);//(1, 24, false); - this->lcd1_d4 = new DigitalIoPin(1, 27, false);//(1, 19, false); - this->lcd1_d5 = new DigitalIoPin(1, 25, false);//(1, 26, false); - this->lcd1_d6 = new DigitalIoPin(1, 28, false);//(1, 27, false); - this->lcd1_d7 = new DigitalIoPin(2, 3, false);//(1, 25, false); + this->lcd1_rs = new DigitalIoPin(ThreadCommon::PORT_LCD_RS, + ThreadCommon::PIN_LCD_RS, false);//(1, 18, false); + this->lcd1_en = new DigitalIoPin(ThreadCommon::PORT_LCD_EN, + ThreadCommon::PIN_LCD_EN, false);//(1, 24, false); + this->lcd1_d4 = new DigitalIoPin(ThreadCommon::PORT_LCD_D4, + ThreadCommon::PIN_LCD_D4, false);//(1, 19, false); + this->lcd1_d5 = new DigitalIoPin(ThreadCommon::PORT_LCD_D5, + ThreadCommon::PIN_LCD_D5, false);//(1, 26, false); + this->lcd1_d6 = new DigitalIoPin(ThreadCommon::PORT_LCD_D6, + ThreadCommon::PIN_LCD_D6, false);//(1, 27, false); + this->lcd1_d7 = new DigitalIoPin(ThreadCommon::PORT_LCD_D7, + ThreadCommon::PIN_LCD_D7, false);//(1, 25, false); this->lcd1_rs->write(false); this->lcd1_en->write(false);