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.cpp
- Committer:
- JardaPajskr
- Date:
- 2014-09-10
- Revision:
- 14:b2f3414a55d3
- Parent:
- 11:d1de61dc3766
- Child:
- 19:8b6f13b16bf5
File content as of revision 14:b2f3414a55d3:
#include "mbed.h"
#include "freemaster_class.h"
#if DEVICE_SERIAL
#define FMSTR_USE_TSA_DYNAMIC 1
#define FMSTR_REC_OWNBUFF 1
namespace mbed {
Freemaster::Freemaster(PinName tx, PinName rx, uint32_t tsaMembers, uint32_t recBufferSize, uint32_t flags) {
serial_init(&_serial, tx, rx);
_baud = 9600;
serial_irq_handler(&_serial, Freemaster::_irq_handler, (uint32_t)this);
FMSTR_SetSciMbedObject((FMSTR_ADDR) &_serial);
FMSTR_Init();
#if !(FMSTR_POLL_DRIVEN)
serial_irq_set(&_serial, RxIrq, 1);
serial_irq_set(&_serial, TxIrq, 0);
// serial_readable(&_serial);
#endif
#if (FMSTR_USE_TSA_DYNAMIC)
tsaTable=malloc(tsaMembers*sizeof(FMSTR_TSA_ENTRY));
FMSTR_SetUpTsaBuff((FMSTR_ADDR)tsaTable, (tsaMembers)*sizeof(FMSTR_TSA_ENTRY));
#endif
#if (FMSTR_REC_OWNBUFF)
recBuf=malloc(recBufferSize);
FMSTR_SetUpRecBuff((FMSTR_ADDR)recBuf, recBufferSize);
#endif
}
FMSTR_BOOL Freemaster::TsaAddVar(FMSTR_TSATBL_STRPTR name, FMSTR_TSATBL_STRPTR type, FMSTR_TSATBL_VOIDPTR addr, FMSTR_TSATBL_VOIDPTR info) {
#if FMSTR_USE_TSA_DYNAMIC
return FMSTR_TsaAddVar(name, type, addr, info);
#else
return FMSTR_FALSE;
#endif
}
void Freemaster::baud(int baudrate) {
serial_baud(&_serial, baudrate);
_baud = baudrate;
}
void Freemaster::Recorder() {
FMSTR_Recorder();
}
void Freemaster::TriggerRec() {
FMSTR_TriggerRec();
}
void Freemaster::Poll() {
FMSTR_Poll();
}
FMSTR_APPCMD_CODE Freemaster::GetAppCmd(void)
{
return FMSTR_GetAppCmd();
}
FMSTR_APPCMD_PDATA Freemaster::GetAppCmdData(FMSTR_SIZE* pDataLen)
{
return FMSTR_GetAppCmdData(pDataLen);
}
FMSTR_BOOL Freemaster::RegisterAppCmdCall(FMSTR_APPCMD_CODE nAppCmdCode, FMSTR_PAPPCMDFUNC pCallbackFunc)
{
return FMSTR_RegisterAppCmdCall(nAppCmdCode, pCallbackFunc);
}
void Freemaster::AppCmdAck(FMSTR_APPCMD_RESULT nResultCode)
{
FMSTR_AppCmdAck(nResultCode);
}
void Freemaster::AppCmdSetResponseData(FMSTR_ADDR nResultDataAddr, FMSTR_SIZE nResultDataLen)
{
FMSTR_AppCmdSetResponseData(nResultDataAddr, nResultDataLen);
}
void Freemaster::_irq_handler(uint32_t id, SerialIrq irq_type) {
FMSTR_Isr();
}
} // namespace mbed
#endif
