Joystick example and code cleanup

This commit is contained in:
Dominik Kotarski
2019-03-15 13:35:50 +01:00
parent 8dbfeb6575
commit 3e1d24fcf0
6 changed files with 19067 additions and 40 deletions
+74 -1
View File
@@ -39,11 +39,33 @@
*
*/
TaskHandle_t initTask;
/**
* @brief State Machine menu task handler
*
*/
TaskHandle_t menuStateMachineTask;
/**
* @brief LDR example task
*
*/
TaskHandle_t LDRTask;
/**
* @brief Joystick example task
*
*/
TaskHandle_t JoystickExampleTask;
/**
* @brief Handle of a task taking care of reading ioexpander over i2c in
* order to dertermine a source of the interrupt
*
*/
TaskHandle_t getInterruptSourceTask;
#if NRF_LOG_ENABLED
extern TaskHandle_t mLoggerThread;
#endif
@@ -57,6 +79,18 @@ TaskHandle_t ledsTask;
TaskHandle_t relayTask;
AconnoI2C i2c(PIN_EXP_SDA, PIN_EXP_SCL);
/**
* @brief handle for a semaphore used in fetching source of the interrupt
*
*/
SemaphoreHandle_t getInterruptSourceSemaphore;
/**
* @brief Object defining current state of the Master Example
*/
State* pMenuState;
AconnoI2C i2c (PIN_EXP_SDA, PIN_EXP_SCL);
AconnoSPI spi(PIN_EPD_MISO, PIN_EPD_MOSI, PIN_EPD_SCK);
AconnoSAADC adc;
@@ -92,6 +126,31 @@ int main(void)
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
// Initialize i2c
i2c.init();
// Initialize ioexpander
initIoExpander(&expdr);
expdr.setupInterruptPin(MCP23017_CENTER, MCP23017_INTMODE::FALLING);
expdr.setupInterruptPin(MCP23017__UP, MCP23017_INTMODE::FALLING);
expdr.setupInterruptPin(MCP23017__DOWN, MCP23017_INTMODE::FALLING);
expdr.setupInterruptPin(MCP23017_RIGHT, MCP23017_INTMODE::FALLING);
expdr.setupInterruptPin(MCP23017_LEFT, MCP23017_INTMODE::FALLING);
// End ioexpander Initialize
// Turn off leds
ledRed.set();
ledBlue.set();
ledGreen.set();
// Initialize state machine
pMenuState = new Intro1State();
pMenuState->displayOnEpd();
// Create all tasks that will be used
xTaskCreate(getInterruptSourceFunction, "GetInterruptSourceTask", 256, NULL,
1, &getInterruptSourceTask);
xTaskCreate(menuStateMachineTaskFunction, "MenuStateMachine", 256, NULL, 1,
&menuStateMachineTask);
xTaskCreate(ldrFunction, "LDR", 256, NULL, 1, &LDRTask);
@@ -103,6 +162,20 @@ int main(void)
xTaskCreate(ledsFunction, "LEDS", 256, NULL, 1, &ledsTask);
xTaskCreate(relayFunction, "RELAYS", 256, NULL, 1, &relayTask);
xTaskCreate(ldrFunction, "LDR", 256, NULL, 2, &LDRTask);
xTaskCreate(joystickTaskFunction, "JoystickTask", 256, NULL, 2,
&JoystickExampleTask);
// Create all semaphores that will be used
getInterruptSourceSemaphore= xSemaphoreCreateBinary();
if( getInterruptSourceSemaphore == NULL )
{
NRF_LOG_ERROR("ERROR, not enough space available to create semaphore!");
}
// Activate deep sleep mode.
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
@@ -110,7 +183,7 @@ int main(void)
timersInit();
applicationTimerStart();
// aconno BLE module init
// Initialize aconno BLE module
AconnoBLE &myBLE = *getAconnoBLEInstance();
myBLE.initBLEStack();
//myBLE.GATTInit();