/** * @file board_config.h * @brief Board-specific configuration */ #ifndef BOARD_CONFIG_H #define BOARD_CONFIG_H #include "mcu_config.h" /* ============================================================================ * Board Selection * ============================================================================ */ #define BOARD_STM32F407_DISCOVERY 1 #define BOARD_NXP_S32K144_EVB 0 #define BOARD_INFINEON_TC397_EVB 0 #if (BOARD_STM32F407_DISCOVERY + BOARD_NXP_S32K144_EVB + BOARD_INFINEON_TC397_EVB) != 1 #error "Exactly one board must be selected" #endif /* ============================================================================ * Pin Mapping * ============================================================================ */ #if BOARD_STM32F407_DISCOVERY /* STM32F407 Discovery board pin mapping */ /* LED pins */ #define LED1_PORT 0 /* GPIOA */ #define LED1_PIN 0 #define LED2_PORT 0 #define LED2_PIN 1 #define LED3_PORT 0 #define LED3_PIN 2 #define LED4_PORT 0 #define LED4_PIN 3 /* Button pins */ #define BUTTON1_PORT 0 /* GPIOA */ #define BUTTON1_PIN 0 /* UART pins */ #define UART1_TX_PORT 0 /* GPIOA */ #define UART1_TX_PIN 9 #define UART1_RX_PORT 0 #define UART1_RX_PIN 10 /* CAN pins */ #define CAN1_TX_PORT 1 /* GPIOB */ #define CAN1_TX_PIN 9 #define CAN1_RX_PORT 1 #define CAN1_RX_PIN 8 /* SPI pins */ #define SPI1_SCK_PORT 0 /* GPIOA */ #define SPI1_SCK_PIN 5 #define SPI1_MISO_PORT 0 #define SPI1_MISO_PIN 6 #define SPI1_MOSI_PORT 0 #define SPI1_MOSI_PIN 7 /* I2C pins */ #define I2C1_SCL_PORT 1 /* GPIOB */ #define I2C1_SCL_PIN 6 #define I2C1_SDA_PORT 1 #define I2C1_SDA_PIN 7 /* ADC pins */ #define ADC1_CH0_PORT 0 /* GPIOA */ #define ADC1_CH0_PIN 0 #define ADC1_CH1_PORT 0 #define ADC1_CH1_PIN 1 /* PWM pins */ #define PWM1_CH1_PORT 0 /* GPIOA */ #define PWM1_CH1_PIN 8 #define PWM1_CH2_PORT 0 #define PWM1_CH2_PIN 9 #elif BOARD_NXP_S32K144_EVB /* NXP S32K144 EVB pin mapping */ /* LED pins */ #define LED_RED_PORT 2 /* GPIOC */ #define LED_RED_PIN 0 #define LED_GREEN_PORT 2 #define LED_GREEN_PIN 1 #define LED_BLUE_PORT 2 #define LED_BLUE_PIN 2 /* Button pins */ #define BUTTON1_PORT 2 /* GPIOC */ #define BUTTON1_PIN 3 #define BUTTON2_PORT 2 #define BUTTON2_PIN 4 /* UART pins */ #define UART0_TX_PORT 0 /* GPIOA */ #define UART0_TX_PIN 2 #define UART0_RX_PORT 0 #define UART0_RX_PIN 3 /* CAN pins */ #define CAN0_TX_PORT 4 /* GPIOE */ #define CAN0_TX_PIN 5 #define CAN0_RX_PORT 4 #define CAN0_RX_PIN 4 /* SPI pins */ #define SPI0_SCK_PORT 0 /* GPIOA */ #define SPI0_SCK_PIN 6 #define SPI0_MISO_PORT 0 #define SPI0_MISO_PIN 7 #define SPI0_MOSI_PORT 0 #define SPI0_MOSI_PIN 8 #elif BOARD_INFINEON_TC397_EVB /* Infineon TC397 EVB pin mapping */ /* LED pins */ #define LED1_PORT 0 /* P00 */ #define LED1_PIN 0 #define LED2_PORT 0 #define LED2_PIN 1 /* Button pins */ #define BUTTON1_PORT 0 /* P00 */ #define BUTTON1_PIN 2 /* UART pins */ #define UART0_TX_PORT 0 /* P00 */ #define UART0_TX_PIN 3 #define UART0_RX_PORT 0 #define UART0_RX_PIN 4 /* CAN pins */ #define CAN0_TX_PORT 0 /* P00 */ #define CAN0_TX_PIN 5 #define CAN0_RX_PORT 0 #define CAN0_RX_PIN 6 #endif /* ============================================================================ * Board Features * ============================================================================ */ /* Debug interface */ #define DEBUG_INTERFACE_SWD 1 #define DEBUG_INTERFACE_JTAG 0 /* External crystal frequency */ #define EXTERNAL_CRYSTAL_HZ 8000000U /* Board voltage */ #define BOARD_VOLTAGE 3.3f /* Volts */ /* ============================================================================ * External Components * ============================================================================ */ /* External memory */ #define EXT_FLASH_ENABLED 0 #define EXT_RAM_ENABLED 0 /* External sensors */ #define TEMP_SENSOR_ENABLED 1 #define ACCELEROMETER_ENABLED 1 #define GYROSCOPE_ENABLED 0 /* Display */ #define LCD_DISPLAY_ENABLED 1 #define LCD_WIDTH 240 #define LCD_HEIGHT 320 #define LCD_COLOR_DEPTH 16 /* CAN transceiver */ #define CAN_TRANSCEIVER_ENABLED 1 #define CAN_TRANSCEIVER_TYPE 0 /* 0=TJA1050, 1=MCP2551 */ /* ============================================================================ * Board-Specific Functions * ============================================================================ */ /* Board initialization function */ void board_init(void); /* Board-specific GPIO initialization */ void board_gpio_init(void); /* Board-specific clock initialization */ void board_clock_init(void); /* Board-specific peripheral initialization */ void board_peripheral_init(void); /* Board-specific CAN initialization */ void board_can_init(void); /* Board-specific UART initialization */ void board_uart_init(void); /* Board-specific SPI initialization */ void board_spi_init(void); /* Board-specific I2C initialization */ void board_i2c_init(void); /* Board-specific ADC initialization */ void board_adc_init(void); /* Board-specific PWM initialization */ void board_pwm_init(void); /* Board LED control */ void board_led_on(uint8_t led); void board_led_off(uint8_t led); void board_led_toggle(uint8_t led); /* Board button reading */ bool board_button_read(uint8_t button); /* Board-specific delay */ void board_delay_ms(uint32_t ms); void board_delay_us(uint32_t us); /* Board-specific watchdog */ void board_watchdog_init(void); void board_watchdog_service(void); /* Board temperature reading */ float board_get_temperature(void); /* Board voltage reading */ float board_get_voltage(void); #endif /* BOARD_CONFIG_H */