Scs (#3)
* Add send scs * Create scs dict * Fix compilation errors * Fix compile error * Change default include * Add Timer SCS manager * Remove unused files * Fix bugs * Add documentation * Add SCS manager bozza * Refactor * Use same naming convention * Add tick provider * Update header * Fix header bit translation * Test HandleNext OK * Remove linting * Remove indents * Add documentation * Improve docs * Remove pointer * Remove mailbox * Remove useless comment * Add newline * Fix compile errors * Separate scs entries from manager * Refactor * Fix include guards Co-authored-by: nicolagutierrez <nicolagutierrez.ng@gmail.com>
This commit was merged in pull request #3.
This commit is contained in:
committed by
GitHub
parent
7aa61ed9ad
commit
4d5c1934a4
+45
-3
@@ -1,19 +1,61 @@
|
||||
/**
|
||||
* @file mmr_can_util.h
|
||||
* @brief
|
||||
* Utility functions and macros.
|
||||
*/
|
||||
|
||||
#ifndef INC_MMR_CAN_UTIL_H_
|
||||
#define INC_MMR_CAN_UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Returns the size of the given array.
|
||||
*
|
||||
* This only works on static arrays declared
|
||||
* within the current scope, that is:
|
||||
* int main() {
|
||||
* int arr[] = {1, 2, 3};
|
||||
* int len = sizeofarray(arr);
|
||||
* }
|
||||
*/
|
||||
#define sizeofarray(array) \
|
||||
(sizeof(array) / sizeof(*(array)))
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Returns the length of a statically, non const ptr, declared
|
||||
* string.
|
||||
* That is:
|
||||
* int main() {
|
||||
* char str[] = "abc";
|
||||
* int len = stringArrayLength(str);
|
||||
* }
|
||||
*/
|
||||
#define stringArrayLength(array) \
|
||||
stringBufferLength((array), sizeofarray(array))
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Returns the length of a string buffer.
|
||||
* Its format must be in bytes, so it could be:
|
||||
* const char*
|
||||
* char*
|
||||
* uint8_t*
|
||||
* etc...
|
||||
*/
|
||||
#define stringBufferLength(pbuffer, maxLen) \
|
||||
strnlen((const char*)(pbuffer), maxLen)
|
||||
|
||||
#define min(a, b) ((a) < (b) ? a : b);
|
||||
/**
|
||||
* @brief
|
||||
* Returns the minimum between the
|
||||
* two given values.
|
||||
* E.g. min(1, 2) == 1 // true
|
||||
*/
|
||||
#define min(a, b) ((a) < (b) ? a : b)
|
||||
#define mask(value, bits) (value & bits)
|
||||
#define convertTo(resultType, lvalue) (*interpretAs(resultType*, &(lvalue)))
|
||||
#define interpretAs(resultType, lvalue) ((resultType)(lvalue))
|
||||
@@ -26,10 +68,10 @@
|
||||
* Either
|
||||
* - Error: the computation resulted in error
|
||||
* - Pending: the computation is still undergoing
|
||||
* - Completed: the computation has completed succesfully
|
||||
* - Completed: the computation has completed successfully
|
||||
* and its results can be read
|
||||
*
|
||||
* Asynchronous logig can be easily implemented using State Machines
|
||||
* Asynchronous logic can be easily implemented using State Machines
|
||||
*/
|
||||
typedef enum {
|
||||
MMR_ASYNC_RESULT_ERROR,
|
||||
|
||||
Reference in New Issue
Block a user