PER Firmware
Loading...
Searching...
No Matches
driver_interface.c File Reference

thread to manage driver-facing LCD, buttons, LEDs More...

#include "driver_interface.h"
#include "fault_library/faults_common.h"
#include "can_library/generated/DASHBOARD.h"
#include "can_library/generated/can_types.h"
#include "rtos/rtos.h"
#include "heartbeat/heartbeat.h"
#include "phal_G4/exti/exti.h"
#include "phal_G4/gpio/gpio.h"
#include "watchdog/watchdog.h"
#include "utils/countof.h"
#include "lap_timer.h"
#include "lcd.h"
#include "main.h"
#include "pages/vcu.h"
Include dependency graph for driver_interface.c:

Macros

#define ACTION_QUEUE_LENGTH   (10)
 

Functions

void HardFault_Handler (void)
 
 RTOS_DEFINE_QUEUE (action_queue, driver_interface_action_t, ACTION_QUEUE_LENGTH)
 
static void enqueue_button_action (uint8_t pin, driver_interface_action_t action)
 
void PHAL_EXTI_callback (GPIO_TypeDef *bank, uint8_t pin)
 Weak callback invoked for each pending GPIO EXTI line.
 
static void init_buttons (void)
 
void action_dispatcher (void)
 
void set_external_leds (void)
 
void driver_interface_periodic (void)
 

Variables

static driver_interface_state_t di_state = DI_STATE_LCD_INIT
 
static driver_interface_state_t next_di_state = DI_STATE_LCD_INIT
 
volatile uint16_t data_mark_index = 0
 
static constexpr uint32_t INTERRUPT_DEBOUNCE_MS = 150
 
static constexpr uint32_t BUTTON_EXTI_IRQ_PRIORITY = 7U
 
static const PHAL_EXTI_InitConfig_t button_exti_config []
 
status_leds_t status_leds
 

Detailed Description

thread to manage driver-facing LCD, buttons, LEDs

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)

Macro Definition Documentation

◆ ACTION_QUEUE_LENGTH

#define ACTION_QUEUE_LENGTH   (10)

Function Documentation

◆ action_dispatcher()

void action_dispatcher ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ driver_interface_periodic()

void driver_interface_periodic ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enqueue_button_action()

static void enqueue_button_action ( uint8_t pin,
driver_interface_action_t action )
static
Here is the caller graph for this function:

◆ HardFault_Handler()

void HardFault_Handler ( void )
extern
Here is the caller graph for this function:

◆ init_buttons()

static void init_buttons ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PHAL_EXTI_callback()

void PHAL_EXTI_callback ( GPIO_TypeDef * bank,
uint8_t pin )

Weak callback invoked for each pending GPIO EXTI line.

Called from an EXTI interrupt handler. Keep overrides short and non-blocking. For both-edge triggers, sample the GPIO input to determine its current level. The default implementation does nothing.

Parameters
bankGPIO port that generated the interrupt
pinPin number, 0-15
Here is the call graph for this function:

◆ RTOS_DEFINE_QUEUE()

RTOS_DEFINE_QUEUE ( action_queue ,
driver_interface_action_t ,
ACTION_QUEUE_LENGTH  )

◆ set_external_leds()

void set_external_leds ( void )
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ button_exti_config

const PHAL_EXTI_InitConfig_t button_exti_config[]
static
Initial value:
= {
{.bank = EBB_MINUS_PORT, .pin = EBB_MINUS_PIN, .trigger = PHAL_EXTI_TRIGGER_FALLING, .irq_priority = BUTTON_EXTI_IRQ_PRIORITY},
{.bank = EBB_PLUS_PORT, .pin = EBB_PLUS_PIN, .trigger = PHAL_EXTI_TRIGGER_FALLING, .irq_priority = BUTTON_EXTI_IRQ_PRIORITY},
{.bank = MARK_DATA_PORT, .pin = MARK_DATA_PIN, .trigger = PHAL_EXTI_TRIGGER_FALLING, .irq_priority = BUTTON_EXTI_IRQ_PRIORITY},
{.bank = UP_BUTTON_PORT, .pin = UP_BUTTON_PIN, .trigger = PHAL_EXTI_TRIGGER_FALLING, .irq_priority = BUTTON_EXTI_IRQ_PRIORITY},
{.bank = LAP_SET_PORT, .pin = LAP_SET_PIN, .trigger = PHAL_EXTI_TRIGGER_FALLING, .irq_priority = BUTTON_EXTI_IRQ_PRIORITY},
{.bank = TV1_MINUS_PORT, .pin = TV1_MINUS_PIN, .trigger = PHAL_EXTI_TRIGGER_FALLING, .irq_priority = BUTTON_EXTI_IRQ_PRIORITY},
}
#define TV1_MINUS_PIN
Definition main.h:87
#define START_BUTTON_PORT
Definition main.h:58
#define LEFT_BUTTON_PIN
Definition main.h:53
#define MARK_DATA_PORT
Definition main.h:78
#define SELECT_BUTTON_PIN
Definition main.h:57
#define LEFT_BUTTON_PORT
Definition main.h:52
#define DOWN_BUTTON_PORT
Definition main.h:50
#define DOWN_BUTTON_PIN
Definition main.h:51
#define SELECT_BUTTON_PORT
Definition main.h:56
#define UP_BUTTON_PORT
Definition main.h:48
#define TV1_MINUS_PORT
Definition main.h:86
#define LAP_SET_PORT
Definition main.h:84
#define REGEN_TOGGLE_PORT
Definition main.h:76
#define REGEN_TOGGLE_PIN
Definition main.h:77
#define LAP_SET_PIN
Definition main.h:85
#define RIGHT_BUTTON_PORT
Definition main.h:54
#define EBB_PLUS_PIN
Definition main.h:83
#define EBB_MINUS_PIN
Definition main.h:81
#define EBB_PLUS_PORT
Definition main.h:82
#define RIGHT_BUTTON_PIN
Definition main.h:55
#define EBB_MINUS_PORT
Definition main.h:80
#define START_BUTTON_PIN
Definition main.h:59
#define MARK_DATA_PIN
Definition main.h:79
#define UP_BUTTON_PIN
Definition main.h:49
static constexpr uint32_t BUTTON_EXTI_IRQ_PRIORITY
Definition driver_interface.c:35
@ PHAL_EXTI_TRIGGER_FALLING
Definition exti.h:19

◆ BUTTON_EXTI_IRQ_PRIORITY

uint32_t BUTTON_EXTI_IRQ_PRIORITY = 7U
staticconstexpr

◆ data_mark_index

volatile uint16_t data_mark_index = 0

◆ di_state

◆ INTERRUPT_DEBOUNCE_MS

uint32_t INTERRUPT_DEBOUNCE_MS = 150
staticconstexpr

◆ next_di_state

◆ status_leds

status_leds_t status_leds
extern