clean up for porting - move platform specific stuff into outer project
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Definition of nRF24L01+ pin mappings for the platform
|
||||
// This file may be omitted if SUPPORT_NRF is not set in plat_compat.h
|
||||
// See rsc_enum.h for the R_ resource constants
|
||||
//
|
||||
|
||||
#ifndef GEX_NRF_PINS_H
|
||||
#define GEX_NRF_PINS_H
|
||||
|
||||
#include "platform.h"
|
||||
#include "rsc_enum.h"
|
||||
|
||||
#define NRF_SPI SPI2
|
||||
#define NRF_R_SPI R_SPI2
|
||||
|
||||
#define NRF_IRQ_Pin LL_GPIO_PIN_15
|
||||
#define NRF_IRQ_GPIO_Port GPIOC
|
||||
#define NRF_R_IRQ R_PC15
|
||||
#define NRF_EXTI_LINENUM 15
|
||||
#define NRF_SYSCFG_EXTI_PORT LL_SYSCFG_EXTI_PORTC
|
||||
|
||||
#define NRF_NSS_Pin LL_GPIO_PIN_13
|
||||
#define NRF_NSS_GPIO_Port GPIOC
|
||||
#define NRF_R_NSS R_PC13
|
||||
|
||||
#define NRF_CE_Pin LL_GPIO_PIN_14
|
||||
#define NRF_CE_GPIO_Port GPIOC
|
||||
#define NRF_R_CE R_PC14
|
||||
|
||||
#define NRF_RST_Pin LL_GPIO_PIN_12
|
||||
#define NRF_RST_GPIO_Port GPIOC
|
||||
#define NRF_R_RST R_PC12
|
||||
|
||||
#define NRF_R_SCK R_PB13
|
||||
#define NRF_SCK_AF LL_GPIO_AF_0
|
||||
#define NRF_R_MISO R_PC2
|
||||
#define NRF_MISO_AF LL_GPIO_AF_1
|
||||
#define NRF_R_MOSI R_PC3
|
||||
#define NRF_MOSI_AF LL_GPIO_AF_1
|
||||
|
||||
#endif //GEX_NRF_PINS_H
|
||||
@@ -0,0 +1,28 @@
|
||||
#if defined(GEX_PLAT_F103_BLUEPILL) || defined(GEX_PLAT_F303_DISCOVERY) \
|
||||
|| defined(GEX_PLAT_F407_DISCOVERY)
|
||||
// This is for F103+
|
||||
|
||||
/* The lowest interrupt priority that can be used in a call to a "set priority"
|
||||
function. */
|
||||
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
|
||||
|
||||
#define configPRIO_BITS 4
|
||||
|
||||
/* The highest interrupt priority that can be used by any interrupt service
|
||||
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
|
||||
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
|
||||
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
|
||||
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
|
||||
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
#elif defined(STM32F072xB)
|
||||
// This is for F072
|
||||
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 3
|
||||
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 1
|
||||
|
||||
#define configPRIO_BITS 2
|
||||
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||
#else
|
||||
#error "BAD PLATFORM!!"
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
#define DEBUG_USART_BAUD 115200
|
||||
|
||||
#if GEX_PLAT_F072
|
||||
|
||||
#define DEBUG_USART USART1
|
||||
#define DEBUG_USART_RSC R_USART1
|
||||
#define DEBUG_USART_PORT 'A'
|
||||
#define DEBUG_USART_PIN 9
|
||||
#define DEBUG_USART_AF 1
|
||||
#define DEBUG_USART_PCLK PLAT_APB1_HZ
|
||||
|
||||
#elif GEX_PLAT_F103
|
||||
|
||||
#define DEBUG_USART USART2
|
||||
#define DEBUG_USART_RSC R_USART2
|
||||
#define DEBUG_USART_PORT 'A'
|
||||
#define DEBUG_USART_PIN 2
|
||||
#define DEBUG_USART_PCLK PLAT_APB1_HZ
|
||||
|
||||
#elif GEX_PLAT_F303
|
||||
|
||||
#define DEBUG_USART USART3
|
||||
#define DEBUG_USART_RSC R_USART3
|
||||
#define DEBUG_USART_PORT 'D'
|
||||
#define DEBUG_USART_PIN 8
|
||||
#define DEBUG_USART_AF 7
|
||||
#define DEBUG_USART_PCLK PLAT_APB1_HZ
|
||||
|
||||
#elif GEX_PLAT_F407
|
||||
|
||||
#define DEBUG_USART USART2
|
||||
#define DEBUG_USART_RSC R_USART2
|
||||
#define DEBUG_USART_PORT 'A'
|
||||
#define DEBUG_USART_PIN 2
|
||||
#define DEBUG_USART_AF 7
|
||||
#define DEBUG_USART_PCLK PLAT_APB1_HZ
|
||||
|
||||
#else
|
||||
#error "BAD PLATFORM!"
|
||||
#endif
|
||||
@@ -0,0 +1,261 @@
|
||||
//
|
||||
// Created by MightyPork on 2017/12/08.
|
||||
//
|
||||
|
||||
#ifndef GEX_PLAT_COMPAT_H
|
||||
#define GEX_PLAT_COMPAT_H
|
||||
|
||||
#if defined(GEX_PLAT_F103_BLUEPILL)
|
||||
|
||||
// platform name for the version string
|
||||
#define GEX_PLATFORM "STM32F103-Bluepill"
|
||||
#define PLAT_AHB_MHZ 72
|
||||
#define PLAT_APB1_MHZ 36
|
||||
|
||||
// feature flags
|
||||
#define PLAT_FLASHBANKS 1
|
||||
#define PLAT_NO_FLOATING_INPUTS 1
|
||||
#define PLAT_NO_AFNUM 1
|
||||
|
||||
#include <stm32f1xx.h>
|
||||
#include <stm32f1xx_hal.h>
|
||||
#include <stm32f1xx_ll_adc.h>
|
||||
#include <stm32f1xx_ll_bus.h>
|
||||
#include <stm32f1xx_ll_cortex.h>
|
||||
#include <stm32f1xx_ll_crc.h>
|
||||
#include <stm32f1xx_ll_dac.h>
|
||||
#include <stm32f1xx_ll_dma.h>
|
||||
#include <stm32f1xx_ll_exti.h>
|
||||
#include <stm32f1xx_ll_fsmc.h>
|
||||
#include <stm32f1xx_ll_gpio.h>
|
||||
#include <stm32f1xx_ll_i2c.h>
|
||||
#include <stm32f1xx_ll_iwdg.h>
|
||||
#include <stm32f1xx_ll_pwr.h>
|
||||
#include <stm32f1xx_ll_rcc.h>
|
||||
#include <stm32f1xx_ll_rtc.h>
|
||||
#include <stm32f1xx_ll_sdmmc.h>
|
||||
#include <stm32f1xx_ll_spi.h>
|
||||
#include <stm32f1xx_ll_system.h>
|
||||
#include <stm32f1xx_ll_tim.h>
|
||||
#include <stm32f1xx_ll_usart.h>
|
||||
#include <stm32f1xx_ll_usb.h>
|
||||
#include <stm32f1xx_ll_utils.h>
|
||||
#include <stm32f1xx_ll_wwdg.h>
|
||||
|
||||
// size, determines position of the flash storage
|
||||
#define FLASH_SIZE (64*1024)
|
||||
#define SETTINGS_BLOCK_SIZE (1024*2) // this must be a multiple of FLASH pages
|
||||
#define SETTINGS_FLASH_ADDR (0x08000000 + FLASH_SIZE - SETTINGS_BLOCK_SIZE)
|
||||
|
||||
// Number of GPIO ports A,B,C...
|
||||
#define PORTS_COUNT 5
|
||||
|
||||
// Lock jumper config - re-use BOOT1, closed = LOW
|
||||
#define LOCK_JUMPER_PORT 'B'
|
||||
#define LOCK_JUMPER_PIN 2
|
||||
|
||||
// Status LED config
|
||||
#define STATUS_LED_PORT 'C'
|
||||
#define STATUS_LED_PIN 13
|
||||
|
||||
#elif defined(STM32F072xB)
|
||||
|
||||
#define PLAT_AHB_MHZ 48
|
||||
#define PLAT_APB1_MHZ 48
|
||||
|
||||
#include <stm32f0xx.h>
|
||||
#include <stm32f0xx_ll_adc.h>
|
||||
#include <stm32f0xx_ll_bus.h>
|
||||
#include <stm32f0xx_ll_comp.h>
|
||||
#include <stm32f0xx_ll_cortex.h>
|
||||
#include <stm32f0xx_ll_crc.h>
|
||||
#include <stm32f0xx_ll_crs.h>
|
||||
#include <stm32f0xx_ll_dac.h>
|
||||
#include <stm32f0xx_ll_dma.h>
|
||||
#include <stm32f0xx_ll_exti.h>
|
||||
#include <stm32f0xx_ll_gpio.h>
|
||||
#include <stm32f0xx_ll_i2c.h>
|
||||
#include <stm32f0xx_ll_iwdg.h>
|
||||
#include <stm32f0xx_ll_pwr.h>
|
||||
#include <stm32f0xx_ll_rcc.h>
|
||||
#include <stm32f0xx_ll_rtc.h>
|
||||
#include <stm32f0xx_ll_spi.h>
|
||||
#include <stm32f0xx_ll_system.h>
|
||||
#include <stm32f0xx_ll_tim.h>
|
||||
#include <stm32f0xx_ll_usart.h>
|
||||
#include <stm32f0xx_ll_utils.h>
|
||||
#include <stm32f0xx_ll_wwdg.h>
|
||||
|
||||
// size, determines position of the flash storage
|
||||
#define FLASH_SIZE (128*1024)
|
||||
#define SETTINGS_BLOCK_SIZE (1024*2) // this must be a multiple of FLASH pages
|
||||
#define SETTINGS_FLASH_ADDR (0x08000000 + FLASH_SIZE - SETTINGS_BLOCK_SIZE)
|
||||
|
||||
// Number of GPIO ports A,B,C...
|
||||
#define PORTS_COUNT 6
|
||||
|
||||
#if defined(GEX_PLAT_F072_DISCOVERY)
|
||||
// platform name for the version string
|
||||
#define GEX_PLATFORM "STM32F072-Discovery"
|
||||
|
||||
// Lock jumper config
|
||||
#define LOCK_JUMPER_PORT 'A'
|
||||
#define LOCK_JUMPER_PIN 0
|
||||
#define PLAT_LOCK_BTN 1 // toggle button instead of a jumper
|
||||
#define PLAT_LOCK_1CLOSED 1 // toggle button active in log. 1
|
||||
|
||||
// Status LED config
|
||||
#define STATUS_LED_PORT 'C'
|
||||
#define STATUS_LED_PIN 6 // RED LED "UP"
|
||||
#elif defined(GEX_PLAT_F072_HUB)
|
||||
// platform name for the version string
|
||||
#define GEX_PLATFORM "STM32F072-HUB"
|
||||
|
||||
#define PLAT_FULL_XTAL 1
|
||||
|
||||
// Lock jumper config
|
||||
#define LOCK_JUMPER_PORT 'D'
|
||||
#define LOCK_JUMPER_PIN 2
|
||||
#define PLAT_LOCK_BTN 1 // toggle button instead of a jumper
|
||||
#define PLAT_LOCK_1CLOSED 0 // toggle button active in log. 1
|
||||
|
||||
// Status LED config
|
||||
#define STATUS_LED_PORT 'A'
|
||||
#define STATUS_LED_PIN 15 // RED LED "UP"
|
||||
#elif defined(GEX_PLAT_F072_ZERO)
|
||||
// platform name for the version string
|
||||
#define GEX_PLATFORM "STM32F072-ZERO"
|
||||
|
||||
#define PLAT_FULL_XTAL 1
|
||||
|
||||
// Lock jumper config
|
||||
#define LOCK_JUMPER_PORT 'D'
|
||||
#define LOCK_JUMPER_PIN 2
|
||||
#define PLAT_LOCK_BTN 1 // toggle button instead of a jumper
|
||||
#define PLAT_LOCK_1CLOSED 1 // toggle button active in log. 1
|
||||
|
||||
// Status LED config
|
||||
#define STATUS_LED_PORT 'A'
|
||||
#define STATUS_LED_PIN 15 // RED LED "UP"
|
||||
|
||||
#define SUPPORT_NRF 1
|
||||
#else
|
||||
#error Bad platform
|
||||
#endif
|
||||
|
||||
#elif defined(GEX_PLAT_F303_DISCOVERY)
|
||||
|
||||
// platform name for the version string
|
||||
#define GEX_PLATFORM "STM32F303-Discovery"
|
||||
#define PLAT_AHB_MHZ 72
|
||||
#define PLAT_APB1_MHZ 36
|
||||
#define PLAT_APB2_MHZ 72
|
||||
|
||||
#include <stm32f3xx.h>
|
||||
#include <stm32f3xx_hal.h>
|
||||
#include <stm32f3xx_ll_adc.h>
|
||||
#include <stm32f3xx_ll_bus.h>
|
||||
#include <stm32f3xx_ll_comp.h>
|
||||
#include <stm32f3xx_ll_cortex.h>
|
||||
#include <stm32f3xx_ll_crc.h>
|
||||
#include <stm32f3xx_ll_dac.h>
|
||||
#include <stm32f3xx_ll_dma.h>
|
||||
#include <stm32f3xx_ll_exti.h>
|
||||
#include <stm32f3xx_ll_fmc.h>
|
||||
#include <stm32f3xx_ll_gpio.h>
|
||||
#include <stm32f3xx_ll_hrtim.h>
|
||||
#include <stm32f3xx_ll_i2c.h>
|
||||
#include <stm32f3xx_ll_iwdg.h>
|
||||
#include <stm32f3xx_ll_opamp.h>
|
||||
#include <stm32f3xx_ll_pwr.h>
|
||||
#include <stm32f3xx_ll_rcc.h>
|
||||
#include <stm32f3xx_ll_rtc.h>
|
||||
#include <stm32f3xx_ll_spi.h>
|
||||
#include <stm32f3xx_ll_system.h>
|
||||
#include <stm32f3xx_ll_tim.h>
|
||||
#include <stm32f3xx_ll_usart.h>
|
||||
#include <stm32f3xx_ll_utils.h>
|
||||
#include <stm32f3xx_ll_wwdg.h>
|
||||
|
||||
// size, determines position of the flash storage
|
||||
#define FLASH_SIZE (256*1024)
|
||||
#define SETTINGS_BLOCK_SIZE (1024*2) // this must be a multiple of FLASH pages
|
||||
#define SETTINGS_FLASH_ADDR (0x08000000 + FLASH_SIZE - SETTINGS_BLOCK_SIZE)
|
||||
|
||||
// Number of GPIO ports A,B,C...
|
||||
#define PORTS_COUNT 6
|
||||
|
||||
// Lock jumper config
|
||||
#define LOCK_JUMPER_PORT 'A'
|
||||
#define LOCK_JUMPER_PIN 0
|
||||
#define PLAT_LOCK_BTN 1 // toggle button instead of a jumper
|
||||
#define PLAT_LOCK_1CLOSED 1 // toggle button active in log. 1
|
||||
|
||||
// Status LED config
|
||||
#define STATUS_LED_PORT 'E'
|
||||
#define STATUS_LED_PIN 13
|
||||
|
||||
#elif defined(GEX_PLAT_F407_DISCOVERY)
|
||||
|
||||
// platform name for the version string
|
||||
#define GEX_PLATFORM "STM32F407-Discovery"
|
||||
#define PLAT_AHB_MHZ 168
|
||||
#define PLAT_APB1_MHZ 48
|
||||
#define PLAT_APB2_MHZ 96
|
||||
|
||||
#define PLAT_USB_PHYCLOCK 1
|
||||
#define PLAT_USB_OTGFS 1
|
||||
|
||||
#include <stm32f4xx.h>
|
||||
#include <stm32f4xx_hal.h>
|
||||
#include <stm32f4xx_ll_adc.h>
|
||||
#include <stm32f4xx_ll_crc.h>
|
||||
#include <stm32f4xx_ll_dac.h>
|
||||
#include <stm32f4xx_ll_dma.h>
|
||||
#include <stm32f4xx_ll_dma2d.h>
|
||||
#include <stm32f4xx_ll_exti.h>
|
||||
#include <stm32f4xx_ll_fmc.h>
|
||||
#include <stm32f4xx_ll_fsmc.h>
|
||||
#include <stm32f4xx_ll_gpio.h>
|
||||
#include <stm32f4xx_ll_i2c.h>
|
||||
#include <stm32f4xx_ll_lptim.h>
|
||||
#include <stm32f4xx_ll_pwr.h>
|
||||
#include <stm32f4xx_ll_rcc.h>
|
||||
#include <stm32f4xx_ll_rng.h>
|
||||
#include <stm32f4xx_ll_rtc.h>
|
||||
#include <stm32f4xx_ll_sdmmc.h>
|
||||
#include <stm32f4xx_ll_spi.h>
|
||||
#include <stm32f4xx_ll_tim.h>
|
||||
#include <stm32f4xx_ll_usart.h>
|
||||
#include <stm32f4xx_ll_usb.h>
|
||||
#include <stm32f4xx_ll_utils.h>
|
||||
|
||||
// size, determines position of the flash storage
|
||||
|
||||
// we use the first 128kB sector. Unfortunately the whole sector must be erased before writing.
|
||||
#define SETTINGS_FLASH_SECTOR FLASH_SECTOR_5
|
||||
#define SETTINGS_BLOCK_SIZE (1024*2)
|
||||
#define SETTINGS_FLASH_ADDR (0x08000000 + (16*4+64)*1024)
|
||||
|
||||
// Number of GPIO ports A,B,C...
|
||||
#define PORTS_COUNT 6
|
||||
|
||||
// Lock jumper config
|
||||
#define LOCK_JUMPER_PORT 'A'
|
||||
#define LOCK_JUMPER_PIN 0
|
||||
#define PLAT_LOCK_BTN 1 // toggle button instead of a jumper
|
||||
#define PLAT_LOCK_1CLOSED 1 // toggle button active in log. 1
|
||||
|
||||
// Status LED config
|
||||
#define STATUS_LED_PORT 'D' // orange
|
||||
#define STATUS_LED_PIN 13
|
||||
|
||||
#else
|
||||
#error "BAD PLATFORM! Please select GEX platform using a -DGEX_PLAT_* compile flag"
|
||||
#endif
|
||||
|
||||
#define PLAT_AHB_HZ (PLAT_AHB_MHZ*1000000)
|
||||
#define PLAT_APB1_HZ (PLAT_APB1_MHZ*1000000)
|
||||
#define PLAT_APB2_HZ (PLAT_APB2_MHZ*1000000)
|
||||
|
||||
#endif //GEX_PLAT_COMPAT_H
|
||||
@@ -0,0 +1,194 @@
|
||||
|
||||
#if defined(GEX_PLAT_F103_BLUEPILL)
|
||||
// Platform STM32F103C8T6 Bluepill ($4 board from eBay)
|
||||
|
||||
// Units supported by the platform (known to work correctly)
|
||||
|
||||
// free all present resources
|
||||
{
|
||||
rsc_free_range(NULL, R_ADC1, R_ADC2);
|
||||
rsc_free_range(NULL, R_I2C1, R_I2C2);
|
||||
rsc_free_range(NULL, R_SPI1, R_SPI2);
|
||||
rsc_free_range(NULL, R_TIM1, R_TIM4);
|
||||
rsc_free_range(NULL, R_USART1, R_USART3);
|
||||
rsc_free_range(NULL, R_PA0, R_PA15);
|
||||
rsc_free_range(NULL, R_PB0, R_PB15);
|
||||
rsc_free_range(NULL, R_PC13, R_PC15);
|
||||
rsc_free_range(NULL, R_PD0, R_PD1);
|
||||
}
|
||||
|
||||
// Claim resources not available due to board layout or internal usage
|
||||
{
|
||||
// HAL timebase
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_TIM1);
|
||||
// HSE crystal
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PD0);
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PD1);
|
||||
// SWD
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
|
||||
// USB
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA11);
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA12);
|
||||
// BOOT pin(s)
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1
|
||||
}
|
||||
#elif defined(STM32F072xB)
|
||||
// Platform STM32F073RBT
|
||||
|
||||
|
||||
// Free all present resources
|
||||
{
|
||||
rsc_free(NULL, R_ADC1);
|
||||
// rsc_free(NULL, R_CAN1);
|
||||
// rsc_free_range(NULL, R_COMP1, R_COMP2);
|
||||
rsc_free(NULL, R_DAC1);
|
||||
// rsc_free(NULL, R_HDMI_CEC);
|
||||
rsc_free(NULL, R_TSC);
|
||||
rsc_free_range(NULL, R_I2C1, R_I2C2);
|
||||
// rsc_free_range(NULL, R_I2S1, R_I2S2);
|
||||
rsc_free_range(NULL, R_SPI1, R_SPI2);
|
||||
rsc_free_range(NULL, R_TIM1, R_TIM3);
|
||||
rsc_free_range(NULL, R_TIM6, R_TIM7);
|
||||
rsc_free_range(NULL, R_TIM14, R_TIM17);
|
||||
rsc_free_range(NULL, R_USART1, R_USART4);
|
||||
rsc_free_range(NULL, R_DMA1_1, R_DMA1_7);
|
||||
|
||||
rsc_free_range(NULL, R_PA0, R_PA15);
|
||||
rsc_free_range(NULL, R_PB0, R_PB15);
|
||||
rsc_free_range(NULL, R_PC0, R_PC15);
|
||||
rsc_free(NULL, R_PD2);
|
||||
rsc_free_range(NULL, R_PF0, R_PF1);
|
||||
}
|
||||
|
||||
// Claim resources not available due to board layout or internal usage
|
||||
{
|
||||
// HAL timebase
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_TIM17);
|
||||
// HSE crystal
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PF0);
|
||||
|
||||
#if PLAT_FULL_XTAL
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PF1); // - not used in BYPASS mode
|
||||
#endif
|
||||
|
||||
// SWD
|
||||
// rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
|
||||
// rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
|
||||
// USB
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA11);
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA12);
|
||||
|
||||
#if defined(GEX_PLAT_F072_ZERO)
|
||||
// unconnected pins
|
||||
rv |= rsc_claim_range(&UNIT_PLATFORM, R_PC0, R_PC1);
|
||||
rv |= rsc_claim_range(&UNIT_PLATFORM, R_PC4, R_PC9);
|
||||
#endif
|
||||
}
|
||||
#elif defined(GEX_PLAT_F303_DISCOVERY)
|
||||
// Platform STM32F303VCT
|
||||
|
||||
// Additional GPIO ports
|
||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||
|
||||
// Units supported by the platform (known to work correctly)
|
||||
// ureg_add_type(&UNIT_XYZ);
|
||||
|
||||
// Free all present resources
|
||||
{
|
||||
rsc_free_range(NULL, R_ADC1, R_ADC4);
|
||||
// rsc_free(NULL, R_CAN1);
|
||||
// rsc_free_range(NULL, R_COMP1, R_COMP7);
|
||||
// rsc_free(NULL, R_HDMI_CEC);
|
||||
rsc_free(NULL, R_DAC1);
|
||||
rsc_free_range(NULL, R_I2C1, R_I2C2);
|
||||
rsc_free_range(NULL, R_I2S2, R_I2S3);
|
||||
// rsc_free_range(NULL, R_OPAMP1, R_OPAMP4);
|
||||
rsc_free_range(NULL, R_SPI1, R_SPI3);
|
||||
rsc_free_range(NULL, R_TIM1, R_TIM4);
|
||||
rsc_free_range(NULL, R_TIM6, R_TIM8);
|
||||
rsc_free_range(NULL, R_TIM15, R_TIM17);
|
||||
rsc_free(NULL, R_TSC);
|
||||
rsc_free_range(NULL, R_USART1, R_USART5);
|
||||
|
||||
rsc_free_range(NULL, R_PA0, R_PA15);
|
||||
rsc_free_range(NULL, R_PB0, R_PB15);
|
||||
rsc_free_range(NULL, R_PC0, R_PC15);
|
||||
rsc_free_range(NULL, R_PD0, R_PD15);
|
||||
rsc_free_range(NULL, R_PE0, R_PE15);
|
||||
|
||||
rsc_free_range(NULL, R_PF0, R_PF2);
|
||||
rsc_free(NULL, R_PF4);
|
||||
rsc_free_range(NULL, R_PF9, R_PF10);
|
||||
}
|
||||
|
||||
// Claim resources not available due to board layout or internal usage
|
||||
{
|
||||
// HAL timebase
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_TIM1);
|
||||
// HSE crystal
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PF0);
|
||||
//rv |= rsc_claim(&UNIT_SYSTEM, R_PF1); // - not used in BYPASS mode
|
||||
// SWD
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
|
||||
// USB
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA11);
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA12);
|
||||
// BOOT pin(s)
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1
|
||||
}
|
||||
#elif defined(GEX_PLAT_F407_DISCOVERY)
|
||||
// Platform STM32F407VGT
|
||||
|
||||
// Additional GPIO ports
|
||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||
|
||||
// Units supported by the platform (known to work correctly)
|
||||
// ureg_add_type(&UNIT_XYZ);
|
||||
|
||||
// Free all present resources
|
||||
{
|
||||
rsc_free_range(NULL, R_ADC1, R_ADC3);
|
||||
// rsc_free_range(NULL, R_CAN1, R_CAN2);
|
||||
// rsc_free_range(NULL, R_COMP1, R_COMP7);
|
||||
rsc_free(NULL, R_DAC1);
|
||||
// rsc_free(NULL, R_DCMI);
|
||||
// rsc_free(NULL, R_ETH);
|
||||
// rsc_free(NULL, R_FSMC);
|
||||
rsc_free_range(NULL, R_I2C1, R_I2C3);
|
||||
rsc_free_range(NULL, R_I2S2, R_I2S3);
|
||||
// rsc_free(NULL, R_SDIO);
|
||||
rsc_free_range(NULL, R_SPI1, R_SPI3);
|
||||
rsc_free_range(NULL, R_TIM1, R_TIM14);
|
||||
rsc_free_range(NULL, R_USART1, R_USART3);
|
||||
rsc_free(NULL, R_USART6);
|
||||
|
||||
rsc_free_range(NULL, R_PA0, R_PA15);
|
||||
rsc_free_range(NULL, R_PB0, R_PB15);
|
||||
rsc_free_range(NULL, R_PC0, R_PC15);
|
||||
rsc_free_range(NULL, R_PD0, R_PD15);
|
||||
rsc_free_range(NULL, R_PE0, R_PE15);
|
||||
// also has 2 PH pins
|
||||
|
||||
// F407 appears to have fewer GPIOs than F303?
|
||||
}
|
||||
|
||||
// Claim resources not available due to board layout or internal usage
|
||||
{
|
||||
// HAL timebase
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_TIM1);
|
||||
// HSE crystal
|
||||
// H0 and H1
|
||||
// SWD
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA13);
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA14);
|
||||
// USB
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA11);
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PA12);
|
||||
// BOOT pin(s)
|
||||
rv |= rsc_claim(&UNIT_SYSTEM, R_PB2); // BOOT1
|
||||
}
|
||||
#else
|
||||
#error "BAD PLATFORM!"
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef GEX_PLAT_COMPAT_H
|
||||
#define GEX_PLAT_COMPAT_H
|
||||
|
||||
// string identifying the GEX board
|
||||
#define GEX_PLATFORM "Discovery-XYZ"
|
||||
#define GEX_PLAT_XYZ 1 // only with the MCU name
|
||||
|
||||
// GEX_PLAT_XYZ_BOARD is defined in build.mk to identify particular board layout
|
||||
|
||||
#define PLAT_AHB_MHZ 72
|
||||
#define PLAT_APB1_MHZ 36
|
||||
|
||||
#include ... // all useful from the peripheral library (HAL / LL)
|
||||
|
||||
// in bytes
|
||||
#define FLASH_SIZE (128*1024)
|
||||
// in bytes
|
||||
#define SETTINGS_BLOCK_SIZE (2*1024)
|
||||
// address where the settings block starts
|
||||
#define SETTINGS_FLASH_ADDR (0x08000000 + FLASH_SIZE - SETTINGS_BLOCK_SIZE)
|
||||
|
||||
#define PORTS_COUNT 5 // number of available GPIO ports A,B,C,D,E,F...
|
||||
#define LOCK_JUMPER_PORT 'A'
|
||||
#define LOCK_JUMPER_PIN 2
|
||||
|
||||
#define STATUS_LED_PORT 'A'
|
||||
#define STATUS_LED_PIN 15
|
||||
|
||||
// Feature flags:
|
||||
#define PLAT_FLASHBANKS 0 // has the Banks field on the Flash config struct
|
||||
#define PLAT_NO_FLOATING_INPUTS 0 // can't have digital inputs with no pull resistor
|
||||
#define PLAT_USB_PHYCLOCK 0 // requires special config of phy clock for USB
|
||||
#define PLAT_USB_OTGFS 0 // uses the USB OTG IP, needs different config code
|
||||
#define PLAT_LOCK_BTN 1 // use a lock button instead of a lock jumper (push to toggle)
|
||||
#define PLAT_LOCK_1CLOSED 1 // lock jumper is active (closed / button pressed) in logical 1
|
||||
#define PLAT_NO_AFNUM 0 // legacy platform without numbered AF alternatives
|
||||
#define PLAT_FULL_XTAL 1 // use two-wire xtal attachment
|
||||
#define PLAT_USB_PU_CTL 1 // platform has USB pullup control
|
||||
|
||||
// FreeRTOS config
|
||||
#define PLAT_FREERTOS_LOWEST_INTERRUPT_PRIORITY 3
|
||||
#define PLAT_FREERTOS_MAX_SYSCALL_INTERRUPT_PRIORITY 1
|
||||
#define PLAT_FREERTOS_PRIO_BITS 2
|
||||
#define PLAT_FREERTOS_USE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||
|
||||
#endif //GEX_PLAT_COMPAT_H
|
||||
Binary file not shown.
Reference in New Issue
Block a user