mirror of
https://github.com/peterantypas/maiana.git
synced 2025-05-20 09:20:10 -07:00
BSP cleanup
This commit is contained in:
parent
fc91389af5
commit
69a4b83d54
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#if BOARD_REV==52
|
#if BOARD_REV==52
|
||||||
|
|
||||||
|
#warning "This board is too old and not recommended for new builds"
|
||||||
|
|
||||||
I2C_HandleTypeDef hi2c1;
|
I2C_HandleTypeDef hi2c1;
|
||||||
SPI_HandleTypeDef hspi1;
|
SPI_HandleTypeDef hspi1;
|
||||||
IWDG_HandleTypeDef hiwdg;
|
IWDG_HandleTypeDef hiwdg;
|
||||||
@ -45,7 +47,7 @@ irq_callback sotdmaCallback = nullptr;
|
|||||||
irq_callback trxClockCallback = nullptr;
|
irq_callback trxClockCallback = nullptr;
|
||||||
irq_callback rxClockCallback = nullptr;
|
irq_callback rxClockCallback = nullptr;
|
||||||
|
|
||||||
#define EEPROM_ADDRESS 0x50 << 1
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -480,55 +482,11 @@ uint8_t bsp_tx_spi_byte(uint8_t data)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bsp_erase_station_data()
|
|
||||||
{
|
|
||||||
uint8_t b = 0xff;
|
|
||||||
HAL_GPIO_WritePin(EEPROM_WREN_PORT, EEPROM_WREN_PIN, GPIO_PIN_RESET);
|
|
||||||
HAL_Delay(1);
|
|
||||||
|
|
||||||
for ( unsigned i = 0; i < sizeof(StationData); ++i )
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, i, 1, &b, 1, 100);
|
|
||||||
HAL_Delay(6);
|
|
||||||
}
|
|
||||||
HAL_GPIO_WritePin(EEPROM_WREN_PORT, EEPROM_WREN_PIN, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bsp_save_station_data(const StationData &data)
|
|
||||||
{
|
|
||||||
HAL_GPIO_WritePin(EEPROM_WREN_PORT, EEPROM_WREN_PIN, GPIO_PIN_RESET);
|
|
||||||
HAL_Delay(1);
|
|
||||||
|
|
||||||
uint8_t *b = (uint8_t*)&data;
|
|
||||||
for ( unsigned i = 0; i < sizeof(StationData); ++i, ++b )
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, i, 1, b, 1, 100);
|
|
||||||
HAL_Delay(6);
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(EEPROM_WREN_PORT, EEPROM_WREN_PIN, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bsp_reboot()
|
void bsp_reboot()
|
||||||
{
|
{
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bsp_read_station_data(StationData &data)
|
|
||||||
{
|
|
||||||
uint8_t *b = (uint8_t*)&data;
|
|
||||||
for ( unsigned i = 0; i < sizeof(StationData); ++i, ++b )
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Read(&hi2c1, EEPROM_ADDRESS, i, 1, b, 1, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bsp_is_tx_disabled()
|
bool bsp_is_tx_disabled()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
|
|
||||||
#if BOARD_REV==61
|
#if BOARD_REV==61
|
||||||
|
|
||||||
|
#warning "This board is too old and not recommended for new builds"
|
||||||
|
|
||||||
|
|
||||||
I2C_HandleTypeDef hi2c1;
|
I2C_HandleTypeDef hi2c1;
|
||||||
SPI_HandleTypeDef hspi1;
|
SPI_HandleTypeDef hspi1;
|
||||||
IWDG_HandleTypeDef hiwdg;
|
IWDG_HandleTypeDef hiwdg;
|
||||||
@ -43,7 +46,6 @@ irq_callback sotdmaCallback = nullptr;
|
|||||||
irq_callback trxClockCallback = nullptr;
|
irq_callback trxClockCallback = nullptr;
|
||||||
irq_callback rxClockCallback = nullptr;
|
irq_callback rxClockCallback = nullptr;
|
||||||
|
|
||||||
#define EEPROM_ADDRESS 0x50 << 1
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -488,55 +490,11 @@ uint8_t bsp_tx_spi_byte(uint8_t data)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bsp_erase_station_data()
|
|
||||||
{
|
|
||||||
uint8_t b = 0xff;
|
|
||||||
HAL_GPIO_WritePin(EEPROM_WREN_PORT, EEPROM_WREN_PIN, GPIO_PIN_RESET);
|
|
||||||
HAL_Delay(1);
|
|
||||||
|
|
||||||
for ( unsigned i = 0; i < sizeof(StationData); ++i )
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, i, 1, &b, 1, 100);
|
|
||||||
HAL_Delay(6);
|
|
||||||
}
|
|
||||||
HAL_GPIO_WritePin(EEPROM_WREN_PORT, EEPROM_WREN_PIN, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bsp_save_station_data(const StationData &data)
|
|
||||||
{
|
|
||||||
HAL_GPIO_WritePin(EEPROM_WREN_PORT, EEPROM_WREN_PIN, GPIO_PIN_RESET);
|
|
||||||
HAL_Delay(1);
|
|
||||||
|
|
||||||
uint8_t *b = (uint8_t*)&data;
|
|
||||||
for ( unsigned i = 0; i < sizeof(StationData); ++i, ++b )
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, i, 1, b, 1, 100);
|
|
||||||
HAL_Delay(6);
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(EEPROM_WREN_PORT, EEPROM_WREN_PIN, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bsp_reboot()
|
void bsp_reboot()
|
||||||
{
|
{
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bsp_read_station_data(StationData &data)
|
|
||||||
{
|
|
||||||
uint8_t *b = (uint8_t*)&data;
|
|
||||||
for ( unsigned i = 0; i < sizeof(StationData); ++i, ++b )
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Read(&hi2c1, EEPROM_ADDRESS, i, 1, b, 1, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bsp_is_tx_disabled()
|
bool bsp_is_tx_disabled()
|
||||||
{
|
{
|
||||||
return HAL_GPIO_ReadPin(TX_DISABLE_PORT, TX_DISABLE_PIN) == GPIO_PIN_RESET;
|
return HAL_GPIO_ReadPin(TX_DISABLE_PORT, TX_DISABLE_PIN) == GPIO_PIN_RESET;
|
||||||
@ -548,7 +506,7 @@ void bsp_enter_dfu()
|
|||||||
bsp_gnss_off();
|
bsp_gnss_off();
|
||||||
|
|
||||||
// This flag simply tells main() to jump to the ROM bootloader immediately upon reset, before initializing anything
|
// This flag simply tells main() to jump to the ROM bootloader immediately upon reset, before initializing anything
|
||||||
*(uint32_t*)DFU_FLAG_ADDRESS = DFU_FLAG_MAGIC;
|
*(uint32_t*)BOOTMODE_ADDRESS = DFU_FLAG_MAGIC;
|
||||||
|
|
||||||
// Give the GNSS enough time to hibernate, then reset
|
// Give the GNSS enough time to hibernate, then reset
|
||||||
HAL_Delay(1000);
|
HAL_Delay(1000);
|
||||||
|
@ -43,7 +43,6 @@ irq_callback sotdmaCallback = nullptr;
|
|||||||
irq_callback trxClockCallback = nullptr;
|
irq_callback trxClockCallback = nullptr;
|
||||||
irq_callback rxClockCallback = nullptr;
|
irq_callback rxClockCallback = nullptr;
|
||||||
|
|
||||||
#define EEPROM_ADDRESS 0x50 << 1
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -486,50 +485,11 @@ uint8_t bsp_tx_spi_byte(uint8_t data)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bsp_erase_station_data()
|
|
||||||
{
|
|
||||||
uint8_t b = 0xff;
|
|
||||||
HAL_Delay(1);
|
|
||||||
|
|
||||||
for ( unsigned i = 0; i < sizeof(StationData); ++i )
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, i, 1, &b, 1, 100);
|
|
||||||
HAL_Delay(6);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bsp_save_station_data(const StationData &data)
|
|
||||||
{
|
|
||||||
HAL_Delay(1);
|
|
||||||
|
|
||||||
uint8_t *b = (uint8_t*)&data;
|
|
||||||
for ( unsigned i = 0; i < sizeof(StationData); ++i, ++b )
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, i, 1, b, 1, 100);
|
|
||||||
HAL_Delay(6);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bsp_reboot()
|
void bsp_reboot()
|
||||||
{
|
{
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bsp_read_station_data(StationData &data)
|
|
||||||
{
|
|
||||||
uint8_t *b = (uint8_t*)&data;
|
|
||||||
for ( unsigned i = 0; i < sizeof(StationData); ++i, ++b )
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Read(&hi2c1, EEPROM_ADDRESS, i, 1, b, 1, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bsp_is_tx_disabled()
|
bool bsp_is_tx_disabled()
|
||||||
{
|
{
|
||||||
return HAL_GPIO_ReadPin(TX_DISABLE_PORT, TX_DISABLE_PIN) == GPIO_PIN_RESET;
|
return HAL_GPIO_ReadPin(TX_DISABLE_PORT, TX_DISABLE_PIN) == GPIO_PIN_RESET;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user