arrangements for easier porting

sipo
Ondřej Hruška 7 years ago
parent e1ce976278
commit 2f24d3789d
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 88
      platform/plat_compat.h
  2. 18
      platform/platform.c

@ -5,48 +5,52 @@
#ifndef GEX_PLAT_COMPAT_H #ifndef GEX_PLAT_COMPAT_H
#define GEX_PLAT_COMPAT_H #define GEX_PLAT_COMPAT_H
#ifdef GEX_PLAT_F103_BLUEPILL
// platform name for the version string // platform name for the version string
#define GEX_PLATFORM "STM32F103" #define GEX_PLATFORM "STM32F103-Bluepill"
#include <stm32f1xx.h>
#include <stm32f1xx.h> #include <stm32f1xx_hal.h>
#include <stm32f1xx_hal.h> #include <stm32f1xx_ll_adc.h>
#include <stm32f1xx_ll_adc.h> #include <stm32f1xx_ll_bus.h>
#include <stm32f1xx_ll_bus.h> #include <stm32f1xx_ll_cortex.h>
#include <stm32f1xx_ll_cortex.h> #include <stm32f1xx_ll_crc.h>
#include <stm32f1xx_ll_crc.h> #include <stm32f1xx_ll_dac.h>
#include <stm32f1xx_ll_dac.h> #include <stm32f1xx_ll_dma.h>
#include <stm32f1xx_ll_dma.h> #include <stm32f1xx_ll_exti.h>
#include <stm32f1xx_ll_exti.h> #include <stm32f1xx_ll_fsmc.h>
#include <stm32f1xx_ll_fsmc.h> #include <stm32f1xx_ll_gpio.h>
#include <stm32f1xx_ll_gpio.h> #include <stm32f1xx_ll_i2c.h>
#include <stm32f1xx_ll_i2c.h> #include <stm32f1xx_ll_iwdg.h>
#include <stm32f1xx_ll_iwdg.h> #include <stm32f1xx_ll_pwr.h>
#include <stm32f1xx_ll_pwr.h> #include <stm32f1xx_ll_rcc.h>
#include <stm32f1xx_ll_rcc.h> #include <stm32f1xx_ll_rtc.h>
#include <stm32f1xx_ll_rtc.h> #include <stm32f1xx_ll_sdmmc.h>
#include <stm32f1xx_ll_sdmmc.h> #include <stm32f1xx_ll_spi.h>
#include <stm32f1xx_ll_spi.h> #include <stm32f1xx_ll_system.h>
#include <stm32f1xx_ll_system.h> #include <stm32f1xx_ll_tim.h>
#include <stm32f1xx_ll_tim.h> #include <stm32f1xx_ll_usart.h>
#include <stm32f1xx_ll_usart.h> #include <stm32f1xx_ll_usb.h>
#include <stm32f1xx_ll_usb.h> #include <stm32f1xx_ll_utils.h>
#include <stm32f1xx_ll_utils.h> #include <stm32f1xx_ll_wwdg.h>
#include <stm32f1xx_ll_wwdg.h>
// size, determines position of the flash storage
// size, determines position of the flash storage #define FLASH_SIZE (64*1024)
#define FLASH_SIZE (64*1024) #define SETTINGS_BLOCK_SIZE (1024*2) // this must be a multiple of FLASH pages
#define SETTINGS_BLOCK_SIZE (1024*2) // this must be a multiple of FLASH pages #define SETTINGS_FLASH_ADDR (0x08000000 + FLASH_SIZE - SETTINGS_BLOCK_SIZE)
#define SETTINGS_FLASH_ADDR (0x08000000 + FLASH_SIZE - SETTINGS_BLOCK_SIZE)
// Number of GPIO ports A,B,C...
// Number of GPIO ports A,B,C... #define PORTS_COUNT 5
#define PORTS_COUNT 5
// Lock jumper config
// Lock jumper config #define LOCK_JUMPER_PORT 'C'
#define LOCK_JUMPER_PORT 'C' #define LOCK_JUMPER_PIN 14
#define LOCK_JUMPER_PIN 14
// Status LED config
// Status LED config #define STATUS_LED_PORT 'C'
#define STATUS_LED_PORT 'C' #define STATUS_LED_PIN 13
#define STATUS_LED_PIN 13 #else
#error "BAD PLATFORM! Please select GEX platform using a -DGEX_PLAT_* compile flag"
#endif
#endif //GEX_PLAT_COMPAT_H #endif //GEX_PLAT_COMPAT_H

@ -7,18 +7,20 @@
#include "USB/usb_device.h" #include "USB/usb_device.h"
#include "framework/resources.h" #include "framework/resources.h"
// ----- SUPPORTED UNITS -----
#include "framework/unit_registry.h" #include "framework/unit_registry.h"
#include "units/pin/unit_pin.h" #include "units/pin/unit_pin.h"
#include "units/neopixel/unit_neopixel.h" #include "units/neopixel/unit_neopixel.h"
// ----- SUPPORTED UNITS -----
void plat_register_units(void) void plat_register_units(void)
{ {
ureg_add_type(&UNIT_PIN); ureg_add_type(&UNIT_PIN);
ureg_add_type(&UNIT_NEOPIXEL); ureg_add_type(&UNIT_NEOPIXEL);
// Platform-specific units could be added here
} }
@ -32,6 +34,8 @@ void plat_init_resources(void)
__HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE();
#ifdef GEX_PLAT_F103_BLUEPILL
// Platform F103C8T6 - free all present resources // Platform F103C8T6 - free all present resources
{ {
rsc_free(NULL, R_ADC1); rsc_free(NULL, R_ADC1);
@ -73,15 +77,21 @@ void plat_init_resources(void)
assert_param(ok); assert_param(ok);
} }
#endif
} }
// ---- USB reconnect ---- // ---- USB reconnect ----
/** USB re-connect */ /**
* USB re-connect (to apply change of the LOCK jumper)
*/
void plat_usb_reconnect(void) void plat_usb_reconnect(void)
{ {
#ifdef GEX_PLAT_F103_BLUEPILL
// F103 doesn't have pull-up control, this is probably the best we can do // F103 doesn't have pull-up control, this is probably the best we can do
// This does not seem to trigger descriptors reload.
USBD_LL_Reset(&hUsbDeviceFS); USBD_LL_Reset(&hUsbDeviceFS);
#endif
} }

Loading…
Cancel
Save