mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Added initialization of flash eeprom for saving settings to PipX.
This commit is contained in:
parent
1048eb7e2c
commit
25ffb99cee
@ -173,7 +173,7 @@ static int32_t RadioComBridgeInitialize(void)
|
||||
|
||||
// Initialize the UAVObjects that we use
|
||||
GCSReceiverInitialize();
|
||||
PipXSettingsInitialize();
|
||||
PipXStatusInitialize();
|
||||
data->send_gcsreceiver = false;
|
||||
data->send_pipxstatus = false;
|
||||
|
||||
@ -247,9 +247,10 @@ static void radio2ComBridgeTask(void *parameters)
|
||||
|
||||
// Receive data from the radio port
|
||||
rx_bytes = PIOS_COM_ReceiveBuffer(data->radio_port, data->radio2com_buf, PIOS_PH_MAX_PACKET, 200);
|
||||
|
||||
// Receive the packet.
|
||||
if (rx_bytes > 0)
|
||||
PHReceivePacket(pios_packet_handler, (PHPacketHandle)data->radio2com_buf, rx_bytes);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +261,7 @@ static void com2RadioBridgeTask(void * parameters)
|
||||
{
|
||||
uint32_t rx_bytes = 0;
|
||||
portTickType packet_start_time = 0;
|
||||
uint32_t timeout = 500;
|
||||
uint32_t timeout = 250;
|
||||
uint32_t inputPort;
|
||||
|
||||
/* Handle usart/usb -> radio direction */
|
||||
@ -439,7 +440,7 @@ static void receiveData(uint8_t *buf, uint8_t len)
|
||||
{
|
||||
UAVTalkRxState state = UAVTalkProcessInputStreamQuiet(data->outUAVTalkCon, buf[i]);
|
||||
/* if(state == UAVTALK_STATE_ERROR) */
|
||||
/* DEBUG_PRINTF(2, "OUT Error\n\r"); */
|
||||
/* DEBUG_PRINTF(2, "OUT Error\n\r\r"); */
|
||||
if((state == UAVTALK_STATE_COMPLETE) || (state == UAVTALK_STATE_SYNC))
|
||||
{
|
||||
// Send the buffer up to this point
|
||||
|
@ -69,7 +69,7 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1
|
||||
//------------------------
|
||||
// WATCHDOG_SETTINGS
|
||||
//------------------------
|
||||
#define PIOS_WATCHDOG_TIMEOUT 250
|
||||
#define PIOS_WATCHDOG_TIMEOUT 500
|
||||
#define PIOS_WDG_REGISTER BKP_DR4
|
||||
#define PIOS_WDG_RADIOCOM 0x0001
|
||||
#define PIOS_WDG_COMRADIO 0x0002
|
||||
@ -158,7 +158,7 @@ extern uint32_t pios_com_rfm22b_id;
|
||||
#define PIOS_COM_TELEM_USB (pios_com_telem_usb_id)
|
||||
#define PIOS_COM_VCP_USB (pios_com_vcp_usb_id)
|
||||
#define PIOS_COM_RFM22B_RF (pios_com_rfm22b_id)
|
||||
#define PIOS_COM_BRIDGE_RADIO PIOS_COM_RFM22B_RF
|
||||
#define PIOS_COM_BRIDGE_RADIO PIOS_COM_RFM22B_RF
|
||||
#define PIOS_COM_DEBUG PIOS_COM_FLEXI
|
||||
#define PIOS_COM_BRIDGE_COM PIOS_COM_TELEM_SERIAL
|
||||
|
||||
@ -292,4 +292,14 @@ uint32_t pios_packet_handler;
|
||||
|
||||
#define RS_ECC_NPARITY 4
|
||||
|
||||
//-------------------------
|
||||
// Flash EEPROM Emulation
|
||||
//-------------------------
|
||||
|
||||
#define PIOS_FLASH_SIZE 0x20000
|
||||
#define PIOS_FLASH_EEPROM_START_ADDR 0x08000000
|
||||
#define PIOS_FLASH_PAGE_SIZE 1024
|
||||
#define PIOS_FLASH_EEPROM_ADDR (PIOS_FLASH_EEPROM_START_ADDR + PIOS_FLASH_SIZE - PIOS_FLASH_PAGE_SIZE)
|
||||
#define PIOS_FLASH_EEPROM_LEN PIOS_FLASH_PAGE_SIZE
|
||||
|
||||
#endif /* STM32103CB_PIPXTREME_H_ */
|
||||
|
@ -159,6 +159,7 @@ SRC += $(PIOSSTM32F10X)/pios_wdg.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_tim.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_pwm.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_adc.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_eeprom.c
|
||||
|
||||
# PIOS USB related files (separated to make code maintenance more easy)
|
||||
SRC += $(PIOSSTM32F10X)/pios_usb.c
|
||||
|
@ -35,7 +35,6 @@
|
||||
|
||||
/* Enable/Disable PiOS Modules */
|
||||
#define PIOS_INCLUDE_DELAY
|
||||
//#define PIOS_INCLUDE_I2C
|
||||
#define PIOS_INCLUDE_IRQ
|
||||
#define PIOS_INCLUDE_LED
|
||||
#define PIOS_INCLUDE_IAP
|
||||
@ -44,16 +43,10 @@
|
||||
#define PIOS_INCLUDE_TIM
|
||||
|
||||
/* Supported receiver interfaces */
|
||||
//#define PIOS_INCLUDE_SPEKTRUM
|
||||
//#define PIOS_INCLUDE_SBUS
|
||||
#define PIOS_INCLUDE_PPM
|
||||
#define PIOS_INCLUDE_PWM
|
||||
|
||||
/* Supported USART-based PIOS modules */
|
||||
#define PIOS_INCLUDE_TELEMETRY_RF
|
||||
//#define PIOS_INCLUDE_GPS
|
||||
|
||||
//#define PIOS_INCLUDE_SERVO
|
||||
#define PIOS_INCLUDE_SPI
|
||||
#define PIOS_INCLUDE_SYS
|
||||
#define PIOS_INCLUDE_USART
|
||||
@ -66,11 +59,9 @@
|
||||
#define PIOS_INCLUDE_GPIO
|
||||
#define PIOS_INCLUDE_EXTI
|
||||
#define PIOS_INCLUDE_RTC
|
||||
//#define PIOS_INCLUDE_WDG
|
||||
#define PIOS_INCLUDE_WDG
|
||||
#define PIOS_INCLUDE_BL_HELPER
|
||||
|
||||
/* A really shitty setting saving implementation */
|
||||
//#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS
|
||||
#define PIOS_INCLUDE_FLASH_EEPROM
|
||||
|
||||
/* Defaults for Logging */
|
||||
#define LOG_FILENAME "PIOS.LOG"
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <pios.h>
|
||||
#include <openpilot.h>
|
||||
#include <pipxsettings.h>
|
||||
#include <board_hw_defs.c>
|
||||
|
||||
#define PIOS_COM_SERIAL_RX_BUF_LEN 192
|
||||
@ -73,8 +74,10 @@ void PIOS_Board_Init(void) {
|
||||
EventDispatcherInitialize();
|
||||
UAVObjInitialize();
|
||||
|
||||
#ifdef PIOS_INCLUDE_WDG
|
||||
/* Initialize watchdog as early as possible to catch faults during init */
|
||||
PIOS_WDG_Init();
|
||||
#endif /* PIOS_INCLUDE_WDG */
|
||||
|
||||
/* Initialize IAP */
|
||||
PIOS_IAP_Init();
|
||||
@ -82,12 +85,25 @@ void PIOS_Board_Init(void) {
|
||||
#if defined(PIOS_INCLUDE_RTC)
|
||||
/* Initialize the real-time clock and its associated tick */
|
||||
PIOS_RTC_Init(&pios_rtc_main_cfg);
|
||||
#endif
|
||||
#endif /* PIOS_INCLUDE_RTC */
|
||||
|
||||
PipXSettingsInitialize();
|
||||
|
||||
#if defined(PIOS_INCLUDE_LED)
|
||||
PIOS_LED_Init(&pios_led_cfg);
|
||||
#endif /* PIOS_INCLUDE_LED */
|
||||
|
||||
#if defined(PIOS_INCLUDE_FLASH_EEPROM)
|
||||
PIOS_EEPROM_Init(&pios_eeprom_cfg);
|
||||
|
||||
/* Read the settings from flash. */
|
||||
PipXSettingsData pipxSettings;
|
||||
if (PIOS_EEPROM_Load((uint8_t*)&pipxSettings, sizeof(PipXSettingsData)) == 0)
|
||||
PipXSettingsSet(&pipxSettings);
|
||||
else
|
||||
PipXSettingsGet(&pipxSettings);
|
||||
#endif /* PIOS_INCLUDE_FLASH_EEPROM */
|
||||
|
||||
/* Initialize the task monitor library */
|
||||
TaskMonitorInitialize();
|
||||
|
||||
|
@ -474,6 +474,15 @@ const struct pios_usb_cdc_cfg pios_usb_cdc_cfg = {
|
||||
};
|
||||
#endif /* PIOS_INCLUDE_USB_CDC */
|
||||
|
||||
#if defined(PIOS_INCLUDE_FLASH_EEPROM)
|
||||
#include <pios_eeprom.h>
|
||||
|
||||
const struct pios_eeprom_cfg pios_eeprom_cfg = {
|
||||
.base_address = PIOS_FLASH_EEPROM_ADDR,
|
||||
.max_size = PIOS_FLASH_EEPROM_LEN,
|
||||
};
|
||||
#endif /* PIOS_INCLUDE_FLASH_EEPROM */
|
||||
|
||||
#if defined(PIOS_INCLUDE_RFM22B)
|
||||
#include <pios_rfm22b_priv.h>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user