mirror of
https://github.com/peterantypas/maiana.git
synced 2025-05-21 09:50:08 -07:00
Broken
This commit is contained in:
parent
8e536c54e8
commit
b4ff0d766f
@ -70,7 +70,7 @@
|
|||||||
#define configUSE_MUTEXES 1
|
#define configUSE_MUTEXES 1
|
||||||
#define configQUEUE_REGISTRY_SIZE 8
|
#define configQUEUE_REGISTRY_SIZE 8
|
||||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||||
#define configCHECK_FOR_STACK_OVERFLOW 1
|
#define configCHECK_FOR_STACK_OVERFLOW 0
|
||||||
|
|
||||||
#define configUSE_TIMERS 1
|
#define configUSE_TIMERS 1
|
||||||
#define configTIMER_TASK_PRIORITY ( 2 )
|
#define configTIMER_TASK_PRIORITY ( 2 )
|
||||||
|
@ -23,8 +23,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cassert>
|
|
||||||
#include "printf_serial.h"
|
#include "printf_serial.h"
|
||||||
#include "_assert.h"
|
#include "_assert.h"
|
||||||
#include "CircularQueue.hpp"
|
#include "CircularQueue.hpp"
|
||||||
@ -85,6 +84,4 @@ private:
|
|||||||
CircularQueue<T*> mQueue;
|
CircularQueue<T*> mQueue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* OBJECTPOOL_HPP_ */
|
#endif /* OBJECTPOOL_HPP_ */
|
||||||
|
@ -20,9 +20,6 @@
|
|||||||
#ifndef TXPACKET_HPP_
|
#ifndef TXPACKET_HPP_
|
||||||
#define TXPACKET_HPP_
|
#define TXPACKET_HPP_
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "ObjectPool.hpp"
|
#include "ObjectPool.hpp"
|
||||||
#include "AISChannels.h"
|
#include "AISChannels.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -32,15 +29,15 @@ class TXPacket
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TXPacket ();
|
TXPacket ();
|
||||||
virtual ~TXPacket();
|
~TXPacket();
|
||||||
|
|
||||||
void addBit(uint8_t bit);
|
void addBit(uint8_t bit);
|
||||||
void pad();
|
void pad();
|
||||||
virtual uint16_t size();
|
uint16_t size();
|
||||||
|
|
||||||
// Iterator pattern for transmitting bit-by-bit
|
// Iterator pattern for transmitting bit-by-bit
|
||||||
virtual bool eof();
|
bool eof();
|
||||||
virtual uint8_t nextBit();
|
uint8_t nextBit();
|
||||||
VHFChannel channel();
|
VHFChannel channel();
|
||||||
|
|
||||||
void setTimestamp(time_t t);
|
void setTimestamp(time_t t);
|
||||||
@ -65,13 +62,6 @@ private:
|
|||||||
bool mTestPacket = false;
|
bool mTestPacket = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TXTestPacket : public TXPacket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TXTestPacket();
|
|
||||||
~TXTestPacket();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class TXPacketPool
|
class TXPacketPool
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
// Either modify this header or define a different symbol in the preprocessor to build for a different board
|
// Either modify this header or define a different symbol in the preprocessor to build for a different board
|
||||||
|
|
||||||
#ifndef BOARD_REV
|
#ifndef BOARD_REV
|
||||||
#define BOARD_REV 52
|
#define BOARD_REV 61
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,8 +85,8 @@ bool bsp_read_station_data(StationData &data);
|
|||||||
#include "bsp_5_2.hpp"
|
#include "bsp_5_2.hpp"
|
||||||
#elif BOARD_REV == 53
|
#elif BOARD_REV == 53
|
||||||
#include "bsp_5_3.hpp"
|
#include "bsp_5_3.hpp"
|
||||||
#elif BOARD_REV == 60
|
#elif BOARD_REV == 61
|
||||||
#include "bsp_6_0.hpp"
|
#include <bsp_6_1.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,6 +93,13 @@
|
|||||||
// Extra debugging using halting assertions
|
// Extra debugging using halting assertions
|
||||||
//#define DEV_MODE 1
|
//#define DEV_MODE 1
|
||||||
|
|
||||||
|
#define DFU_FLAG_ADDRESS 0x20009C00
|
||||||
|
#define DFU_FLAG_MAGIC 0xa191feed
|
||||||
|
|
||||||
|
#ifdef STM32L432xx
|
||||||
|
#define BOOTLOADER_STACK_ADDRESS 0x202C0020
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* CONFIG_H_ */
|
#endif /* CONFIG_H_ */
|
||||||
|
@ -14,7 +14,7 @@ GET = 0x00
|
|||||||
PAGE_SIZE = 2048
|
PAGE_SIZE = 2048
|
||||||
FLASH_BASE = 0x08000000
|
FLASH_BASE = 0x08000000
|
||||||
BAUD_RATE = 115200
|
BAUD_RATE = 115200
|
||||||
MAX_IMAGE_SIZE = 128*1024
|
MAX_IMAGE_SIZE = 64*1024
|
||||||
|
|
||||||
# These defaults will be overwritten with results of GET command
|
# These defaults will be overwritten with results of GET command
|
||||||
GET_VER_CMD = 0x01
|
GET_VER_CMD = 0x01
|
||||||
@ -71,12 +71,19 @@ def packet_checksum(p):
|
|||||||
return x
|
return x
|
||||||
|
|
||||||
def read_byte():
|
def read_byte():
|
||||||
r = port.read()
|
r = port.read(1)
|
||||||
if len(r) > 0:
|
if len(r) > 0:
|
||||||
return (True, ord(r[0]))
|
return (True, ord(r[0]))
|
||||||
else:
|
else:
|
||||||
return (False, 0)
|
return (False, 0)
|
||||||
|
|
||||||
|
def drain():
|
||||||
|
keepreading = True
|
||||||
|
while True:
|
||||||
|
(r, keepreading) = read_byte()
|
||||||
|
if r == False:
|
||||||
|
break
|
||||||
|
|
||||||
def do_handshake():
|
def do_handshake():
|
||||||
port.write([0x7f])
|
port.write([0x7f])
|
||||||
(success, b) = read_byte()
|
(success, b) = read_byte()
|
||||||
@ -93,8 +100,10 @@ def complement(cmd):
|
|||||||
|
|
||||||
def send_command(cmd):
|
def send_command(cmd):
|
||||||
packet = [cmd, complement(cmd)]
|
packet = [cmd, complement(cmd)]
|
||||||
|
#print packet
|
||||||
port.write(packet)
|
port.write(packet)
|
||||||
(success, r) = read_byte()
|
(success, r) = read_byte()
|
||||||
|
#print r
|
||||||
if not success:
|
if not success:
|
||||||
print "Failed to send command 0x{0:2x}".format(cmd)
|
print "Failed to send command 0x{0:2x}".format(cmd)
|
||||||
return False
|
return False
|
||||||
@ -103,6 +112,7 @@ def send_command(cmd):
|
|||||||
print "Got NACK for command 0x{0:2x}".format(cmd)
|
print "Got NACK for command 0x{0:2x}".format(cmd)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
#print "Got ACK"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -255,6 +265,8 @@ if __name__ == '__main__':
|
|||||||
if not bl_present:
|
if not bl_present:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
drain()
|
||||||
|
|
||||||
(success, data) = send_get()
|
(success, data) = send_get()
|
||||||
if success:
|
if success:
|
||||||
configure_commands(data[2:])
|
configure_commands(data[2:])
|
||||||
|
@ -55,13 +55,13 @@ ENTRY(Reset_Handler)
|
|||||||
/* Highest address of the user mode stack */
|
/* Highest address of the user mode stack */
|
||||||
_estack = 0x2000A000; /* end of RAM */
|
_estack = 0x2000A000; /* end of RAM */
|
||||||
/* Generate a link error if heap and stack don't fit into RAM */
|
/* Generate a link error if heap and stack don't fit into RAM */
|
||||||
_Min_Heap_Size = 0x200; /* required amount of heap */
|
_Min_Heap_Size = 0x400; /* required amount of heap */
|
||||||
_Min_Stack_Size = 0x400; /* required amount of stack */
|
_Min_Stack_Size = 0x400; /* required amount of stack */
|
||||||
|
|
||||||
/* Specify the memory areas */
|
/* Specify the memory areas */
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 39K
|
||||||
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K
|
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
|
|||||||
/* Specify the memory areas */
|
/* Specify the memory areas */
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 39K
|
||||||
RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 16K
|
RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 16K
|
||||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 100K
|
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 100K
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
#if BOARD_REV==60
|
#if BOARD_REV==61
|
||||||
|
|
||||||
I2C_HandleTypeDef hi2c1;
|
I2C_HandleTypeDef hi2c1;
|
||||||
SPI_HandleTypeDef hspi1;
|
SPI_HandleTypeDef hspi1;
|
||||||
@ -79,11 +79,13 @@ static const GPIO __gpios[] = {
|
|||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
void Error_Handler(void)
|
void Error_Handler(uint8_t i)
|
||||||
{
|
{
|
||||||
printf_serial_now("[ERROR]\r\n");
|
|
||||||
printf_serial_now("[ERROR] ***** System error handler resetting *****\r\n");
|
asm("BKPT 0");
|
||||||
NVIC_SystemReset();
|
printf_serial_now("[ERROR %d]\r\n", i);
|
||||||
|
//printf_serial_now("[ERROR] ***** System error handler resetting *****\r\n");
|
||||||
|
//NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +160,7 @@ void bsp_hw_init()
|
|||||||
|
|
||||||
if (HAL_SPI_Init(&hspi1) != HAL_OK)
|
if (HAL_SPI_Init(&hspi1) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
__HAL_SPI_ENABLE(&hspi1);
|
__HAL_SPI_ENABLE(&hspi1);
|
||||||
@ -209,20 +211,33 @@ void bsp_hw_init()
|
|||||||
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||||
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler(0);
|
||||||
}
|
}
|
||||||
/** Configure Analogue filter
|
/** Configure Analogue filter
|
||||||
*/
|
*/
|
||||||
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler(0);
|
||||||
}
|
}
|
||||||
/** Configure Digital filter
|
/** Configure Digital filter
|
||||||
*/
|
*/
|
||||||
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
|
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1PPS signal
|
||||||
|
HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(EXTI2_IRQn);
|
||||||
|
|
||||||
|
|
||||||
|
// RF IC clock interrupts
|
||||||
|
HAL_NVIC_SetPriority(EXTI1_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(EXTI1_IRQn);
|
||||||
|
|
||||||
|
|
||||||
|
HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(EXTI3_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -252,7 +267,7 @@ void SystemClock_Config()
|
|||||||
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
|
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Initializes the CPU, AHB and APB bus clocks
|
/**Initializes the CPU, AHB and APB bus clocks
|
||||||
@ -266,21 +281,21 @@ void SystemClock_Config()
|
|||||||
|
|
||||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;
|
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;
|
||||||
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_HSI;
|
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_HSI;
|
||||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Configure the main internal regulator output voltage
|
/**Configure the main internal regulator output voltage
|
||||||
*/
|
*/
|
||||||
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
|
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Configure the Systick interrupt time
|
/**Configure the Systick interrupt time
|
@ -31,22 +31,24 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
|
|
||||||
|
void jump_to_bootloader()
|
||||||
#if 0
|
|
||||||
void determineCauseOfReset()
|
|
||||||
{
|
{
|
||||||
std::string cause;
|
typedef void (*pFunction)(void);
|
||||||
if ( __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) )
|
pFunction systemBootloader;
|
||||||
cause += "Watchdog, ";
|
|
||||||
if ( __HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) )
|
|
||||||
cause += "Software, ";
|
|
||||||
if ( __HAL_RCC_GET_FLAG(RCC_FLAG_BORRST) )
|
|
||||||
cause += "Brownout";
|
|
||||||
|
|
||||||
//DBG("Cause of reset: %s\r\n", cause.c_str());
|
/**
|
||||||
__HAL_RCC_CLEAR_RESET_FLAGS();
|
* System bootloader for L412 and L432 series resides at 0x1fff0000,
|
||||||
|
* so the first 4 bytes contain the stack pointer and the next 4 contain the
|
||||||
|
* program counter
|
||||||
|
*/
|
||||||
|
systemBootloader = (pFunction) (*((uint32_t *)(0x1fff0004)));
|
||||||
|
uint32_t *pp = (uint32_t*)0x1fff0000;
|
||||||
|
uint32_t msp = *pp;
|
||||||
|
__set_MSP(msp);
|
||||||
|
|
||||||
|
// That's it, jump!
|
||||||
|
systemBootloader();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
TimerHandle_t timerHandle1, timerHandle2;
|
TimerHandle_t timerHandle1, timerHandle2;
|
||||||
StaticTimer_t timer1, timer2;
|
StaticTimer_t timer1, timer2;
|
||||||
@ -85,8 +87,10 @@ void mainTask(void *params)
|
|||||||
TXScheduler::instance().init();
|
TXScheduler::instance().init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
RadioManager::instance().init();
|
RadioManager::instance().init();
|
||||||
RadioManager::instance().start();
|
RadioManager::instance().start();
|
||||||
|
#endif
|
||||||
|
|
||||||
timerHandle1 = xTimerCreateStatic("1sec", 1000, pdTRUE, NULL, on1sec, &timer1);
|
timerHandle1 = xTimerCreateStatic("1sec", 1000, pdTRUE, NULL, on1sec, &timer1);
|
||||||
xTimerStart(timerHandle1, 10);
|
xTimerStart(timerHandle1, 10);
|
||||||
@ -103,17 +107,18 @@ void mainTask(void *params)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
__attribute__((used)) void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )
|
|
||||||
{
|
|
||||||
//printf_serial_now("WHOOPS!\r\n");
|
|
||||||
asm("BKPT 0");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
//if ( *(uint32_t*)DFU_FLAG_ADDRESS == DFU_FLAG_MAGIC )
|
||||||
|
if ( true )
|
||||||
|
{
|
||||||
|
*(uint32_t*)DFU_FLAG_ADDRESS = 0;
|
||||||
|
jump_to_bootloader();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//*(uint8_t *)0xe000ed08 |= 2;
|
//*(uint8_t *)0xe000ed08 |= 2;
|
||||||
bsp_hw_init();
|
bsp_hw_init();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user