Initial commit
mbed-dev-master/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_MODULE_UBLOX_ODIN_W2/sdk/ublox-odin-w2-drivers/cb_hw.h@0:bb348c97df44, 2020-09-16 (annotated)
- Committer:
- lypinator
- Date:
- Wed Sep 16 01:11:49 2020 +0000
- Revision:
- 0:bb348c97df44
Added PWM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lypinator | 0:bb348c97df44 | 1 | /*--------------------------------------------------------------------------- |
lypinator | 0:bb348c97df44 | 2 | * Copyright (c) 2016, u-blox Malmö, All Rights Reserved |
lypinator | 0:bb348c97df44 | 3 | * SPDX-License-Identifier: LicenseRef-PBL |
lypinator | 0:bb348c97df44 | 4 | * |
lypinator | 0:bb348c97df44 | 5 | * This file and the related binary are licensed under the |
lypinator | 0:bb348c97df44 | 6 | * Permissive Binary License, Version 1.0 (the "License"); |
lypinator | 0:bb348c97df44 | 7 | * you may not use these files except in compliance with the License. |
lypinator | 0:bb348c97df44 | 8 | * |
lypinator | 0:bb348c97df44 | 9 | * You may obtain a copy of the License here: |
lypinator | 0:bb348c97df44 | 10 | * LICENSE-permissive-binary-license-1.0.txt and at |
lypinator | 0:bb348c97df44 | 11 | * https://www.mbed.com/licenses/PBL-1.0 |
lypinator | 0:bb348c97df44 | 12 | * |
lypinator | 0:bb348c97df44 | 13 | * See the License for the specific language governing permissions and |
lypinator | 0:bb348c97df44 | 14 | * limitations under the License. |
lypinator | 0:bb348c97df44 | 15 | * |
lypinator | 0:bb348c97df44 | 16 | * Component: CB HW |
lypinator | 0:bb348c97df44 | 17 | * File : cb_hw.h |
lypinator | 0:bb348c97df44 | 18 | * |
lypinator | 0:bb348c97df44 | 19 | * Description: Setup of hardware. |
lypinator | 0:bb348c97df44 | 20 | * TODO clean up this interface.. |
lypinator | 0:bb348c97df44 | 21 | *-------------------------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 22 | |
lypinator | 0:bb348c97df44 | 23 | #ifndef _CB_HW_H_ |
lypinator | 0:bb348c97df44 | 24 | #define _CB_HW_H_ |
lypinator | 0:bb348c97df44 | 25 | |
lypinator | 0:bb348c97df44 | 26 | #include "cb_comdefs.h" |
lypinator | 0:bb348c97df44 | 27 | |
lypinator | 0:bb348c97df44 | 28 | #ifdef __cplusplus |
lypinator | 0:bb348c97df44 | 29 | extern "C" { |
lypinator | 0:bb348c97df44 | 30 | #endif |
lypinator | 0:bb348c97df44 | 31 | |
lypinator | 0:bb348c97df44 | 32 | /*=========================================================================== |
lypinator | 0:bb348c97df44 | 33 | * DEFINES |
lypinator | 0:bb348c97df44 | 34 | *=========================================================================*/ |
lypinator | 0:bb348c97df44 | 35 | #define cbHW_SECUREBOOT_SIGN_LENGTH 344 |
lypinator | 0:bb348c97df44 | 36 | #define cbHW_FW_NAME_MAX_LENGTH 22 |
lypinator | 0:bb348c97df44 | 37 | #define cbHW_FW_NAME_MIN_LENGTH 1 |
lypinator | 0:bb348c97df44 | 38 | #define cbHW_FW_FLAG_MAX_LENGTH 8 // 8 bit fields |
lypinator | 0:bb348c97df44 | 39 | #define cbHW_FW_FLAG_MIN_LENGTH 1 |
lypinator | 0:bb348c97df44 | 40 | #define cbHW_UNIQUE_ID_SIZE 12 |
lypinator | 0:bb348c97df44 | 41 | |
lypinator | 0:bb348c97df44 | 42 | typedef enum { |
lypinator | 0:bb348c97df44 | 43 | cbHW_PCB_VERSION_UNKNOWN, |
lypinator | 0:bb348c97df44 | 44 | cbHW_PCB_VERSION_1, |
lypinator | 0:bb348c97df44 | 45 | cbHW_PCB_VERSION_2, |
lypinator | 0:bb348c97df44 | 46 | cbHW_PCB_VERSION_3, |
lypinator | 0:bb348c97df44 | 47 | cbHW_PCB_VERSION_4, |
lypinator | 0:bb348c97df44 | 48 | cbHW_PCB_VERSION_5 |
lypinator | 0:bb348c97df44 | 49 | } cbHW_PCBVersion; |
lypinator | 0:bb348c97df44 | 50 | |
lypinator | 0:bb348c97df44 | 51 | typedef enum { |
lypinator | 0:bb348c97df44 | 52 | cbHW_RESET_REASON_UNKNOWN = 0, |
lypinator | 0:bb348c97df44 | 53 | cbHW_RESET_REASON_FW_UPDATE, |
lypinator | 0:bb348c97df44 | 54 | cbHW_RESET_REASON_PRODUCTION_MODE |
lypinator | 0:bb348c97df44 | 55 | } cbHW_ResetReason; |
lypinator | 0:bb348c97df44 | 56 | |
lypinator | 0:bb348c97df44 | 57 | typedef enum { |
lypinator | 0:bb348c97df44 | 58 | cbHW_FLOW_CONTROL_DISABLED = 0, |
lypinator | 0:bb348c97df44 | 59 | cbHW_FLOW_CONTROL_ENABLED |
lypinator | 0:bb348c97df44 | 60 | } cbHW_FlowControl; |
lypinator | 0:bb348c97df44 | 61 | |
lypinator | 0:bb348c97df44 | 62 | typedef enum { |
lypinator | 0:bb348c97df44 | 63 | cbHW_IRQ_HIGH = 2U, |
lypinator | 0:bb348c97df44 | 64 | cbHW_IRQ_MEDIUM = 3U, |
lypinator | 0:bb348c97df44 | 65 | cbHW_IRQ_DEFAULT = 5U, |
lypinator | 0:bb348c97df44 | 66 | cbHW_IRQ_LOW = 12U |
lypinator | 0:bb348c97df44 | 67 | } cbHW_PRIO_LVL; |
lypinator | 0:bb348c97df44 | 68 | |
lypinator | 0:bb348c97df44 | 69 | typedef enum { |
lypinator | 0:bb348c97df44 | 70 | cbHW_SYSTICK_DISABLED, |
lypinator | 0:bb348c97df44 | 71 | cbHW_SYSTICK_LOW_FREQ, |
lypinator | 0:bb348c97df44 | 72 | cbHW_SYSTICK_DEFAULT, |
lypinator | 0:bb348c97df44 | 73 | } cbHW_SysTickMode; |
lypinator | 0:bb348c97df44 | 74 | |
lypinator | 0:bb348c97df44 | 75 | typedef enum { |
lypinator | 0:bb348c97df44 | 76 | cbHW_HASH_MD5 |
lypinator | 0:bb348c97df44 | 77 | } cbHW_HashType; |
lypinator | 0:bb348c97df44 | 78 | /*=========================================================================== |
lypinator | 0:bb348c97df44 | 79 | * TYPES |
lypinator | 0:bb348c97df44 | 80 | *=========================================================================*/ |
lypinator | 0:bb348c97df44 | 81 | |
lypinator | 0:bb348c97df44 | 82 | typedef void (*cbHW_StopModeStatusEvt)(cb_boolean enable); |
lypinator | 0:bb348c97df44 | 83 | typedef void (*cbHW_SysTickCb)(void); |
lypinator | 0:bb348c97df44 | 84 | |
lypinator | 0:bb348c97df44 | 85 | /*=========================================================================== |
lypinator | 0:bb348c97df44 | 86 | * FUNCTIONS |
lypinator | 0:bb348c97df44 | 87 | *=========================================================================*/ |
lypinator | 0:bb348c97df44 | 88 | |
lypinator | 0:bb348c97df44 | 89 | void cbHW_init(void); |
lypinator | 0:bb348c97df44 | 90 | void cbHW_registerStopModeStatusEvt(cbHW_StopModeStatusEvt evt); |
lypinator | 0:bb348c97df44 | 91 | void cbHW_disableIrq(void); |
lypinator | 0:bb348c97df44 | 92 | void cbHW_enableIrq(void); |
lypinator | 0:bb348c97df44 | 93 | void cbHW_disableAllIrq(void); // Should not be used unless extremely critical |
lypinator | 0:bb348c97df44 | 94 | void cbHW_enableAllIrq(void); |
lypinator | 0:bb348c97df44 | 95 | void cbHW_enterSleepMode(void); |
lypinator | 0:bb348c97df44 | 96 | void cbHW_enterStopMode(void); |
lypinator | 0:bb348c97df44 | 97 | void cbHW_setWakeupEvent(void); |
lypinator | 0:bb348c97df44 | 98 | void cbHW_resetWakeupEvent(void); |
lypinator | 0:bb348c97df44 | 99 | void cbHW_setSysTickMode(cbHW_SysTickMode sysTickMode); |
lypinator | 0:bb348c97df44 | 100 | |
lypinator | 0:bb348c97df44 | 101 | /** |
lypinator | 0:bb348c97df44 | 102 | * Wait for specified amount of microseconds. May be interrupt dependent. |
lypinator | 0:bb348c97df44 | 103 | * @note Granularity may vary between systems. Will be at least systick based. |
lypinator | 0:bb348c97df44 | 104 | * The system may go to sleep during the delay. |
lypinator | 0:bb348c97df44 | 105 | * |
lypinator | 0:bb348c97df44 | 106 | * @param us Time to delay in microseconds. |
lypinator | 0:bb348c97df44 | 107 | */ |
lypinator | 0:bb348c97df44 | 108 | void cbHW_delay(cb_uint32 us); |
lypinator | 0:bb348c97df44 | 109 | |
lypinator | 0:bb348c97df44 | 110 | /** |
lypinator | 0:bb348c97df44 | 111 | * Puts the chip in NVIC soft reset |
lypinator | 0:bb348c97df44 | 112 | * @note: this does not reset any watchdog timer already enabled |
lypinator | 0:bb348c97df44 | 113 | */ |
lypinator | 0:bb348c97df44 | 114 | void cbHW_reset(void); |
lypinator | 0:bb348c97df44 | 115 | |
lypinator | 0:bb348c97df44 | 116 | /** |
lypinator | 0:bb348c97df44 | 117 | * Wait for specified amount of microseconds using a software loop. |
lypinator | 0:bb348c97df44 | 118 | * @note Granularity may vary between systems. |
lypinator | 0:bb348c97df44 | 119 | * The system will not go to sleep during the delay. |
lypinator | 0:bb348c97df44 | 120 | * |
lypinator | 0:bb348c97df44 | 121 | * @param us Time to delay in microseconds. |
lypinator | 0:bb348c97df44 | 122 | */ |
lypinator | 0:bb348c97df44 | 123 | void cbHW_softDelay(cb_uint32 us); |
lypinator | 0:bb348c97df44 | 124 | cb_boolean cbHW_sysFreqIsSupported(cb_uint32 sysFreq); |
lypinator | 0:bb348c97df44 | 125 | void cbHW_setSysFreq(cb_uint32 sysFreq); |
lypinator | 0:bb348c97df44 | 126 | cb_uint32 cbHW_getSysFreq(void); |
lypinator | 0:bb348c97df44 | 127 | void cbHW_writeBackupRegister(cb_uint32 registerId, cb_uint32 value); |
lypinator | 0:bb348c97df44 | 128 | cb_uint32 cbHW_readBackupRegister(cb_int32 registerId); |
lypinator | 0:bb348c97df44 | 129 | void cbHW_getHWId(cb_uint8 uid[cbHW_UNIQUE_ID_SIZE]); |
lypinator | 0:bb348c97df44 | 130 | cbHW_PCBVersion cbHW_getPCBVersion(void); |
lypinator | 0:bb348c97df44 | 131 | |
lypinator | 0:bb348c97df44 | 132 | /** |
lypinator | 0:bb348c97df44 | 133 | * Register a system tick callback. |
lypinator | 0:bb348c97df44 | 134 | * The system tick will be generated once evert millisecond. |
lypinator | 0:bb348c97df44 | 135 | * |
lypinator | 0:bb348c97df44 | 136 | * @param cb Callback function for the system tick timer. |
lypinator | 0:bb348c97df44 | 137 | */ |
lypinator | 0:bb348c97df44 | 138 | void cbHW_registerSysTickISRCallback(cbHW_SysTickCb cb); |
lypinator | 0:bb348c97df44 | 139 | |
lypinator | 0:bb348c97df44 | 140 | /** |
lypinator | 0:bb348c97df44 | 141 | * Get the current tick frequency for the @ref cbHW_getTicks tick counter. |
lypinator | 0:bb348c97df44 | 142 | * @note The frequency may be altered with different system clocks and power modes. |
lypinator | 0:bb348c97df44 | 143 | * |
lypinator | 0:bb348c97df44 | 144 | * @return The current tick frequency. |
lypinator | 0:bb348c97df44 | 145 | */ |
lypinator | 0:bb348c97df44 | 146 | cb_uint32 cbHW_getTickFrequency(void); |
lypinator | 0:bb348c97df44 | 147 | |
lypinator | 0:bb348c97df44 | 148 | /** |
lypinator | 0:bb348c97df44 | 149 | * Get the current value of the tick counter. |
lypinator | 0:bb348c97df44 | 150 | * Time base in @ref cbHW_getTickFrequency. |
lypinator | 0:bb348c97df44 | 151 | * @note The value may wrap. |
lypinator | 0:bb348c97df44 | 152 | * |
lypinator | 0:bb348c97df44 | 153 | * @return The current tick counter. |
lypinator | 0:bb348c97df44 | 154 | */ |
lypinator | 0:bb348c97df44 | 155 | cb_uint32 cbHW_getTicks(void); |
lypinator | 0:bb348c97df44 | 156 | |
lypinator | 0:bb348c97df44 | 157 | /** |
lypinator | 0:bb348c97df44 | 158 | * Enter forced boot mode. The bootloader will start in x-modem |
lypinator | 0:bb348c97df44 | 159 | * mode and emit CCCC.. to notify that it is ready to receive |
lypinator | 0:bb348c97df44 | 160 | * a new fw. |
lypinator | 0:bb348c97df44 | 161 | * This function will return and boot mode will be entered |
lypinator | 0:bb348c97df44 | 162 | * after a device specific timeout. |
lypinator | 0:bb348c97df44 | 163 | * @param address x-modem file download start address |
lypinator | 0:bb348c97df44 | 164 | * @param baudrate x-modem download buadrate |
lypinator | 0:bb348c97df44 | 165 | * @return None |
lypinator | 0:bb348c97df44 | 166 | */ |
lypinator | 0:bb348c97df44 | 167 | void cbHW_forceBoot(cb_uint32 address, cb_uint32 baudrate); |
lypinator | 0:bb348c97df44 | 168 | |
lypinator | 0:bb348c97df44 | 169 | /** |
lypinator | 0:bb348c97df44 | 170 | * Enter forced boot mode. The bootloader will start in x-modem |
lypinator | 0:bb348c97df44 | 171 | * mode and emit CCCC.. to notify that it is ready to receive |
lypinator | 0:bb348c97df44 | 172 | * a new fw. |
lypinator | 0:bb348c97df44 | 173 | * This function will return and boot mode will be entered |
lypinator | 0:bb348c97df44 | 174 | * after a device specific timeout. |
lypinator | 0:bb348c97df44 | 175 | * @param address x-modem file download start address |
lypinator | 0:bb348c97df44 | 176 | * @param baudrate x-modem download buadrate |
lypinator | 0:bb348c97df44 | 177 | * @param fwId firmware id |
lypinator | 0:bb348c97df44 | 178 | * @param fwSize firmware file size |
lypinator | 0:bb348c97df44 | 179 | * @param fwSignature firmware signature |
lypinator | 0:bb348c97df44 | 180 | * @param fwName firmware name |
lypinator | 0:bb348c97df44 | 181 | * @param fwFlags firmware flags |
lypinator | 0:bb348c97df44 | 182 | * @return None |
lypinator | 0:bb348c97df44 | 183 | */ |
lypinator | 0:bb348c97df44 | 184 | void cbHW_forceBootSecure( |
lypinator | 0:bb348c97df44 | 185 | cb_uint32 address, |
lypinator | 0:bb348c97df44 | 186 | cb_uint32 baudrate, |
lypinator | 0:bb348c97df44 | 187 | cb_uint32 fwId, |
lypinator | 0:bb348c97df44 | 188 | cb_uint32 fwSize, |
lypinator | 0:bb348c97df44 | 189 | cb_char* fwSignature, |
lypinator | 0:bb348c97df44 | 190 | cb_char* fwName, |
lypinator | 0:bb348c97df44 | 191 | cb_char* fwFlags); |
lypinator | 0:bb348c97df44 | 192 | |
lypinator | 0:bb348c97df44 | 193 | /** |
lypinator | 0:bb348c97df44 | 194 | * Cancel entry into boot mode. The user canceled entry |
lypinator | 0:bb348c97df44 | 195 | * into forced boot mode. |
lypinator | 0:bb348c97df44 | 196 | * This function will clean up the RTC memory that was |
lypinator | 0:bb348c97df44 | 197 | * configured for a forced boot operation. Use this function |
lypinator | 0:bb348c97df44 | 198 | * for both cbHW_forceBootSecure and cbHW_forceBoot |
lypinator | 0:bb348c97df44 | 199 | * @return None |
lypinator | 0:bb348c97df44 | 200 | */ |
lypinator | 0:bb348c97df44 | 201 | void cbHW_cancelforceBoot(void); |
lypinator | 0:bb348c97df44 | 202 | |
lypinator | 0:bb348c97df44 | 203 | void cbHW_enterProductionMode(cbHW_FlowControl flowControl); |
lypinator | 0:bb348c97df44 | 204 | cbHW_ResetReason cbHW_resetReason(void); |
lypinator | 0:bb348c97df44 | 205 | cbHW_FlowControl cbHW_flowControl(void); |
lypinator | 0:bb348c97df44 | 206 | |
lypinator | 0:bb348c97df44 | 207 | /** |
lypinator | 0:bb348c97df44 | 208 | * Calculates a hash over a dataset. |
lypinator | 0:bb348c97df44 | 209 | * @param type: type of hashing, MD5 for now |
lypinator | 0:bb348c97df44 | 210 | * @param pInData: pointer to Data over which the hashing should be done |
lypinator | 0:bb348c97df44 | 211 | * @param indataSize: size of data buffer. |
lypinator | 0:bb348c97df44 | 212 | * @param pOutData: pointer to result data |
lypinator | 0:bb348c97df44 | 213 | * @return None |
lypinator | 0:bb348c97df44 | 214 | */ |
lypinator | 0:bb348c97df44 | 215 | void cbHW_hash(cbHW_HashType type, const cb_uint8* pInData,cb_uint32 indataSize, cb_uint8* pOutData); |
lypinator | 0:bb348c97df44 | 216 | |
lypinator | 0:bb348c97df44 | 217 | #ifdef __cplusplus |
lypinator | 0:bb348c97df44 | 218 | } |
lypinator | 0:bb348c97df44 | 219 | #endif |
lypinator | 0:bb348c97df44 | 220 | |
lypinator | 0:bb348c97df44 | 221 | #endif |
lypinator | 0:bb348c97df44 | 222 |