Commit cf439d20 authored by Christian Sponfeldner's avatar Christian Sponfeldner

Merge branch 'API20180607' into 'master'

API20180607

See merge request !1
parents f2ce505c e75693ea
This diff is collapsed.
......@@ -23,59 +23,82 @@ typedef struct
} FILEIF_Type;
typedef enum {
FILE_RESULT_OK = 0,
FILE_RESULT_DISK_ERR = -1,
FILE_RESULT_INT_ERR = -2,
FILE_RESULT_NOT_READY = -3,
FILE_RESULT_NO_FILE = -4,
FILE_RESULT_NO_PATH = -5,
FILE_RESULT_INVALID_NAME = -6,
FILE_RESULT_DENIED = -7,
FILE_RESULT_EXIST = -8,
FILE_RESULT_INVALID_OBJECT = -9,
FILE_RESULT_WRITE_PROTECTED = -10,
FILE_RESULT_INVALID_DRIVE = -11,
FILE_RESULT_NOT_ENABLED = -12,
FILE_RESULT_NO_FILESYSTEM = -13,
FILE_RESULT_MKFS_ABORTED = -14,
FILE_RESULT_TIMEOUT = -15,
FILE_RESULT_LOCKED = -16,
FILE_RESULT_NOT_ENOUGH_CORE = -17,
FILE_RESULT_TOO_MANY_OPEN_FILES = -18,
FILE_RESULT_INVALID_PARAMETER = -19
} file_result_t;
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;
#define FILEFLAG_READ 0x1
#define FILEFLAG_WRITE 0x2
#define FILEFLAG_CREATENEW 0x4
#define FILEFLAG_CREATE 0x8
#define FILEFLAG_AUTOSYNC 0x100
typedef enum {
FILEFLAG_READ = 0x1,
FILEFLAG_WRITE = 0x2,
FILEFLAG_READWRITE = 0x3
} fileflag_t;
typedef uint32_t file_flag_t;
// additional flags not available to user:
#define _FILEFLAG_OPENALWAYS 0x40
#define _FILEFLAG_AUTOSYNC 0x80
namespace File
{
void Initialize(void);
void Reset(void);
int32_t Open(const char *filename, file_flag_t openflags);
int32_t Read(void *buffer, uint32_t length);
int32_t Write(const void *buffer, uint32_t length);
int32_t Close(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(const char *dirname, char *namebuffer);
bool ListNextFile(char *namebuffer);
bool ListFirstFile(asciistring_t dirname, char namebuffer[]);
bool ListNextFile(char namebuffer[]);
int32_t Delete(const char *filename);
int32_t Copy(const char *filenamesrc, const char *filenamedest);
bool Delete(asciistring_t filename);
bool Copy(asciistring_t filenamesrc, asciistring_t filenamedest);
handle_t LoadToCache(const char *filename);
handle_t LoadToCache(asciistring_t filename);
void ClearCache(void);
int32_t GetCachedFileSize(handle_t handle);
void SaveCacheState(void);
void RestoreCacheState(void);
file_result_t GetLastResult(void);
fileresult_t GetLastResult(void);
void EnableSafeWriting(bool bEnable);
}
#pragma once
#include <stdint.h>
#ifdef FREETYPE_LIB_BUILD
#include "ft2build.h" // these files are only required when the libnanotec_em.a is built with freetype support
#include <ft2build.h> // these files are only required when the libnanotec_em.a is built with freetype support
#include FT_FREETYPE_H
#endif
......@@ -207,10 +205,13 @@ typedef struct
void Dma2DSvcCall(void);
#if defined ( __ICCARM__ )
extern fonthandle_t SYSFONT12;
extern fonthandle_t SYSFONT16;
#if defined (__GNUC__)
#else
extern fonthandle_t SYSFONT8;
extern fonthandle_t SYSFONT12;
extern fonthandle_t SYSFONT16;
extern fonthandle_t SYSFONT20;
extern fonthandle_t SYSFONT24;
#endif
......@@ -218,7 +219,8 @@ extern fonthandle_t SYSFONT24;
namespace Graphics
{
void Initialize(GFXIF_Type *gfxif = nullptr);
void Reset(void);
bool DrawBitmap(bitmaphandle_t hbmp, uint32_t left, uint32_t top);
bool DrawImage(imagehandle_t hbmp, uint32_t left, uint32_t top);
bool DrawBitmapPartial(bitmaphandle_t hbmp, uint32_t srcLeft, uint32_t srcTop, uint32_t srcWidth, uint32_t srcHeight, uint32_t destLeft, uint32_t destTop);
......
#include "graphics.h"
#include "fileiprocif.h"
#define COLOR_BUTTON_STD COLOR_LIGHTGRAY
#define COLOR_BUTTON_PRESSED COLOR_DARKGRAY
......@@ -66,9 +65,6 @@ typedef struct
class CClickableArea
{
public:
CClickableArea();
bool Draw(void);
gui_element_t m_Type;
......@@ -180,7 +176,7 @@ class CButtonGrid : public CClickableArea
public:
CButtonGrid();
void Initialize(uint16_t id, rectangle_t rect, uint8_t *filename, uint8_t columns, uint8_t rows);
void Draw(void) ;
void Draw(void);
void Pressed(uint16_t x, uint16_t y);
void Released(uint16_t x, uint16_t y, bool bChangeValue = true);
......@@ -322,7 +318,7 @@ touchpanel_msg_t DecodeTouchpanelMsg(os_msg_t &msg);
void RemoveFocusFromPage(const guipage_t page[]);
void SetFontForPage(const guipage_t page[], fonthandle_t font, gui_element_t guielement = GUI_ELEMENT_ANY);
void SetDefaultFont(fonthandle_t font);
optiondialog_result_t ShowOptionDialog(uint16_t id, rectangle_t &rect, const char *text, optiondialog_buttons_t optdlgbuttons, bool blockingmode = true);
optiondialog_result_t ShowOptionDialog(uint16_t id, rectangle_t &rect, string_t text, optiondialog_buttons_t optdlgbuttons, bool blockingmode = true);
}
extern CDummyArea GUI_PAGEEND;
extern CDummyArea GUI_PAGEEND;
\ No newline at end of file
#include <stdint.h>
#include "mtmessaging.h"
// This file includes a svc call wrapper for OS functions
......
......@@ -55,6 +55,7 @@ namespace Io
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
......@@ -17,8 +17,10 @@
#define OS_MSG_CANOPEN_NOTIFICATION 0x80030001
// messages are no longer used directly (except COPINIT), but keep here for compatibility
#define OS_MSG_CANOPEN_COPINIT_EVNT 0x80030020
// messages are used directly, because they should not be disengageable
#define OS_MSG_CANOPEN_PDO_RX 0x8003001E
#define OS_MSG_CANOPEN_SYNC_TX 0x8003001F
#define OS_MSG_CANOPEN_COPINIT_EVNT 0x80030020
#define OS_MSG_FILE_OPEN 0x80040000
#define OS_MSG_FILE_CLOSE 0x80040001
......
......@@ -10,8 +10,6 @@
#include "internalif.h"
#include "stdint.h"
#include "mtmessaging.h"
#include "messagedefs.h"
#include "graphics.h"
#include "networkiprocif.h"
......@@ -19,6 +17,7 @@
#include "soundiprocif.h"
#include "usbiprocif.h"
#include "caniprocif.h"
#include "pdomapping.h"
#include "ioiprocif.h"
#include "spiiprocif.h"
#include "gui.h"
......@@ -167,8 +166,8 @@ namespace System
uint32_t GetLowPrioMsg(os_msg_t &msg);
os_msg_t GetLowPrioMsg(void);
bool PostUserMsgDelayed(task_id_t task, uint16_t msgid, uint16_t delay_ms, msg_priority_t msgpriority = MSG_PRIORITY_HIGH);
bool CancelPostUserMsgDelayed(uint16_t msgid);
bool PostUserMsgDelayed(task_id_t task, uint16_t usermsg, uint16_t delay_ms, msg_priority_t msgpriority = MSG_PRIORITY_HIGH);
bool CancelPostUserMsgDelayed(uint16_t usermsg);
void GetDateTimeUtc(datetime_t &utc);
void GetDateTimeLocal(datetime_t &localdatetime);
bool SetDateTimeUtc(datetime_t &utc);
......@@ -196,7 +195,7 @@ namespace System
{
uint32_t start = GETREFTIMER;
while ((GETREFTIMER - start) < duration_us);
while ( (GETREFTIMER - start) < duration_us);
}
inline uint32_t GetReferenceTimer(void)
......@@ -214,9 +213,9 @@ namespace System
Internal::ControlCmd(0, 0);
}
inline uint32_t PostUserMsg(task_id_t task, uint16_t msgid, uint32_t tag, msg_priority_t msgpriority = MSG_PRIORITY_HIGH)
inline bool PostUserMsg(task_id_t task, uint16_t usermsg, uint32_t tag, msg_priority_t msgpriority = MSG_PRIORITY_HIGH)
{
return Internal::PostMessage(task, OS_MSG_USER | msgid | (0x80000000 * msgpriority), GETREFTIMER, tag);
return (bool) Internal::PostMessage(task, OS_MSG_USER | usermsg | (0x80000000 * msgpriority), GETREFTIMER, tag);
}
......@@ -242,9 +241,14 @@ namespace System
return ((msg.msgid << 1) == (msgid << 1));
}
inline bool IsUserMsg(os_msg_t &msg, uint16_t msgid)
inline bool IsUserMsg(os_msg_t &msg, uint16_t usermsg)
{
return ((msg.msgid & 0x7fffffff) == (uint32_t) (OS_MSG_USER + msgid));
return ((msg.msgid & 0x7fffffff) == (uint32_t) (OS_MSG_USER + usermsg));
}
inline uint32_t GetTag(os_msg_t &msg)
{
return msg.tag;
}
inline bool IsTimerMsg(os_msg_t &msg)
......@@ -265,16 +269,16 @@ namespace System
namespace Debug
{
bool LiveView(uint32_t &var, const char *displaytext);
bool LiveView(uint16_t &var, const char *displaytext);
bool LiveView(uint8_t &var, const char *displaytext);
bool LiveView(int32_t &var, const char *displaytext);
bool LiveView(int16_t &var, const char *displaytext);
bool LiveView(int8_t &var, const char *displaytext);
bool LiveView(float &var, const char *displaytext);
bool LiveView(void *var, uint32_t size, const char *displaytext);
void LiveView_SetUpdateInterval(uint32_t interval);
void LiveView_SetClientIp(uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4);
bool SpotVariable(uint32_t &var, asciistring_t displaytext);
bool SpotVariable(uint16_t &var, asciistring_t displaytext);
bool SpotVariable(uint8_t &var, asciistring_t displaytext);
bool SpotVariable(int32_t &var, asciistring_t displaytext);
bool SpotVariable(int16_t &var, asciistring_t displaytext);
bool SpotVariable(int8_t &var, asciistring_t displaytext);
bool SpotVariable(float &var, asciistring_t displaytext);
bool SpotVariable(void *var, uint32_t size, asciistring_t displaytext);
void SetSpotUpdateInterval(uint32_t interval);
void SetSpotClientAddress(uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4);
void RestartMe(void);
}
......
......@@ -11,6 +11,21 @@ typedef union
uint32_t w;
} net_status_flags_t;
// Types
typedef enum
{
NETWORK_NOTIFICATION_UDP_RX = (1 << 0),
NETWORK_NOTIFICATION_STD = NETWORK_NOTIFICATION_UDP_RX,
NETWORK_NOTIFICATION_ALL = NETWORK_NOTIFICATION_UDP_RX
}
network_notification_t;
typedef struct
{
uint32_t transferredBytes;
}
ndata_udp_rx_t;
typedef struct
{
uint32_t Version;
......@@ -40,14 +55,32 @@ namespace Network
void Reset(void);
void SetLocalAddress(uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4);
void SetRemoteAddress(uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4);
void GetRemoteAddress(uint8_t &a1, uint8_t &a2, uint8_t &a3, uint8_t &a4);
void SetNetmask(uint8_t m1, uint8_t m2, uint8_t m3, uint8_t m4);
void SetGateway(uint8_t g1, uint8_t g2, uint8_t g3, uint8_t g4);
void SetPort(uint16_t port);
void UdpStart(void);
void UdpStop(void);
uint32_t WriteData(const uint8_t *data, uint32_t len);
uint32_t ReadData(uint8_t *data, uint32_t len);
void SetRxNotificationMsg(uint32_t msg);
bool IsRxNotificationMsg(os_msg_t msg);
void EnableRxNotification(msg_priority_t priority);
void UdpOpen(void);
void UdpClose(void);
uint32_t Write(const void *data, uint32_t len);
bool Write(uint8_t data);
bool Write(uint16_t data);
bool Write(uint32_t data);
bool Write(int8_t data);
bool Write(int16_t data);
bool Write(int32_t data);
uint32_t Read(void *data, uint32_t len);
bool Read(uint8_t &data);
bool Read(uint16_t &data);
bool Read(uint32_t &data);
bool Read(int8_t &data);
bool Read(int16_t &data);
bool Read(int32_t &data);
void SetUdpRxNotificationMsg(uint32_t msgid);
bool IsNotificationMsg(os_msg_t &msg, network_notification_t notification);
void EnableNotification(network_notification_t notification, msg_priority_t priority);
bool GetNotificationData(os_msg_t &msg, ndata_udp_rx_t &data);
}
// this file is an extension for the CAN-IF to create PDO mappings dynamically
#include <stdint.h>
typedef uint8_t * pdohandleU8_t;
typedef uint16_t * pdohandleU16_t;
typedef uint32_t * pdohandleU32_t;
typedef int8_t * pdohandleI8_t;
typedef int16_t * pdohandleI16_t;
typedef int32_t * pdohandleI32_t;
typedef void *pdohandle_t;
typedef enum
{
TRANSMISSIONTYPE_ACYCLIC_SYNCHRONOUS = 0,
TRANSMISSIONTYPE_CYCLIC_SYNCHRONOUS = 1,
TRANSMISSIONTYPE_ASYNCHRONOUS = 0xff
} transmissiontype_t;
// for fast access to PDOs:
#define PDO(x) *(x)
// ...but better use these functions, because the pdohandle is checked:
namespace Can
{
uint8_t GetPdoValue(pdohandleU8_t objhandle);
uint16_t GetPdoValue(pdohandleU16_t objhandle);
uint32_t GetPdoValue(pdohandleU32_t objhandle);
int8_t GetPdoValue(pdohandleI8_t objhandle);
int16_t GetPdoValue(pdohandleI16_t objhandle);
int32_t GetPdoValue(pdohandleI32_t objhandle);
void SetPdoValue(pdohandleU8_t objhandle, uint8_t value);
void SetPdoValue(pdohandleU16_t objhandle, uint16_t value);
void SetPdoValue(pdohandleU32_t objhandle, uint32_t value);
void SetPdoValue(pdohandleI8_t objhandle, int8_t value);
void SetPdoValue(pdohandleI16_t objhandle, int16_t value);
void SetPdoValue(pdohandleI32_t objhandle, int32_t value);
}
class CPdoMapping
{
public:
uint16_t AssignNode(uint8_t nodeid, uint8_t pdonumber);
pdohandleU8_t AddObjectU8(uint16_t index, uint8_t subindex);
pdohandleU16_t AddObjectU16(uint16_t index, uint8_t subindex);
pdohandleU32_t AddObjectU32(uint16_t index, uint8_t subindex);
pdohandleI8_t AddObjectI8(uint16_t index, uint8_t subindex);
pdohandleI16_t AddObjectI16(uint16_t index, uint8_t subindex);
pdohandleI32_t AddObjectI32(uint16_t index, uint8_t subindex);
bool Submit(bool bDevOnly = false);
void SetInhibittime(uint16_t inhibittime);
void SetTransmissionType(transmissiontype_t transmissiontype, uint8_t synccycle_interval = 1);
void SetEventTimer(uint16_t eventtimer);
void SetMappingId(uint16_t id = 0);
operator uint16_t()
{
return uint16_t(m_Id); // return the mapping id (value of 140x:01/180x:01 on device)
}
virtual ~CPdoMapping() = 0; // make CPdoMapping abstract class
protected:
uint32_t m_Mappings[8]; // mapping on device (value that will be written to 0x160x/0x1A0x)
uint32_t m_LocalMappings[8]; // mapping on master including subindex and size (e.g. 0xA1000108)
pdohandle_t m_pObj[8]; // pointer to local od objects (A100-A680)
uint8_t m_ObjectCnt; // number of objects used in this mapping
uint16_t m_InhibitTime;
uint16_t m_EventTimer;
transmissiontype_t m_TransmissionType;
uint8_t m_NodeId;
uint8_t m_PdoNumber; // number of PDO on device
uint32_t m_Id;
bool m_bTxPdo; // true if PDO is a rx PDO
bool InstallTxPdoMapping(bool bDevOnly);
bool InstallRxPdoMapping(bool bDevOnly);
bool CheckPdo(uint8_t newpdosize);
};
////////////////////////////////////////////////////////////////////////////////////////////////////
class CRxPdoMapping : public CPdoMapping
{
public:
CRxPdoMapping();
CRxPdoMapping(uint8_t nodeid, uint8_t pdonumber, transmissiontype_t transmissiontype = TRANSMISSIONTYPE_ASYNCHRONOUS);
};
class CTxPdoMapping : public CPdoMapping
{
public:
CTxPdoMapping();
CTxPdoMapping(uint8_t nodeid, uint8_t pdonumber, transmissiontype_t transmissiontype = TRANSMISSIONTYPE_ASYNCHRONOUS);
};
......@@ -2,6 +2,15 @@
#define USB_IF_VERSION 0x20171206
// Types
typedef enum
{
USB_NOTIFICATION_COMPORT_RX = (1 << 0),
USB_NOTIFICATION_STD = USB_NOTIFICATION_COMPORT_RX,
USB_NOTIFICATION_ALL = USB_NOTIFICATION_COMPORT_RX
}
usb_notification_t;
typedef union
{
struct
......@@ -11,6 +20,12 @@ typedef union
uint32_t w;
} usb_status_flags_t;
typedef struct
{
uint32_t transferredBytes;
}
ndata_comport_rx_t;
typedef struct
{
uint32_t Version;
......@@ -32,13 +47,29 @@ namespace Usb
{
void Initialize(void);
void Reset(void);
void ComPortStart(void);
void ComPortStop(void);
uint32_t WriteData(const uint8_t *data, uint32_t len);
uint32_t ReadData(uint8_t *data, uint32_t len);
void ComPortOpen(void);
void ComPortClose(void);
uint32_t Write(const void *data, uint32_t len);
bool Write(uint8_t data);
bool Write(uint16_t data);
bool Write(uint32_t data);
bool Write(int8_t data);
bool Write(int16_t data);
bool Write(int32_t data);
uint32_t Read(void *data, uint32_t len);
bool Read(uint8_t &data);
bool Read(uint16_t &data);
bool Read(uint32_t &data);
bool Read(int8_t &data);
bool Read(int16_t &data);
bool Read(int32_t &data);
void SetRxNotificationMsg(uint32_t msg);
void EnableRxNotification(msg_priority_t priority);
void EnableNotification(usb_notification_t notification, msg_priority_t priority);
void EnableBusPower(bool bEnable);
void EnableDrive(bool bEnable);
bool IsRxNotificationMsg(os_msg_t msg);
bool IsNotificationMsg(os_msg_t &msg, usb_notification_t notification);
bool GetNotificationData(os_msg_t &msg, ndata_comport_rx_t &data);
}
No preview for this file type
No preview for this file type
No preview for this file type
This diff is collapsed.
File mode changed from 100755 to 100644
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment