Restructure of expansion board lib, moving files & folders.
Revision 6:9a5313607546, committed 2020-11-03
- Comitter:
- johnAlexander
- Date:
- Tue Nov 03 15:28:52 2020 +0000
- Parent:
- 5:6020b7ced569
- Commit message:
- Remove display, and duplicate classes from the sensor lib.
Changed in this revision
--- a/Components/Display/Display.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,415 +0,0 @@ -/** - ****************************************************************************** - * @file Display.h - * @author AST / EST - * @version V0.0.1 - * @date 14-April-2015 - * @brief Header file for display - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** -*/ - -#ifndef __DISPLAY_H -#define __DISPLAY_H - -/* Includes ------------------------------------------------------------------*/ -#include "mbed.h" -#include "Stmpe1600.h" -#include "DevI2C.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * GPIO monitor pin state register - * 16 bit register LSB at lowest offset (little endian) - */ -#define GPMR 0x10 -/** - * STMPE1600 GPIO set pin state register - * 16 bit register LSB at lowest offset (little endian) - */ -#define GPSR 0x12 -/** - * STMPE1600 GPIO set pin direction register - * 16 bit register LSB at lowest offset - */ -#define GPDR 0x14 - - -/** - * cache the full set of expanded GPIO values to avoid i2c reading - */ -static union CurIOVal_u { - uint8_t bytes[4]; /*!< 4 bytes array i/o view */ - uint32_t u32; /*!< single dword i/o view */ -} -/** cache the extended IO values */ -cur_io_val; - -/** - * lookup table for digit to bit position - */ -static int display_bit_posn[4] = {0, 7, 16, 16 + 7}; - -/** - * @defgroup XNUCLEO53L0A1_7Segment 7 segment display - * - * macro use for human readable segment building - * @code - * --s0-- - * s s - * 5 1 - * --s6-- - * s s - * 4 2 - * --s3-- . s7 (dp) - * @endcode - * - * @{ - */ -/** decimal point bit mapping* */ -#define DP (1 << 7) - -/** sgement s0 bit mapping*/ -#define S0 (1 << 3) -/** sgement s1 bit mapping*/ -#define S1 (1 << 5) -/** sgement s2 bit mapping*/ -#define S2 (1 << 6) -/** sgement s3 bit mapping*/ -#define S3 (1 << 4) -/** sgement s4 bit mapping*/ -#define S4 (1 << 0) -/** sgement s5 bit mapping*/ -#define S5 (1 << 1) -/** sgement s6 bit mapping*/ -#define S6 (1 << 2) - -/** - * build a character by defining the non lighted segment (not one and no DP) - * - * @param ... literal sum and or combine of any macro to define any segment #S0 .. #S6 - * - * example '9' is all segment on but S4 - * @code - * ['9']= NOT_7_NO_DP(S4), - * @endcode - */ -#define NOT_7_NO_DP( ... ) (uint8_t) ~( __VA_ARGS__ + DP ) - -/** - * Ascii to 7 segment lookup table - * - * Most common character are supported and follow http://www.twyman.org.uk/Fonts/ - * few extra special \@ ^~ ... etc are present for specific demo purpose - */ -#ifndef __cpluplus -/* refer to http://www.twyman.org.uk/Fonts/ */ -static const uint8_t ascii_to_display_lut[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - [32] = 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, - [42] = NOT_7_NO_DP(), - 0, 0, - [45] = S6, - 0, 0, - [48] = NOT_7_NO_DP(S6), - [49] = S1 + S2, - [50] = S0 + S1 + S6 + S4 + S3, - [51] = NOT_7_NO_DP(S4 + S5), - [52] = S5 + S1 + S6 + S2, - [53] = NOT_7_NO_DP(S1 + S4), - [54] = NOT_7_NO_DP(S1), - [55] = S0 + S1 + S2, - [56] = NOT_7_NO_DP(0), - [57] = NOT_7_NO_DP(S4), - 0, 0, 0, - [61] = S3 + S6, - 0, - [63] = NOT_7_NO_DP(S5 + S3 + S2), - [64] = S0 + S3, - [65] = NOT_7_NO_DP(S3), - [66] = NOT_7_NO_DP(S0 + S1), /* as b */ - [67] = S0 + S3 + S4 + S5, // same as [ - [68] = S0 + S3 + S4 + S5, // same as [ DUMMY - [69] = NOT_7_NO_DP(S1 + S2), - [70] = S6 + S5 + S4 + S0, - [71] = NOT_7_NO_DP(S4), /* same as 9 */ - [72] = NOT_7_NO_DP(S0 + S3), - [73] = S1 + S2, - [74] = S1 + S2 + S3 + S4, - [75] = NOT_7_NO_DP(S0 + S3), /* same as H */ - [76] = S3 + S4 + S5, - [77] = S0 + S4 + S2, /* same as m*/ - [78] = S2 + S4 + S6, /* same as n*/ - [79] = NOT_7_NO_DP(S6), - [80] = S0 + S1 + S2 + S5 + S6, // sames as 'q' - [81] = NOT_7_NO_DP(S3 + S2), - [82] = S4 + S6, - [83] = NOT_7_NO_DP(S1 + S4), /* sasme as 5 */ - [84] = NOT_7_NO_DP(S0 + S1 + S2), /* sasme as t */ - [85] = NOT_7_NO_DP(S6 + S0), - [86] = S4 + S3 + S2, // is u but u use U - [87] = S1 + S3 + S5, - [88] = NOT_7_NO_DP(S0 + S3), // similar to H - [89] = NOT_7_NO_DP(S0 + S4), - [90] = S0 + S1 + S6 + S4 + S3, // same as 2 - [91] = S0 + S3 + S4 + S5, - 0, - [93] = S0 + S3 + S2 + S1, - [94] = S0, /* use as top bar */ - [95] = S3, - 0, - [97] = S2 + S3 + S4 + S6, - [98] = NOT_7_NO_DP(S0 + S1), - [99] = S6 + S4 + S3, - [100] = NOT_7_NO_DP(S0 + S5), - [101] = NOT_7_NO_DP(S2), - [102] = S6 + S5 + S4 + S0, /* same as F */ - [103] = NOT_7_NO_DP(S4), /* same as 9 */ - [104] = S6 + S5 + S4 + S2, - [105] = S4, - [106] = S1 + S2 + S3 + S4, - [107] = S6 + S5 + S4 + S2, /* a h */ - [108] = S3 + S4, - [109] = S0 + S4 + S2, /* same as */ - [110] = S2 + S4 + S6, - [111] = S6 + S4 + S3 + S2, - [112] = NOT_7_NO_DP(S3 + S2), // same as P - [113] = S0 + S1 + S2 + S5 + S6, - [114] = S4 + S6, - [115] = NOT_7_NO_DP(S1 + S4), - [116] = NOT_7_NO_DP(S0 + S1 + S2), - [117] = S4 + S3 + S2 + S5 + S1, // U - [118] = S4 + S3 + S2, // is u but u use U - [119] = S1 + S3 + S5, - [120] = NOT_7_NO_DP(S0 + S3), // similar to H - [121] = NOT_7_NO_DP(S0 + S4), - [122] = S0 + S1 + S6 + S4 + S3, // same as 2 - 0, 0, 0, - [126] = S0 + S3 + S6 /* 3 h bar */ -}; -#else -/* refer to http://www.twyman.org.uk/Fonts/ */ -static const uint8_t ascii_to_display_lut[256] = { - [' '] = 0, - ['-'] = S6, - ['_'] = S3, - ['='] = S3 + S6, - ['~'] = S0 + S3 + S6, /* 3 h bar */ - ['^'] = S0, /* use as top bar */ - - ['?'] = NOT_7_NO_DP(S5 + S3 + S2), - ['*'] = NOT_7_NO_DP(), - ['['] = S0 + S3 + S4 + S5, - [']'] = S0 + S3 + S2 + S1, - ['@'] = S0 + S3, - - ['0'] = NOT_7_NO_DP(S6), - ['1'] = S1 + S2, - ['2'] = S0 + S1 + S6 + S4 + S3, - ['3'] = NOT_7_NO_DP(S4 + S5), - ['4'] = S5 + S1 + S6 + S2, - ['5'] = NOT_7_NO_DP(S1 + S4), - ['6'] = NOT_7_NO_DP(S1), - ['7'] = S0 + S1 + S2, - ['8'] = NOT_7_NO_DP(0), - ['9'] = NOT_7_NO_DP(S4), - - ['a'] = S2 + S3 + S4 + S6, - ['b'] = NOT_7_NO_DP(S0 + S1), - ['c'] = S6 + S4 + S3, - ['d'] = NOT_7_NO_DP(S0 + S5), - ['e'] = NOT_7_NO_DP(S2), - ['f'] = S6 + S5 + S4 + S0, /* same as F */ - ['g'] = NOT_7_NO_DP(S4), /* same as 9 */ - ['h'] = S6 + S5 + S4 + S2, - ['i'] = S4, - ['j'] = S1 + S2 + S3 + S4, - ['k'] = S6 + S5 + S4 + S2, /* a h */ - ['l'] = S3 + S4, - ['m'] = S0 + S4 + S2, /* same as */ - ['n'] = S2 + S4 + S6, - ['o'] = S6 + S4 + S3 + S2, - ['p'] = NOT_7_NO_DP(S3 + S2), // same as P - ['q'] = S0 + S1 + S2 + S5 + S6, - ['r'] = S4 + S6, - ['s'] = NOT_7_NO_DP(S1 + S4), - ['t'] = NOT_7_NO_DP(S0 + S1 + S2), - ['u'] = S4 + S3 + S2 + S5 + S1, // U - ['v'] = S4 + S3 + S2, // is u but u use U - ['w'] = S1 + S3 + S5, - ['x'] = NOT_7_NO_DP(S0 + S3), // similar to H - ['y'] = NOT_7_NO_DP(S0 + S4), - ['z'] = S0 + S1 + S6 + S4 + S3, // same as 2 - - ['A'] = NOT_7_NO_DP(S3), - ['B'] = NOT_7_NO_DP(S0 + S1), /* as b */ - ['C'] = S0 + S3 + S4 + S5, // same as [ - ['E'] = NOT_7_NO_DP(S1 + S2), - ['F'] = S6 + S5 + S4 + S0, - ['G'] = NOT_7_NO_DP(S4), /* same as 9 */ - ['H'] = NOT_7_NO_DP(S0 + S3), - ['I'] = S1 + S2, - ['J'] = S1 + S2 + S3 + S4, - ['K'] = NOT_7_NO_DP(S0 + S3), /* same as H */ - ['L'] = S3 + S4 + S5, - ['M'] = S0 + S4 + S2, /* same as m*/ - ['N'] = S2 + S4 + S6, /* same as n*/ - ['O'] = NOT_7_NO_DP(S6), - ['P'] = S0 + S1 + S2 + S5 + S6, // sames as 'q' - ['Q'] = NOT_7_NO_DP(S3 + S2), - ['R'] = S4 + S6, - ['S'] = NOT_7_NO_DP(S1 + S4), /* sasme as 5 */ - ['T'] = NOT_7_NO_DP(S0 + S1 + S2), /* sasme as t */ - ['U'] = NOT_7_NO_DP(S6 + S0), - ['V'] = S4 + S3 + S2, // is u but u use U - ['W'] = S1 + S3 + S5, - ['X'] = NOT_7_NO_DP(S0 + S3), // similar to H - ['Y'] = NOT_7_NO_DP(S0 + S4), - ['Z'] = S0 + S1 + S6 + S4 + S3 // same as 2 -}; -#endif - - -#undef S0 -#undef S1 -#undef S2 -#undef S3 -#undef S4 -#undef S5 -#undef S6 -#undef DP - -/** @} */ - -//#define DISPLAY_DELAY 1 // in mSec - -/* Classes -------------------------------------------------------------------*/ -/** Class representing Display - */ - -class Display -{ -private: - Stmpe1600 *stmpe1600_exp0; - Stmpe1600 *stmpe1600_exp1; -public: - /** Constructor - * @param[in] &stmpe_1600 device handler to be used for display control - */ -//<<<<<<< local - Display(Stmpe1600 *stmpe_1600_exp0, Stmpe1600 *stmpe_1600_exp1) : stmpe1600_exp0(stmpe_1600_exp0), - stmpe1600_exp1(stmpe_1600_exp1) -//======= -// Display(Stmpe1600 &stmpe_1600_exp0, Stmpe1600 &stmpe_1600_exp1) : stmpe1600_exp0(&stmpe_1600_exp0), -// stmpe1600_exp1(&stmpe_1600_exp1) -//>>>>>>> other - { - uint16_t expander_data; - - // detect the extenders - stmpe1600_exp0->read_16bit_reg(0x00, &expander_data); -// if (ExpanderData != 0x1600) {/* log - failed to find expander exp0 */ } - stmpe1600_exp1->read_16bit_reg(0x00, &expander_data); -// if (ExpanderData != 0x1600) {/* log - failed to find expander exp1 */ } - - // configure all necessary GPIO pins as outputs - expander_data = 0xFFFF; - stmpe1600_exp0->write_16bit_reg(GPDR, &expander_data); - expander_data = 0xBFFF; // leave bit 14 as an input, for the pushbutton, PB1. - stmpe1600_exp1->write_16bit_reg(GPDR, &expander_data); - - // shut down all segment and all device - expander_data = 0x7F + (0x7F << 7); - stmpe1600_exp0->write_16bit_reg(GPSR, &expander_data); - stmpe1600_exp1->write_16bit_reg(GPSR, &expander_data); - } - - /*** Interface Methods ***/ - /** - * @brief Print the string on display - * @param[in] String to be printed - * @param[in] String lenght [min 1, max 4] - * @return void - */ - void display_string(const char *str) - { - uint16_t expander_data; - uint32_t segments; - int bit_posn; - int i; - - for (i = 0; (i < 4 && str[i] != 0); i++) { - segments = (uint32_t) ascii_to_display_lut[(uint8_t) str[i]]; - segments = (~segments) & 0x7F; - bit_posn = display_bit_posn[i]; - cur_io_val.u32 &= ~(0x7F << bit_posn); - cur_io_val.u32 |= segments << bit_posn; - } - /* clear unused digit */ - for (; i < 4; i++) { - bit_posn = display_bit_posn[i]; - cur_io_val.u32 |= 0x7F << bit_posn; - } - -// stmpe1600_exp0.write16bitReg(GPSR, (uint16_t *)&CurIOVal.bytes[0]); -// stmpe1600_exp1.write16bitReg(GPSR, (uint16_t *)&CurIOVal.bytes[2]); - -// ordered low-byte/high-byte! - cur_io_val.bytes[1] |= 0xC0; // ensure highest bits are high, as these are xshutdown pins for left & right sensors! - expander_data = (cur_io_val.bytes[1] << 8) + cur_io_val.bytes[0]; - stmpe1600_exp0->write_16bit_reg(GPSR, &expander_data); - cur_io_val.bytes[3] |= 0x80; // ensure highest bit is high, as this is xshutdown pin on central sensor! - expander_data = (cur_io_val.bytes[3] << 8) + cur_io_val.bytes[2]; - stmpe1600_exp1->write_16bit_reg(GPSR, &expander_data); - - } - - void clear_display(void) - { - uint16_t expander_data; - - expander_data = 0x7F + (0x7F << 7); - stmpe1600_exp0->write_16bit_reg(GPSR, &expander_data); - stmpe1600_exp1->write_16bit_reg(GPSR, &expander_data); - } - -}; - -#ifdef __cplusplus -} -#endif -#endif // __DISPLAY_H
--- a/Components/STMPE1600/Stmpe1600.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,340 +0,0 @@ -/** - ****************************************************************************** - * @file Stmpe1600.h - * @author AST / EST - * @version V0.0.1 - * @date 14-April-2015 - * @brief Header file for component stmpe1600 - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** -*/ -#ifndef __STMPE1600_CLASS -#define __STMPE1600_CLASS -/* Includes ------------------------------------------------------------------*/ -#include "DevI2C.h" - -#define STMPE1600_DEF_DEVICE_ADDRESS (uint8_t)0x42*2 -#define STMPE1600_DEF_DIGIOUT_LVL 1 - -/** STMPE1600 registr map **/ -#define CHIP_ID_0_7 (uint8_t)0x00 -#define CHIP_ID_8_15 (uint8_t)0x01 -#define VERSION_ID (uint8_t)0x02 -#define SYS_CTRL (uint8_t)0x03 -#define IEGPIOR_0_7 (uint8_t)0x08 -#define IEGPIOR_8_15 (uint8_t)0x09 -#define ISGPIOR_0_7 (uint8_t)0x0A -#define ISGPIOR_8_15 (uint8_t)0x0B -#define GPMR_0_7 (uint8_t)0x10 -#define GPMR_8_15 (uint8_t)0x11 -#define GPSR_0_7 (uint8_t)0x12 -#define GPSR_8_15 (uint8_t)0x13 -#define GPDR_0_7 (uint8_t)0x14 -#define GPDR_8_15 (uint8_t)0x15 -#define GPIR_0_7 (uint8_t)0x16 -#define GPIR_8_15 (uint8_t)0x17 - -#define SOFT_RESET (uint8_t)0x80 - -typedef enum { - // GPIO Expander pin names - GPIO_0 = 0, - GPIO_1, - GPIO_2, - GPIO_3, - GPIO_4, - GPIO_5, - GPIO_6, - GPIO_7, - GPIO_8, - GPIO_9, - GPIO_10, - GPIO_11, - GPIO_12, - GPIO_13, - GPIO_14, - GPIO_15, - NOT_CON -} ExpGpioPinName; - -typedef enum { - INPUT = 0, - OUTPUT, - NOT_CONNECTED -} ExpGpioPinDirection; - -/* Classes -------------------------------------------------------------------*/ -/** Class representing a single stmpe1600 GPIO expander output pin - */ -class Stmpe1600DigiOut -{ - -public: - /** Constructor - * @param[in] &i2c device I2C to be used for communication - * @param[in] outpinname the desired out pin name to be created - * @param[in] DevAddr the stmpe1600 I2C device address (deft STMPE1600_DEF_DEVICE_ADDRESS) - * @param[in] lvl the default ot pin level - */ - Stmpe1600DigiOut(DevI2C *i2c, ExpGpioPinName out_pin_name, uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS, - bool lvl = STMPE1600_DEF_DIGIOUT_LVL) : _dev_i2c(i2c), exp_dev_addr(dev_addr), exp_pin_name(out_pin_name) - { - uint8_t data[2]; - - if (exp_pin_name == NOT_CON) { - return; - } - /* set the exp_pin_name as output */ - _dev_i2c->i2c_read(data, exp_dev_addr, GPDR_0_7, 1); - _dev_i2c->i2c_read(&data[1], exp_dev_addr, GPDR_8_15, 1); - * (uint16_t *) data = * (uint16_t *) data | (1 << (uint16_t) exp_pin_name); // set gpio as out - _dev_i2c->i2c_write(data, exp_dev_addr, GPDR_0_7, 1); - _dev_i2c->i2c_write(&data[1], exp_dev_addr, GPDR_8_15, 1); - write(lvl); - } - - /** - * @brief Write on the out pin - * @param[in] lvl level to write - * @return 0 on Success - */ - void write(int lvl) - { - uint8_t data[2]; - - if (exp_pin_name == NOT_CON) { - return; - } - /* set the exp_pin_name state to lvl */ - _dev_i2c->i2c_read(data, exp_dev_addr, GPSR_0_7, 2); - * (uint16_t *) data = * (uint16_t *) data & (uint16_t)(~(1 << (uint16_t) exp_pin_name)); // set pin mask - if (lvl) { - * (uint16_t *) data = * (uint16_t *) data | (uint16_t)(1 << (uint16_t) exp_pin_name); - } - _dev_i2c->i2c_write(data, exp_dev_addr, GPSR_0_7, 2); - } - - /** - * @brief Overload assignement operator - */ - Stmpe1600DigiOut &operator= (int lvl) - { - write(lvl); - return *this; - } - -private: - DevI2C *_dev_i2c; - uint8_t exp_dev_addr; - ExpGpioPinName exp_pin_name; -}; - -/* Classes -------------------------------------------------------------------*/ -/** Class representing a single stmpe1600 GPIO expander input pin - */ -class Stmpe1600DigiIn -{ -public: - /** Constructor - * @param[in] &i2c device I2C to be used for communication - * @param[in] inpinname the desired input pin name to be created - * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS) - */ - Stmpe1600DigiIn(DevI2C *i2c, ExpGpioPinName in_pin_name, - uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS) : _dev_i2c(i2c), exp_dev_addr(dev_addr), - exp_pin_name(in_pin_name) - { - uint8_t data[2]; - - if (exp_pin_name == NOT_CON) { - return; - } - /* set the exp_pin_name as input pin direction */ - _dev_i2c->i2c_read(data, exp_dev_addr, GPDR_0_7, 2); - * (uint16_t *) data = * (uint16_t *) data & (uint16_t)(~(1 << (uint16_t) exp_pin_name)); // set gpio as in - _dev_i2c->i2c_write(data, exp_dev_addr, GPDR_0_7, 2); - } - - /** - * @brief Read the input pin - * @return The pin logical state 0 or 1 - */ - bool read() - { - uint8_t data[2]; - - if (exp_pin_name == NOT_CON) { - return false; - } - /* read the exp_pin_name */ - _dev_i2c->i2c_read(data, exp_dev_addr, GPMR_0_7, 2); - * (uint16_t *) data = * (uint16_t *) data & (uint16_t)(1 << (uint16_t) exp_pin_name); // mask the in gpio - if (data[0] || data[1]) { - return true; - } - return false; - } - - operator int() - { - return read(); - } - -private: - DevI2C *_dev_i2c; - uint8_t exp_dev_addr; - ExpGpioPinName exp_pin_name; -}; - -/* Classes -------------------------------------------------------------------*/ -/** Class representing a whole stmpe1600 component (16 gpio) - */ -class Stmpe1600 -{ - -public: - /** Constructor - * @param[in] &i2c device I2C to be used for communication - * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS) - */ - Stmpe1600(DevI2C *i2c, uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS) : _dev_i2c(i2c) - { - exp_dev_addr = dev_addr; - write_sys_ctrl(SOFT_RESET); - - gpdr0_15 = (uint16_t) 0; // gpio dir all IN - write_16bit_reg(GPDR_0_7, &gpdr0_15); - gpsr0_15 = (uint16_t) 0x0ffff; // gpio status all 1 - write_16bit_reg(GPSR_0_7, &gpsr0_15); - } - - /** - * @brief Write the SYS_CTRL register - * @param[in] Data to be written (bit fields) - */ - void write_sys_ctrl(uint8_t data) // data = SOFT_RESET reset the device - { - _dev_i2c->i2c_write(&data, exp_dev_addr, SYS_CTRL, 1); - } - - /** - * @brief Set the out pin - * @param[in] The pin name - * @return 0 on Success - */ - bool set_gpio(ExpGpioPinName pin_name) - { - if (pin_name == NOT_CON) { - return true; - } - gpsr0_15 = gpsr0_15 | ((uint16_t) 0x0001 << pin_name); - write_16bit_reg(GPSR_0_7, &gpsr0_15); - return false; - } - - /** - * @brief Clear the out pin - * @param[in] The pin name - * @return 0 on Success - */ - bool clear_gpio(ExpGpioPinName pin_name) - { - if (pin_name == NOT_CON) { - return true; - } - gpsr0_15 = gpsr0_15 & (~((uint16_t) 0x0001 << pin_name)); - write_16bit_reg(GPSR_0_7, &gpsr0_15); - return false; - } - - /** - * @brief Read the input pin - * @param[in] The pin name - * @return The logical pin level - */ - bool read_gpio(ExpGpioPinName pin_name) - { - uint16_t gpmr0_15; - if (pin_name == NOT_CON) { - return true; - } - read_16bit_reg(GPMR_0_7, &gpmr0_15); - gpmr0_15 = gpmr0_15 & ((uint16_t) 0x0001 << pin_name); - if (gpmr0_15) { - return true; - } - return false; - } - - /** - * @brief Set the pin direction - * @param[in] The pin name - * @param[in] The pin direction - * @return 0 on success - */ - bool set_gpio_dir(ExpGpioPinName pin_name, ExpGpioPinDirection pin_dir) - { - - if (pin_name == NOT_CON || pin_dir == NOT_CONNECTED) { - return true; - } - gpdr0_15 = gpdr0_15 & (~((uint16_t) 0x0001 << pin_name)); // clear the Pin - gpdr0_15 = gpdr0_15 | ((uint16_t) pin_dir << pin_name); - write_16bit_reg(GPDR_0_7, &gpdr0_15); - return false; - } - - /** - * @brief Read a 16 bits register - * @param[in] The register address - * @param[in] The pointer to the read data - */ - void read_16bit_reg(uint8_t reg16_addr, uint16_t *reg16_data) - { - _dev_i2c->i2c_read((uint8_t *) reg16_data, exp_dev_addr, reg16_addr, 2); - } - - /** - * @brief Write a 16 bits register - * @param[in] The register address - * @param[in] The pointer to the data to be written - */ - void write_16bit_reg(uint8_t reg16_addr, uint16_t *reg16_data) - { - _dev_i2c->i2c_write((uint8_t *) reg16_data, exp_dev_addr, reg16_addr, 2); - } - -private: - DevI2C *_dev_i2c; - uint16_t gpdr0_15; // local copy of bit direction reg - uint16_t gpsr0_15; // local copy of bit status reg - uint8_t exp_dev_addr; // expander device i2c addr -}; - -#endif // __STMPE1600_CLASS
--- a/Components/STMPE1600/stmpe1600_class.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,333 +0,0 @@ -/** - ****************************************************************************** - * @file stmpe1600_class.h - * @author AST / EST - * @version V0.0.1 - * @date 14-April-2015 - * @brief Header file for component stmpe1600 - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** -*/ -#ifndef __STMPE1600_CLASS -#define __STMPE1600_CLASS -/* Includes ------------------------------------------------------------------*/ -#include "DevI2C.h" - -#define STMPE1600_DEF_DEVICE_ADDRESS (uint8_t)0x42*2 -#define STMPE1600_DEF_DIGIOUT_LVL 1 - -/** STMPE1600 registr map **/ -#define CHIP_ID_0_7 (uint8_t)0x00 -#define CHIP_ID_8_15 (uint8_t)0x01 -#define VERSION_ID (uint8_t)0x02 -#define SYS_CTRL (uint8_t)0x03 -#define IEGPIOR_0_7 (uint8_t)0x08 -#define IEGPIOR_8_15 (uint8_t)0x09 -#define ISGPIOR_0_7 (uint8_t)0x0A -#define ISGPIOR_8_15 (uint8_t)0x0B -#define GPMR_0_7 (uint8_t)0x10 -#define GPMR_8_15 (uint8_t)0x11 -#define GPSR_0_7 (uint8_t)0x12 -#define GPSR_8_15 (uint8_t)0x13 -#define GPDR_0_7 (uint8_t)0x14 -#define GPDR_8_15 (uint8_t)0x15 -#define GPIR_0_7 (uint8_t)0x16 -#define GPIR_8_15 (uint8_t)0x17 - -#define SOFT_RESET (uint8_t)0x80 - -typedef enum { - // GPIO Expander pin names - GPIO_0 = 0, - GPIO_1, - GPIO_2, - GPIO_3, - GPIO_4, - GPIO_5, - GPIO_6, - GPIO_7, - GPIO_8, - GPIO_9, - GPIO_10, - GPIO_11, - GPIO_12, - GPIO_13, - GPIO_14, - GPIO_15, - NOT_CON -} ExpGpioPinName; - -typedef enum { - INPUT = 0, - OUTPUT, - NOT_CONNECTED -} ExpGpioPinDirection; - -/* Classes -------------------------------------------------------------------*/ -/** Class representing a single stmpe1600 GPIO expander output pin - */ -class Stmpe1600DigiOut -{ - -public: - /** Constructor - * @param[in] &i2c device I2C to be used for communication - * @param[in] outpinname the desired out pin name to be created - * @param[in] DevAddr the stmpe1600 I2C device address (deft STMPE1600_DEF_DEVICE_ADDRESS) - * @param[in] lvl the default ot pin level - */ - Stmpe1600DigiOut(DevI2C &i2c, ExpGpioPinName out_pin_name, uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS, - bool lvl = STMPE1600_DEF_DIGIOUT_LVL) : dev_i2c(&i2c), exp_dev_addr(dev_addr), exp_pin_name(out_pin_name) - { - uint8_t data[2]; - - if (exp_pin_name == NOT_CON) - return; - /* set the exp_pin_name as output */ - dev_i2c->i2c_read(data, exp_dev_addr, GPDR_0_7, 1); - dev_i2c->i2c_read(&data[1], exp_dev_addr, GPDR_8_15, 1); - *(uint16_t *)data = *(uint16_t *)data | (1 << (uint16_t)exp_pin_name); // set gpio as out - dev_i2c->i2c_write(data, exp_dev_addr, GPDR_0_7, 1); - dev_i2c->i2c_write(&data[1], exp_dev_addr, GPDR_8_15, 1); - write(lvl); - } - - /** - * @brief Write on the out pin - * @param[in] lvl level to write - * @return 0 on Success - */ - void write(int lvl) - { - uint8_t data[2]; - - if (exp_pin_name == NOT_CON) - return; - /* set the exp_pin_name state to lvl */ - dev_i2c->i2c_read(data, exp_dev_addr, GPSR_0_7, 2); - *(uint16_t *)data = *(uint16_t *)data & (uint16_t)(~(1 << (uint16_t)exp_pin_name)); // set pin mask - if (lvl) - *(uint16_t *)data = *(uint16_t *)data | (uint16_t)(1 << (uint16_t)exp_pin_name); - dev_i2c->i2c_write(data, exp_dev_addr, GPSR_0_7, 2); - } - - /** - * @brief Overload assignement operator - */ - Stmpe1600DigiOut &operator= (int lvl) - { - write(lvl); - return *this; - } - -private: - DevI2C *dev_i2c; - uint8_t exp_dev_addr; - ExpGpioPinName exp_pin_name; -}; - -/* Classes -------------------------------------------------------------------*/ -/** Class representing a single stmpe1600 GPIO expander input pin - */ -class Stmpe1600DigiIn -{ -public: - /** Constructor - * @param[in] &i2c device I2C to be used for communication - * @param[in] inpinname the desired input pin name to be created - * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS) - */ - Stmpe1600DigiIn(DevI2C &i2c, ExpGpioPinName in_pin_name, - uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS) : dev_i2c(&i2c), exp_dev_addr(dev_addr), - exp_pin_name(in_pin_name) - { - uint8_t data[2]; - - if (exp_pin_name == NOT_CON) - return; - /* set the exp_pin_name as input pin direction */ - dev_i2c->i2c_read(data, exp_dev_addr, GPDR_0_7, 2); - *(uint16_t *)data = *(uint16_t *)data & (uint16_t)(~(1 << (uint16_t)exp_pin_name)); // set gpio as in - dev_i2c->i2c_write(data, exp_dev_addr, GPDR_0_7, 2); - } - - /** - * @brief Read the input pin - * @return The pin logical state 0 or 1 - */ - bool read() - { - uint8_t data[2]; - - if (exp_pin_name == NOT_CON) - return false; - /* read the exp_pin_name */ - dev_i2c->i2c_read(data, exp_dev_addr, GPMR_0_7, 2); - *(uint16_t *)data = *(uint16_t *)data & (uint16_t)(1 << (uint16_t)exp_pin_name); // mask the in gpio - if (data[0] || data[1]) - return true; - return false; - } - - operator int() - { - return read(); - } - -private: - DevI2C *dev_i2c; - uint8_t exp_dev_addr; - ExpGpioPinName exp_pin_name; -}; - -/* Classes -------------------------------------------------------------------*/ -/** Class representing a whole stmpe1600 component (16 gpio) - */ -class Stmpe1600 -{ - -public: - /** Constructor - * @param[in] &i2c device I2C to be used for communication - * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS) - */ - Stmpe1600(DevI2C &i2c, uint8_t dev_addr = STMPE1600_DEF_DEVICE_ADDRESS) : dev_i2c(&i2c) - { - exp_dev_addr = dev_addr; - write_sys_ctrl(SOFT_RESET); - - gpdr0_15 = (uint16_t) 0; // gpio dir all IN - write_16bit_reg(GPDR_0_7, &gpdr0_15); - gpsr0_15 = (uint16_t) 0x0ffff; // gpio status all 1 - write_16bit_reg(GPSR_0_7, &gpsr0_15); - } - - /** - * @brief Write the SYS_CTRL register - * @param[in] Data to be written (bit fields) - */ - void write_sys_ctrl(uint8_t data) // data = SOFT_RESET reset the device - { - dev_i2c->i2c_write(&data, exp_dev_addr, SYS_CTRL, 1); - } - - /** - * @brief Set the out pin - * @param[in] The pin name - * @return 0 on Success - */ - bool set_gpio(ExpGpioPinName pin_name) - { - if (pin_name == NOT_CON) - return true; - gpsr0_15 = gpsr0_15 | ((uint16_t) 0x0001 << pin_name); - write_16bit_reg(GPSR_0_7, &gpsr0_15); - return false; - } - - /** - * @brief Clear the out pin - * @param[in] The pin name - * @return 0 on Success - */ - bool clear_gpio(ExpGpioPinName pin_name) - { - if (pin_name == NOT_CON) - return true; - gpsr0_15 = gpsr0_15 & (~((uint16_t) 0x0001 << pin_name)); - write_16bit_reg(GPSR_0_7, &gpsr0_15); - return false; - } - - /** - * @brief Read the input pin - * @param[in] The pin name - * @return The logical pin level - */ - bool read_gpio(ExpGpioPinName pin_name) - { - - uint16_t gpmr0_15; - if (pin_name == NOT_CON) - return true; - read_16bit_reg(GPMR_0_7, &gpmr0_15); - gpmr0_15 = gpmr0_15 & ((uint16_t) 0x0001 << pin_name); - if (gpmr0_15) - return true; - return false; - } - - /** - * @brief Set the pin direction - * @param[in] The pin name - * @param[in] The pin direction - * @return 0 on success - */ - bool set_gpio_dir(ExpGpioPinName pin_name, ExpGpioPinDirection pin_dir) - { - - if (pin_name == NOT_CON || pin_dir == NOT_CONNECTED) - return true; - gpdr0_15 = gpdr0_15 & (~((uint16_t) 0x0001 << pin_name)); // clear the Pin - gpdr0_15 = gpdr0_15 | ((uint16_t) pin_dir << pin_name); - write_16bit_reg(GPDR_0_7, &gpdr0_15); - return false; - } - - /** - * @brief Read a 16 bits register - * @param[in] The register address - * @param[in] The pointer to the read data - */ - void read_16bit_reg(uint8_t reg16_addr, uint16_t *reg16_data) - { - dev_i2c->i2c_read((uint8_t *) reg16_data, exp_dev_addr, reg16_addr, 2); - } - - /** - * @brief Write a 16 bits register - * @param[in] The register address - * @param[in] The pointer to the data to be written - */ - void write_16bit_reg(uint8_t reg16_addr, uint16_t *reg16_data) - { - dev_i2c->i2c_write((uint8_t *) reg16_data, exp_dev_addr, reg16_addr, 2); - printf("##################################write_16bit_reg %d %d %d \n",reg16_addr,exp_dev_addr); - } - -private: - DevI2C *dev_i2c; - uint16_t gpdr0_15; // local copy of bit direction reg - uint16_t gpsr0_15; // local copy of bit status reg - uint8_t exp_dev_addr; // expander device i2c addr -}; - -#endif // __STMPE1600_CLASS - -
--- a/Components/ST_INTERFACES/Actuators/BDCMotor.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/** - ****************************************************************************** - * @file BDCMotor.h - * @author IPC Rennes - * @version V1.0.0 - * @date April 6th, 2016 - * @brief This file contains the abstract class describing the interface of a - * Brush DC motor component. - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __BDCMOTOR_CLASS_H -#define __BDCMOTOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for BDCMotor components. - */ -class BDCMotor : public Component { -public: - - /** - * @brief Rotation modes. - */ - typedef enum { - BWD = 0, /* Backward. */ - FWD = 1 /* Forward. */ - } direction_t; - - /** - * @brief Disabling the specified bridge. - * @param bridgeId from 0 for bridge A to 1 for bridge B. - * @retval None. - */ - virtual void disable_bridge(unsigned int) = 0; - - /** - * @brief Enabling the specified bridge. - * @param bridgeId from 0 for bridge A to 1 for bridge B - * @retval None. - */ - virtual void enable_bridge(unsigned int) = 0; - - /** - * @brief Getting the PWM frequency of the specified bridge; - * @param bridgeId from 0 for bridge A to 1 for bridge B. - * @retval The frequency in Hz of the specified bridge input PWM. - */ - virtual unsigned int get_bridge_input_pwm_freq(unsigned int) = 0; - - /** - * @brief Getting the bridge status. - * @param bridgeId from 0 for bridge A to 1 for bridge B. - * @retval The status. - */ - virtual unsigned int get_bridge_status(unsigned int) = 0; - - /** - * @brief Getting the device State. - * @param motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). - * @retval The device state - */ - virtual unsigned int get_device_state(unsigned int) = 0; - - /** - * @brief Getting the current speed in % of the specified motor. - * @param motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). - * @retval The current speed in %. - */ - virtual unsigned int get_speed(unsigned int) = 0; - - /** - * @brief Stopping the motor and disabling the power bridge immediately. - * @param motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). - * @retval None. - */ - virtual void hard_hiz(unsigned int) = 0; - - /** - * @brief Stopping the motor immediately. - * @param motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). - * @retval None. - */ - virtual void hard_stop(unsigned int) = 0; - - /** - * @brief Running the motor. - * @param motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). - * @param direction The direction of rotation. - * @retval None. - */ - virtual void run(unsigned int, direction_t) = 0; - - /** - * @brief Setting the PWM frequency of the specified bridge. - * @param bridgeId from 0 for bridge A to 1 for bridge B. - * @param frequency of the PWM in Hz - * @retval None. - */ - virtual void set_bridge_input_pwm_freq(unsigned int, unsigned int) = 0; - - /** - * @brief Setting the dual bridge configuration mode. - * @param configuration. The bridge configuration. - * @retval None. - */ - virtual void set_dual_full_bridge_config(unsigned int) = 0; - - /** - * @brief Setting the speed in %. - * @param motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). - * @param speed The new speed in %. - * @retval "true" in case of success, "false" otherwise. - */ - virtual bool set_speed(unsigned int, unsigned int) = 0; - - /** - * @brief Destructor. - */ - virtual ~BDCMotor() {}; -}; - -#endif /* __BDCMOTOR_CLASS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/ST_INTERFACES/Actuators/StepperMotor.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,275 +0,0 @@ -/** - ****************************************************************************** - * @file StepperMotor.h - * @author Davide Aliprandi, STMicroelectronics - * @version V1.1.0 - * @date April 6th, 2016 - * @brief This file contains the abstract class describing the interface of a - * stepper-motor component. - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __STEPPERMOTOR_CLASS_H -#define __STEPPERMOTOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for StepperMotor components. - */ -class StepperMotor : public Component { -public: - - /** - * @brief Rotation modes. - */ - typedef enum { - BWD = 0, /* Backward. */ - FWD = 1 /* Forward. */ - } direction_t; - - /** - * @brief Step modes. - */ - typedef enum { - STEP_MODE_FULL = 0, /* Full-step. */ - STEP_MODE_HALF, /* Half-step. */ - STEP_MODE_1_4, /* 1/4 microstep. */ - STEP_MODE_1_8, /* 1/8 microstep. */ - STEP_MODE_1_16, /* 1/16 microstep. */ - STEP_MODE_1_32, /* 1/32 microstep. */ - STEP_MODE_1_64, /* 1/64 microstep. */ - STEP_MODE_1_128, /* 1/128 microstep. */ - STEP_MODE_1_256, /* 1/256 microstep. */ - STEP_MODE_UNKNOWN, /* Unknown. */ - STEP_MODE_WAVE /* Full-step one-phase-on. */ - } step_mode_t; - - /** - * @brief Getting the status. - * @param None. - * @retval The status. - */ - virtual unsigned int get_status(void) = 0; - - /** - * @brief Getting the position. - * @param None. - * @retval The position. - */ - virtual signed int get_position(void) = 0; - - /** - * @brief Getting the marked position. - * @param None. - * @retval The marked position. - */ - virtual signed int get_mark(void) = 0; - - /** - * @brief Getting the current speed in pps. - * @param None. - * @retval The current speed in pps. - */ - virtual unsigned int get_speed(void) = 0; - - /** - * @brief Getting the maximum speed in pps. - * @param None. - * @retval The maximum speed in pps. - */ - virtual unsigned int get_max_speed(void) = 0; - - /** - * @brief Getting the minimum speed in pps. - * @param None. - * @retval The minimum speed in pps. - */ - virtual unsigned int get_min_speed(void) = 0; - - /** - * @brief Getting the acceleration in pps^2. - * @param None. - * @retval The acceleration in pps^2. - */ - virtual unsigned int get_acceleration(void) = 0; - - /** - * @brief Getting the deceleration in pps^2. - * @param None. - * @retval The deceleration in pps^2. - */ - virtual unsigned int get_deceleration(void) = 0; - - /** - * @brief Getting the direction of rotation. - * @param None. - * @retval The direction of rotation. - */ - virtual direction_t get_direction(void) = 0; - - /** - * @brief Setting the current position to be the home position. - * @param None. - * @retval None. - */ - virtual void set_home(void) = 0; - - /** - * @brief Setting the current position to be the marked position. - * @param None. - * @retval None. - */ - virtual void set_mark(void) = 0; - - /** - * @brief Setting the maximum speed in pps. - * @param speed The maximum speed in pps. - * @retval "true" in case of success, "false" otherwise. - */ - virtual bool set_max_speed(unsigned int speed) = 0; - - /** - * @brief Setting the minimum speed in pps. - * @param speed The minimum speed in pps. - * @retval "true" in case of success, "false" otherwise. - */ - virtual bool set_min_speed(unsigned int speed) = 0; - - /** - * @brief Setting the acceleration in pps^2. - * @param acceleration The acceleration in pps^2. - * @retval "true" in case of success, "false" otherwise. - */ - virtual bool set_acceleration(unsigned int acceleration) = 0; - - /** - * @brief Setting the deceleration in pps^2. - * @param deceleration The deceleration in pps^2. - * @retval "true" in case of success, "false" otherwise. - */ - virtual bool set_deceleration(unsigned int deceleration) = 0; - - /** - * @brief Setting the Step Mode. - * @param step_mode The Step Mode. - * @retval "true" in case of success, "false" otherwise. - */ - virtual bool set_step_mode(step_mode_t step_mode) = 0; - - /** - * @brief Going to a specified position. - * @param position The desired position. - * @retval None. - */ - virtual void go_to(signed int position) = 0; - - /** - * @brief Going to the home position. - * @param None. - * @retval None. - */ - virtual void go_home(void) = 0; - - /** - * @brief Going to the marked position. - * @param None. - * @retval None. - */ - virtual void go_mark(void) = 0; - - /** - * @brief Running the motor towards a specified direction. - * @param direction The direction of rotation. - * @retval None. - */ - virtual void run(direction_t direction) = 0; - - /** - * @brief Moving the motor towards a specified direction for a certain number of steps. - * @param direction The direction of rotation. - * @param steps The desired number of steps. - * @retval None. - */ - virtual void move(direction_t direction, unsigned int steps) = 0; - - /** - * @brief Stopping the motor through an immediate deceleration up to zero speed. - * @param None. - * @retval None. - */ - virtual void soft_stop(void) = 0; - - /** - * @brief Stopping the motor through an immediate infinite deceleration. - * @param None. - * @retval None. - */ - virtual void hard_stop(void) = 0; - - /** - * @brief Disabling the power bridge after performing a deceleration to zero. - * @param None. - * @retval None. - */ - virtual void soft_hiz(void) = 0; - - /** - * @brief Disabling the power bridge immediately. - * @param None. - * @retval None. - */ - virtual void hard_hiz(void) = 0; - - /** - * @brief Waiting while the motor is active. - * @param None. - * @retval None. - */ - virtual void wait_while_active(void) = 0; - - /** - * @brief Destructor. - */ - virtual ~StepperMotor() {}; -}; - -#endif /* __STEPPERMOTOR_CLASS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/ST_INTERFACES/Common/Component.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -/** - ****************************************************************************** - * @file Component.h - * @author AST - * @version V1.0.0 - * @date April 13th, 2015 - * @brief This file contains the abstract class describing the interface of a - * generic component. - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ - -#ifndef __COMPONENT_CLASS_H -#define __COMPONENT_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <stdint.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for Generic components. - */ -class Component { -public: - - /** - * @brief Initializing the component. - * @param[in] init pointer to device specific initalization structure. - * @retval "0" in case of success, an error code otherwise. - */ - virtual int init(void *init) = 0; - - /** - * @brief Getting the ID of the component. - * @param[out] id pointer to an allocated variable to store the ID into. - * @retval "0" in case of success, an error code otherwise. - */ - virtual int read_id(uint8_t *id) = 0; - - /** - * @brief Destructor. - */ - virtual ~Component() {}; -}; - -#endif /* __COMPONENT_CLASS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/ST_INTERFACES/Communications/Nfc.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/** - ****************************************************************************** - * @file Nfc.h - * @author ST Central Labs - * @version V1.0.0 - * @date 13-April-2015 - * @brief This file contains the abstract class describing the interface of a - * nfc component. - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Generated with Stm32CubeTOO -----------------------------------------------*/ - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __NFC_CLASS_H -#define __NFC_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - -typedef enum { - NFC_SUCCESS = 0, -} NFC_t; -/* Error codes are in component driver */ - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for Nfc components. - */ -class Nfc : public Component { -public: - - /** - * Read data from the tag. - * @param offset Read offset. - * @param nb_bytes_to_read Number of bytes to read. - * @param[out] p_buffer_read Buffer to store the read data into. - * @return NFC_SUCCESS if no errors - */ - virtual int read_binary(uint16_t offset, uint8_t nb_bytes_to_read, uint8_t *p_buffer_read) = 0; - - /** - * Write data to the tag. - * @param offset Write offset. - * @param nb_bytes_to_write Number of bytes to write. - * @param p_buffer_write Buffer to write. - * @return NFC_SUCCESS if no errors - */ - virtual int update_binary(uint16_t offset, uint8_t nb_bytes_to_write, uint8_t *p_buffer_write) = 0; - - /** - * @brief Destructor. - */ - virtual ~Nfc() {}; -}; - -#endif /* __NFC_CLASS_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/ST_INTERFACES/Sensors/GyroSensor.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/** - ****************************************************************************** - * @file GyroSensor.h - * @author AST / EST - * @version V0.0.1 - * @date 13-April-2015 - * @brief This file contains the abstract class describing in general - * the interfaces of a gyroscope - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __GYRO_SENSOR_CLASS_H -#define __GYRO_SENSOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for a Gyroscope - */ -class GyroSensor : public Component { -public: - - /** - * @brief Get current gyroscope angular rate X/Y/Z-axes values - * in standard data units [mdps] - * @param[out] p_data Pointer to where to store angular rates to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_g_axes(int32_t *p_data) = 0; - - /** - * @brief Get current gyroscope raw data X/Y/Z-axes values - * in device sepcific LSB units - * @param[out] p_data Pointer to where to store gyroscope raw data to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_g_axes_raw(int16_t *p_data) = 0; - - /** - * @brief Get gyroscope's current sensitivity [mdps/LSB] - * @param[out] pf_data Pointer to where the gyroscope's sensitivity is stored to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_g_sensitivity(float *pf_data) = 0; - - /** - * @brief Get gyroscope's current output data rate [Hz] - * @param[out] pf_data Pointer to where the gyroscope output data rate is stored to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_g_odr(float *pf_data) = 0; - - /** - * @brief Set gyroscope's output data rate - * @param[in] odr New value for gyroscope's output data rate in [Hz] - * @return 0 in case of success, an error code otherwise - */ - virtual int set_g_odr(float odr) = 0; - - /** - * @brief Get gyroscope's full scale value - * i.e.\ min/max measurable value [dps] - * @param[out] pf_data Pointer to where the gyroscope full scale value is stored to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_g_fs(float *pf_data) = 0; - - /** - * @brief Set gyroscope's full scale value - * i.e.\ min/max measurable value - * @param[in] fs New full scale value for gyroscope in [dps] - * @return 0 in case of success, an error code otherwise - */ - virtual int set_g_fs(float fs) = 0; - - /** - * @brief Destructor. - */ - virtual ~GyroSensor() {}; -}; - -#endif /* __GYRO_SENSOR_CLASS_H */
--- a/Components/ST_INTERFACES/Sensors/HumiditySensor.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/** - ****************************************************************************** - * @file HumiditySensor.h - * @author AST / EST - * @version V0.0.1 - * @date 13-April-2015 - * @brief This file contains the abstract class describing in general - * the interfaces of a humidity sensor - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __HUMIDITY_SENSOR_CLASS_H -#define __HUMIDITY_SENSOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for Humidity sensors - */ -class HumiditySensor : public Component { -public: - - /** - * @brief Get current humidity [%] - * @param[out] pf_data Pointer to where to store humidity to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_humidity(float *pf_data) = 0; - - /** - * @brief Destructor. - */ - virtual ~HumiditySensor() {}; -}; - -#endif /* __HUMIDITY_SENSOR_CLASS_H */
--- a/Components/ST_INTERFACES/Sensors/LightSensor.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/** - ****************************************************************************** - * @file LightSensor.h - * @author AST / EST - * @version V0.0.1 - * @date 13-April-2015 - * @brief This file contains the abstract class describing in general - * the interfaces of an ambient light sensor (ALS) - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __LIGHT_SENSOR_CLASS_H -#define __LIGHT_SENSOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for ambient light sensors - */ -class LightSensor : public Component { -public: - - /** - * @brief Get current light [lux] - * @param[out] pi_data Pointer to where to store light to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_lux(uint32_t *pi_data) = 0; - - /** - * @brief Destructor. - */ - virtual ~LightSensor() {}; -}; - -#endif /* __LIGHT_SENSOR_CLASS_H */
--- a/Components/ST_INTERFACES/Sensors/MagneticSensor.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/** - ****************************************************************************** - * @file MagneticSensor.h - * @author AST / EST - * @version V0.0.1 - * @date 13-April-2015 - * @brief This file contains the abstract class describing in general - * the interfaces of a magnetometer - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __MAGNETIC_SENSOR_CLASS_H -#define __MAGNETIC_SENSOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for a magnetometer - */ -class MagneticSensor : public Component { -public: - - /** - * @brief Get current magnetometer magnetic X/Y/Z-axes values - * in standard data units [mgauss] - * @param[out] p_data Pointer to where to store magnetic values to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_m_axes(int32_t *p_data) = 0; - - /** - * @brief Get current magnetometer raw data X/Y/Z-axes values - * in device sepcific LSB units - * @param[out] p_data Pointer to where to store magnetometer raw data to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_m_axes_raw(int16_t *p_data) = 0; - - /** - * @brief Destructor. - */ - virtual ~MagneticSensor() {}; -}; - -#endif /* __MAGNETIC_SENSOR_CLASS_H */
--- a/Components/ST_INTERFACES/Sensors/MotionSensor.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/** - ****************************************************************************** - * @file MotionSensor.h - * @author AST / EST - * @version V0.0.1 - * @date 13-April-2015 - * @brief This file contains the abstract class describing in general - * the interfaces of an accelerometer - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __MOTION_SENSOR_CLASS_H -#define __MOTION_SENSOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for an Accelerometer - */ -class MotionSensor : public Component { -public: - - /** - * @brief Get current accelerometer linear acceleration X/Y/Z-axes values - * in standard data units [mg] - * @param[out] p_data Pointer to where to store linear accelerations to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_x_axes(int32_t *p_data) = 0; - - /** - * @brief Get current accelerometer raw data X/Y/Z-axes values - * in device sepcific LSB units - * @param[out] p_data Pointer to where to store accelerometer raw data to. - * p_data must point to an array of (at least) three elements, where: - * p_data[0] corresponds to X-axis, - * p_data[1] corresponds to Y-axis, and - * p_data[2] corresponds to Z-axis. - * @return 0 in case of success, an error code otherwise - */ - virtual int get_x_axes_raw(int16_t *p_data) = 0; - - /** - * @brief Get accelerometer's current sensitivity [mg/LSB] - * @param[out] pf_data Pointer to where the accelerometer's sensitivity is stored to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_x_sensitivity(float *pf_data) = 0; - - /** - * @brief Get accelerometer's current output data rate [Hz] - * @param[out] pf_data Pointer to where the accelerometer output data rate is stored to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_x_odr(float *pf_data) = 0; - - /** - * @brief Set accelerometer's output data rate - * @param[in] odr New value for accelerometer's output data rate in [Hz] - * @return 0 in case of success, an error code otherwise - */ - virtual int set_x_odr(float odr) = 0; - - /** - * @brief Get accelerometer's full scale value - * i.e.\ min/max measurable value [g] - * @param[out] pf_data Pointer to where the accelerometer full scale value is stored to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_x_fs(float *pf_data) = 0; - - /** - * @brief Set accelerometer's full scale value - * i.e.\ min/max measurable value - * @param[in] fs New full scale value for accelerometer in [g] - * @return 0 in case of success, an error code otherwise - */ - virtual int set_x_fs(float fs) = 0; - - /** - * @brief Destructor. - */ - virtual ~MotionSensor() {}; -}; - -#endif /* __MOTION_SENSOR_CLASS_H */
--- a/Components/ST_INTERFACES/Sensors/PressureSensor.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/** - ****************************************************************************** - * @file PressureSensor.h - * @author AST / EST - * @version V0.0.1 - * @date 13-April-2015 - * @brief This file contains the abstract class describing in general - * the interfaces of a pressure sensor - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __PRESSURE_SENSOR_CLASS_H -#define __PRESSURE_SENSOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for a Pressure Sensor - */ -class PressureSensor : public Component { -public: - - /** - * @brief Get current pressure [mbar] - * @param[out] pf_data Pointer to where to store pressure to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_pressure(float *pf_data) = 0; - - /** - * @brief Destructor. - */ - virtual ~PressureSensor() {}; -}; - -#endif /* __PRESSURE_SENSOR_CLASS_H */
--- a/Components/ST_INTERFACES/Sensors/RangeSensor.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/** - ****************************************************************************** - * @file RangeSensor.h - * @author AST / EST - * @version V0.0.1 - * @date 13-April-2015 - * @brief This file contains the abstract class describing in general - * the interfaces of a range sensor - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __RANGE_SENSOR_CLASS_H -#define __RANGE_SENSOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for range sensors - */ -class RangeSensor : public Component { -public: - - /** - * @brief Get current range [mm] - * @param[out] pi_data Pointer to where to store range to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_distance(uint32_t *pi_data) = 0; - - /** - * @brief Destructor. - */ - virtual ~RangeSensor() {}; -}; - -#endif /* __RANGE_SENSOR_CLASS_H */
--- a/Components/ST_INTERFACES/Sensors/TempSensor.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -/** - ****************************************************************************** - * @file TempSensor.h - * @author AST / EST - * @version V0.0.1 - * @date 13-April-2015 - * @brief This file contains the abstract class describing in general - * the interfaces of a temperature sensor - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - -/* Define to prevent from recursive inclusion --------------------------------*/ - -#ifndef __TEMP_SENSOR_CLASS_H -#define __TEMP_SENSOR_CLASS_H - - -/* Includes ------------------------------------------------------------------*/ - -#include <Component.h> - - -/* Classes ------------------------------------------------------------------*/ - -/** - * An abstract class for Temperature sensors - */ -class TempSensor : public Component { -public: - - /** - * @brief Get current temperature in degrees Celsius [°C] - * @param[out] pf_data Pointer to where to store temperature to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_temperature(float *pf_data) = 0; - - /** - * @brief Get current temperature in degrees Fahrenheit [°F] - * @param[out] pf_data Pointer to where to store temperature to - * @return 0 in case of success, an error code otherwise - */ - virtual int get_fahrenheit(float *pf_data) { - float celsius; - int ret; - - ret = get_temperature(&celsius); - if (ret) { - return ret; - } - - *pf_data = ((celsius * 1.8f) + 32.0f); - - return 0; - } - - /** - * @brief Destructor. - */ - virtual ~TempSensor() {}; -}; - -#endif /* __TEMP_SENSOR_CLASS_H */
--- a/Components/VL53L3_Lib.lib Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/users/johnAlexander/code/VL53L3_Lib/#ad33ff89d2cf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VL53L3_Lib.lib Tue Nov 03 15:28:52 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/johnAlexander/code/VL53L3_Lib/#316175f392f7
--- a/X_NUCLEO_COMMON/DbgMCU/DbgMCU.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/** - ****************************************************************************** - * @file DbgMCU.h - * @author AST / EST - * @version V0.0.1 - * @date 30-March-2015 - * @brief Header file for enabling debugging in sleep modes for STM32 MCUs - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent from recursive inclusion --------------------------------*/ -#ifndef __DBG_MCU_H -#define __DBG_MCU_H - -/* Includes ------------------------------------------------------------------*/ - -/* Classes -------------------------------------------------------------------*/ -/** Helper class DbgMCU providing a default constructor which enables debugging - * on STM32 MCUs while using sleep modes. - */ -class DbgMCU -{ - public: - /** Create a DbgMCU dummy object */ - DbgMCU(void) { - /* the following code is NOT portable */ - volatile uint32_t *dbgmcu_creg = (uint32_t*)0xE0042004; - uint32_t tmp = *dbgmcu_creg; - - tmp &= ~(0xE7); - tmp |= 0x27; // Set asynchronous communication via DBGMCU_CR (for ITM/printf) - // tmp |= 0xE7; // Set 4-pin tracing via DBGMCU_CR (for ETM) - *dbgmcu_creg = tmp; - } -}; - -#endif /* __DBG_MCU_H */
--- a/X_NUCLEO_COMMON/DevI2C/DevI2C.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -/** - ****************************************************************************** - * @file DevI2C.h - * @author AST / EST - * @version V1.1.0 - * @date 21-January-2016 - * @brief Header file for a special I2C class DevI2C which provides some - * helper function for on-board communication - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent from recursive inclusion --------------------------------*/ -#ifndef __DEV_I2C_H -#define __DEV_I2C_H - -/* Includes ------------------------------------------------------------------*/ -#include "mbed.h" -#include "pinmap.h" - -/* Classes -------------------------------------------------------------------*/ -/** Helper class DevI2C providing functions for multi-register I2C communication - * common for a series of I2C devices - */ -class DevI2C : public I2C -{ -public: - /** Create a DevI2C Master interface, connected to the specified pins - * - * @param sda I2C data line pin - * @param scl I2C clock line pin - */ - DevI2C(PinName sda, PinName scl) : I2C(sda, scl) {} - - /** - * @brief Writes a buffer towards the I2C peripheral device. - * @param pBuffer pointer to the byte-array data to send - * @param DeviceAddr specifies the peripheral device slave address. - * @param RegisterAddr specifies the internal address register - * where to start writing to (must be correctly masked). - * @param NumByteToWrite number of bytes to be written. - * @retval 0 if ok, - * @retval -1 if an I2C error has occured, or - * @retval -2 on temporary buffer overflow (i.e. NumByteToWrite was too high) - * @note On some devices if NumByteToWrite is greater - * than one, the RegisterAddr must be masked correctly! - */ - int i2c_write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, - uint16_t NumByteToWrite) { - int ret; - uint8_t tmp[TEMP_BUF_SIZE]; - - if(NumByteToWrite >= TEMP_BUF_SIZE) return -2; - - /* First, send device address. Then, send data and STOP condition */ - tmp[0] = RegisterAddr; - memcpy(tmp+1, pBuffer, NumByteToWrite); - - ret = write(DeviceAddr, (const char*)tmp, NumByteToWrite+1, false); - - if(ret) return -1; - return 0; - } - - /** - * @brief Reads a buffer from the I2C peripheral device. - * @param pBuffer pointer to the byte-array to read data in to - * @param DeviceAddr specifies the peripheral device slave address. - * @param RegisterAddr specifies the internal address register - * where to start reading from (must be correctly masked). - * @param NumByteToRead number of bytes to be read. - * @retval 0 if ok, - * @retval -1 if an I2C error has occured - * @note On some devices if NumByteToWrite is greater - * than one, the RegisterAddr must be masked correctly! - */ - int i2c_read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, - uint16_t NumByteToRead) { - int ret; - - /* Send device address, with no STOP condition */ - ret = write(DeviceAddr, (const char*)&RegisterAddr, 1, true); - if(!ret) { - /* Read data, with STOP condition */ - ret = read(DeviceAddr, (char*)pBuffer, NumByteToRead, false); - } - - if(ret) return -1; - return 0; - } - -private: - static const unsigned int TEMP_BUF_SIZE = 256; //~~ was 32 -}; - -#endif /* __DEV_I2C_H */
--- a/X_NUCLEO_COMMON/DevSPI/DevSPI.h Tue Nov 03 15:09:55 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,302 +0,0 @@ -/** - ****************************************************************************** - * @file DevSPI.h - * @author AST / Software Platforms and Cloud / EST - * @version V1.2.1 - * @date 19-February-2016 - * @brief Header file for a special SPI class DevSPI which provides some - * helper functions for on-board communication. - ****************************************************************************** - * @attention - * - * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/* Define to prevent from recursive inclusion --------------------------------*/ -#ifndef __DEV_SPI_H -#define __DEV_SPI_H - -/* Includes ------------------------------------------------------------------*/ -#include "mbed.h" - -/* Macros --------------------------------------------------------------------*/ -#if (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) /* GCC */ || \ - (defined(G_BYTE_ORDER) && (G_BYTE_ORDER == G_BIG_ENDIAN)) /* IAR */ || \ - (defined(__BIG_ENDIAN)) /* ARM */ -#define __DEV_SPI_BIG_ENDIAN -#endif - -/* Classes -------------------------------------------------------------------*/ -/** Helper class DevSPI providing functions for synchronous SPI communication - * common for a series of SPI devices. - */ -class DevSPI : public SPI -{ - public: - /* - * Create a DevSPI interface. - * @param mosi pin name of the MOSI pin of the SPI device to be used for communication. - * @param miso pin name of the MISO pin of the SPI device to be used for communication. - * @param sclk pin name of the SCLK pin of the SPI device to be used for communication. - */ - DevSPI(PinName mosi, PinName miso, PinName sclk) : SPI(mosi, miso, sclk) - { - /* Set default configuration. */ - setup(8, 3, 1E6); - } - - /* - * Setup the spi. - * Typically: - * + 8 bit data; - * + high steady state clock; - * + second edge capture; - * + 1MHz clock rate. - * - * @param bits Number of bits per SPI frame (4 - 16) - * @param mode Clock polarity and phase mode (0 - 3) - * @param frequency_hz SCLK frequency in hz (default = 1MHz) - * - * @code - * mode | POL PHA - * -----+-------- - * 0 | 0 0 - * 1 | 0 1 - * 2 | 1 0 - * 3 | 1 1 - * @endcode - */ - void setup(int bits, int mode = 0, int frequency_hz = 1E6) - { - /* Set given configuration. */ - format(bits, mode); - frequency(frequency_hz); - } - - /** - * @brief Writes a buffer to the SPI peripheral device in 8-bit data mode - * using synchronous SPI communication. - * @param[in] pBuffer pointer to the buffer of data to send. - * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. - * @param[in] NumBytesToWrite number of bytes to write. - * @retval 0 if ok. - * @retval -1 if data format error. - * @note When using the SPI in Interrupt-mode, remember to disable interrupts - * before calling this function and to enable them again after. - */ - int spi_write(uint8_t* pBuffer, DigitalOut &ssel, uint16_t NumBytesToWrite) - { - /* Check data format */ - if(_bits != 8) return -1; - - /* Select the chip. */ - ssel = 0; - - /* Write data. */ - for (int i = 0; i < NumBytesToWrite; i++) { - write(pBuffer[i]); - } - - /* Unselect the chip. */ - ssel = 1; - - return 0; - } - - /** - * @brief Reads a buffer from the SPI peripheral device in 8-bit data mode - * using synchronous SPI communication. - * @param[out] pBuffer pointer to the buffer to read data into. - * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. - * @param[in] NumBytesToRead number of bytes to read. - * @retval 0 if ok. - * @retval -1 if data format error. - * @note When using the SPI in Interrupt-mode, remember to disable interrupts - * before calling this function and to enable them again after. - */ - int spi_read(uint8_t* pBuffer, DigitalOut &ssel, uint16_t NumBytesToRead) - { - /* Check data format */ - if(_bits != 8) return -1; - - /* Select the chip. */ - ssel = 0; - - /* Read data. */ - for (int i = 0; i < NumBytesToRead; i++) { - pBuffer[i] = write(0); - } - - /* Unselect the chip. */ - ssel = 1; - - return 0; - } - - /** - * @brief Reads and write a buffer from/to the SPI peripheral device at the same time - * in 8-bit data mode using synchronous SPI communication. - * @param[out] pBufferToRead pointer to the buffer to read data into. - * @param[in] pBufferToWrite pointer to the buffer of data to send. - * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. - * @param[in] NumBytes number of bytes to read and write. - * @retval 0 if ok. - * @retval -1 if data format error. - * @note When using the SPI in Interrupt-mode, remember to disable interrupts - * before calling this function and to enable them again after. - */ - int spi_read_write(uint8_t* pBufferToRead, uint8_t* pBufferToWrite, DigitalOut &ssel, uint16_t NumBytes) - { - /* Check data format */ - if(_bits != 8) return -1; - - /* Select the chip. */ - ssel = 0; - - /* Read and write data at the same time. */ - for (int i = 0; i < NumBytes; i++) { - pBufferToRead[i] = write(pBufferToWrite[i]); - } - - /* Unselect the chip. */ - ssel = 1; - - return 0; - } - - /** - * @brief Writes a buffer to the SPI peripheral device in 16-bit data mode - * using synchronous SPI communication. - * @param[in] pBuffer pointer to the buffer of data to send. - * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. - * @param[in] NumValuesToWrite number of 16-bit values to write. - * @retval 0 if ok. - * @retval -1 if data format error. - * @note When using the SPI in Interrupt-mode, remember to disable interrupts - * before calling this function and to enable them again after. - * @note In order to guarantee this method to work correctly you have to - * pass buffers which are correctly aligned. - */ - int spi_write(uint16_t* pBuffer, DigitalOut &ssel, uint16_t NumValuesToWrite) - { - /* Check data format */ - if(_bits != 16) return -1; - - /* Select the chip. */ - ssel = 0; - - /* Write data. */ - for (int i = 0; i < NumValuesToWrite; i++) { - write(htons(pBuffer[i])); - } - - /* Unselect the chip. */ - ssel = 1; - - return 0; - } - - /** - * @brief Reads a buffer from the SPI peripheral device in 16-bit data mode - * using synchronous SPI communication. - * @param[out] pBuffer pointer to the buffer to read data into. - * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. - * @param[in] NumValuesToRead number of 16-bit values to read. - * @retval 0 if ok. - * @retval -1 if data format error. - * @note When using the SPI in Interrupt-mode, remember to disable interrupts - * before calling this function and to enable them again after. - * @note In order to guarantee this method to work correctly you have to - * pass buffers which are correctly aligned. - */ - int spi_read(uint16_t* pBuffer, DigitalOut &ssel, uint16_t NumValuesToRead) - { - /* Check data format */ - if(_bits != 16) return -1; - - /* Select the chip. */ - ssel = 0; - - /* Read data. */ - for (int i = 0; i < NumValuesToRead; i++) { - pBuffer[i] = ntohs((uint16_t)write(0)); - } - - /* Unselect the chip. */ - ssel = 1; - - return 0; - } - - /** - * @brief Reads and write a buffer from/to the SPI peripheral device at the same time - * in 16-bit data mode using synchronous SPI communication. - * @param[out] pBufferToRead pointer to the buffer to read data into. - * @param[in] pBufferToWrite pointer to the buffer of data to send. - * @param[in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. - * @param[in] NumValues number of 16-bit values to read and write. - * @retval 0 if ok. - * @retval -1 if data format error. - * @note When using the SPI in Interrupt-mode, remember to disable interrupts - * before calling this function and to enable them again after. - * @note In order to guarantee this method to work correctly you have to - * pass buffers which are correctly aligned. - */ - int spi_read_write(uint16_t* pBufferToRead, uint16_t* pBufferToWrite, DigitalOut &ssel, uint16_t NumValues) - { - /* Check data format */ - if(_bits != 16) return -1; - - /* Select the chip. */ - ssel = 0; - - /* Read and write data at the same time. */ - for (int i = 0; i < NumValues; i++) { - pBufferToRead[i] = ntohs((uint16_t)write(htons(pBufferToWrite[i]))); - } - - /* Unselect the chip. */ - ssel = 1; - - return 0; - } - -protected: - inline uint16_t htons(uint16_t x) { -#ifndef __DEV_SPI_BIG_ENDIAN - return (((x)<<8)|((x)>>8)); -#else // __DEV_SPI_BIG_ENDIAN - return (x); -#endif // __DEV_SPI_BIG_ENDIAN - } - - inline uint16_t ntohs(uint16_t x) { - return htons(x); - } -}; - -#endif /* __DEV_SPI_H */