implemented GPIO Raspi Shutdown indicator,

added documentation for dtoverlay
main
Jonas Arnold 4 years ago
parent b29fca6c5f
commit 059423ca66
  1. 10
      ADIS_tinyK22_RpiHat/raspi-overlayconfig.txt
  2. 45
      ADIS_tinyK22_RpiHat/source/application.c
  3. 1
      ADIS_tinyK22_RpiHat/source/platform.c

@ -1,11 +1,17 @@
To use GPIO shutdown for the Raspberry Pi, add following lines in the file /boot/config.txt
- Only one signal can be used (only one gpio-poweroff)
- When gpio-poweroff and gpio-shutdown is used, the gpio-shutdown can only shutdown the Pi, not start
- When only gpio-shutdown is used, the gpio-shutdown can also start the Pi
edit file: sudo nano /boot/config.txt
# signal power off with green led
dtoverlay=gpio-poweroff,gpiopin=16
# signal power off to GPIO GP1 pin
dtoverlay=gpio-poweroff,gpiopin=18
# shutdown Pi when joystick button is pressed
dtoverlay=gpio-shutdown,gpio_pin=26,gpio-pull=up
dtoverlay=gpio-shutdown,gpio_pin=26,gpio_pull=up
# shutdown Pi when GPIO GP0 on Hat is set to low
dtoverlay=gpio-shutdown,gpio_pin=17
dtoverlay=gpio-shutdown,gpio_pin=17,gpio_pull=up

@ -23,6 +23,7 @@
/* vars */
static McuLED_Handle_t LED_blue;
static McuGPIO_Handle_t GPIO_PowerRaspi;
static McuGPIO_Handle_t GPIO_RaspiShutdownIndicator;
static uint32_t taskParameter1 = 5;
static TaskHandle_t appTaskHandle = NULL;
static QueueHandle_t eventQueueHandle = NULL;
@ -41,13 +42,26 @@ void App_Init(void){
config.hw.pin = LED_BLUE_PIN;
LED_blue = McuLED_InitLed(&config);
/* configure gpio raspi power disable */
McuGPIO_Config_t config_gpio;
McuGPIO_GetDefaultConfig(&config_gpio);
config_gpio.hw.gpio = GPIOA;
config_gpio.hw.port = PORTA;
config_gpio.hw.pin = 1U;
GPIO_PowerRaspi = McuGPIO_InitGPIO(&config_gpio);
/* configure gpio raspi power off GPIO (GP_0)*/
McuGPIO_Config_t config_gp0;
McuGPIO_GetDefaultConfig(&config_gp0);
config_gp0.hw.gpio = GPIOA;
config_gp0.hw.port = PORTA;
config_gp0.hw.pin = 1U;
config_gp0.isInput = false; // Output
config_gp0.isHighOnInit = true; // active low
config_gp0.hw.pull = McuGPIO_PULL_DISABLE; // disable pull
GPIO_PowerRaspi = McuGPIO_InitGPIO(&config_gp0);
/* configure gpio raspi shutdown indicator (GP_1) */
McuGPIO_Config_t config_gp1;
McuGPIO_GetDefaultConfig(&config_gp1);
config_gp1.hw.gpio = GPIOA;
config_gp1.hw.port = PORTA;
config_gp1.hw.pin = 2U;
config_gp1.isInput = true; // input
config_gp1.hw.pull = McuGPIO_PULL_DISABLE; // disable pull
GPIO_RaspiShutdownIndicator = McuGPIO_InitGPIO(&config_gp1);
// get the event queue handle from debounce
eventQueueHandle = Debounce_GetEventQueueHandle();
@ -57,9 +71,11 @@ void App_Init(void){
static void App_Task(void* pv){
McuLog_info("Application Task starting");
Debounce_event_e event = Event_None;
while(1){
Debounce_event_e event = Event_None;
// get event data from queue if it can be reached
if(eventQueueHandle != NULL)
{
@ -67,12 +83,21 @@ static void App_Task(void* pv){
xQueueReceive(eventQueueHandle, &event, pdMS_TO_TICKS(20));
}
if(event == Button_Center_Pressed){
// turn off raspberry pi if requested by button press
if(event == Button_Up_Pressed){
McuGPIO_SetLow(GPIO_PowerRaspi);
vTaskDelay(pdMS_TO_TICKS(5000));
vTaskDelay(pdMS_TO_TICKS(1000));
McuGPIO_SetHigh(GPIO_PowerRaspi);
}
// turn on led if the power off indicator is on (Raspi is shut down)
if(McuGPIO_IsHigh(GPIO_RaspiShutdownIndicator)){
McuLED_On(LED_blue);
}else{
McuLED_Off(LED_blue);
}
vTaskDelay(pdMS_TO_TICKS(100));
}
}

@ -25,7 +25,6 @@ void PL_Init(void){
CLOCK_EnableClock(kCLOCK_PortA);
CLOCK_EnableClock(kCLOCK_PortB);
CLOCK_EnableClock(kCLOCK_PortC);
CLOCK_EnableClock(kCLOCK_PortD);
McuLib_Init();
McuRTOS_Init();

Loading…
Cancel
Save