Moved size defines to plat_compat

sipo
Ondřej Hruška 6 years ago
parent 8ded459c68
commit bef9b83826
  1. 22
      TinyFrame/TF_Config.h
  2. 4
      USB/usbd_conf.h
  3. 4
      comm/messages.h
  4. 7
      comm/msg_responses.c
  5. 2
      debug.c
  6. 9
      framework/settings.c
  7. 20
      freertos.c
  8. 68
      platform/plat_compat.h
  9. 3
      tasks/sched_queue.h
  10. 4
      utils/ini_parser.h
  11. 2
      utils/ini_writer.c

@ -48,26 +48,6 @@ typedef uint8_t TF_COUNT;
//----------------------------- PARAMETERS ---------------------------------- //----------------------------- PARAMETERS ----------------------------------
// Maximum received payload size (static buffer) // buffers, counts and timeout are defined in plat_compat.h
// Larger payloads will be rejected.
#define TF_MAX_PAYLOAD_RX 640
// Size of the sending buffer. Larger payloads will be split to pieces and sent
// in multiple calls to the write function. This can be lowered to reduce RAM usage.
#define TF_SENDBUF_LEN 64
// --- Listener counts - determine sizes of the static slot tables ---
// Frame ID listeners (wait for response / multi-part message)
#define TF_MAX_ID_LST 4
// Frame Type listeners (wait for frame with a specific first payload byte)
#define TF_MAX_TYPE_LST 6
// Generic listeners (fallback if no other listener catches it)
#define TF_MAX_GEN_LST 1
// Timeout for receiving & parsing a frame
// ticks = number of calls to TF_Tick()
#define TF_PARSER_TIMEOUT_TICKS 250
//------------------------- End of user config ------------------------------
#endif //TF_CONFIG_H #endif //TF_CONFIG_H

@ -76,7 +76,7 @@
/*---------- -----------*/ /*---------- -----------*/
#define USBD_MAX_NUM_CONFIGURATION 1 #define USBD_MAX_NUM_CONFIGURATION 1
/*---------- -----------*/ /*---------- -----------*/
#define USBD_MAX_STR_DESC_SIZ 128 //#define USBD_MAX_STR_DESC_SIZ 128 /* Moved to plat_compat.h */
/*---------- -----------*/ /*---------- -----------*/
#define USBD_SUPPORT_USER_STRING 1 #define USBD_SUPPORT_USER_STRING 1
/*---------- -----------*/ /*---------- -----------*/
@ -84,7 +84,7 @@
/*---------- -----------*/ /*---------- -----------*/
#define USBD_SELF_POWERED 1 #define USBD_SELF_POWERED 1
/*---------- -----------*/ /*---------- -----------*/
#define MSC_MEDIA_PACKET 512 //#define MSC_MEDIA_PACKET 512 /* Moved to plat_compat.h */
/****************************************/ /****************************************/
/* #define for FS and HS identification */ /* #define for FS and HS identification */
#define DEVICE_FS 0 #define DEVICE_FS 0

@ -5,13 +5,11 @@
#ifndef GEX_MESSAGES_H #ifndef GEX_MESSAGES_H
#define GEX_MESSAGES_H #define GEX_MESSAGES_H
#include "platform.h"
#include "sched_queue.h" #include "sched_queue.h"
#include "task_sched.h" #include "task_sched.h"
#include "TinyFrame.h" #include "TinyFrame.h"
#define BULK_LST_TIMEOUT_MS 200
#define BULKREAD_MAX_CHUNK 512 // this is a static buffer
/** /**
* Supported message types (TF_TYPE) * Supported message types (TF_TYPE)
*/ */

