Revision 1f94ac64
| modules/DiWheelDrive_1-1/alldconf.h | ||
|---|---|---|
| 32 | 32 |
* compatibility guards |
| 33 | 33 |
*/ |
| 34 | 34 |
#define _AMIRO_LLD_CFG_ |
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1 |
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0 |
|
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1
|
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0
|
|
| 37 | 37 |
|
| 38 | 38 |
/** |
| 39 | 39 |
* @brief Width of the apalTime_t data type. |
| ... | ... | |
| 41 | 41 |
* @details Possible values are 8, 16, 32, and 64 bits. |
| 42 | 42 |
* By definition time is represented at microsecond precision. |
| 43 | 43 |
*/ |
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32 |
|
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32
|
|
| 45 | 45 |
|
| 46 | 46 |
/** |
| 47 | 47 |
* @brief Enable flag for the A3906 motor driver. |
| 48 | 48 |
*/ |
| 49 |
#define AMIROLLD_CFG_A3906 1 |
|
| 49 |
#define AMIROLLD_CFG_A3906 1
|
|
| 50 | 50 |
|
| 51 | 51 |
/** |
| 52 | 52 |
* @brief Enable flag for the AT24C01BN-SH-B EEPROM. |
| 53 | 53 |
*/ |
| 54 |
#define AMIROLLD_CFG_AT24C01B 1 |
|
| 54 |
#define AMIROLLD_CFG_AT24C01B 1
|
|
| 55 | 55 |
|
| 56 | 56 |
/** |
| 57 | 57 |
* @brief Enable flag for the MHC5883L compass. |
| 58 | 58 |
*/ |
| 59 |
#define AMIROLLD_CFG_HMC5883L 1 |
|
| 59 |
#define AMIROLLD_CFG_HMC5883L 1
|
|
| 60 | 60 |
|
| 61 | 61 |
/** |
| 62 | 62 |
* @brief Enable flag for the INA219 power monitor. |
| 63 | 63 |
*/ |
| 64 |
#define AMIROLLD_CFG_INA219 1 |
|
| 64 |
#define AMIROLLD_CFG_INA219 1
|
|
| 65 | 65 |
|
| 66 | 66 |
/** |
| 67 | 67 |
* @brief Enable flag for the L3G4200D gyroscope. |
| 68 | 68 |
*/ |
| 69 |
#define AMIROLLD_CFG_L3G4200D 1 |
|
| 69 |
#define AMIROLLD_CFG_L3G4200D 1
|
|
| 70 | 70 |
|
| 71 | 71 |
/** |
| 72 | 72 |
* @brief Enable flag for the status LED. |
| 73 | 73 |
*/ |
| 74 |
#define AMIROLLD_CFG_LED 1 |
|
| 74 |
#define AMIROLLD_CFG_LED 1
|
|
| 75 | 75 |
|
| 76 | 76 |
/** |
| 77 | 77 |
* @brief Enable flag for the LIS331DLH accelerometer. |
| 78 | 78 |
*/ |
| 79 |
#define AMIROLLD_CFG_LIS331DLH 1 |
|
| 79 |
#define AMIROLLD_CFG_LIS331DLH 1
|
|
| 80 | 80 |
|
| 81 | 81 |
/** |
| 82 | 82 |
* @brief Enable flag for the LTC4412 power path controller. |
| 83 | 83 |
*/ |
| 84 |
#define AMIROLLD_CFG_LTC4412 1 |
|
| 84 |
#define AMIROLLD_CFG_LTC4412 1
|
|
| 85 | 85 |
|
| 86 | 86 |
/** |
| 87 | 87 |
* @brief Enable flag for the PCA9544A I2C multiplexer. |
| 88 | 88 |
*/ |
| 89 |
#define AMIROLLD_CFG_PCA9544A 1 |
|
| 89 |
#define AMIROLLD_CFG_PCA9544A 1
|
|
| 90 | 90 |
|
| 91 | 91 |
/** |
| 92 | 92 |
* @brief Enable flag for the TPS62113 step-down converter. |
| 93 | 93 |
*/ |
| 94 |
#define AMIROLLD_CFG_TPS6211x 1 |
|
| 94 |
#define AMIROLLD_CFG_TPS6211x 1
|
|
| 95 | 95 |
|
| 96 | 96 |
/** |
| 97 | 97 |
* @brief Enable flag for the VCNL4020 proximity sensor. |
| 98 | 98 |
*/ |
| 99 |
#define AMIROLLD_CFG_VCNL4020 1 |
|
| 99 |
#define AMIROLLD_CFG_VCNL4020 1
|
|
| 100 | 100 |
|
| 101 | 101 |
#endif /* ALLDCONF_H */ |
| 102 | 102 |
|
| modules/LightRing_1-0/alldconf.h | ||
|---|---|---|
| 32 | 32 |
* compatibility guards |
| 33 | 33 |
*/ |
| 34 | 34 |
#define _AMIRO_LLD_CFG_ |
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1 |
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0 |
|
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1
|
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0
|
|
| 37 | 37 |
|
| 38 | 38 |
/** |
| 39 | 39 |
* @brief Width of the apalTime_t data type. |
| ... | ... | |
| 41 | 41 |
* @details Possible values are 8, 16, 32, and 64 bits. |
| 42 | 42 |
* By definition time is represented at microsecond precision. |
| 43 | 43 |
*/ |
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32 |
|
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32
|
|
| 45 | 45 |
|
| 46 | 46 |
/** |
| 47 | 47 |
* @brief Enable flag for the AT24C01BN-SH-B EEPROM. |
| 48 | 48 |
*/ |
| 49 |
#define AMIROLLD_CFG_AT24C01B 1 |
|
| 49 |
#define AMIROLLD_CFG_AT24C01B 1
|
|
| 50 | 50 |
|
| 51 | 51 |
/** |
| 52 | 52 |
* @brief Enable flag for the TLC5947 LED driver. |
| 53 | 53 |
*/ |
| 54 |
#define AMIROLLD_CFG_TLC5947 1 |
|
| 54 |
#define AMIROLLD_CFG_TLC5947 1
|
|
| 55 | 55 |
|
| 56 | 56 |
/** |
| 57 | 57 |
* @brief Enable flag for the TPS2051BDBV power switch. |
| 58 | 58 |
*/ |
| 59 |
#define AMIROLLD_CFG_TPS20xxB 1 |
|
| 59 |
#define AMIROLLD_CFG_TPS20xxB 1
|
|
| 60 | 60 |
|
| 61 | 61 |
#endif /* ALLDCONF_H */ |
| 62 | 62 |
|
| modules/NUCLEO-F103RB/alldconf.h | ||
|---|---|---|
| 32 | 32 |
* compatibility guards |
| 33 | 33 |
*/ |
| 34 | 34 |
#define _AMIRO_LLD_CFG_ |
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1 |
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0 |
|
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1
|
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0
|
|
| 37 | 37 |
|
| 38 | 38 |
/** |
| 39 | 39 |
* @brief Width of the apalTime_t data type. |
| ... | ... | |
| 41 | 41 |
* @details Possible values are 8, 16, 32, and 64 bits. |
| 42 | 42 |
* By definition time is represented at microsecond precision. |
| 43 | 43 |
*/ |
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32 |
|
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32
|
|
| 45 | 45 |
|
| 46 | 46 |
#endif /* ALLDCONF_H */ |
| 47 | 47 |
|
| modules/NUCLEO-L476RG/alldconf.h | ||
|---|---|---|
| 32 | 32 |
* compatibility guards |
| 33 | 33 |
*/ |
| 34 | 34 |
#define _AMIRO_LLD_CFG_ |
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1 |
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0 |
|
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1
|
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0
|
|
| 37 | 37 |
|
| 38 | 38 |
/** |
| 39 | 39 |
* @brief Width of the apalTime_t data type. |
| ... | ... | |
| 41 | 41 |
* @details Possible values are 8, 16, 32, and 64 bits. |
| 42 | 42 |
* By definition time is represented at microsecond precision. |
| 43 | 43 |
*/ |
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32 |
|
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32
|
|
| 45 | 45 |
|
| 46 | 46 |
#endif /* ALLDCONF_H */ |
| 47 | 47 |
|
| modules/PowerManagement_1-1/alldconf.h | ||
|---|---|---|
| 32 | 32 |
* compatibility guards |
| 33 | 33 |
*/ |
| 34 | 34 |
#define _AMIRO_LLD_CFG_ |
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1 |
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0 |
|
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1
|
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0
|
|
| 37 | 37 |
|
| 38 | 38 |
/** |
| 39 | 39 |
* @brief Width of the apalTime_t data type. |
| ... | ... | |
| 41 | 41 |
* @details Possible values are 8, 16, 32, and 64 bits. |
| 42 | 42 |
* By definition time is represented at microsecond precision. |
| 43 | 43 |
*/ |
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32 |
|
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32
|
|
| 45 | 45 |
|
| 46 | 46 |
// required to differentiate between various sensor rings |
| 47 | 47 |
#include <board.h> |
| ... | ... | |
| 49 | 49 |
/** |
| 50 | 50 |
* @brief Enable flag for the AT24C01BN-SH-B EEPROM. |
| 51 | 51 |
*/ |
| 52 |
#define AMIROLLD_CFG_AT24C01B 1 |
|
| 52 |
#define AMIROLLD_CFG_AT24C01B 1
|
|
| 53 | 53 |
|
| 54 | 54 |
/** |
| 55 | 55 |
* @brief Enable flag for the BQ24103A charger. |
| 56 | 56 |
*/ |
| 57 |
#define AMIROLLD_CFG_BQ241xx 1 |
|
| 57 |
#define AMIROLLD_CFG_BQ241xx 1
|
|
| 58 | 58 |
|
| 59 | 59 |
/** |
| 60 | 60 |
* @brief Enable flag for the BQ27500 fuel gauge. |
| 61 | 61 |
*/ |
| 62 |
#define AMIROLLD_CFG_BQ27500 1 |
|
| 62 |
#define AMIROLLD_CFG_BQ27500 1
|
|
| 63 | 63 |
|
| 64 | 64 |
/** |
| 65 | 65 |
* @brief Enable flag for the INA219 power monitor. |
| 66 | 66 |
*/ |
| 67 |
#define AMIROLLD_CFG_INA219 1 |
|
| 67 |
#define AMIROLLD_CFG_INA219 1
|
|
| 68 | 68 |
|
| 69 | 69 |
/** |
| 70 | 70 |
* @brief Enable flag for the status LED. |
| 71 | 71 |
*/ |
| 72 |
#define AMIROLLD_CFG_LED 1 |
|
| 72 |
#define AMIROLLD_CFG_LED 1
|
|
| 73 | 73 |
|
| 74 | 74 |
/** |
| 75 | 75 |
* @brief Enable flag for the PKLCS1212E4001 buzzer. |
| 76 | 76 |
*/ |
| 77 |
#define AMIROLLD_CFG_PKxxxExxx 1 |
|
| 78 |
#define PKxxxExxx_LLD_FREQUENCY_MIN 2000 |
|
| 79 |
#define PKxxxExxx_LLD_FREQUENCY_SPEC 4000 |
|
| 80 |
#define PKxxxExxx_LLD_FREQUENCY_MAX 6000 |
|
| 77 |
#define AMIROLLD_CFG_PKxxxExxx 1
|
|
| 78 |
#define PKxxxExxx_LLD_FREQUENCY_MIN 2000
|
|
| 79 |
#define PKxxxExxx_LLD_FREQUENCY_SPEC 4000
|
|
| 80 |
#define PKxxxExxx_LLD_FREQUENCY_MAX 6000
|
|
| 81 | 81 |
|
| 82 | 82 |
/** |
| 83 | 83 |
* @brief Enable flag for the TPS2051BDBV power switch. |
| 84 | 84 |
*/ |
| 85 |
#define AMIROLLD_CFG_TPS20xxB 1 |
|
| 85 |
#define AMIROLLD_CFG_TPS20xxB 1
|
|
| 86 | 86 |
|
| 87 | 87 |
/** |
| 88 | 88 |
* @brief Enable flag for the TPS62113 step-down converter. |
| 89 | 89 |
*/ |
| 90 |
#define AMIROLLD_CFG_TPS6211x 1 |
|
| 90 |
#define AMIROLLD_CFG_TPS6211x 1
|
|
| 91 | 91 |
|
| 92 | 92 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__) |
| 93 | 93 |
|
| 94 | 94 |
/** |
| 95 | 95 |
* @brief Enable flag for the MPR121 touch sensor. |
| 96 | 96 |
*/ |
| 97 |
#define AMIROLLD_CFG_MPR121 1 |
|
| 97 |
#define AMIROLLD_CFG_MPR121 1
|
|
| 98 | 98 |
|
| 99 | 99 |
/** |
| 100 | 100 |
* @brief Enable flag for the PCA9544A I2C multiplexer. |
| 101 | 101 |
*/ |
| 102 |
#define AMIROLLD_CFG_PCA9544A 1 |
|
| 102 |
#define AMIROLLD_CFG_PCA9544A 1
|
|
| 103 | 103 |
|
| 104 | 104 |
/** |
| 105 | 105 |
* @brief Enable flag for the VCNL4020 proximity sensor. |
| 106 | 106 |
*/ |
| 107 |
#define AMIROLLD_CFG_VCNL4020 1 |
|
| 107 |
#define AMIROLLD_CFG_VCNL4020 1
|
|
| 108 | 108 |
|
| 109 | 109 |
#endif /* BOARD_SENSORRING == BOARD_PROXIMITYSENSOR */ |
| 110 | 110 |
|
| ... | ... | |
| 113 | 113 |
/** |
| 114 | 114 |
* @brief Enable flag for the PCAL6524 GPIO extender |
| 115 | 115 |
*/ |
| 116 |
#define AMIROLLD_CFG_PCAL6524 1 |
|
| 116 |
#define AMIROLLD_CFG_PCAL6524 1
|
|
| 117 | 117 |
|
| 118 | 118 |
/** |
| 119 | 119 |
* @brief Enable flag for the AT42Q1050 touch sensor. |
| 120 | 120 |
*/ |
| 121 |
#define AMIROLLD_CFG_AT42QT1050 1 |
|
| 121 |
#define AMIROLLD_CFG_AT42QT1050 1
|
|
| 122 | 122 |
|
| 123 | 123 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X */ |
| 124 | 124 |
|
| ... | ... | |
| 127 | 127 |
/** |
| 128 | 128 |
* @brief Enable flag for the PCAL6524 GPIO extender |
| 129 | 129 |
*/ |
| 130 |
#define AMIROLLD_CFG_PCAL6524 1 |
|
| 130 |
#define AMIROLLD_CFG_PCAL6524 1
|
|
| 131 | 131 |
|
| 132 | 132 |
/** |
| 133 | 133 |
* @brief Enable flag for the AT42Q1050 touch sensor. |
| 134 | 134 |
*/ |
| 135 |
#define AMIROLLD_CFG_AT42QT1050 1 |
|
| 135 |
#define AMIROLLD_CFG_AT42QT1050 1
|
|
| 136 | 136 |
|
| 137 | 137 |
#endif /* BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X */ |
| 138 | 138 |
|
| modules/STM32F407G-DISC1/alldconf.h | ||
|---|---|---|
| 32 | 32 |
* compatibility guards |
| 33 | 33 |
*/ |
| 34 | 34 |
#define _AMIRO_LLD_CFG_ |
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1 |
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0 |
|
| 35 |
#define AMIRO_LLD_CFG_VERSION_MAJOR 1
|
|
| 36 |
#define AMIRO_LLD_CFG_VERSION_MINOR 0
|
|
| 37 | 37 |
|
| 38 | 38 |
/** |
| 39 | 39 |
* @brief Width of the apalTime_t data type. |
| ... | ... | |
| 41 | 41 |
* @details Possible values are 8, 16, 32, and 64 bits. |
| 42 | 42 |
* By definition time is represented at microsecond precision. |
| 43 | 43 |
*/ |
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32 |
|
| 44 |
#define AMIROLLD_CFG_TIME_SIZE 32
|
|
| 45 | 45 |
|
| 46 | 46 |
#endif /* ALLDCONF_H */ |
| 47 | 47 |
|
| periphery-lld/periphAL.c | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform. |
|
| 3 |
Copyright (C) 2016..2019 Thomas Schöpping et al. |
|
| 4 |
|
|
| 5 |
This program is free software: you can redistribute it and/or modify |
|
| 6 |
it under the terms of the GNU General Public License as published by |
|
| 7 |
the Free Software Foundation, either version 3 of the License, or |
|
| 8 |
(at your option) any later version. |
|
| 9 |
|
|
| 10 |
This program is distributed in the hope that it will be useful, |
|
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 13 |
GNU General Public License for more details. |
|
| 14 |
|
|
| 15 |
You should have received a copy of the GNU General Public License |
|
| 16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
#include <amiro-lld.h> |
|
| 20 |
|
|
| 21 |
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__) |
|
| 22 |
|
|
| 23 |
#include <amiroos.h> |
|
| 24 |
#include <chprintf.h> |
|
| 25 |
|
|
| 26 |
/** |
|
| 27 |
* @brief Assert function to check a given condition and print a message string. |
|
| 28 |
* |
|
| 29 |
* @param[in] c The condition to check. |
|
| 30 |
* @param[in] fmt Formatted message string to print. |
|
| 31 |
*/ |
|
| 32 |
void _apalDbgAssertMsg(const bool c, const char* fmt, ...) |
|
| 33 |
{
|
|
| 34 |
if (!c) {
|
|
| 35 |
va_list ap; |
|
| 36 |
|
|
| 37 |
va_start(ap, fmt); |
|
| 38 |
chvprintf((BaseSequentialStream*)&aos.iostream, fmt, ap); |
|
| 39 |
va_end(ap); |
|
| 40 |
chThdExit(MSG_RESET); |
|
| 41 |
} |
|
| 42 |
return; |
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
/** |
|
| 46 |
* @brief Printf function for messages printed only in debug builds. |
|
| 47 |
* |
|
| 48 |
* @param[in] fmt Formatted string to print. |
|
| 49 |
*/ |
|
| 50 |
void apalDbgPrintf(const char* fmt, ...) |
|
| 51 |
{
|
|
| 52 |
va_list ap; |
|
| 53 |
|
|
| 54 |
va_start(ap, fmt); |
|
| 55 |
chvprintf((BaseSequentialStream*)&aos.iostream, fmt, ap); |
|
| 56 |
va_end(ap); |
|
| 57 |
|
|
| 58 |
return; |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
#endif /* AMIROOS_CFG_DBG == true */ |
|
| periphery-lld/periphAL.h | ||
|---|---|---|
| 41 | 41 |
/* DEPENDENCIES */ |
| 42 | 42 |
/*============================================================================*/ |
| 43 | 43 |
|
| 44 |
#include <aosconf.h> |
|
| 44 | 45 |
#include <hal.h> |
| 45 | 46 |
|
| 46 | 47 |
/*============================================================================*/ |
| 48 |
/* DEBUG */ |
|
| 49 |
/*============================================================================*/ |
|
| 50 |
|
|
| 51 |
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__) |
|
| 52 |
|
|
| 53 |
#ifdef __cplusplus |
|
| 54 |
extern "C" {
|
|
| 55 |
#endif |
|
| 56 |
void _apalDbgAssertMsg(const bool c, const char* fmt, ...); |
|
| 57 |
void apalDbgPrintf(const char* fmt, ...); |
|
| 58 |
#ifdef __cplusplus |
|
| 59 |
} |
|
| 60 |
#endif |
|
| 61 |
|
|
| 62 |
/** |
|
| 63 |
* @brief Assert function to check a given condition. |
|
| 64 |
* |
|
| 65 |
* @param[in] c The condition to check. |
|
| 66 |
*/ |
|
| 67 |
#define apalDbgAssert(c) \ |
|
| 68 |
_apalDbgAssertMsg(c, "%s(%u): apalDbgAssert failed", __FILE__, __LINE__); |
|
| 69 |
|
|
| 70 |
#else /* AMIROOS_CFG_DBG != true */ |
|
| 71 |
|
|
| 72 |
#define apalDbgAssert(constition) |
|
| 73 |
#define apalDbgAssertMsg(condition, fmt, ...) |
|
| 74 |
#define apalDbgPrintf(fmt, ...) |
|
| 75 |
|
|
| 76 |
#endif /* AMIROOS_CFG_DBG */ |
|
| 77 |
|
|
| 78 |
/*============================================================================*/ |
|
| 47 | 79 |
/* GENERAL */ |
| 48 | 80 |
/*============================================================================*/ |
| 49 | 81 |
|
| ... | ... | |
| 55 | 87 |
static inline void usleep(apalTime_t us) |
| 56 | 88 |
{
|
| 57 | 89 |
// check if the specified time can be represented by the system |
| 58 |
chDbgCheck(us <= chTimeI2US(TIME_INFINITE));
|
|
| 90 |
apalDbgAssert(us <= chTimeI2US(TIME_INFINITE));
|
|
| 59 | 91 |
|
| 60 | 92 |
const sysinterval_t interval = chTimeUS2I(us); |
| 61 | 93 |
// TIME_IMMEDIATE makes no sense and would even cause system halt |
| ... | ... | |
| 89 | 121 |
*/ |
| 90 | 122 |
static inline apalExitStatus_t apalGpioRead(apalGpio_t* gpio, apalGpioState_t* const val) |
| 91 | 123 |
{
|
| 92 |
chDbgCheck(gpio != NULL);
|
|
| 93 |
chDbgCheck(val != NULL);
|
|
| 124 |
apalDbgAssert(gpio != NULL);
|
|
| 125 |
apalDbgAssert(val != NULL);
|
|
| 94 | 126 |
|
| 95 | 127 |
*val = (palReadPad(gpio->port, gpio->pad) == PAL_HIGH) ? APAL_GPIO_HIGH : APAL_GPIO_LOW; |
| 96 | 128 |
return APAL_STATUS_OK; |
| ... | ... | |
| 106 | 138 |
*/ |
| 107 | 139 |
static inline apalExitStatus_t apalGpioWrite(apalGpio_t* gpio, const apalGpioState_t val) |
| 108 | 140 |
{
|
| 109 |
chDbgCheck(gpio != NULL);
|
|
| 141 |
apalDbgAssert(gpio != NULL);
|
|
| 110 | 142 |
|
| 111 | 143 |
// palWritePad() is not guaranteed to be atomic, thus the scheduler is locked. |
| 112 | 144 |
syssts_t sysstatus = chSysGetStatusAndLockX(); |
| ... | ... | |
| 124 | 156 |
*/ |
| 125 | 157 |
static inline apalExitStatus_t apalGpioToggle(apalGpio_t* gpio) |
| 126 | 158 |
{
|
| 127 |
chDbgCheck(gpio != NULL);
|
|
| 159 |
apalDbgAssert(gpio != NULL);
|
|
| 128 | 160 |
|
| 129 | 161 |
// palWritePad() is not guaranteed to be atomic, thus the scheduler is locked. |
| 130 | 162 |
syssts_t sysstatus = chSysGetStatusAndLockX(); |
| ... | ... | |
| 143 | 175 |
*/ |
| 144 | 176 |
static inline apalExitStatus_t apalControlGpioGet(const apalControlGpio_t* const cgpio, apalControlGpioState_t* const val) |
| 145 | 177 |
{
|
| 146 |
chDbgCheck(cgpio != NULL);
|
|
| 147 |
chDbgCheck(cgpio->gpio != NULL);
|
|
| 148 |
chDbgCheck(val != NULL);
|
|
| 178 |
apalDbgAssert(cgpio != NULL);
|
|
| 179 |
apalDbgAssert(cgpio->gpio != NULL);
|
|
| 180 |
apalDbgAssert(val != NULL);
|
|
| 149 | 181 |
|
| 150 | 182 |
*val = ((palReadPad(cgpio->gpio->port, cgpio->gpio->pad) == PAL_HIGH) ^ (cgpio->meta.active == APAL_GPIO_ACTIVE_HIGH)) ? APAL_GPIO_OFF : APAL_GPIO_ON; |
| 151 | 183 |
return APAL_STATUS_OK; |
| ... | ... | |
| 161 | 193 |
*/ |
| 162 | 194 |
static inline apalExitStatus_t apalControlGpioSet(const apalControlGpio_t* const cgpio, const apalControlGpioState_t val) |
| 163 | 195 |
{
|
| 164 |
chDbgCheck(cgpio != NULL);
|
|
| 165 |
chDbgCheck(cgpio->gpio != NULL);
|
|
| 166 |
chDbgCheck(cgpio->meta.direction == APAL_GPIO_DIRECTION_OUTPUT || cgpio->meta.direction == APAL_GPIO_DIRECTION_BIDIRECTIONAL);
|
|
| 196 |
apalDbgAssert(cgpio != NULL);
|
|
| 197 |
apalDbgAssert(cgpio->gpio != NULL);
|
|
| 198 |
apalDbgAssert(cgpio->meta.direction == APAL_GPIO_DIRECTION_OUTPUT || cgpio->meta.direction == APAL_GPIO_DIRECTION_BIDIRECTIONAL);
|
|
| 167 | 199 |
|
| 168 | 200 |
// palWritePad() is not guaranteed to be atomic, thus the scheduler is locked. |
| 169 | 201 |
syssts_t sysstatus = chSysGetStatusAndLockX(); |
| ... | ... | |
| 180 | 212 |
(edge == APAL_GPIO_EDGE_FALLING) ? PAL_EVENT_MODE_FALLING_EDGE : \ |
| 181 | 213 |
(edge == APAL_GPIO_EDGE_BOTH) ? PAL_EVENT_MODE_BOTH_EDGES : 0) |
| 182 | 214 |
|
| 183 |
#endif |
|
| 215 |
#endif /* HAL_USE_PAL */
|
|
| 184 | 216 |
|
| 185 | 217 |
/*============================================================================*/ |
| 186 | 218 |
/* PWM */ |
| ... | ... | |
| 204 | 236 |
*/ |
| 205 | 237 |
static inline apalExitStatus_t apalPWMSet(apalPWMDriver_t* pwm, const apalPWMchannel_t channel, const apalPWMwidth_t width) |
| 206 | 238 |
{
|
| 207 |
chDbgCheck(pwm != NULL);
|
|
| 239 |
apalDbgAssert(pwm != NULL);
|
|
| 208 | 240 |
|
| 209 | 241 |
pwmEnableChannel(pwm, (pwmchannel_t)channel, pwm->period * ((float)width / (float)APAL_PWM_WIDTH_MAX) + 0.5f); |
| 210 | 242 |
return APAL_STATUS_OK; |
| ... | ... | |
| 220 | 252 |
*/ |
| 221 | 253 |
static inline apalExitStatus_t apalPWMGetFrequency(apalPWMDriver_t* pwm, apalPWMfrequency_t* const frequency) |
| 222 | 254 |
{
|
| 223 |
chDbgCheck(pwm != NULL);
|
|
| 224 |
chDbgCheck(frequency != NULL);
|
|
| 255 |
apalDbgAssert(pwm != NULL);
|
|
| 256 |
apalDbgAssert(frequency != NULL);
|
|
| 225 | 257 |
|
| 226 | 258 |
*frequency = pwm->config->frequency; |
| 227 | 259 |
return APAL_STATUS_OK; |
| ... | ... | |
| 237 | 269 |
*/ |
| 238 | 270 |
static inline apalExitStatus_t apalPWMGetPeriod(apalPWMDriver_t* pwm, apalPWMperiod_t* const period) |
| 239 | 271 |
{
|
| 240 |
chDbgCheck(pwm != NULL);
|
|
| 241 |
chDbgCheck(period != NULL);
|
|
| 272 |
apalDbgAssert(pwm != NULL);
|
|
| 273 |
apalDbgAssert(period != NULL);
|
|
| 242 | 274 |
|
| 243 | 275 |
*period = pwm->period; |
| 244 | 276 |
return APAL_STATUS_OK; |
| 245 | 277 |
} |
| 246 | 278 |
|
| 247 |
#endif |
|
| 279 |
#endif /* HAL_USE_PWM */
|
|
| 248 | 280 |
|
| 249 | 281 |
/*============================================================================*/ |
| 250 | 282 |
/* QEI */ |
| ... | ... | |
| 267 | 299 |
*/ |
| 268 | 300 |
static inline apalExitStatus_t apalQEIGetDirection(apalQEIDriver_t* qei, apalQEIDirection_t* const direction) |
| 269 | 301 |
{
|
| 270 |
chDbgCheck(qei != NULL);
|
|
| 271 |
chDbgCheck(direction != NULL);
|
|
| 302 |
apalDbgAssert(qei != NULL);
|
|
| 303 |
apalDbgAssert(direction != NULL);
|
|
| 272 | 304 |
|
| 273 | 305 |
*direction = (qei_lld_get_direction(qei)) ? APAL_QEI_DIRECTION_DOWN : APAL_QEI_DIRECTION_UP; |
| 274 | 306 |
|
| ... | ... | |
| 285 | 317 |
*/ |
| 286 | 318 |
static inline apalExitStatus_t apalQEIGetPosition(apalQEIDriver_t* qei, apalQEICount_t* const position) |
| 287 | 319 |
{
|
| 288 |
chDbgCheck(qei != NULL);
|
|
| 289 |
chDbgCheck(position != NULL);
|
|
| 320 |
apalDbgAssert(qei != NULL);
|
|
| 321 |
apalDbgAssert(position != NULL);
|
|
| 290 | 322 |
|
| 291 | 323 |
*position = qei_lld_get_position(qei); |
| 292 | 324 |
|
| ... | ... | |
| 303 | 335 |
*/ |
| 304 | 336 |
static inline apalExitStatus_t apalQEIGetRange(apalQEIDriver_t* qei, apalQEICount_t* const range) |
| 305 | 337 |
{
|
| 306 |
chDbgCheck(qei != NULL);
|
|
| 307 |
chDbgCheck(range != NULL);
|
|
| 338 |
apalDbgAssert(qei != NULL);
|
|
| 339 |
apalDbgAssert(range != NULL);
|
|
| 308 | 340 |
|
| 309 | 341 |
*range = qei_lld_get_range(qei); |
| 310 | 342 |
|
| 311 | 343 |
return APAL_STATUS_OK; |
| 312 | 344 |
} |
| 313 | 345 |
|
| 314 |
#endif |
|
| 346 |
#endif /* HAL_USE_QEI */
|
|
| 315 | 347 |
|
| 316 | 348 |
/*============================================================================*/ |
| 317 | 349 |
/* I2C */ |
| ... | ... | |
| 339 | 371 |
*/ |
| 340 | 372 |
static inline apalExitStatus_t apalI2CMasterTransmit(apalI2CDriver_t* i2cd, const apalI2Caddr_t addr, const uint8_t* const txbuf, const size_t txbytes, uint8_t* const rxbuf, const size_t rxbytes, const apalTime_t timeout) |
| 341 | 373 |
{
|
| 342 |
chDbgCheck(i2cd != NULL);
|
|
| 374 |
apalDbgAssert(i2cd != NULL);
|
|
| 343 | 375 |
|
| 344 | 376 |
#if (I2C_USE_MUTUAL_EXCLUSION == TRUE) |
| 345 | 377 |
// check whether the I2C driver was locked externally |
| ... | ... | |
| 401 | 433 |
*/ |
| 402 | 434 |
static inline apalExitStatus_t apalI2CMasterReceive(apalI2CDriver_t* i2cd, const apalI2Caddr_t addr, uint8_t* const rxbuf, const size_t rxbytes, const apalTime_t timeout) |
| 403 | 435 |
{
|
| 404 |
chDbgCheck(i2cd != NULL);
|
|
| 436 |
apalDbgAssert(i2cd != NULL);
|
|
| 405 | 437 |
|
| 406 | 438 |
#if (I2C_USE_MUTUAL_EXCLUSION == TRUE) |
| 407 | 439 |
// check whether the I2C driver was locked externally |
| ... | ... | |
| 450 | 482 |
} |
| 451 | 483 |
} |
| 452 | 484 |
|
| 453 |
#endif |
|
| 485 |
#endif /* HAL_USE_I2C */
|
|
| 454 | 486 |
|
| 455 | 487 |
/*============================================================================*/ |
| 456 | 488 |
/* SPI */ |
| ... | ... | |
| 475 | 507 |
*/ |
| 476 | 508 |
static inline apalExitStatus_t apalSPIExchange(apalSPIDriver_t* spid, const uint8_t* const txData , uint8_t* const rxData, const size_t length) |
| 477 | 509 |
{
|
| 478 |
chDbgCheck(spid != NULL);
|
|
| 510 |
apalDbgAssert(spid != NULL);
|
|
| 479 | 511 |
|
| 480 | 512 |
#if (SPI_USE_MUTUAL_EXCLUSION) |
| 481 | 513 |
// check whether the SPI driver was locked externally |
| ... | ... | |
| 509 | 541 |
*/ |
| 510 | 542 |
static inline apalExitStatus_t apalSPIReceive(apalSPIDriver_t* spid, uint8_t* const data, const size_t length) |
| 511 | 543 |
{
|
| 512 |
chDbgCheck(spid != NULL);
|
|
| 544 |
apalDbgAssert(spid != NULL);
|
|
| 513 | 545 |
|
| 514 | 546 |
#if (SPI_USE_MUTUAL_EXCLUSION) |
| 515 | 547 |
// check whether the SPI driver was locked externally |
| ... | ... | |
| 543 | 575 |
*/ |
| 544 | 576 |
static inline apalExitStatus_t apalSPITransmit(apalSPIDriver_t* spid, const uint8_t* const data, const size_t length) |
| 545 | 577 |
{
|
| 546 |
chDbgCheck(spid != NULL);
|
|
| 578 |
apalDbgAssert(spid != NULL);
|
|
| 547 | 579 |
|
| 548 | 580 |
#if (SPI_USE_MUTUAL_EXCLUSION) |
| 549 | 581 |
// check whether the SPI driver was locked externally |
| ... | ... | |
| 579 | 611 |
*/ |
| 580 | 612 |
static inline apalExitStatus_t apalSPITransmitAndReceive(apalSPIDriver_t* spid, const uint8_t* const txData , uint8_t* const rxData, const size_t txLength, const size_t rxLength) |
| 581 | 613 |
{
|
| 582 |
chDbgCheck(spid != NULL);
|
|
| 614 |
apalDbgAssert(spid != NULL);
|
|
| 583 | 615 |
|
| 584 | 616 |
#if (SPI_USE_MUTUAL_EXCLUSION) |
| 585 | 617 |
// check whether the SPI driver was locked externally |
| ... | ... | |
| 603 | 635 |
return APAL_STATUS_OK; |
| 604 | 636 |
} |
| 605 | 637 |
|
| 606 |
#endif |
|
| 607 |
|
|
| 608 |
/*============================================================================*/ |
|
| 609 |
/* DEBUG */ |
|
| 610 |
/*============================================================================*/ |
|
| 611 |
|
|
| 612 |
/** |
|
| 613 |
* @brief Assert function to check a given condition. |
|
| 614 |
* |
|
| 615 |
* @param[in] c The condition to check. |
|
| 616 |
*/ |
|
| 617 |
#define apalDbgAssert(c) chDbgAssert(c, "") |
|
| 618 |
|
|
| 619 |
|
|
| 620 |
/** |
|
| 621 |
* @brief Printf function for messages printed only in debug builds. |
|
| 622 |
* |
|
| 623 |
* @param[in] fmt Formatted string to print. |
|
| 624 |
*/ |
|
| 625 |
#if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__) |
|
| 626 |
#define apalDbgPrintf(fmt, ...) chprintf((BaseSequentialStream*)&aos.iostream, fmt, ##__VA_ARGS__) |
|
| 627 |
#else |
|
| 628 |
#define apalDbgPrintf(fmt, ...) { \
|
|
| 629 |
(void)(fmt); \ |
|
| 630 |
} |
|
| 631 |
#endif |
|
| 638 |
#endif /* HAL_USE_SPI */ |
|
| 632 | 639 |
|
| 633 | 640 |
#endif /* AMIROOS_PERIPHAL_H */ |
| periphery-lld/periphery-lld.mk | ||
|---|---|---|
| 33 | 33 |
$(PERIPHERYLLD_DIR:/=) |
| 34 | 34 |
|
| 35 | 35 |
# C sources |
| 36 |
PERIPHERYLLDCSRC = $(AMIROLLD_CSRC) |
|
| 36 |
PERIPHERYLLDCSRC = $(AMIROLLD_CSRC) \ |
|
| 37 |
$(PERIPHERYLLD_DIR)periphAL.c |
|
| 37 | 38 |
|
Also available in: Unified diff