|
HRI board firmware
v2.1
Microcontroller firmware of the board used during the HRI labs.
|
Control the communication with the computer. More...
Data Structures | |
| struct | comm_SyncVar |
Macros | |
| #define | comm_SendDebugMessageDecimated(decimation, format, ...) |
| Sends a debug message to the computer, with decimation. This macro is useful to print human-readable text, in a fast loop, to avoid overloading the communication bus, or the computer. More... | |
Functions | |
| void | comm_Init (void) |
| Init the communication manager. More... | |
| void | comm_Step (void) |
| Updates the communication manager. Send the bytes waiting in the TX buffer, and process the bytes received. More... | |
| void | comm_NotifyReady (void) |
| Sends a packet to notify the PC that the board just (re)started. This informs the PC software that the board is ready, and that the variables list can be retrieved. More... | |
| void | comm_monitorVar (const char name[], void *address, comm_VarType type, uint8_t size, comm_VarAccess access) |
| Adds a monitored variable to the list, with its address. More... | |
| void | comm_monitorVarFunc (const char name[], comm_VarType type, uint8_t size, void(*getFunc)(void), void(*setFunc)(void)) |
| Adds a monitored variable to the list, with getter/setter functions. If the getter and setter are set to an actual function address (not NULL), the variable will be READWRITE. If the getter is NULL but setter is not NULL, the variable will be WRITEONLY. If the getter is not NULL the setter is NULL, the variable will be READONLY. If the getter and setter are both NULL, the variable will not be added to the variables list. More... | |
| void | comm_monitorBool (const char name[], bool *address, comm_VarAccess access) |
| Adds a monitored bool variable to the list, with its address. More... | |
| void | comm_monitorUint8 (const char name[], uint8_t *address, comm_VarAccess access) |
| Adds a monitored uint8_t variable to the list, with its address. More... | |
| void | comm_monitorInt8 (const char name[], int8_t *address, comm_VarAccess access) |
| Adds a monitored int8_t variable to the list, with its address. More... | |
| void | comm_monitorUint16 (const char name[], uint16_t *address, comm_VarAccess access) |
| Adds a monitored uint16_t variable to the list, with its address. More... | |
| void | comm_monitorInt16 (const char name[], int16_t *address, comm_VarAccess access) |
| Adds a monitored int16_t variable to the list, with its address. More... | |
| void | comm_monitorUint32 (const char name[], uint32_t *address, comm_VarAccess access) |
| Adds a monitored uint32_t variable to the list, with its address. More... | |
| void | comm_monitorInt32 (const char name[], int32_t *address, comm_VarAccess access) |
| Adds a monitored int32_t variable to the list, with its address. More... | |
| void | comm_monitorUint64 (const char name[], uint64_t *address, comm_VarAccess access) |
| Adds a monitored uint64_t variable to the list, with its address. More... | |
| void | comm_monitorInt64 (const char name[], int64_t *address, comm_VarAccess access) |
| Adds a monitored int64_t variable to the list, with its address. More... | |
| void | comm_monitorFloat (const char name[], float *address, comm_VarAccess access) |
| Adds a monitored float variable to the list, with its address. More... | |
| void | comm_monitorDouble (const char name[], double *address, comm_VarAccess access) |
| Adds a monitored double variable to the list, with its address. More... | |
| void | comm_monitorBoolFunc (const char name[], bool(*getFunc)(void), void(*setFunc)(bool)) |
| Adds a monitored bool variable to the list, with getter/setter. More... | |
| void | comm_monitorUint8Func (const char name[], uint8_t(*getFunc)(void), void(*setFunc)(uint8_t)) |
| Adds a monitored uint8_t variable to the list, with getter/setter. More... | |
| void | comm_monitorInt8Func (const char name[], int8_t(*getFunc)(void), void(*setFunc)(int8_t)) |
| Adds a monitored int8_t variable to the list, with getter/setter. More... | |
| void | comm_monitorUint16Func (const char name[], uint16_t(*getFunc)(void), void(*setFunc)(uint16_t)) |
| Adds a monitored uint16_t variable to the list, with getter/setter. More... | |
| void | comm_monitorInt16Func (const char name[], int16_t(*getFunc)(void), void(*setFunc)(int16_t)) |
| Adds a monitored int16_t variable to the list, with getter/setter. More... | |
| void | comm_monitorUint32Func (const char name[], uint32_t(*getFunc)(void), void(*setFunc)(uint32_t)) |
| Adds a monitored uint32_t variable to the list, with getter/setter. More... | |
| void | comm_monitorInt32Func (const char name[], int32_t(*getFunc)(void), void(*setFunc)(int32_t)) |
| Adds a monitored int32_t variable to the list, with getter/setter. More... | |
| void | comm_monitorUint64Func (const char name[], uint64_t(*getFunc)(void), void(*setFunc)(uint64_t)) |
| Adds a monitored uint64_t variable to the list, with getter/setter. More... | |
| void | comm_monitorInt64Func (const char name[], int64_t(*getFunc)(void), void(*setFunc)(int64_t)) |
| Adds a monitored int64_t variable to the list, with getter/setter. More... | |
| void | comm_monitorFloatFunc (const char name[], float(*getFunc)(void), void(*setFunc)(float)) |
| Adds a monitored float variable to the list, with getter/setter. More... | |
| void | comm_monitorDoubleFunc (const char name[], double(*getFunc)(void), void(*setFunc)(double)) |
| Adds a monitored double variable to the list, with getter/setter. More... | |
| void | comm_LockSyncVarsList (void) |
| Locks the monitored variables, so it can be used. After the call to this function, adding variables will not be possible anymore. The PC will not be able to get the variables list until this function is called. More... | |
| void | comm_SendDebugMessage (const char *format,...) |
| Sends a debug message to the computer. More... | |
Control the communication with the computer.
This module controls all the communication logic between the board and the computer. It uses a specific communication protocol between the computer and the board, with a system of messages. Thanks to this, the the MATLAB application is able to get the value of selected variables on the STM, and is even capable of modifiying them remotely.
Make sure that the files communication.h/.c are up-to-date with the Excel spreadsheet "Protocol description.xlsx".
Call comm_Init() to setup this module. Its interrupt function will be called automatically when a message arrives, or periodically when the data streaming is enabled.
| #define comm_SendDebugMessageDecimated | ( | decimation, | |
| format, | |||
| ... | |||
| ) |
Sends a debug message to the computer, with decimation. This macro is useful to print human-readable text, in a fast loop, to avoid overloading the communication bus, or the computer.
| decimation | this macro will actually print once out of decimation, and do nothing otherwise. |
| format | format string. See the printf() documentation for format specification. |
| ... | variables to be printed in the format string. |
| void comm_Init | ( | void | ) |
Init the communication manager.
| void comm_LockSyncVarsList | ( | void | ) |
Locks the monitored variables, so it can be used. After the call to this function, adding variables will not be possible anymore. The PC will not be able to get the variables list until this function is called.
| void comm_monitorBool | ( | const char | name[], |
| bool * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored bool variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorBoolFunc | ( | const char | name[], |
| bool(*)(void) | getFunc, | ||
| void(*)(bool) | setFunc | ||
| ) |
Adds a monitored bool variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorDouble | ( | const char | name[], |
| double * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored double variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorDoubleFunc | ( | const char | name[], |
| double(*)(void) | getFunc, | ||
| void(*)(double) | setFunc | ||
| ) |
Adds a monitored double variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorFloat | ( | const char | name[], |
| float * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored float variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorFloatFunc | ( | const char | name[], |
| float(*)(void) | getFunc, | ||
| void(*)(float) | setFunc | ||
| ) |
Adds a monitored float variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorInt16 | ( | const char | name[], |
| int16_t * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored int16_t variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorInt16Func | ( | const char | name[], |
| int16_t(*)(void) | getFunc, | ||
| void(*)(int16_t) | setFunc | ||
| ) |
Adds a monitored int16_t variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorInt32 | ( | const char | name[], |
| int32_t * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored int32_t variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorInt32Func | ( | const char | name[], |
| int32_t(*)(void) | getFunc, | ||
| void(*)(int32_t) | setFunc | ||
| ) |
Adds a monitored int32_t variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorInt64 | ( | const char | name[], |
| int64_t * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored int64_t variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorInt64Func | ( | const char | name[], |
| int64_t(*)(void) | getFunc, | ||
| void(*)(int64_t) | setFunc | ||
| ) |
Adds a monitored int64_t variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorInt8 | ( | const char | name[], |
| int8_t * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored int8_t variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorInt8Func | ( | const char | name[], |
| int8_t(*)(void) | getFunc, | ||
| void(*)(int8_t) | setFunc | ||
| ) |
Adds a monitored int8_t variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorUint16 | ( | const char | name[], |
| uint16_t * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored uint16_t variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorUint16Func | ( | const char | name[], |
| uint16_t(*)(void) | getFunc, | ||
| void(*)(uint16_t) | setFunc | ||
| ) |
Adds a monitored uint16_t variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorUint32 | ( | const char | name[], |
| uint32_t * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored uint32_t variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorUint32Func | ( | const char | name[], |
| uint32_t(*)(void) | getFunc, | ||
| void(*)(uint32_t) | setFunc | ||
| ) |
Adds a monitored uint32_t variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorUint64 | ( | const char | name[], |
| uint64_t * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored uint64_t variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorUint64Func | ( | const char | name[], |
| uint64_t(*)(void) | getFunc, | ||
| void(*)(uint64_t) | setFunc | ||
| ) |
Adds a monitored uint64_t variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorUint8 | ( | const char | name[], |
| uint8_t * | address, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored uint8_t variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorUint8Func | ( | const char | name[], |
| uint8_t(*)(void) | getFunc, | ||
| void(*)(uint8_t) | setFunc | ||
| ) |
Adds a monitored uint8_t variable to the list, with getter/setter.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_monitorVar | ( | const char | name[], |
| void * | address, | ||
| comm_VarType | type, | ||
| uint8_t | size, | ||
| comm_VarAccess | access | ||
| ) |
Adds a monitored variable to the list, with its address.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| address | a pointer to the variable to monitor. |
| type | the type of the variable. |
| size | the size of the variable [bytes]. |
| access | the access rights to this variable (READONLY, WRITEONLY, or READWRITE). |
| void comm_monitorVarFunc | ( | const char | name[], |
| comm_VarType | type, | ||
| uint8_t | size, | ||
| void(*)(void) | getFunc, | ||
| void(*)(void) | setFunc | ||
| ) |
Adds a monitored variable to the list, with getter/setter functions. If the getter and setter are set to an actual function address (not NULL), the variable will be READWRITE. If the getter is NULL but setter is not NULL, the variable will be WRITEONLY. If the getter is not NULL the setter is NULL, the variable will be READONLY. If the getter and setter are both NULL, the variable will not be added to the variables list.
| name | the description of the variable, as it should be displayed to the user. It should also include the unit, if relevant. |
| type | the type of the variable. |
| size | the size of the variable [bytes]. |
| getFunc | function pointer on the getter function. |
| setFunc | function pointer on the setter function. |
| void comm_NotifyReady | ( | void | ) |
Sends a packet to notify the PC that the board just (re)started. This informs the PC software that the board is ready, and that the variables list can be retrieved.
| void comm_SendDebugMessage | ( | const char * | format, |
| ... | |||
| ) |
Sends a debug message to the computer.
| format | format string. |
| ... | variables to be printed in the format string. |
| void comm_Step | ( | void | ) |
Updates the communication manager. Send the bytes waiting in the TX buffer, and process the bytes received.
1.8.13