@ -2,17 +2,16 @@
// Created by MightyPork on 2017/12/22. // Created by MightyPork on 2017/12/22.
// //
#include "platform.h"
#include "messages.h" #include "messages.h"
#include "msg_responses.h" #include "msg_responses.h"
void com_respond_snprintf(TF_ID frame_id, TF_TYPE type, const char *format, ...) void com_respond_snprintf(TF_ID frame_id, TF_TYPE type, const char *format, ...)
{ {
#define ERR_STR_LEN 64 char buf[ERR_MSG_STR_LEN];
char buf[ERR_STR_LEN];
va_list args; va_list args;
va_start(args, format); va_start(args, format);
uint32_t len = (uint32_t) fixup_vsnprintf(&buf[0], ERR_STR_LEN, format, args); uint32_t len = (uint32_t) fixup_vsnprintf(&buf[0], ERR_MSG_STR_LEN, format, args);
va_end(args); va_end(args);
com_respond_buf(frame_id, type, (const uint8_t *) buf, len); com_respond_buf(frame_id, type, (const uint8_t *) buf, len);

@ -7,8 +7,6 @@
#if USE_DEBUG_UART #if USE_DEBUG_UART
#define DBG_BUF_LEN 80
// debug printf // debug printf
int PRINTF(const char *format, ...) int PRINTF(const char *format, ...)
{ {

@ -2,8 +2,8 @@
// Created by MightyPork on 2017/11/26. // Created by MightyPork on 2017/11/26.
// //
#include "utils/hexdump.h"
#include "platform.h" #include "platform.h"
#include "utils/hexdump.h"
#include "settings.h" #include "settings.h"
#include "unit_registry.h" #include "unit_registry.h"
#include "system_settings.h" #include "system_settings.h"
@ -47,8 +47,7 @@ void settings_load(void)
} }
#define SAVE_BUF_SIZE 256 static uint8_t save_buffer[FLASH_SAVE_BUF_LEN];
static uint8_t save_buffer[SAVE_BUF_SIZE];
static uint32_t save_addr; static uint32_t save_addr;
#if DEBUG_FLASH_WRITE #if DEBUG_FLASH_WRITE
@ -126,7 +125,7 @@ static void savebuf_flush(PayloadBuilder *pb, bool final)
*/ */
static bool savebuf_ovhandler(PayloadBuilder *pb, uint32_t more) static bool savebuf_ovhandler(PayloadBuilder *pb, uint32_t more)
{ {
if (more > SAVE_BUF_SIZE) return false; if (more > FLASH_SAVE_BUF_LEN) return false;
savebuf_flush(pb, false); savebuf_flush(pb, false);
return true; return true;
} }
@ -135,7 +134,7 @@ static bool savebuf_ovhandler(PayloadBuilder *pb, uint32_t more)
void settings_save(void) void settings_save(void)
{ {
HAL_StatusTypeDef hst; HAL_StatusTypeDef hst;
PayloadBuilder pb = pb_start(save_buffer, SAVE_BUF_SIZE, savebuf_ovhandler); PayloadBuilder pb = pb_start(save_buffer, FLASH_SAVE_BUF_LEN, savebuf_ovhandler);
save_addr = SETTINGS_FLASH_ADDR; save_addr = SETTINGS_FLASH_ADDR;

@ -48,30 +48,26 @@
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "task.h"
#include "cmsis_os.h" #include "cmsis_os.h"
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#include "platform.h"
#include "tasks/sched_queue.h" #include "tasks/sched_queue.h"
#include "stacksmon.h" #include "stacksmon.h"
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Variables -----------------------------------------------------------------*/ /* Variables -----------------------------------------------------------------*/
#define STACK_MAIN 160
#define STACK_MSG 200
#define STACK_JOBRUNNER 128
osThreadId tskMainHandle; osThreadId tskMainHandle;
uint32_t mainTaskBuffer[ STACK_MAIN ]; uint32_t mainTaskBuffer[ TSK_STACK_MAIN ];
osStaticThreadDef_t mainTaskControlBlock; osStaticThreadDef_t mainTaskControlBlock;
osThreadId tskMsgHandle; osThreadId tskMsgHandle;
uint32_t msgTaskBuffer[ STACK_MSG ]; uint32_t msgTaskBuffer[ TSK_STACK_MSG ];
osStaticThreadDef_t msgTaskControlBlock; osStaticThreadDef_t msgTaskControlBlock;
osThreadId tskJobRunnerHandle; osThreadId tskJobRunnerHandle;
uint32_t jobRunnerBuffer[ STACK_JOBRUNNER ]; uint32_t jobRunnerBuffer[ TSK_STACK_JOBRUNNER ];
osStaticThreadDef_t jobRunnerControlBlock; osStaticThreadDef_t jobRunnerControlBlock;
osMessageQId queSchedHandle; osMessageQId queSchedHandle;
@ -166,15 +162,15 @@ void MX_FREERTOS_Init(void) {
/* Create the thread(s) */ /* Create the thread(s) */
/* definition and creation of tskMain */ /* definition and creation of tskMain */
osThreadStaticDef(tskMain, TaskMain, osPriorityHigh, 0, STACK_MAIN, mainTaskBuffer, &mainTaskControlBlock); osThreadStaticDef(tskMain, TaskMain, osPriorityHigh, 0, TSK_STACK_MAIN, mainTaskBuffer, &mainTaskControlBlock);
tskMainHandle = osThreadCreate(osThread(tskMain), NULL); tskMainHandle = osThreadCreate(osThread(tskMain), NULL);
/* definition and creation of tskJobRunner */ /* definition and creation of tskJobRunner */
osThreadStaticDef(tskJobRunner, TaskJobQueue, osPriorityAboveNormal, 0, STACK_JOBRUNNER, jobRunnerBuffer, &jobRunnerControlBlock); osThreadStaticDef(tskJobRunner, TaskJobQueue, osPriorityAboveNormal, 0, TSK_STACK_JOBRUNNER, jobRunnerBuffer, &jobRunnerControlBlock);
tskJobRunnerHandle = osThreadCreate(osThread(tskJobRunner), NULL); tskJobRunnerHandle = osThreadCreate(osThread(tskJobRunner), NULL);
/* definition and creation of TaskMessaging */ /* definition and creation of TaskMessaging */
osThreadStaticDef(tskMsg, TaskMessaging, osPriorityNormal, 0, STACK_MSG, msgTaskBuffer, &msgTaskControlBlock); osThreadStaticDef(tskMsg, TaskMessaging, osPriorityNormal, 0, TSK_STACK_MSG, msgTaskBuffer, &msgTaskControlBlock);
tskMsgHandle = osThreadCreate(osThread(tskMsg), NULL); tskMsgHandle = osThreadCreate(osThread(tskMsg), NULL);
/* USER CODE BEGIN RTOS_THREADS */ /* USER CODE BEGIN RTOS_THREADS */

@ -5,6 +5,74 @@
#ifndef GEX_PLAT_COMPAT_H #ifndef GEX_PLAT_COMPAT_H
#define GEX_PLAT_COMPAT_H #define GEX_PLAT_COMPAT_H
// -------- Buffers and stack sizes ---------
// FreeRTOS thread stacks (in 4-byte words)
#define TSK_STACK_MAIN 160
#define TSK_STACK_MSG 200
#define TSK_STACK_JOBRUNNER 128
// Size of the snprintf buffer for debug messages
// (this is on stack to avoid races)
#define DBG_BUF_LEN 80
// Bulk read/write
#define BULK_LST_TIMEOUT_MS 200 // timeout for the bulk transaction to expire
#define BULKREAD_MAX_CHUNK 512 // this is a static buffer
// Error message buffer size (on stack)
#define ERR_MSG_STR_LEN 32
// Static buffer for saving to flash
#define FLASH_SAVE_BUF_LEN 256
// Number of job runner slots
#define HP_SCHED_CAPACITY 5
// Number of message queue slots (64 bytes each)
#define RX_QUE_CAPACITY 10
// ------ TinyFrame config ------
// Maximum received payload size (static buffer)
// Larger payloads will be rejected.
#define TF_MAX_PAYLOAD_RX 640
// Size of the sending buffer. Larger payloads will be split to pieces and sent
// in multiple calls to the write function. This can be lowered to reduce RAM usage.
#define TF_SENDBUF_LEN 64
// --- Listener counts - determine sizes of the static slot tables ---
// Frame ID listeners (wait for response / multi-part message)
#define TF_MAX_ID_LST 4
// Frame Type listeners (wait for frame with a specific first payload byte)
#define TF_MAX_TYPE_LST 6
// Generic listeners (fallback if no other listener catches it)
#define TF_MAX_GEN_LST 1
// Timeout for receiving & parsing a frame
// ticks = number of calls to TF_Tick()
#define TF_PARSER_TIMEOUT_TICKS 250
// --- Mass Storage / USB config ---
#define USBD_MAX_STR_DESC_SIZ 128
#define MSC_MEDIA_PACKET 512
// INI buffer sizes
#define INI_KEY_MAX 20
#define INI_VALUE_MAX 30
// ini writer
#define IWBUFFER_LEN 128
// -------- Platform specific includes and defines ---------
#if defined(GEX_PLAT_F103_BLUEPILL) #if defined(GEX_PLAT_F103_BLUEPILL)
// platform name for the version string // platform name for the version string

@ -35,7 +35,4 @@ struct rx_que_item {
uint8_t data[64]; uint8_t data[64];
}; };
#define HP_SCHED_CAPACITY 5
#define RX_QUE_CAPACITY 10
#endif //GEX_SCHED_QUEUE_H #endif //GEX_SCHED_QUEUE_H

@ -10,8 +10,8 @@
#endif #endif
// buffer sizes // buffer sizes
#define INI_KEY_MAX 20 //#define INI_KEY_MAX 20
#define INI_VALUE_MAX 30 //#define INI_VALUE_MAX 30 // moved to plat_compat.h
/** /**
* INI parser callback, called for each found key-value pair. * INI parser callback, called for each found key-value pair.

@ -13,7 +13,7 @@
#define MAX(a,b) ((a)>(b)?(a):(b)) #define MAX(a,b) ((a)>(b)?(a):(b))
#endif #endif
#define IWBUFFER_LEN 128 //#define IWBUFFER_LEN 128 // moved to plat_compat.h
// sprintf from varargs, allocating buffer on stack. Uses 'format' argument // sprintf from varargs, allocating buffer on stack. Uses 'format' argument
#define IW_VPRINTF() do { \ #define IW_VPRINTF() do { \

Loading…
Cancel
Save