Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: FreeMASTER_HelloWorld FreeMASTER_HelloWorld2 FreeMASTER_HelloWorld3
Fork of freemaster_lib by
class/freemaster_class.h
- Committer:
- JardaPajskr
- Date:
- 2014-05-15
- Revision:
- 8:17470feaa6be
- Parent:
- 4:256c3ffc6f40
- Child:
- 11:d1de61dc3766
File content as of revision 8:17470feaa6be:
#ifndef MBED_FREEMASTER_H #define MBED_FREEMASTER_H #include "platform.h" #if DEVICE_SERIAL #include "serial_api.h" #include "freemaster.h" namespace mbed { /** A FreeMASTER serial driver * * Can be used for debugging code over the serial line * * Example: * @code * // Set up the FreeMASTER serial driver * * #include "mbed.h" * #include "freemaster_class.h" * * Freemaster fm(USBTX, USBRX); * * FMSTR_TSA_TABLE_LIST_BEGIN() * FMSTR_TSA_TABLE_LIST_END() * * //define global variables * volatile unsigned char example_var8; * volatile unsigned short example_var16; * * int main() { * //register global or static variables * fm.TsaAddVar(FMSTR_TSA_RW_VAR_CFG(example_var8,FMSTR_TSA_UINT8)); * //register read only variable * fm.TsaAddVar(FMSTR_TSA_RO_VAR_CFG(example_var16,FMSTR_TSA_UINT16)); * while(1) * { * //your application * } * } * @endcode */ class Freemaster { public: /** Create FreeMASTER interface * * @param tx Transmit pin * @param rx Receive pin * @param tsaMembers Maximum of variables to register dynamically. (optional) * @param recBufferSize Buffer size for recorder feature. (optional) * @param flags Advanced configuration. (optional) * */ Freemaster(PinName tx, PinName rx, uint32_t tsaMembers = 20, uint32_t recBufferSize = 1024, uint32_t flags = 0); /** Set the baud rate of the serial port * * @param baudrate The baudrate of the serial port (default = 9600). */ void baud(int baudrate); /** Catch initialized variables into recorder buffer. */ void Recorder(void); /** Triggert sampling of the recorder. */ void TriggerRec(void); /** This function can be used to detect if any Application Command is waiting to be processed by the application. */ void GetAppCmd(void); /** This function can be used to retrieve the Application Command data. */ FMSTR_APPCMD_PDATA GetAppCmdData(FMSTR_SIZE* pDataLen); /** This function can be used to register a given function as a callback handler for an Application Command. */ FMSTR_BOOL RegisterAppCmdCall(FMSTR_APPCMD_CODE nAppCmdCode, FMSTR_PAPPCMDFUNC pCallbackFunc); /** This function is used when Application Command processing is finished in the application. */ void AppCmdAck(FMSTR_APPCMD_RESULT nResultCode); /** This function can be used before the Application Command processing is finished. */ void AppCmdSetResponseData(FMSTR_ADDR nResultDataAddr, FMSTR_SIZE nResultDataLen); void Poll(void); /** Register variables to TSA table * * @param name, type, addr, info, use following macros to register variable * FMSTR_TSA_STRUCT_CFG(name) - register structure * FMSTR_TSA_MEMBER_CFG(parenttype,name,type) - register member of structure * FMSTR_TSA_RO_VAR_CFG(name,type) - register Read Only variable * FMSTR_TSA_RW_VAR_CFG(name,type) - register variable * FMSTR_TSA_RO_MEM_CFG(name,type,addr,size) - register read only of memory block * FMSTR_TSA_RW_MEM_CFG(name,type,addr,size) - register memory block * * @returns * 1 if there is space to register a variable, * 0 otherwise */ FMSTR_BOOL TsaAddVar(FMSTR_TSATBL_STRPTR name, FMSTR_TSATBL_STRPTR type, FMSTR_TSATBL_VOIDPTR addr, FMSTR_TSATBL_VOIDPTR info); static void _irq_handler(uint32_t id, SerialIrq irq_type); protected: serial_t _serial; int _baud; void* tsaTable; void* recBuf; }; } // namespace mbed #endif #endif