1
0
mirror of https://github.com/peterantypas/maiana.git synced 2025-05-21 01:40:09 -07:00
This commit is contained in:
Peter Antypas 2020-10-13 11:39:58 -07:00
parent 8e536c54e8
commit b4ff0d766f
11 changed files with 90 additions and 64 deletions

View File

@ -70,7 +70,7 @@
#define configUSE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 8
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#define configCHECK_FOR_STACK_OVERFLOW 1
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( 2 )

View File

@ -23,8 +23,7 @@
using namespace std;
#include <cstdlib>
#include <cassert>
#include "printf_serial.h"
#include "_assert.h"
#include "CircularQueue.hpp"
@ -85,6 +84,4 @@ private:
CircularQueue<T*> mQueue;
};
#endif /* OBJECTPOOL_HPP_ */

View File

@ -20,9 +20,6 @@
#ifndef TXPACKET_HPP_
#define TXPACKET_HPP_
#include <inttypes.h>
#include <time.h>
#include "ObjectPool.hpp"
#include "AISChannels.h"
#include "config.h"
@ -32,15 +29,15 @@ class TXPacket
{
public:
TXPacket ();
virtual ~TXPacket();
~TXPacket();
void addBit(uint8_t bit);
void pad();
virtual uint16_t size();
uint16_t size();
// Iterator pattern for transmitting bit-by-bit
virtual bool eof();
virtual uint8_t nextBit();
bool eof();
uint8_t nextBit();
VHFChannel channel();
void setTimestamp(time_t t);
@ -65,13 +62,6 @@ private:
bool mTestPacket = false;
};
class TXTestPacket : public TXPacket
{
public:
TXTestPacket();
~TXTestPacket();
};
class TXPacketPool
{

View File

@ -26,7 +26,7 @@
// Either modify this header or define a different symbol in the preprocessor to build for a different board
#ifndef BOARD_REV
#define BOARD_REV 52
#define BOARD_REV 61
#endif
/**
@ -85,8 +85,8 @@ bool bsp_read_station_data(StationData &data);
#include "bsp_5_2.hpp"
#elif BOARD_REV == 53
#include "bsp_5_3.hpp"
#elif BOARD_REV == 60
#include "bsp_6_0.hpp"
#elif BOARD_REV == 61
#include <bsp_6_1.hpp>
#endif

View File

@ -93,6 +93,13 @@
// Extra debugging using halting assertions
//#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_ */

View File

@ -14,7 +14,7 @@ GET = 0x00
PAGE_SIZE = 2048
FLASH_BASE = 0x08000000
BAUD_RATE = 115200
MAX_IMAGE_SIZE = 128*1024
MAX_IMAGE_SIZE = 64*1024
# These defaults will be overwritten with results of GET command
GET_VER_CMD = 0x01
@ -62,7 +62,7 @@ def configure_commands(data):
print s
"""
def packet_checksum(p):
x = 0
for b in p:
@ -71,12 +71,19 @@ def packet_checksum(p):
return x
def read_byte():
r = port.read()
r = port.read(1)
if len(r) > 0:
return (True, ord(r[0]))
else:
return (False, 0)
def drain():
keepreading = True
while True:
(r, keepreading) = read_byte()
if r == False:
break
def do_handshake():
port.write([0x7f])
(success, b) = read_byte()
@ -93,8 +100,10 @@ def complement(cmd):
def send_command(cmd):
packet = [cmd, complement(cmd)]
#print packet
port.write(packet)
(success, r) = read_byte()
#print r
if not success:
print "Failed to send command 0x{0:2x}".format(cmd)
return False
@ -102,7 +111,8 @@ def send_command(cmd):
if r != ACK:
print "Got NACK for command 0x{0:2x}".format(cmd)
return False
#print "Got ACK"
return True
@ -254,7 +264,9 @@ if __name__ == '__main__':
if not bl_present:
sys.exit(1)
drain()
(success, data) = send_get()
if success:
configure_commands(data[2:])

View File

@ -55,13 +55,13 @@ ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x2000A000; /* end of 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 */
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 39K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K
}

View File

@ -60,7 +60,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 39K
RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 16K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 100K
}

View File

@ -25,7 +25,7 @@
#include <string.h>
#if BOARD_REV==60
#if BOARD_REV==61
I2C_HandleTypeDef hi2c1;
SPI_HandleTypeDef hspi1;
@ -79,11 +79,13 @@ static const GPIO __gpios[] = {
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");
NVIC_SystemReset();
asm("BKPT 0");
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)
{
Error_Handler();
Error_Handler(0);
}
__HAL_SPI_ENABLE(&hspi1);
@ -209,20 +211,33 @@ void bsp_hw_init()
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
Error_Handler();
Error_Handler(0);
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
Error_Handler(0);
}
/** Configure Digital filter
*/
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;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
Error_Handler(0);
}
/**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)
{
Error_Handler();
Error_Handler(0);
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_HSI;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
Error_Handler(0);
}
/**Configure the main internal regulator output voltage
*/
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
{
Error_Handler();
Error_Handler(0);
}
/**Configure the Systick interrupt time

View File

@ -31,22 +31,24 @@
#include "task.h"
#include "timers.h"
#if 0
void determineCauseOfReset()
void jump_to_bootloader()
{
std::string cause;
if ( __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) )
cause += "Watchdog, ";
if ( __HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) )
cause += "Software, ";
if ( __HAL_RCC_GET_FLAG(RCC_FLAG_BORRST) )
cause += "Brownout";
typedef void (*pFunction)(void);
pFunction systemBootloader;
//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;
StaticTimer_t timer1, timer2;
@ -85,8 +87,10 @@ void mainTask(void *params)
TXScheduler::instance().init();
#endif
#if 0
RadioManager::instance().init();
RadioManager::instance().start();
#endif
timerHandle1 = xTimerCreateStatic("1sec", 1000, pdTRUE, NULL, on1sec, &timer1);
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)
{
#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;
bsp_hw_init();