Commit 6ac0a37c authored by Christian Sponfeldner's avatar Christian Sponfeldner

update to firmware EM5-FEM-v2004 to fix issue #1

parent 19d154af
This diff is collapsed.
#pragma once
#include <stdint.h>
typedef struct
......
#pragma once
#define FILE_IF_VERSION 0x20171122
typedef struct
{
uint32_t Version;
uint32_t Status;
uint32_t OwnerThreadId;
const char *Filename;
uint8_t *Buffer;
uint32_t Length;
volatile int32_t Result; // since Result might get polled, must use volatile
uint32_t CacheAddress;
uint32_t CacheSize;
uint32_t CacheFillLevel;
uint32_t OpenFlags;
uint32_t StorageStartSector;
uint32_t StorageAvailableSectors;
bool IsOpen;
const char *FilenameExtOps; // for delete, change attribute flags etc.
char *FilenameExtOps2; // for directory access
} FILEIF_Type;
typedef enum {
FILERESULT_OK = 0,
FILERESULT_DISK_ERR = 1,
FILERESULT_INT_ERR = 2,
FILERESULT_NOT_READY = 3,
FILERESULT_NO_FILE = 4,
FILERESULT_NO_PATH = 5,
FILERESULT_INVALID_NAME = 6,
FILERESULT_DENIED = 7,
FILERESULT_EXIST = 8,
FILERESULT_INVALID_OBJECT = 9,
FILERESULT_WRITE_PROTECTED = 10,
FILERESULT_INVALID_DRIVE = 11,
FILERESULT_NOT_ENABLED = 12,
FILERESULT_NO_FILESYSTEM = 13,
FILERESULT_MKFS_ABORTED = 14,
FILERESULT_TIMEOUT = 15,
FILERESULT_LOCKED = 16,
FILERESULT_NOT_ENOUGH_CORE = 17,
FILERESULT_TOO_MANY_OPEN_FILES = 18,
FILERESULT_INVALID_PARAMETER = 19
} fileresult_t;
typedef const uint8_t * handle_t;
typedef enum {
FILEFLAG_READ = 0x1,
FILEFLAG_WRITE = 0x2,
FILEFLAG_READWRITE = 0x3
} fileflag_t;
// additional flags not available to user:
#define _FILEFLAG_OPENALWAYS 0x40
#define _FILEFLAG_AUTOSYNC 0x80
namespace File
{
void Initialize(void);
void Reset(void);
bool Open(asciistring_t filename, fileflag_t openflags);
bool OpenAlways(asciistring_t filename, fileflag_t openflags);
bool Read(uint8_t &var);
bool Read(uint16_t &var);
bool Read(uint32_t &var);
bool Read(int8_t &var);
bool Read(int16_t &var);
bool Read(int32_t &var);
bool Read(char buffer[], uint32_t length, uint32_t &readbytes);
bool Read(uint8_t buffer[], uint32_t length, uint32_t &readbytes);
bool Read(void *buffer, uint32_t length, uint32_t *readbytes = nullptr);
bool Write(uint8_t &var);
bool Write(uint16_t &var);
bool Write(uint32_t &var);
bool Write(int8_t &var);
bool Write(int16_t &var);
bool Write(int32_t &var);
bool Write(const char buffer[], uint32_t length);
bool Write(const uint8_t buffer[], uint32_t length);
bool Write(const void *buffer, uint32_t length);
bool Close(void);
bool ListFirstFile(asciistring_t dirname, char namebuffer[]);
bool ListNextFile(char namebuffer[]);
bool Delete(asciistring_t filename);
bool Copy(asciistring_t filenamesrc, asciistring_t filenamedest);
handle_t LoadToCache(asciistring_t filename);
void ClearCache(void);
int32_t GetCachedFileSize(handle_t handle);
void SaveCacheState(void);
void RestoreCacheState(void);
fileresult_t GetLastResult(void);
void EnableSafeWriting(bool bEnable);
}
#pragma once
#define FILE_IF_VERSION 0x20171122
#if __cplusplus <= 199711L
#define NULLPOINTER 0 // < C++11
#else
#define NULLPOINTER nullptr // >= C++11
#endif
typedef struct
{
uint32_t Version;
uint32_t Status;
uint32_t OwnerThreadId;
const char *Filename;
uint8_t *Buffer;
uint32_t Length;
volatile int32_t Result; // since Result might get polled, must use volatile
uint32_t CacheAddress;
uint32_t CacheSize;
uint32_t CacheFillLevel;
uint32_t OpenFlags;
uint32_t StorageStartSector;
uint32_t StorageAvailableSectors;
bool IsOpen;
const char *FilenameExtOps; // for delete, change attribute flags etc.
char *FilenameExtOps2; // for directory access
} FILEIF_Type;
typedef enum {
FILERESULT_OK = 0,
FILERESULT_DISK_ERR = 1,
FILERESULT_INT_ERR = 2,
FILERESULT_NOT_READY = 3,
FILERESULT_NO_FILE = 4,
FILERESULT_NO_PATH = 5,
FILERESULT_INVALID_NAME = 6,
FILERESULT_DENIED = 7,
FILERESULT_EXIST = 8,
FILERESULT_INVALID_OBJECT = 9,
FILERESULT_WRITE_PROTECTED = 10,
FILERESULT_INVALID_DRIVE = 11,
FILERESULT_NOT_ENABLED = 12,
FILERESULT_NO_FILESYSTEM = 13,
FILERESULT_MKFS_ABORTED = 14,
FILERESULT_TIMEOUT = 15,
FILERESULT_LOCKED = 16,
FILERESULT_NOT_ENOUGH_CORE = 17,
FILERESULT_TOO_MANY_OPEN_FILES = 18,
FILERESULT_INVALID_PARAMETER = 19
} fileresult_t;
typedef const uint8_t * handle_t;
typedef enum {
FILEFLAG_READ = 0x1,
FILEFLAG_WRITE = 0x2,
FILEFLAG_READWRITE = 0x3
} fileflag_t;
// additional flags not available to user:
#define _FILEFLAG_OPENALWAYS 0x40
#define _FILEFLAG_AUTOSYNC 0x80
namespace File
{
void Initialize(void);
void Reset(void);
bool Open(asciistring_t filename, fileflag_t openflags);
bool OpenAlways(asciistring_t filename, fileflag_t openflags);
bool Read(uint8_t &var);
bool Read(uint16_t &var);
bool Read(uint32_t &var);
bool Read(int8_t &var);
bool Read(int16_t &var);
bool Read(int32_t &var);
bool Read(char buffer[], uint32_t length, uint32_t &readbytes);
bool Read(uint8_t buffer[], uint32_t length, uint32_t &readbytes);
bool Read(void *buffer, uint32_t length, uint32_t *readbytes = NULLPOINTER);
bool Write(uint8_t &var);
bool Write(uint16_t &var);
bool Write(uint32_t &var);
bool Write(int8_t &var);
bool Write(int16_t &var);
bool Write(int32_t &var);
bool Write(const char buffer[], uint32_t length);
bool Write(const uint8_t buffer[], uint32_t length);
bool Write(const void *buffer, uint32_t length);
bool Close(void);
bool ListFirstFile(asciistring_t dirname, char namebuffer[]);
bool ListNextFile(char namebuffer[]);
bool Delete(asciistring_t filename);
bool Copy(asciistring_t filenamesrc, asciistring_t filenamedest);
handle_t LoadToCache(asciistring_t filename);
void ClearCache(void);
int32_t GetCachedFileSize(handle_t handle);
void SaveCacheState(void);
void RestoreCacheState(void);
fileresult_t GetLastResult(void);
void EnableSafeWriting(bool bEnable);
}
......@@ -49,10 +49,10 @@
/** @addtogroup Utilities
* @{
*/
/** @addtogroup STM32_EVAL
* @{
*/
*/
/** @addtogroup Common
* @{
......@@ -60,17 +60,17 @@
/** @addtogroup FONTS
* @{
*/
*/
/** @defgroup FONTS_Exported_Types
* @{
*/
*/
typedef struct _tFont
{
{
const uint8_t *table;
uint16_t Width;
uint16_t Height;
} sFONT;
extern const sFONT Font24;
......@@ -80,27 +80,27 @@ extern const sFONT Font12;
extern const sFONT Font8;
/**
* @}
*/
*/
/** @defgroup FONTS_Exported_Constants
* @{
*/
*/
#define LINE(x) ((x) * (((sFONT *)BSP_LCD_GetFont())->Height))
/**
* @}
*/
*/
/** @defgroup FONTS_Exported_Macros
* @{
*/
*/
/**
* @}
*/
*/
/** @defgroup FONTS_Exported_Functions
* @{
*/
*/
/**
* @}
*/
......@@ -108,16 +108,16 @@ extern const sFONT Font8;
#ifdef __cplusplus
}
#endif
#endif /* __FONTS_H */
/**
* @}
*/
/**
* @}
*/
*/
/**
* @}
......@@ -129,6 +129,6 @@ extern const sFONT Font8;
/**
* @}
*/
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
This diff is collapsed.
This diff is collapsed.
#include "mtmessaging.h"
// This file includes a svc call wrapper for OS functions
// A developer of an user program should not call any of this functions directly
#if defined ( __ICCARM__ )
#pragma default_function_attributes = @ ".VMM_Section_ROM"
#endif
// GCC is used when user program is compiled; must provide the used SVC calls here:
namespace Internal
{
#if defined (__GNUC__)
__attribute__ ( ( always_inline ) ) inline os_msgqueue_t * GetMessageQueuePointer(uint32_t threadnum)
{
os_msgqueue_t * result;
asm volatile ("mov r0, %1\n"
"svc 0x00\n"
"mov %0,r0" : "=r" (result) : "r" (threadnum) : "r0");
return result;
}
__attribute__ ( ( always_inline ) ) inline void SetActiveThreadMonitor(uint32_t *pThreadSelect)
{
asm volatile ("mov r0, %0\n"
"svc 0x04\n" : : "r" (pThreadSelect) : "r0");
}
__attribute__ ( ( always_inline ) ) inline void ControlCmd(uint32_t cmd, uint32_t param)
{
asm volatile ("mov r0, %0\n"
"mov r1, %1\n"
"svc 0x05\n" : : "r" (cmd), "r" (param) : "r0","r1");
}
__attribute__ ( ( always_inline ) ) inline void Sleep(uint32_t ms)
{
asm volatile ("mov r0, %0\n"
"svc 0xe1\n" : : "r" (ms): "r0");
}
__attribute__ ( ( always_inline ) ) inline void SleepEx(uint32_t ms, uint32_t threadtorun)
{
asm volatile ("mov r0, %0\n"
"mov r1, %1\n"
"svc 0xf0\n" : : "r" (ms), "r" (threadtorun) : "r0","r1");
}
__attribute__ ( ( always_inline ) ) inline void WaitForMessage(uint32_t timeout)
{
asm volatile ("mov r0, %0\n"
"svc 0xeb\n" : : "r" (timeout): "r0");
}
__attribute__ ( ( always_inline ) ) inline uint32_t PostMessage(uint32_t threadnum, uint32_t msg, uint32_t timestamp, uint32_t tag)
{
uint32_t result;
asm volatile ("mov r0, %1\n"
"mov r1, %2\n"
"mov r2, %3\n"
"mov r3, %4\n"
"svc 0xec\n"
"mov %0,r0" : "=r" (result) : "r" (threadnum), "r" (msg), "r" (timestamp), "r" (tag) : "r0","r1","r2","r3");
return result;
}
__attribute__ ( ( always_inline ) ) inline void ConfigureScheduler(uint32_t multiplier)
{
asm volatile ("mov r0, %0\n"
"svc 0x06\n" : : "r" (multiplier): "r0");
}
__attribute__ ( ( always_inline ) ) inline void WakeupThread(uint32_t threadnum)
{
asm volatile ("mov r0, %0\n"
"svc 0xe5\n" : : "r" (threadnum): "r0");
}
__attribute__ ( ( always_inline ) ) inline void ContinueThread(uint32_t threadnum)
{
asm volatile ("mov r0, %0\n"
"svc 0xe3\n" : : "r" (threadnum): "r0");
}
__attribute__ ( ( always_inline ) ) inline uint32_t GetCurrentThreadID(void)
{
uint32_t result;
asm volatile ("svc 0x01\n"
"mov %0,r0" : "=r" (result) : : "r0");
return result;
}
__attribute__ ( ( always_inline ) ) inline void * GetIprocInterface(const char name[4], uint32_t version)
{
void * result;
asm volatile ("mov r0, %1\n"
"mov r1, %2\n"
"svc 0x02\n"
"mov %0,r0" : "=r" (result) : "r" (name) , "r" (version) : "r0","r1");
return result;
}
#endif
// IAR is used for the internal user program in user.cpp
#if defined ( __ICCARM__ )
#pragma swi_number=0x00
__swi os_msgqueue_t * GetMessageQueuePointer(uint32_t threadnum);
#pragma swi_number=0x01
__swi uint32_t GetCurrentThreadID(void);
#pragma swi_number=0x02
__swi void * GetIprocInterface(const char name[4], uint32_t version);
#pragma swi_number=0x03
__swi uint32_t RegisterIprocInterface(const char name[4], void *ptIF);
#pragma swi_number=0x04
__swi uint32_t SetActiveThreadMonitor(uint32_t *pThreadSelect);
#pragma swi_number=0x05
__swi uint32_t ControlCmd(uint32_t cmd, uint32_t param);
#pragma swi_number=0xe3
__swi void ContinueThread(uint32_t threadnum);
#pragma swi_number=0xe5
__swi void WakeupThread(uint32_t threadnum);
#pragma swi_number=0xeb
__swi void WaitForMessage(uint32_t timeout);
#pragma swi_number=0xec
__swi uint32_t PostMessage(uint32_t threadnum, uint32_t msg, uint32_t timestamp, uint32_t tag);
#pragma swi_number=0xf0
__swi uint32_t SleepEx(uint32_t ms, uint32_t threadselect);
#endif
inline uint32_t PostMsgToRealtimeTask(uint32_t msgid, uint32_t tag, msg_priority_t msgpriority = MSG_PRIORITY_HIGH)
{
return PostMessage(3, msgid | (0x80000000 * msgpriority), GETREFTIMER, tag);
}
}
#include "mtmessaging.h"
// This file includes a svc call wrapper for OS functions
// A developer of an user program should not call any of this functions directly
#if defined ( __ICCARM__ )
#pragma default_function_attributes = @ ".VMM_Section_ROMFunction"
#endif
// GCC is used when user program is compiled; must provide the used SVC calls here:
namespace Internal
{
#if defined (__GNUC__)
__attribute__ ( ( always_inline ) ) inline os_msgqueue_t * GetMessageQueuePointer(uint32_t threadnum)
{
os_msgqueue_t * result;
asm volatile ("mov r0, %1\n"
"svc 0x00\n"
"mov %0,r0" : "=r" (result) : "r" (threadnum) : "r0");
return result;
}
__attribute__ ( ( always_inline ) ) inline void SetActiveThreadMonitor(uint32_t *pThreadSelect)
{
asm volatile ("mov r0, %0\n"
"svc 0x04\n" : : "r" (pThreadSelect) : "r0");
}
__attribute__ ( ( always_inline ) ) inline void ControlCmd(uint32_t cmd, uint32_t param)
{
asm volatile ("mov r0, %0\n"
"mov r1, %1\n"
"svc 0x05\n" : : "r" (cmd), "r" (param) : "r0","r1");
}
__attribute__ ( ( always_inline ) ) inline void Sleep(uint32_t ms)
{
asm volatile ("mov r0, %0\n"
"svc 0xe1\n" : : "r" (ms): "r0");
}
__attribute__ ( ( always_inline ) ) inline void SleepEx(uint32_t ms, uint32_t threadtorun)
{
asm volatile ("mov r0, %0\n"
"mov r1, %1\n"
"svc 0xf0\n" : : "r" (ms), "r" (threadtorun) : "r0","r1");
}
__attribute__ ( ( always_inline ) ) inline void WaitForMessage(uint32_t timeout)
{
asm volatile ("mov r0, %0\n"
"svc 0xeb\n" : : "r" (timeout): "r0");
}
__attribute__ ( ( always_inline ) ) inline uint32_t PostMessage(uint32_t threadnum, uint32_t msg, uint32_t timestamp, uint32_t tag)
{
uint32_t result;
asm volatile ("mov r0, %1\n"
"mov r1, %2\n"
"mov r2, %3\n"
"mov r3, %4\n"
"svc 0xec\n"
"mov %0,r0" : "=r" (result) : "r" (threadnum), "r" (msg), "r" (timestamp), "r" (tag) : "r0","r1","r2","r3");
return result;
}
__attribute__ ( ( always_inline ) ) inline void ConfigureScheduler(uint32_t multiplier)
{
asm volatile ("mov r0, %0\n"
"svc 0x06\n" : : "r" (multiplier): "r0");
}
__attribute__ ( ( always_inline ) ) inline void WakeupThread(uint32_t threadnum)
{
asm volatile ("mov r0, %0\n"
"svc 0xe5\n" : : "r" (threadnum): "r0");
}
__attribute__ ( ( always_inline ) ) inline void ContinueThread(uint32_t threadnum)
{
asm volatile ("mov r0, %0\n"
"svc 0xe3\n" : : "r" (threadnum): "r0");
}
__attribute__ ( ( always_inline ) ) inline uint32_t GetCurrentThreadID(void)
{
uint32_t result;
asm volatile ("svc 0x01\n"
"mov %0,r0" : "=r" (result) : : "r0");
return result;
}
__attribute__ ( ( always_inline ) ) inline void * GetIprocInterface(const char name[4], uint32_t version)
{
void * result;
asm volatile ("mov r0, %1\n"
"mov r1, %2\n"
"svc 0x02\n"
"mov %0,r0" : "=r" (result) : "r" (name) , "r" (version) : "r0","r1");
return result;
}
#endif
// IAR is used for the internal user program in user.cpp
#if defined ( __ICCARM__ )
#pragma swi_number=0x00
__swi os_msgqueue_t * GetMessageQueuePointer(uint32_t threadnum);
#pragma swi_number=0x01
__swi uint32_t GetCurrentThreadID(void);
#pragma swi_number=0x02
__swi void * GetIprocInterface(const char name[4], uint32_t version);
#pragma swi_number=0x03
__swi uint32_t RegisterIprocInterface(const char name[4], void *ptIF);
#pragma swi_number=0x04
__swi uint32_t SetActiveThreadMonitor(uint32_t *pThreadSelect);
#pragma swi_number=0x05
__swi uint32_t ControlCmd(uint32_t cmd, uint32_t param);
#pragma swi_number=0xe3
__swi void ContinueThread(uint32_t threadnum);
#pragma swi_number=0xe5
__swi void WakeupThread(uint32_t threadnum);
#pragma swi_number=0xeb
__swi void WaitForMessage(uint32_t timeout);
#pragma swi_number=0xec
__swi uint32_t PostMessage(uint32_t threadnum, uint32_t msg, uint32_t timestamp, uint32_t tag);
#pragma swi_number=0xf0
__swi uint32_t SleepEx(uint32_t ms, uint32_t threadselect);
#endif
inline uint32_t PostMsgToRealtimeTask(uint32_t msgid, uint32_t tag, msg_priority_t msgpriority = MSG_PRIORITY_HIGH)
{
return PostMessage(3, msgid | (0x80000000 * msgpriority), GETREFTIMER, tag);
}
}
#pragma once
#define IO_IF_VERSION 0x20170411
uint32_t IOGetAnalogValue(uint32_t);
typedef struct
{
uint32_t Version;
uint32_t Status;
uint32_t OwnerThreadId;
uint32_t AdcBufferAddress;
uint32_t PinChangeIrqThread;
uint32_t PinChangeNotificationMsg;
uint32_t input_portaddresses[8];
uint32_t output_portaddresses[8];
} IOIF_Type;
typedef enum
{
PINCHANGE_NOTIFY_OFF = 0,
PINCHANGE_NOTIFY_RISINGEDGE = 1,
PINCHANGE_NOTIFY_FALLINGEDGE = 2,
PINCHANGE_NOTIFY_BOTHEDGES = 3
} pinchange_notify_t;
typedef enum
{
INPUT_DIGITAL_1 = 0,
INPUT_DIGITAL_2 = 1,
INPUT_DIGITAL_3 = 2,
INPUT_DIGITAL_4 = 3,
INPUT_DIGITAL_5 = 4,
INPUT_DIGITAL_6 = 5,
INPUT_ANALOG_1 = 100,
INPUT_ANALOG_2 = 101
} input_id_t;
typedef enum
{
OUTPUT_DIGITAL_1 = 0,
OUTPUT_DIGITAL_2 = 1,
OUTPUT_DIGITAL_3 = 2,
OUTPUT_DIGITAL_4 = 3,
OUTPUT_LED_RED = 4,
OUTPUT_LED_GREEN = 5
} output_id_t;
namespace Io
{
void Initialize(void);
void Reset(void);
bool EnableInputChangeNotification(input_id_t inputid, pinchange_notify_t notify, msg_priority_t priority);
void DisableInputChangeNotification(input_id_t inputid);
bool WriteOutput(output_id_t outputnumber, uint32_t value);
uint32_t ReadInput(input_id_t inputid);
bool IsInputChangeNotificationMsg(os_msg_t msg);
uint32_t ReadCounter(input_id_t inputid);
}
uint16_t GetAdcSupplyValue(void); // no user function, do not add to namespace
#pragma once
#define IO_IF_VERSION 0x20170411
uint32_t IOGetAnalogValue(uint32_t);
typedef struct
{
uint32_t Version;
uint32_t Status;
uint32_t OwnerThreadId;
uint32_t AdcBufferAddress;
uint32_t PinChangeIrqThread;
uint32_t PinChangeNotificationMsg;
uint32_t input_portaddresses[8];
uint32_t output_portaddresses[8];
} IOIF_Type;
typedef enum
{
PINCHANGE_NOTIFY_OFF = 0,
PINCHANGE_NOTIFY_RISINGEDGE = 1,
PINCHANGE_NOTIFY_FALLINGEDGE = 2,
PINCHANGE_NOTIFY_BOTHEDGES = 3
} pinchange_notify_t;
typedef enum
{
INPUT_DIGITAL_1 = 0,
INPUT_DIGITAL_2 = 1,
INPUT_DIGITAL_3 = 2,
INPUT_DIGITAL_4 = 3,
INPUT_DIGITAL_5 = 4,
INPUT_DIGITAL_6 = 5,
INPUT_ANALOG_1 = 100,
INPUT_ANALOG_2 = 101
} input_id_t;
typedef enum
{
OUTPUT_DIGITAL_1 = 0,
OUTPUT_DIGITAL_2 = 1,
OUTPUT_DIGITAL_3 = 2,
OUTPUT_DIGITAL_4 = 3,
OUTPUT_LED_RED = 4,
OUTPUT_LED_GREEN = 5
} output_id_t;
namespace Io