|
| 1 | +/****************************************************************************** |
| 2 | + * @file luosHAL |
| 3 | + * @brief Luos Hardware Abstration Layer. Describe Low layer fonction |
| 4 | + * @Family x86/Linux/Mac |
| 5 | + * @author Luos |
| 6 | + * @version 0.0.0 |
| 7 | + ******************************************************************************/ |
| 8 | +#include "luos_hal.h" |
| 9 | + |
| 10 | +#include <stdio.h> |
| 11 | +#include <time.h> |
| 12 | +#include <stdbool.h> |
| 13 | +#include <string.h> |
| 14 | + |
| 15 | +/******************************************************************************* |
| 16 | + * Function |
| 17 | + ******************************************************************************/ |
| 18 | +static void LuosHAL_SystickInit(void); |
| 19 | +static void LuosHAL_FlashInit(void); |
| 20 | +static void LuosHAL_FlashEraseLuosMemoryInfo(void); |
| 21 | + |
| 22 | +/////////////////////////Luos Library Needed function/////////////////////////// |
| 23 | + |
| 24 | +/****************************************************************************** |
| 25 | + * @brief Luos HAL general initialisation |
| 26 | + * @param None |
| 27 | + * @return None |
| 28 | + ******************************************************************************/ |
| 29 | +void LuosHAL_Init(void) |
| 30 | +{ |
| 31 | + { |
| 32 | + // Systick Initialization |
| 33 | + LuosHAL_SystickInit(); |
| 34 | + |
| 35 | + // Flash Initialization |
| 36 | + LuosHAL_FlashInit(); |
| 37 | + |
| 38 | + // start timestamp |
| 39 | + LuosHAL_StartTimestamp(); |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +/****************************************************************************** |
| 44 | + * @brief Luos HAL general disable IRQ |
| 45 | + * @param None |
| 46 | + * @return None |
| 47 | + ******************************************************************************/ |
| 48 | +void LuosHAL_SetIrqState(uint8_t Enable) |
| 49 | +{ |
| 50 | +} |
| 51 | + |
| 52 | +/****************************************************************************** |
| 53 | + * @brief Luos HAL general systick tick at 1ms initialize |
| 54 | + * @param None |
| 55 | + * @return tick Counter |
| 56 | + ******************************************************************************/ |
| 57 | +static void LuosHAL_SystickInit(void) |
| 58 | +{ |
| 59 | +} |
| 60 | + |
| 61 | +/****************************************************************************** |
| 62 | + * @brief Luos HAL general systick tick at 1ms |
| 63 | + * @param None |
| 64 | + * @return tick Counter |
| 65 | + ******************************************************************************/ |
| 66 | +uint32_t LuosHAL_GetSystick(void) |
| 67 | +{ |
| 68 | + clock_t tick = clock(); |
| 69 | + return tick; // return tick |
| 70 | +} |
| 71 | + |
| 72 | +/****************************************************************************** |
| 73 | + * @brief Luos GetTimestamp |
| 74 | + * @param None |
| 75 | + * @return uint64_t |
| 76 | + ******************************************************************************/ |
| 77 | +uint64_t LuosHAL_GetTimestamp(void) |
| 78 | +{ |
| 79 | + return (LuosHAL_GetSystick() * 1000); |
| 80 | +} |
| 81 | + |
| 82 | +/****************************************************************************** |
| 83 | + * @brief Luos start Timestamp |
| 84 | + * @param None |
| 85 | + * @return None |
| 86 | + ******************************************************************************/ |
| 87 | +void LuosHAL_StartTimestamp(void) |
| 88 | +{ |
| 89 | +} |
| 90 | + |
| 91 | +/****************************************************************************** |
| 92 | + * @brief Luos stop Timestamp |
| 93 | + * @param None |
| 94 | + * @return None |
| 95 | + ******************************************************************************/ |
| 96 | +void LuosHAL_StopTimestamp(void) |
| 97 | +{ |
| 98 | +} |
| 99 | + |
| 100 | +/****************************************************************************** |
| 101 | + * @brief Flash Initialisation |
| 102 | + * @param None |
| 103 | + * @return None |
| 104 | + ******************************************************************************/ |
| 105 | +static void LuosHAL_FlashInit(void) |
| 106 | +{ |
| 107 | + for (uint16_t i = 0; i < FLASH_PAGE_NUMBER; i++) |
| 108 | + { |
| 109 | + for (uint16_t j = 0; j < FLASH_PAGE_SIZE; j++) |
| 110 | + { |
| 111 | + stub_flash_x86[i][j] = 0; |
| 112 | + } |
| 113 | + } |
| 114 | +} |
| 115 | + |
| 116 | +/****************************************************************************** |
| 117 | + * @brief Erase flash page where Luos keep permanente information |
| 118 | + * @param None |
| 119 | + * @return None |
| 120 | + ******************************************************************************/ |
| 121 | +static void LuosHAL_FlashEraseLuosMemoryInfo(void) |
| 122 | +{ |
| 123 | +} |
| 124 | + |
| 125 | +/****************************************************************************** |
| 126 | + * @brief Write flash page where Luos keep permanente information |
| 127 | + * @param Address page / size to write / pointer to data to write |
| 128 | + * @return |
| 129 | + ******************************************************************************/ |
| 130 | +void LuosHAL_FlashWriteLuosMemoryInfo(uint32_t addr, uint16_t size, uint8_t *data) |
| 131 | +{ |
| 132 | +} |
| 133 | + |
| 134 | +/****************************************************************************** |
| 135 | + * @brief read information from page where Luos keep permanente information |
| 136 | + * @param Address info / size to read / pointer callback data to read |
| 137 | + * @return |
| 138 | + ******************************************************************************/ |
| 139 | +void LuosHAL_FlashReadLuosMemoryInfo(uint32_t addr, uint16_t size, uint8_t *data) |
| 140 | +{ |
| 141 | + memset(data, 0xFF, size); |
| 142 | +} |
| 143 | + |
| 144 | +/****************************************************************************** |
| 145 | + * @brief Set boot mode in shared flash memory |
| 146 | + * @param |
| 147 | + * @return |
| 148 | + ******************************************************************************/ |
| 149 | +void LuosHAL_SetMode(uint8_t mode) |
| 150 | +{ |
| 151 | +} |
| 152 | + |
| 153 | +/****************************************************************************** |
| 154 | + * @brief Save node ID in shared flash memory |
| 155 | + * @param Address, node_id |
| 156 | + * @return |
| 157 | + ******************************************************************************/ |
| 158 | +void LuosHAL_SaveNodeID(uint16_t node_id) |
| 159 | +{ |
| 160 | +} |
| 161 | + |
| 162 | +/****************************************************************************** |
| 163 | + * @brief software reboot the microprocessor |
| 164 | + * @param |
| 165 | + * @return |
| 166 | + ******************************************************************************/ |
| 167 | +void LuosHAL_Reboot(void) |
| 168 | +{ |
| 169 | +} |
| 170 | + |
| 171 | +#ifdef BOOTLOADER_CONFIG |
| 172 | +/****************************************************************************** |
| 173 | + * @brief DeInit Bootloader peripherals |
| 174 | + * @param |
| 175 | + * @return |
| 176 | + ******************************************************************************/ |
| 177 | +void LuosHAL_DeInit(void) |
| 178 | +{ |
| 179 | +} |
| 180 | + |
| 181 | +/****************************************************************************** |
| 182 | + * @brief DeInit Bootloader peripherals |
| 183 | + * @param |
| 184 | + * @return |
| 185 | + ******************************************************************************/ |
| 186 | +typedef void (*pFunction)(void); /*!< Function pointer definition */ |
| 187 | + |
| 188 | +void LuosHAL_JumpToApp(uint32_t app_addr) |
| 189 | +{ |
| 190 | +} |
| 191 | + |
| 192 | +/****************************************************************************** |
| 193 | + * @brief Return bootloader mode saved in flash |
| 194 | + * @param |
| 195 | + * @return |
| 196 | + ******************************************************************************/ |
| 197 | +uint8_t LuosHAL_GetMode(void) |
| 198 | +{ |
| 199 | +} |
| 200 | + |
| 201 | +/****************************************************************************** |
| 202 | + * @brief Get node id saved in flash memory |
| 203 | + * @param Address |
| 204 | + * @return node_id |
| 205 | + ******************************************************************************/ |
| 206 | +uint16_t LuosHAL_GetNodeID(void) |
| 207 | +{ |
| 208 | +} |
| 209 | + |
| 210 | +/****************************************************************************** |
| 211 | + * @brief erase sectors in flash memory |
| 212 | + * @param Address, size |
| 213 | + * @return |
| 214 | + ******************************************************************************/ |
| 215 | +void LuosHAL_EraseMemory(uint32_t address, uint16_t size) |
| 216 | +{ |
| 217 | +} |
| 218 | + |
| 219 | +/****************************************************************************** |
| 220 | + * @brief Save binary data in shared flash memory |
| 221 | + * @param Address, size, data[] |
| 222 | + * @return |
| 223 | + ******************************************************************************/ |
| 224 | +void LuosHAL_ProgramFlash(uint32_t address, uint16_t size, uint8_t *data) |
| 225 | +{ |
| 226 | +} |
| 227 | +#endif |
0 commit comments