├── .gdbinit ├── .gitignore ├── .vscode ├── c_cpp_properties.json └── settings.json ├── QEMU.md ├── README.md ├── STM32L151XBA_FLASH.ld ├── WINDOWS.md ├── instruction.png ├── lib ├── crypto │ ├── aes.c │ ├── aes.h │ ├── cmac.c │ └── cmac.h ├── obme280 │ ├── OBME280.c │ └── OBME280.h ├── radio │ ├── radio.h │ └── sx1276 │ │ ├── sx1276.c │ │ ├── sx1276.h │ │ ├── sx1276Regs-Fsk.h │ │ └── sx1276Regs-LoRa.h ├── readme.txt ├── system_utils │ ├── adc.h │ ├── delay.h │ ├── eeprom.h │ ├── fifo.h │ ├── gpio.h │ ├── gps.h │ ├── i2c.h │ ├── serial.h │ ├── spi.h │ ├── src │ │ ├── adc.c │ │ ├── delay.c │ │ ├── eeprom.c │ │ ├── fifo.c │ │ ├── gpio.c │ │ ├── gps.c │ │ ├── i2c.c │ │ ├── timer.c │ │ └── uart.c │ ├── timer.h │ └── uart.h └── wakeup │ ├── WakeUp.h │ └── WakeUp_STM_RTC.cpp ├── mapper.md ├── parallell_run.md ├── platformio.ini ├── rak811.json ├── src ├── Commissioning.h ├── RAK811BreakBoard │ ├── BME680-board.c │ ├── BME680-board.h │ ├── BME680-selftest.c │ ├── BME680-selftest.h │ ├── adc-board.c │ ├── adc-board.h │ ├── board.c │ ├── board.h │ ├── cmsis │ │ ├── stm32l151xb.sav │ │ ├── stm32l151xba.h │ │ ├── stm32l1xx.sav │ │ ├── system_stm32l1xx.c │ │ └── system_stm32l1xx.h │ ├── eeprom-board.c │ ├── eeprom-board.h │ ├── gpio-board.c │ ├── gpio-board.h │ ├── gps-board.c │ ├── gps-board.h │ ├── i2c-board.c │ ├── i2c-board.h │ ├── pinName-board.h │ ├── pinName-ioe.h │ ├── rtc-board.c │ ├── rtc-board.h │ ├── rw_sys.h │ ├── spi-board.c │ ├── spi-board.h │ ├── sx1276-board.c │ ├── sx1276-board.h │ ├── uart-board.c │ ├── uart-board.h │ ├── uart-usb-board.c │ └── uart-usb-board.h ├── boards │ ├── RAK811BreakBoard │ │ └── cmsis │ │ │ └── arm-gcc │ │ │ ├── STM32L151XBA_FLASH.ld │ │ │ └── STM32L151XB_FLASH.ld │ └── mcu │ │ └── stm32 │ │ ├── RTE_Components.h │ │ ├── STM32L1xx_HAL_Driver │ │ ├── Inc │ │ │ ├── Legacy │ │ │ │ └── stm32_hal_legacy.h │ │ │ ├── mxconstants.h │ │ │ ├── stm32_assert_template.h │ │ │ ├── stm32l1xx_hal.h │ │ │ ├── stm32l1xx_hal_adc.h │ │ │ ├── stm32l1xx_hal_adc_ex.h │ │ │ ├── stm32l1xx_hal_comp.h │ │ │ ├── stm32l1xx_hal_comp_ex.h │ │ │ ├── stm32l1xx_hal_conf.h │ │ │ ├── stm32l1xx_hal_conf_template.h │ │ │ ├── stm32l1xx_hal_cortex.h │ │ │ ├── stm32l1xx_hal_crc.h │ │ │ ├── stm32l1xx_hal_cryp.h │ │ │ ├── stm32l1xx_hal_cryp_ex.h │ │ │ ├── stm32l1xx_hal_dac.h │ │ │ ├── stm32l1xx_hal_dac_ex.h │ │ │ ├── stm32l1xx_hal_def.h │ │ │ ├── stm32l1xx_hal_dma.h │ │ │ ├── stm32l1xx_hal_dma_ex.h │ │ │ ├── stm32l1xx_hal_flash.h │ │ │ ├── stm32l1xx_hal_flash_ex.h │ │ │ ├── stm32l1xx_hal_flash_ramfunc.h │ │ │ ├── stm32l1xx_hal_gpio.h │ │ │ ├── stm32l1xx_hal_gpio_ex.h │ │ │ ├── stm32l1xx_hal_i2c.h │ │ │ ├── stm32l1xx_hal_i2s.h │ │ │ ├── stm32l1xx_hal_irda.h │ │ │ ├── stm32l1xx_hal_iwdg.h │ │ │ ├── stm32l1xx_hal_lcd.h │ │ │ ├── stm32l1xx_hal_nor.h │ │ │ ├── stm32l1xx_hal_opamp.h │ │ │ ├── stm32l1xx_hal_opamp_ex.h │ │ │ ├── stm32l1xx_hal_pcd.h │ │ │ ├── stm32l1xx_hal_pcd_ex.h │ │ │ ├── stm32l1xx_hal_pwr.h │ │ │ ├── stm32l1xx_hal_pwr_ex.h │ │ │ ├── stm32l1xx_hal_rcc.h │ │ │ ├── stm32l1xx_hal_rcc_ex.h │ │ │ ├── stm32l1xx_hal_rtc.h │ │ │ ├── stm32l1xx_hal_rtc_ex.h │ │ │ ├── stm32l1xx_hal_sd.h │ │ │ ├── stm32l1xx_hal_smartcard.h │ │ │ ├── stm32l1xx_hal_spi.h │ │ │ ├── stm32l1xx_hal_spi_ex.h │ │ │ ├── stm32l1xx_hal_sram.h │ │ │ ├── stm32l1xx_hal_tim.h │ │ │ ├── stm32l1xx_hal_tim_ex.h │ │ │ ├── stm32l1xx_hal_uart.h │ │ │ ├── stm32l1xx_hal_usart.h │ │ │ ├── stm32l1xx_hal_wwdg.h │ │ │ ├── stm32l1xx_ll_adc.h │ │ │ ├── stm32l1xx_ll_bus.h │ │ │ ├── stm32l1xx_ll_comp.h │ │ │ ├── stm32l1xx_ll_cortex.h │ │ │ ├── stm32l1xx_ll_crc.h │ │ │ ├── stm32l1xx_ll_dac.h │ │ │ ├── stm32l1xx_ll_dma.h │ │ │ ├── stm32l1xx_ll_exti.h │ │ │ ├── stm32l1xx_ll_fsmc.h │ │ │ ├── stm32l1xx_ll_gpio.h │ │ │ ├── stm32l1xx_ll_i2c.h │ │ │ ├── stm32l1xx_ll_iwdg.h │ │ │ ├── stm32l1xx_ll_opamp.h │ │ │ ├── stm32l1xx_ll_pwr.h │ │ │ ├── stm32l1xx_ll_rcc.h │ │ │ ├── stm32l1xx_ll_rtc.h │ │ │ ├── stm32l1xx_ll_sdmmc.h │ │ │ ├── stm32l1xx_ll_spi.h │ │ │ ├── stm32l1xx_ll_system.h │ │ │ ├── stm32l1xx_ll_tim.h │ │ │ ├── stm32l1xx_ll_usart.h │ │ │ ├── stm32l1xx_ll_utils.h │ │ │ └── stm32l1xx_ll_wwdg.h │ │ └── Src │ │ │ ├── stm32l1xx_hal.c │ │ │ ├── stm32l1xx_hal_adc.c │ │ │ ├── stm32l1xx_hal_adc_ex.c │ │ │ ├── stm32l1xx_hal_comp.c │ │ │ ├── stm32l1xx_hal_cortex.c │ │ │ ├── stm32l1xx_hal_crc.c │ │ │ ├── stm32l1xx_hal_cryp.c │ │ │ ├── stm32l1xx_hal_cryp_ex.c │ │ │ ├── stm32l1xx_hal_dac.c │ │ │ ├── stm32l1xx_hal_dac_ex.c │ │ │ ├── stm32l1xx_hal_dma.c │ │ │ ├── stm32l1xx_hal_flash.c │ │ │ ├── stm32l1xx_hal_flash_ex.c │ │ │ ├── stm32l1xx_hal_flash_ramfunc.c │ │ │ ├── stm32l1xx_hal_gpio.c │ │ │ ├── stm32l1xx_hal_i2c.c │ │ │ ├── stm32l1xx_hal_i2s.c │ │ │ ├── stm32l1xx_hal_irda.c │ │ │ ├── stm32l1xx_hal_iwdg.c │ │ │ ├── stm32l1xx_hal_lcd.c │ │ │ ├── stm32l1xx_hal_msp_template.c │ │ │ ├── stm32l1xx_hal_nor.c │ │ │ ├── stm32l1xx_hal_opamp.c │ │ │ ├── stm32l1xx_hal_opamp_ex.c │ │ │ ├── stm32l1xx_hal_pcd.c │ │ │ ├── stm32l1xx_hal_pcd_ex.c │ │ │ ├── stm32l1xx_hal_pwr.c │ │ │ ├── stm32l1xx_hal_pwr_ex.c │ │ │ ├── stm32l1xx_hal_rcc.c │ │ │ ├── stm32l1xx_hal_rcc_ex.c │ │ │ ├── stm32l1xx_hal_rtc.c │ │ │ ├── stm32l1xx_hal_rtc_ex.c │ │ │ ├── stm32l1xx_hal_sd.c │ │ │ ├── stm32l1xx_hal_smartcard.c │ │ │ ├── stm32l1xx_hal_spi.c │ │ │ ├── stm32l1xx_hal_spi_ex.c │ │ │ ├── stm32l1xx_hal_sram.c │ │ │ ├── stm32l1xx_hal_tim.c │ │ │ ├── stm32l1xx_hal_tim_ex.c │ │ │ ├── stm32l1xx_hal_uart.c │ │ │ ├── stm32l1xx_hal_usart.c │ │ │ ├── stm32l1xx_hal_wwdg.c │ │ │ ├── stm32l1xx_ll_adc.c │ │ │ ├── stm32l1xx_ll_comp.c │ │ │ ├── stm32l1xx_ll_crc.c │ │ │ ├── stm32l1xx_ll_dac.c │ │ │ ├── stm32l1xx_ll_dma.c │ │ │ ├── stm32l1xx_ll_exti.c │ │ │ ├── stm32l1xx_ll_fsmc.c │ │ │ ├── stm32l1xx_ll_gpio.c │ │ │ ├── stm32l1xx_ll_i2c.c │ │ │ ├── stm32l1xx_ll_opamp.c │ │ │ ├── stm32l1xx_ll_pwr.c │ │ │ ├── stm32l1xx_ll_rcc.c │ │ │ ├── stm32l1xx_ll_rtc.c │ │ │ ├── stm32l1xx_ll_sdmmc.c │ │ │ ├── stm32l1xx_ll_spi.c │ │ │ ├── stm32l1xx_ll_tim.c │ │ │ ├── stm32l1xx_ll_usart.c │ │ │ └── stm32l1xx_ll_utils.c │ │ ├── STM32_USB_Device_Library │ │ ├── Class │ │ │ ├── CDC │ │ │ │ ├── Inc │ │ │ │ │ └── usbd_cdc.h │ │ │ │ └── Src │ │ │ │ │ └── usbd_cdc.c │ │ │ └── DFU │ │ │ │ ├── Inc │ │ │ │ └── usbd_dfu.h │ │ │ │ └── Src │ │ │ │ └── usbd_dfu.c │ │ └── Core │ │ │ ├── Inc │ │ │ ├── usbd_core.h │ │ │ ├── usbd_ctlreq.h │ │ │ ├── usbd_def.h │ │ │ └── usbd_ioreq.h │ │ │ └── Src │ │ │ ├── usbd_core.c │ │ │ ├── usbd_ctlreq.c │ │ │ └── usbd_ioreq.c │ │ ├── cmsis │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.h │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armcc_V6.h │ │ ├── cmsis_gcc.h │ │ ├── core_cm0.h │ │ ├── core_cm0plus.h │ │ ├── core_cm3.h │ │ ├── core_cm4.h │ │ ├── core_cm7.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── core_cmSimd.h │ │ ├── core_sc000.h │ │ └── core_sc300.h │ │ ├── sysIrqHandlers.c │ │ ├── utilities.c │ │ └── utilities.h ├── mac │ ├── LoRaMac.c │ ├── LoRaMac.h │ ├── LoRaMacCrypto.c │ ├── LoRaMacCrypto.h │ ├── LoRaMacTest.h │ └── region │ │ ├── Region.c │ │ ├── Region.h │ │ ├── RegionAS923.c │ │ ├── RegionAS923.h │ │ ├── RegionAU915.c │ │ ├── RegionAU915.h │ │ ├── RegionCN470.c │ │ ├── RegionCN470.h │ │ ├── RegionCN779.c │ │ ├── RegionCN779.h │ │ ├── RegionCommon.c │ │ ├── RegionCommon.h │ │ ├── RegionEU433.c │ │ ├── RegionEU433.h │ │ ├── RegionEU868.c │ │ ├── RegionEU868.h │ │ ├── RegionIN865.c │ │ ├── RegionIN865.h │ │ ├── RegionKR920.c │ │ ├── RegionKR920.h │ │ ├── RegionUS915-Hybrid.c │ │ ├── RegionUS915-Hybrid.h │ │ ├── RegionUS915.c │ │ └── RegionUS915.h ├── main.c ├── peripherals │ ├── BME680.c │ ├── BME680.h │ ├── BME680_defs.h │ ├── gpio-ioe.c │ ├── gpio-ioe.h │ ├── lis3dh.c │ ├── lis3dh.h │ ├── lis3dh.h~RF65283d0.TMP │ ├── mag3110.c │ ├── mag3110.h │ ├── mma8451.c │ ├── mma8451.h │ ├── mpl3115.c │ ├── mpl3115.h │ ├── pam7q.c │ ├── pam7q.h │ ├── selector.c │ ├── selector.h │ ├── sx1509.c │ ├── sx1509.h │ ├── sx9500.c │ └── sx9500.h ├── printf.c ├── stm32l0xx.h ├── stm32l0xx_hal_conf.h ├── swo.c ├── swo.h ├── test_wakeup.cpp └── usb │ ├── cdc │ ├── inc │ │ ├── usbd_cdc_if.h │ │ ├── usbd_conf.h │ │ └── usbd_desc.h │ └── src │ │ ├── usbd_cdc_if.c │ │ ├── usbd_conf.c │ │ └── usbd_desc.c │ └── dfu │ ├── inc │ ├── usbd_conf.h │ ├── usbd_desc.h │ └── usbd_dfu_flash.h │ └── src │ ├── usbd_conf.c │ ├── usbd_desc.c │ └── usbd_dfu_flash.c ├── stm32flash_src ├── AUTHORS ├── Android.mk ├── HOWTO ├── I2C.txt ├── INSTALL ├── Makefile ├── README.md ├── TODO ├── dev_table.c ├── file.flash ├── firmware.bin ├── gpl-2.0.txt ├── i2c.c ├── init.c ├── init.h ├── main.c ├── parsers │ ├── Android.mk │ ├── Makefile │ ├── binary.c │ ├── binary.h │ ├── hex.c │ ├── hex.h │ └── parser.h ├── port.c ├── port.h ├── protocol.txt ├── serial.h ├── serial_common.c ├── serial_platform.c ├── serial_posix.c ├── serial_w32.c ├── stm32.c ├── stm32.h ├── stm32flash.1 ├── stm32flash.exe ├── utils.c └── utils.h ├── swo └── gdbtrace.init └── wincompile.txt /.gdbinit: -------------------------------------------------------------------------------- 1 | source swo/gdbtrace.init 2 | monitor swdp_scan 3 | attach 1 4 | set mem inaccessible-by-default off 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.o 3 | .pioenvs 4 | .piolibdeps 5 | .vscode/c_cpp_properties.json 6 | .vscode/launch.json 7 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "terminal.integrated.env.windows": { 3 | "PATH": "C:\\Users\\Olof\\.platformio\\penv\\Scripts;C:\\Users\\Olof\\.platformio\\penv;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Windows Live\\Shared;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Users\\Olof\\.dnx\\bin;C:\\Program Files\\Microsoft DNX\\Dnvm\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\PuTTY\\;C:\\Program Files\\Git\\cmd;D:\\software\\nodejs\\;D:\\software\\vagrant\\bin;;D:\\software\\docker_toolbox\\Docker Toolbox;C:\\Program Files (x86)\\Microsoft VS Code\\bin;C:\\Users\\Olof\\AppData\\Local\\Microsoft\\WindowsApps;c:\\Program Files\\Saxonica\\SaxonHE9.4N\\bin;C:\\Users\\Olof\\AppData\\Roaming\\npm;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Windows Live\\Shared;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Users\\Olof\\.dnx\\bin;C:\\Program Files\\Microsoft DNX\\Dnvm\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\PuTTY\\;C:\\Program Files\\Git\\cmd;D:\\software\\nodejs\\;D:\\software\\vagrant\\bin;;D:\\software\\docker_toolbox\\Docker Toolbox;C:\\Program Files (x86)\\Microsoft VS Code\\bin;C:\\Users\\Olof\\AppData\\Local\\Microsoft\\WindowsApps;c:\\Program Files\\Saxonica\\SaxonHE9.4N\\bin;C:\\Users\\Olof\\AppData\\Roaming\\npm", 4 | "PLATFORMIO_CALLER": "vscode" 5 | } 6 | } -------------------------------------------------------------------------------- /STM32L151XBA_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/STM32L151XBA_FLASH.ld -------------------------------------------------------------------------------- /WINDOWS.md: -------------------------------------------------------------------------------- 1 | 2 | From here, 3 | https://www.thethingsnetwork.org/forum/t/rak811-tracker-board/11006/194 4 | Written by barillaro 5 | 6 | 7 | How to Edit and Upload the code without a J-Link on Win10 and Atom 8 | Download Atom. 9 | 10 | https://atom.io/ 11 | 12 | Once Download, install and open Atom up. 13 | Then go to settings > install, search for platformio 14 | 15 | Install the following. 16 | platformio-ide-terminal 17 | platformio-ide 18 | platformio-ide-debugger 19 | 20 | Once done, download and install the comm drivers for the RAK811 21 | http://docs.rakwireless.com/en/RAK811 TrackerBoard/Tool/CP210x_Windows_Drivers.zip 22 | 23 | Then download the git from OlofAst 24 | 25 | https://github.com/Ebiroll/RAK811_BreakBoard 26 | 27 | open Atom, on the PlatformIO Home Tab, go to Platform 28 | 29 | Search ST STM32, Install 30 | 31 | Then click Reveal 32 | 33 | It will open up a Explorer window, then open folder ststm32/boards 34 | 35 | copy the file from OlofAst’s git, rak811.json to the ststm32/boards folder. 36 | 37 | Then in Atom, click open folder. 38 | 39 | Open the folder RAK811_BreakBoard from OlofAst’s git. 40 | 41 | Then open the Terminal in Atom 42 | 43 | To edit the DevEUI and etc… open the file src\Commissioning.h 44 | Save, and close the tab. 45 | 46 | Now to Compile. 47 | 48 | In the Terminal window in Atom type: pio run 49 | if you see SUCCESS, compiling went ok 50 | 51 | Calculating size .pioenvs\rak811\firmware.elf 52 | text data bss dec hex filename 53 | 53236 1628 5244 60108 eacc .pioenvs\rak811\firmware.elf 54 | ===[SUCCESS] Took 12.25 seconds 55 | 56 | Now to Upload .bin file to the board 57 | Change the jumper on the board. 58 | 59 | Connect the usb, go to Device manager and check what is you comm port number for the board. 60 | 61 | Then in the terminal window In Atom, run the following 62 | stm32flash_src/stm32flash.exe -w .pioenvs/rak811/firmware.bin COM5 63 | 64 | This will upload the .bin file, the result should be 65 | 66 | stm32flash 0.5 67 | 68 | http://stm32flash.sourceforge.net/ 69 | 70 | Using Parser : Raw BINARY 71 | Interface serial_w32: 115200 8E1 72 | Version : 0x31 73 | Option 1 : 0x00 74 | Option 2 : 0x00 75 | Device ID : 0x0429 (STM32L1xxx6(8/B)A) 76 | 77 | RAM : 32KiB (4096b reserved by bootloader) 78 | Flash : 128KiB (size first sector: 16x256) 79 | Option RAM : 32b 80 | System RAM : 4KiB 81 | Write to memory 82 | Data size: 54868 bytes 83 | Erasing memory 84 | Wrote address 0x0800d654 (100.00%) Done. 85 | 86 | You should all be done. Unplug, change the jumper back to original position. 87 | Power up the board and it should connect to the AP. 88 | To monitor the board, download Uart Terminal, Connect to the Comm port of the board, at baud rate 115200 89 | 90 | https://sourceforge.net/projects/uartterminal/ 91 | 92 | RAK811 BreakBoard soft version: 1.0.2 93 | Selected LoraWAN 1.0.2 Region: EU868 94 | OTAA: 95 | Dev_EUI: XX XX XX XX XX XX XX XX 96 | AppEui: XX XX XX XX XX XX XX XX 97 | AppKey: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 98 | OTAA Join Start… 99 | OTAA Join Success -------------------------------------------------------------------------------- /instruction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/instruction.png -------------------------------------------------------------------------------- /lib/crypto/cmac.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | Copyright (C) 2009 Lander Casado, Philippas Tsigas 3 | 4 | All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files 8 | (the "Software"), to deal with the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | Redistributions of source code must retain the above copyright notice, 15 | this list of conditions and the following disclaimers. Redistributions in 16 | binary form must reproduce the above copyright notice, this list of 17 | conditions and the following disclaimers in the documentation and/or 18 | other materials provided with the distribution. 19 | 20 | In no event shall the authors or copyright holders be liable for any special, 21 | incidental, indirect or consequential damages of any kind, or any damages 22 | whatsoever resulting from loss of use, data or profits, whether or not 23 | advised of the possibility of damage, and on any theory of liability, 24 | arising out of or in connection with the use or performance of this software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 27 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 31 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 32 | DEALINGS WITH THE SOFTWARE 33 | 34 | *****************************************************************************/ 35 | 36 | #ifndef _CMAC_H_ 37 | #define _CMAC_H_ 38 | 39 | #include "aes.h" 40 | 41 | #define AES_CMAC_KEY_LENGTH 16 42 | #define AES_CMAC_DIGEST_LENGTH 16 43 | 44 | typedef struct _AES_CMAC_CTX { 45 | aes_context rijndael; 46 | uint8_t X[16]; 47 | uint8_t M_last[16]; 48 | uint32_t M_n; 49 | } AES_CMAC_CTX; 50 | 51 | //#include 52 | 53 | //__BEGIN_DECLS 54 | void AES_CMAC_Init(AES_CMAC_CTX * ctx); 55 | void AES_CMAC_SetKey(AES_CMAC_CTX * ctx, const uint8_t key[AES_CMAC_KEY_LENGTH]); 56 | void AES_CMAC_Update(AES_CMAC_CTX * ctx, const uint8_t * data, uint32_t len); 57 | // __attribute__((__bounded__(__string__,2,3))); 58 | void AES_CMAC_Final(uint8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX * ctx); 59 | // __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH))); 60 | //__END_DECLS 61 | 62 | #endif /* _CMAC_H_ */ 63 | 64 | -------------------------------------------------------------------------------- /lib/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for the project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link to executable file. 4 | 5 | The source code of each library should be placed in separate directory, like 6 | "lib/private_lib/[here are source files]". 7 | 8 | For example, see how can be organized `Foo` and `Bar` libraries: 9 | 10 | |--lib 11 | | |--Bar 12 | | | |--docs 13 | | | |--examples 14 | | | |--src 15 | | | |- Bar.c 16 | | | |- Bar.h 17 | | |--Foo 18 | | | |- Foo.c 19 | | | |- Foo.h 20 | | |- readme.txt --> THIS FILE 21 | |- platformio.ini 22 | |--src 23 | |- main.c 24 | 25 | Then in `src/main.c` you should use: 26 | 27 | #include 28 | #include 29 | 30 | // rest H/C/CPP code 31 | 32 | PlatformIO will find your libraries automatically, configure preprocessor's 33 | include paths and build them. 34 | 35 | More information about PlatformIO Library Dependency Finder 36 | - http://docs.platformio.org/page/librarymanager/ldf.html 37 | -------------------------------------------------------------------------------- /lib/system_utils/adc.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Implements a generic ADC driver 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __ADC_H__ 16 | #define __ADC_H__ 17 | 18 | /*! 19 | * ADC object type definition 20 | */ 21 | typedef struct 22 | { 23 | Gpio_t AdcInput; 24 | }Adc_t; 25 | 26 | /*! 27 | * \brief Initializes the ADC input 28 | * 29 | * \param [IN] obj ADC object 30 | * \param [IN] scl ADC input pin name to be used 31 | */ 32 | void AdcInit( Adc_t *obj, PinNames adcInput ); 33 | 34 | /*! 35 | * \brief DeInitializes the ADC 36 | * 37 | * \param [IN] obj ADC object 38 | */ 39 | void AdcDeInit( Adc_t *obj ); 40 | 41 | /*! 42 | * \brief Read the analogue voltage value 43 | * 44 | * \param [IN] obj ADC object 45 | * \param [IN] channel ADC channel 46 | * \retval value Analogue pin value 47 | */ 48 | uint16_t AdcReadChannel( Adc_t *obj, uint32_t channel ); 49 | 50 | #endif // __ADC_H__ 51 | -------------------------------------------------------------------------------- /lib/system_utils/delay.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Delay functions implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __DELAY_H__ 16 | #define __DELAY_H__ 17 | 18 | /*! 19 | * Blocking delay of "s" seconds 20 | */ 21 | void Delay( float s ); 22 | 23 | /*! 24 | * Blocking delay of "ms" milliseconds 25 | */ 26 | void DelayMs( uint32_t ms ); 27 | 28 | #endif // __DELAY_H__ 29 | 30 | -------------------------------------------------------------------------------- /lib/system_utils/eeprom.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Timer objects and scheduling management 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __EEPROM_H__ 16 | #define __EEPROM_H__ 17 | 18 | /*! 19 | * Writes the given buffer to the EEPROM at the specified address. 20 | * 21 | * \param[IN] addr EEPROM address to write to 22 | * \param[IN] buffer Pointer to the buffer to be written. 23 | * \param[IN] size Size of the buffer to be written. 24 | * \retval status [SUCCESS, FAIL] 25 | */ 26 | uint8_t EepromWriteBuffer( uint16_t addr, uint8_t *buffer, uint16_t size ); 27 | 28 | /*! 29 | * Reads the EEPROM at the specified address to the given buffer. 30 | * 31 | * \param[IN] addr EEPROM address to read from 32 | * \param[OUT] buffer Pointer to the buffer to be written with read data. 33 | * \param[IN] size Size of the buffer to be read. 34 | * \retval status [SUCCESS, FAIL] 35 | */ 36 | uint8_t EepromReadBuffer( uint16_t addr, uint8_t *buffer, uint16_t size ); 37 | 38 | /*! 39 | * Sets the device address. 40 | * 41 | * \remark Useful for I2C external EEPROMS 42 | * 43 | * \param[IN] addr External EEPROM address 44 | */ 45 | void EepromSetDeviceAddr( uint8_t addr ); 46 | 47 | /*! 48 | * Gets the current device address. 49 | * 50 | * \remark Useful for I2C external EEPROMS 51 | * 52 | * \retval addr External EEPROM address 53 | */ 54 | uint8_t EepromGetDeviceAddr( void ); 55 | 56 | #endif // __EEPROM_H__ 57 | -------------------------------------------------------------------------------- /lib/system_utils/fifo.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Implements a FIFO buffer 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __FIFO_H__ 16 | #define __FIFO_H__ 17 | 18 | #include 19 | #include 20 | 21 | /*! 22 | * FIFO structure 23 | */ 24 | typedef struct Fifo_s 25 | { 26 | uint16_t Begin; 27 | uint16_t End; 28 | uint8_t *Data; 29 | uint16_t Size; 30 | }Fifo_t; 31 | 32 | /*! 33 | * Initializes the FIFO structure 34 | * 35 | * \param [IN] fifo Pointer to the FIFO object 36 | * \param [IN] buffer Buffer to be used as FIFO 37 | * \param [IN] size Size of the buffer 38 | */ 39 | void FifoInit( Fifo_t *fifo, uint8_t *buffer, uint16_t size ); 40 | 41 | /*! 42 | * Pushes data to the FIFO 43 | * 44 | * \param [IN] fifo Pointer to the FIFO object 45 | * \param [IN] data Data to be pushed into the FIFO 46 | */ 47 | void FifoPush( Fifo_t *fifo, uint8_t data ); 48 | 49 | /*! 50 | * Pops data from the FIFO 51 | * 52 | * \param [IN] fifo Pointer to the FIFO object 53 | * \retval data Data popped from the FIFO 54 | */ 55 | uint8_t FifoPop( Fifo_t *fifo ); 56 | 57 | /*! 58 | * Flushes the FIFO 59 | * 60 | * \param [IN] fifo Pointer to the FIFO object 61 | */ 62 | void FifoFlush( Fifo_t *fifo ); 63 | 64 | /*! 65 | * Checks if the FIFO is empty 66 | * 67 | * \param [IN] fifo Pointer to the FIFO object 68 | * \retval isEmpty true: FIFO is empty, false FIFO is not empty 69 | */ 70 | bool IsFifoEmpty( Fifo_t *fifo ); 71 | 72 | /*! 73 | * Checks if the FIFO is full 74 | * 75 | * \param [IN] fifo Pointer to the FIFO object 76 | * \retval isFull true: FIFO is full, false FIFO is not full 77 | */ 78 | bool IsFifoFull( Fifo_t *fifo ); 79 | 80 | #endif // __FIFO_H__ 81 | -------------------------------------------------------------------------------- /lib/system_utils/gps.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Generic driver for the GPS receiver UP501 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __GPS_H__ 16 | #define __GPS_H__ 17 | 18 | /* Structure to handle the GPS parsed data in ASCII */ 19 | typedef struct 20 | { 21 | char NmeaDataType[6]; 22 | char NmeaUtcTime[11]; 23 | char NmeaDataStatus[2]; 24 | char NmeaLatitude[10]; 25 | char NmeaLatitudePole[2]; 26 | char NmeaLongitude[11]; 27 | char NmeaLongitudePole[2]; 28 | char NmeaFixQuality[2]; 29 | char NmeaSatelliteTracked[3]; 30 | char NmeaHorizontalDilution[6]; 31 | char NmeaAltitude[8]; 32 | char NmeaAltitudeUnit[2]; 33 | char NmeaHeightGeoid[8]; 34 | char NmeaHeightGeoidUnit[2]; 35 | char NmeaSpeed[8]; 36 | char NmeaDetectionAngle[8]; 37 | char NmeaDate[8]; 38 | }tNmeaGpsData; 39 | 40 | extern tNmeaGpsData NmeaGpsData; 41 | 42 | /*! 43 | * \brief Initializes the handling of the GPS receiver 44 | */ 45 | void GpsInit( void ); 46 | 47 | /*! 48 | * \brief Switch ON the GPS 49 | */ 50 | void GpsStart( void ); 51 | 52 | /*! 53 | * \brief Switch OFF the GPS 54 | */ 55 | void GpsStop( void ); 56 | 57 | /*! 58 | * Updates the GPS status 59 | */ 60 | void GpsProcess( void ); 61 | 62 | /*! 63 | * \brief PPS signal handling function 64 | */ 65 | void GpsPpsHandler( bool *parseData ); 66 | 67 | /*! 68 | * \brief PPS signal handling function 69 | * 70 | * \retval ppsDetected State of PPS signal. 71 | */ 72 | bool GpsGetPpsDetectedState( void ); 73 | 74 | /*! 75 | * \brief Indicates if GPS has fix 76 | * 77 | * \retval hasFix 78 | */ 79 | bool GpsHasFix( void ); 80 | 81 | /*! 82 | * \brief Converts the latest Position (latitude and longitude) into a binary 83 | * number 84 | */ 85 | void GpsConvertPositionIntoBinary( void ); 86 | 87 | /*! 88 | * \brief Converts the latest Position (latitude and Longitude) from ASCII into 89 | * DMS numerical format 90 | */ 91 | void GpsConvertPositionFromStringToNumerical( void ); 92 | 93 | /*! 94 | * \brief Gets the latest Position (latitude and Longitude) as two double values 95 | * if available 96 | * 97 | * \param [OUT] lati Latitude value 98 | * \param [OUT] longi Longitude value 99 | * 100 | * \retval status [SUCCESS, FAIL] 101 | */ 102 | uint8_t GpsGetLatestGpsPositionDouble ( double *lati, double *longi ); 103 | 104 | /*! 105 | * \brief Gets the latest Position (latitude and Longitude) as two binary values 106 | * if available 107 | * 108 | * \param [OUT] latiBin Latitude value 109 | * \param [OUT] longiBin Longitude value 110 | * 111 | * \retval status [SUCCESS, FAIL] 112 | */ 113 | uint8_t GpsGetLatestGpsPositionBinary ( int32_t *latiBin, int32_t *longiBin ); 114 | 115 | /*! 116 | * \brief Parses the NMEA sentence. 117 | * 118 | * \remark Only parses GPGGA and GPRMC sentences 119 | * 120 | * \param [IN] rxBuffer Data buffer to be parsed 121 | * \param [IN] rxBufferSize Size of data buffer 122 | * 123 | * \retval status [SUCCESS, FAIL] 124 | */ 125 | uint8_t GpsParseGpsData( int8_t *rxBuffer, int32_t rxBufferSize ); 126 | 127 | /*! 128 | * \brief Returns the latest altitude from the parsed NMEA sentence 129 | * 130 | * \retval altitude 131 | */ 132 | int16_t GpsGetLatestGpsAltitude( void ); 133 | 134 | /*! 135 | * \brief Format GPS data into numeric and binary formats 136 | */ 137 | void GpsFormatGpsData( void ); 138 | 139 | /*! 140 | * \brief Resets the GPS position variables 141 | */ 142 | void GpsResetPosition( void ); 143 | 144 | #endif // __GPS_H__ 145 | -------------------------------------------------------------------------------- /lib/system_utils/i2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Implements the generic I2C driver 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __I2C_H__ 16 | #define __I2C_H__ 17 | 18 | #include "stm32l1xx.h" 19 | #include "stm32l1xx_hal.h" 20 | 21 | /*! 22 | * I2C object type definition 23 | */ 24 | typedef struct 25 | { 26 | I2C_HandleTypeDef I2c; 27 | Gpio_t Scl; 28 | Gpio_t Sda; 29 | } I2c_t; 30 | 31 | /*! 32 | * \brief Initializes the I2C object and MCU peripheral 33 | * 34 | * \param [IN] obj I2C object 35 | * \param [IN] scl I2C Scl pin name to be used 36 | * \param [IN] sda I2C Sda pin name to be used 37 | */ 38 | void I2cInit( I2c_t *obj, PinNames scl, PinNames sda ); 39 | 40 | /*! 41 | * \brief DeInitializes the I2C object and MCU peripheral 42 | * 43 | * \param [IN] obj I2C object 44 | */ 45 | void I2cDeInit( I2c_t *obj ); 46 | 47 | /*! 48 | * \brief Reset the I2C object and MCU peripheral 49 | * 50 | * \param [IN] obj I2C object 51 | */ 52 | void I2cResetBus( I2c_t *obj ); 53 | 54 | /*! 55 | * \brief Write data to the I2C device 56 | * 57 | * \param [IN] obj I2C object 58 | * \param [IN] deviceAddr device address 59 | * \param [IN] addr data address 60 | * \param [IN] data data to write 61 | */ 62 | uint8_t I2cWrite( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t data ); 63 | 64 | /*! 65 | * \brief Write several data to the I2C device 66 | * 67 | * \param [IN] obj I2C object 68 | * \param [IN] deviceAddr device address 69 | * \param [IN] addr data address 70 | * \param [IN] buffer data buffer to write 71 | * \param [IN] size number of bytes to write 72 | */ 73 | uint8_t I2cWriteBuffer( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *buffer, uint16_t size ); 74 | 75 | /*! 76 | * \brief Read data from the I2C device 77 | * 78 | * \param [IN] obj I2C object 79 | * \param [IN] deviceAddr device address 80 | * \param [IN] addr data address 81 | * \param [OUT] data variable used to store the data read 82 | */ 83 | uint8_t I2cRead( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *data ); 84 | 85 | /*! 86 | * \brief Read several data byte from the I2C device 87 | * 88 | * \param [IN] obj I2C object 89 | * \param [IN] deviceAddr device address 90 | * \param [IN] addr data address 91 | * \param [OUT] buffer data buffer used to store the data read 92 | * \param [IN] size number of data byte to read 93 | */ 94 | uint8_t I2cReadBuffer( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *buffer, uint16_t size ); 95 | 96 | #endif // __I2C_H__ 97 | -------------------------------------------------------------------------------- /lib/system_utils/serial.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Implements the generic UART driver 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __SERIAL_H__ 16 | #define __SERIAL_H__ 17 | 18 | #endif // __SERIAL_H__ 19 | -------------------------------------------------------------------------------- /lib/system_utils/spi.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Implements the generic SPI driver 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __SPI_H__ 16 | #define __SPI_H__ 17 | 18 | #include "spi-board.h" 19 | 20 | /*! 21 | * SPI object type definition 22 | */ 23 | typedef struct Spi_s Spi_t; 24 | 25 | /*! 26 | * \brief Initializes the SPI object and MCU peripheral 27 | * 28 | * \remark When NSS pin is software controlled set the pin name to NC otherwise 29 | * set the pin name to be used. 30 | * 31 | * \param [IN] obj SPI object 32 | * \param [IN] mosi SPI MOSI pin name to be used 33 | * \param [IN] miso SPI MISO pin name to be used 34 | * \param [IN] sclk SPI SCLK pin name to be used 35 | * \param [IN] nss SPI NSS pin name to be used 36 | */ 37 | void SpiInit( Spi_t *obj, PinNames mosi, PinNames miso, PinNames sclk, PinNames nss ); 38 | 39 | /*! 40 | * \brief De-initializes the SPI object and MCU peripheral 41 | * 42 | * \param [IN] obj SPI object 43 | */ 44 | void SpiDeInit( Spi_t *obj ); 45 | 46 | /*! 47 | * \brief Configures the SPI peripheral 48 | * 49 | * \remark Slave mode isn't currently handled 50 | * 51 | * \param [IN] obj SPI object 52 | * \param [IN] bits Number of bits to be used. [8 or 16] 53 | * \param [IN] cpol Clock polarity 54 | * \param [IN] cpha Clock phase 55 | * \param [IN] slave When set the peripheral acts in slave mode 56 | */ 57 | void SpiFormat( Spi_t *obj, int8_t bits, int8_t cpol, int8_t cpha, int8_t slave ); 58 | 59 | /*! 60 | * \brief Sets the SPI speed 61 | * 62 | * \param [IN] obj SPI object 63 | * \param [IN] hz SPI clock frequency in hz 64 | */ 65 | void SpiFrequency( Spi_t *obj, uint32_t hz ); 66 | 67 | /*! 68 | * \brief Sends outData and receives inData 69 | * 70 | * \param [IN] obj SPI object 71 | * \param [IN] outData Byte to be sent 72 | * \retval inData Received byte. 73 | */ 74 | uint16_t SpiInOut( Spi_t *obj, uint16_t outData ); 75 | 76 | #endif // __SPI_H__ 77 | -------------------------------------------------------------------------------- /lib/system_utils/src/adc.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Implements a generic ADC driver 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | #include "adc-board.h" 17 | 18 | /*! 19 | * Flag to indicates if the ADC is initialized 20 | */ 21 | static bool AdcInitialized = false; 22 | 23 | void AdcInit( Adc_t *obj, PinNames adcInput ) 24 | { 25 | if( AdcInitialized == false ) 26 | { 27 | AdcInitialized = true; 28 | 29 | AdcMcuInit( obj, adcInput ); 30 | AdcMcuConfig( ); 31 | } 32 | } 33 | 34 | void AdcDeInit( Adc_t *obj ) 35 | { 36 | AdcInitialized = false; 37 | } 38 | 39 | uint16_t AdcReadChannel( Adc_t *obj, uint32_t channel ) 40 | { 41 | if( AdcInitialized == true ) 42 | { 43 | return AdcMcuReadChannel( obj, channel ); 44 | } 45 | else 46 | { 47 | return 0; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/system_utils/src/delay.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Delay functions implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | 17 | void Delay( float s ) 18 | { 19 | DelayMs( s * 1000.0f ); 20 | } 21 | 22 | void DelayMs( uint32_t ms ) 23 | { 24 | HAL_Delay( ms ); 25 | } 26 | -------------------------------------------------------------------------------- /lib/system_utils/src/eeprom.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Timer objects and scheduling management 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | 17 | #include "eeprom-board.h" 18 | 19 | uint8_t EepromWriteBuffer( uint16_t addr, uint8_t *buffer, uint16_t size ) 20 | { 21 | return EepromMcuWriteBuffer( addr, buffer, size ); 22 | } 23 | 24 | uint8_t EepromReadBuffer( uint16_t addr, uint8_t *buffer, uint16_t size ) 25 | { 26 | return EepromMcuReadBuffer( addr, buffer, size ); 27 | } 28 | 29 | void EepromSetDeviceAddr( uint8_t addr ) 30 | { 31 | EepromMcuSetDeviceAddr( addr ); 32 | } 33 | 34 | uint8_t EepromGetDeviceAddr( void ) 35 | { 36 | return EepromMcuGetDeviceAddr( ); 37 | } 38 | -------------------------------------------------------------------------------- /lib/system_utils/src/fifo.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Implements a FIFO buffer 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "fifo.h" 16 | 17 | static uint16_t FifoNext( Fifo_t *fifo, uint16_t index ) 18 | { 19 | return ( index + 1 ) % fifo->Size; 20 | } 21 | 22 | void FifoInit( Fifo_t *fifo, uint8_t *buffer, uint16_t size ) 23 | { 24 | fifo->Begin = 0; 25 | fifo->End = 0; 26 | fifo->Data = buffer; 27 | fifo->Size = size; 28 | } 29 | 30 | void FifoPush( Fifo_t *fifo, uint8_t data ) 31 | { 32 | fifo->End = FifoNext( fifo, fifo->End ); 33 | fifo->Data[fifo->End] = data; 34 | } 35 | 36 | uint8_t FifoPop( Fifo_t *fifo ) 37 | { 38 | uint8_t data = fifo->Data[FifoNext( fifo, fifo->Begin )]; 39 | 40 | fifo->Begin = FifoNext( fifo, fifo->Begin ); 41 | return data; 42 | } 43 | 44 | void FifoFlush( Fifo_t *fifo ) 45 | { 46 | fifo->Begin = 0; 47 | fifo->End = 0; 48 | } 49 | 50 | bool IsFifoEmpty( Fifo_t *fifo ) 51 | { 52 | return ( fifo->Begin == fifo->End ); 53 | } 54 | 55 | bool IsFifoFull( Fifo_t *fifo ) 56 | { 57 | return ( FifoNext( fifo, fifo->End ) == fifo->Begin ); 58 | } 59 | -------------------------------------------------------------------------------- /lib/system_utils/src/gpio.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Generic GPIO driver implementation 10 | 11 | Comment: Relies on the specific board GPIO implementation as well as on 12 | IO expander driver implementation if one is available on the target 13 | board. 14 | 15 | License: Revised BSD License, see LICENSE.TXT file include in the project 16 | 17 | Maintainer: Miguel Luis and Gregory Cristian 18 | */ 19 | #include "board.h" 20 | 21 | #include "gpio-board.h" 22 | 23 | #if defined( BOARD_IOE_EXT ) 24 | #include "gpio-ioe.h" 25 | #endif 26 | 27 | void GpioInit( Gpio_t *obj, PinNames pin, PinModes mode, PinConfigs config, PinTypes type, uint32_t value ) 28 | { 29 | if( ( uint32_t )( pin >> 4 ) <= 6 ) 30 | { 31 | GpioMcuInit( obj, pin, mode, config, type, value ); 32 | } 33 | else 34 | { 35 | #if defined( BOARD_IOE_EXT ) 36 | // IOExt Pin 37 | GpioIoeInit( obj, pin, mode, config, type, value ); 38 | #endif 39 | } 40 | } 41 | 42 | void GpioSetInterrupt( Gpio_t *obj, IrqModes irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler ) 43 | { 44 | if( ( uint32_t )( obj->pin >> 4 ) <= 6 ) 45 | { 46 | GpioMcuSetInterrupt( obj, irqMode, irqPriority, irqHandler ); 47 | } 48 | else 49 | { 50 | #if defined( BOARD_IOE_EXT ) 51 | // IOExt Pin 52 | GpioIoeSetInterrupt( obj, irqMode, irqPriority, irqHandler ); 53 | #endif 54 | } 55 | } 56 | 57 | void GpioRemoveInterrupt( Gpio_t *obj ) 58 | { 59 | if( ( uint32_t )( obj->pin >> 4 ) <= 6 ) 60 | { 61 | //GpioMcuRemoveInterrupt( obj ); 62 | } 63 | else 64 | { 65 | #if defined( BOARD_IOE_EXT ) 66 | // IOExt Pin 67 | //GpioIoeRemoveInterrupt( obj ); 68 | #endif 69 | } 70 | } 71 | 72 | void GpioWrite( Gpio_t *obj, uint32_t value ) 73 | { 74 | if( ( uint32_t )( obj->pin >> 4 ) <= 6 ) 75 | { 76 | GpioMcuWrite( obj, value ); 77 | } 78 | else 79 | { 80 | #if defined( BOARD_IOE_EXT ) 81 | // IOExt Pin 82 | GpioIoeWrite( obj, value ); 83 | #endif 84 | } 85 | } 86 | 87 | void GpioToggle( Gpio_t *obj ) 88 | { 89 | if( ( uint32_t )( obj->pin >> 4 ) <= 6 ) 90 | { 91 | GpioMcuToggle( obj ); 92 | } 93 | else 94 | { 95 | #if defined( BOARD_IOE_EXT ) 96 | // IOExt Pin 97 | GpioIoeWrite( obj, GpioIoeRead( obj ) ^ 1 ); 98 | #endif 99 | } 100 | } 101 | 102 | uint32_t GpioRead( Gpio_t *obj ) 103 | { 104 | if( ( uint32_t )( obj->pin >> 4 ) <= 6 ) 105 | { 106 | return GpioMcuRead( obj ); 107 | } 108 | else 109 | { 110 | #if defined( BOARD_IOE_EXT ) 111 | // IOExt Pin 112 | return GpioIoeRead( obj ); 113 | #else 114 | return 0; 115 | #endif 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /lib/system_utils/src/i2c.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Implements the generic I2C driver 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | #include "i2c-board.h" 17 | 18 | /*! 19 | * Flag to indicates if the I2C is initialized 20 | */ 21 | static bool I2cInitialized = false; 22 | 23 | void I2cInit( I2c_t *obj, PinNames scl, PinNames sda ) 24 | { 25 | if( I2cInitialized == false ) 26 | { 27 | I2cInitialized = true; 28 | 29 | I2cMcuInit( obj, scl, sda ); 30 | I2cMcuFormat( obj, MODE_I2C, I2C_DUTY_CYCLE_2, true, I2C_ACK_ADD_7_BIT, 400000 ); 31 | } 32 | } 33 | 34 | void I2cDeInit( I2c_t *obj ) 35 | { 36 | I2cInitialized = false; 37 | I2cMcuDeInit( obj ); 38 | } 39 | 40 | void I2cResetBus( I2c_t *obj ) 41 | { 42 | I2cInitialized = false; 43 | I2cInit( obj, I2C_SCL, I2C_SDA ); 44 | } 45 | 46 | uint8_t I2cWrite( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t data ) 47 | { 48 | if( I2cInitialized == true ) 49 | { 50 | if( I2cMcuWriteBuffer( obj, deviceAddr, addr, &data, 1 ) == FAIL ) 51 | { 52 | // if first attempt fails due to an IRQ, try a second time 53 | if( I2cMcuWriteBuffer( obj, deviceAddr, addr, &data, 1 ) == FAIL ) 54 | { 55 | return FAIL; 56 | } 57 | else 58 | { 59 | return SUCCESS; 60 | } 61 | } 62 | else 63 | { 64 | return SUCCESS; 65 | } 66 | } 67 | else 68 | { 69 | return FAIL; 70 | } 71 | } 72 | 73 | uint8_t I2cWriteBuffer( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *buffer, uint16_t size ) 74 | { 75 | if( I2cInitialized == true ) 76 | { 77 | if( I2cMcuWriteBuffer( obj, deviceAddr, addr, buffer, size ) == FAIL ) 78 | { 79 | // if first attempt fails due to an IRQ, try a second time 80 | if( I2cMcuWriteBuffer( obj, deviceAddr, addr, buffer, size ) == FAIL ) 81 | { 82 | return FAIL; 83 | } 84 | else 85 | { 86 | return SUCCESS; 87 | } 88 | } 89 | else 90 | { 91 | return SUCCESS; 92 | } 93 | } 94 | else 95 | { 96 | return FAIL; 97 | } 98 | } 99 | 100 | uint8_t I2cRead( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *data ) 101 | { 102 | if( I2cInitialized == true ) 103 | { 104 | return( I2cMcuReadBuffer( obj, deviceAddr, addr, data, 1 ) ); 105 | } 106 | else 107 | { 108 | return FAIL; 109 | } 110 | } 111 | 112 | uint8_t I2cReadBuffer( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *buffer, uint16_t size ) 113 | { 114 | if( I2cInitialized == true ) 115 | { 116 | return( I2cMcuReadBuffer( obj, deviceAddr, addr, buffer, size ) ); 117 | } 118 | else 119 | { 120 | return FAIL; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /lib/system_utils/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Timer objects and scheduling management 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __TIMER_H__ 16 | #define __TIMER_H__ 17 | 18 | /*! 19 | * \brief Timer object description 20 | */ 21 | typedef struct TimerEvent_s 22 | { 23 | uint32_t Timestamp; //! Current timer value 24 | uint32_t ReloadValue; //! Timer delay value 25 | bool IsRunning; //! Is the timer currently running 26 | void ( *Callback )( void ); //! Timer IRQ callback function 27 | struct TimerEvent_s *Next; //! Pointer to the next Timer object. 28 | }TimerEvent_t; 29 | 30 | /*! 31 | * \brief Timer time variable definition 32 | */ 33 | #ifndef TimerTime_t 34 | typedef uint32_t TimerTime_t; 35 | #endif 36 | 37 | /*! 38 | * \brief Initializes the timer object 39 | * 40 | * \remark TimerSetValue function must be called before starting the timer. 41 | * this function initializes timestamp and reload value at 0. 42 | * 43 | * \param [IN] obj Structure containing the timer object parameters 44 | * \param [IN] callback Function callback called at the end of the timeout 45 | */ 46 | void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) ); 47 | 48 | /*! 49 | * Timer IRQ event handler 50 | */ 51 | void TimerIrqHandler( void ); 52 | 53 | /*! 54 | * \brief Starts and adds the timer object to the list of timer events 55 | * 56 | * \param [IN] obj Structure containing the timer object parameters 57 | */ 58 | void TimerStart( TimerEvent_t *obj ); 59 | 60 | /*! 61 | * \brief Stops and removes the timer object from the list of timer events 62 | * 63 | * \param [IN] obj Structure containing the timer object parameters 64 | */ 65 | void TimerStop( TimerEvent_t *obj ); 66 | 67 | /*! 68 | * \brief Resets the timer object 69 | * 70 | * \param [IN] obj Structure containing the timer object parameters 71 | */ 72 | void TimerReset( TimerEvent_t *obj ); 73 | 74 | /*! 75 | * \brief Set timer new timeout value 76 | * 77 | * \param [IN] obj Structure containing the timer object parameters 78 | * \param [IN] value New timer timeout value 79 | */ 80 | void TimerSetValue( TimerEvent_t *obj, uint32_t value ); 81 | 82 | /*! 83 | * \brief Read the current time 84 | * 85 | * \retval time returns current time 86 | */ 87 | TimerTime_t TimerGetCurrentTime( void ); 88 | 89 | /*! 90 | * \brief Return the Time elapsed since a fix moment in Time 91 | * 92 | * \param [IN] savedTime fix moment in Time 93 | * \retval time returns elapsed time 94 | */ 95 | TimerTime_t TimerGetElapsedTime( TimerTime_t savedTime ); 96 | 97 | /*! 98 | * \brief Return the Time elapsed since a fix moment in Time 99 | * 100 | * \param [IN] eventInFuture fix moment in the future 101 | * \retval time returns difference between now and future event 102 | */ 103 | TimerTime_t TimerGetFutureTime( TimerTime_t eventInFuture ); 104 | 105 | /*! 106 | * \brief Manages the entry into ARM cortex deep-sleep mode 107 | */ 108 | void TimerLowPowerHandler( void ); 109 | 110 | #endif // __TIMER_H__ 111 | -------------------------------------------------------------------------------- /lib/wakeup/WakeUp.h: -------------------------------------------------------------------------------- 1 | //#include "mbed.h" 2 | #include 3 | 4 | /** 5 | * Class to make wake up a microcontroller from deepsleep using a low-power timer. 6 | * 7 | * @code 8 | * // Depending on the LED connections either the LED is off the 2 seconds 9 | * // the target spends in deepsleep(), and on for the other second. Or it is inverted 10 | * 11 | * #include "mbed.h" 12 | * #include "WakeUp.h" 13 | * 14 | * DigitalOut myled(LED1); 15 | * 16 | * int main() { 17 | * wait(5); 18 | * 19 | * //The low-power oscillator can be quite inaccurate on some targets 20 | * //this function calibrates it against the main clock 21 | * WakeUp::calibrate(); 22 | * 23 | * while(1) { 24 | * //Set LED to zero 25 | * myled = 0; 26 | * 27 | * //Set wakeup time for 2 seconds 28 | * WakeUp::set_ms(2000); 29 | * 30 | * //Enter deepsleep, the program won't go beyond this point until it is woken up 31 | * deepsleep(); 32 | * 33 | * //Set LED for 1 second to one 34 | * myled = 1; 35 | * wait(1); 36 | * } 37 | * } 38 | * @endcode 39 | */ 40 | 41 | class WakeUp 42 | { 43 | public: 44 | /** 45 | * Set the timeout 46 | * 47 | * @param s required time in seconds 48 | */ 49 | static void set(uint32_t s) { 50 | set_ms(1000 * s); 51 | } 52 | 53 | /** 54 | * Set the timeout 55 | * 56 | * @param ms required time in milliseconds 57 | */ 58 | static void set_ms(uint32_t ms); 59 | 60 | /** 61 | * Attach a function to be called after timeout 62 | * 63 | * This is optional, if you just want to wake up you 64 | * do not need to attach a function. 65 | * 66 | * Important: Many targets will run the wake-up routine 67 | * at reduced clock speed, afterwards clock speed is restored. 68 | * This means that clock speed dependent functions, such as printf 69 | * might end up distorted. 70 | * 71 | * @code 72 | * // Attaching regular function 73 | * WakeUp::attach(&yourFunc); 74 | * // Attaching member function inside another library 75 | * WakeUp::attach(callback(this, &YourLib::yourLibFunction)); 76 | * @endcode 77 | * 78 | * It uses the new Callback system to attach functions. 79 | * 80 | * @param *function function to call 81 | */ 82 | //static void attach(Callback function) { 83 | // callback = function; 84 | //} 85 | 86 | /** 87 | * Calibrate the timer 88 | * 89 | * Some of the low-power timers have very bad accuracy. 90 | * This function calibrates it against the main timer. 91 | * 92 | * Warning: Blocks for 100ms! 93 | */ 94 | static void calibrate(void); 95 | 96 | 97 | private: 98 | //static Callback callback; 99 | static void irq_handler(void); 100 | static float cycles_per_ms; 101 | }; 102 | 103 | -------------------------------------------------------------------------------- /mapper.md: -------------------------------------------------------------------------------- 1 | # Viewing gps data with node red 2 | 3 | The mapper app have to be adjusted for the RAK811 payload format. 4 | 5 | https://mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload 6 | This is the app, modify your "accessKey": "ttn-account-accessKEY" 7 | The mapper part could also probably be replaced with something simpler... 8 | 9 | [ 10 | { 11 | "id": "7740b706.25b758", 12 | "type": "worldmap", 13 | "z": "85694fb8.ca277", 14 | "name": "Gateway", 15 | "lat": "59.42304736", 16 | "lon": "17.82984428", 17 | "zoom": "", 18 | "layer": "OSM", 19 | "cluster": "", 20 | "maxage": "", 21 | "usermenu": "show", 22 | "layers": "show", 23 | "panit": "false", 24 | "x": 700, 25 | "y": 240, 26 | "wires": [] 27 | }, 28 | { 29 | "id": "1be9e006.56db3", 30 | "type": "mapper", 31 | "z": "85694fb8.ca277", 32 | "name": "", 33 | "x": 420, 34 | "y": 240, 35 | "wires": [ 36 | [ 37 | "7740b706.25b758" 38 | ] 39 | ] 40 | }, 41 | { 42 | "id": "87353fbb.34fb5", 43 | "type": "ttn message", 44 | "z": "85694fb8.ca277", 45 | "name": "mess", 46 | "app": "80a5700b.dd19c", 47 | "dev_id": "0x00012345", 48 | "field": "", 49 | "x": 230, 50 | "y": 160, 51 | "wires": [ 52 | [ 53 | "1be9e006.56db3" 54 | ] 55 | ] 56 | }, 57 | { 58 | "id": "ef2eb3c8.f0ac7", 59 | "type": "debug", 60 | "z": "85694fb8.ca277", 61 | "name": "", 62 | "active": true, 63 | "console": "false", 64 | "complete": "true", 65 | "x": 690, 66 | "y": 140, 67 | "wires": [] 68 | }, 69 | { 70 | "id": "80a5700b.dd19c", 71 | "type": "ttn app", 72 | "z": "", 73 | "appId": "esp32_heltec", 74 | "region": "eu", 75 | "accessKey": "ttn-account-accessKEY" 76 | } 77 | ] 78 | 79 | git clone https://github.com/Ebiroll/mapper 80 | 81 | sudo npm link 82 | 83 | cd .. 84 | 85 | npm link mapper 86 | 87 | 88 | # More info 89 | 90 | https://www.thethingsnetwork.org/docs/applications/nodered/quick-start.html 91 | 92 | https://flows.nodered.org/node/node-red-contrib-web-worldmap 93 | 94 | https://www.hackster.io/naresh-krish/integrate-node-red-with-rak811-lora-node-using-the-ttn-c4564a -------------------------------------------------------------------------------- /parallell_run.md: -------------------------------------------------------------------------------- 1 | # Parallell run 2 | 3 | Here I compare the software built by platformio compared to the Makefile build which should be more similar to the Original RAK source. 4 | 5 | 6 | clone https://github.com/RAKWireless/RAK811_BreakBoard 7 | cd RAK811_BreakBoard 8 | wget https://raw.githubusercontent.com/oguiter/RAK811_BreakBoard/master/Makefile 9 | make 10 | 11 | 12 | # Start qemu 13 | ./qemu-system-arm -S -s -serial file:uart1.log -d unimp -monitor stdio -machine rak811 -cpu cortex-m3 -pflash Debug/classA.bin 14 | 15 | 16 | # Start debugger 17 | arm-none-eabi-gdb Debug/classA.axf -ex ' target remote:1234' 18 | 19 | 20 | 21 | 22 | The biggest difference is that platformio has commented out the call to __libc_init_array, There also _init is called. 23 | 24 | 25 | bl 0x8012874 <_init> 26 | 27 | 28 | Here is the code, 29 | 30 | 31 | 32 | ``` 33 | 34 | 0x80123dc <__libc_init_array> push {r4, r5, r6, lr} │ 35 | │0x80123de <__libc_init_array+2> movs r5, #0 │ 36 | │0x80123e0 <__libc_init_array+4> ldr r6, [pc, #48] ; (0x8012414 <__libc_init_array+56>) │ 37 | │0x80123e2 <__libc_init_array+6> ldr r4, [pc, #52] ; (0x8012418 <__libc_init_array+60>) │ 38 | │0x80123e4 <__libc_init_array+8> subs r4, r4, r6 │ 39 | │0x80123e6 <__libc_init_array+10> asrs r4, r4, #2 │ 40 | │0x80123e8 <__libc_init_array+12> cmp r5, r4 │ 41 | │0x80123ea <__libc_init_array+14> bne.n 0x8012400 <__libc_init_array+36> │ 42 | │0x80123ec <__libc_init_array+16> bl 0x8012874 <_init> │ 43 | │0x80123f0 <__libc_init_array+20> movs r5, #0 │ 44 | │0x80123f2 <__libc_init_array+22> ldr r6, [pc, #40] ; (0x801241c <__libc_init_array+64>) │ 45 | │0x80123f4 <__libc_init_array+24> ldr r4, [pc, #40] ; (0x8012420 <__libc_init_array+68>) │ 46 | │0x80123f6 <__libc_init_array+26> subs r4, r4, r6 │ 47 | │0x80123f8 <__libc_init_array+28> asrs r4, r4, #2 │ 48 | │0x80123fa <__libc_init_array+30> cmp r5, r4 49 | 50 | ``` -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; http://docs.platformio.org/page/projectconf.html1 10 | 11 | [platformio] 12 | env_default = wistrio 13 | boards_dir = . 14 | 15 | [env:rak811] 16 | lib_dir = lib 17 | src_dir = src, src/RAK811BreakBoard/ 18 | lib_extra_dirs = crypto , radio/sx1276 , wakeup 19 | lib_deps = system_utils, obme280, wakeup 20 | platform = ststm32 21 | board = rak811 22 | framework=cmsis 23 | build_flags = -g -fno-builtin -D STM32L151xB -D STM32L151CBU6 -D REGION_EU868 -D USE_HAL_DRIVER -std=gnu99 -I src -I lib/wakeup -I lib/crypto -I lib/radio -I lib/radio/sx1276 -I src/mac -I src/usb/dfu/inc -I src/mac/region -I lib/system_utils/crypto -I src/boards/mcu/stm32/STM32_USB_Device_Library/Class/DFU/Inc/ -I src/boards/mcu/stm32/STM32_USB_Device_Library/Class/CDC/Inc/ -I src/usb/cdc/inc -I src/boards/mcu/stm32/STM32_USB_Device_Library/Core/Inc/ -I src/boards/mcu/stm32/STM32L0xx_HAL_Driver/Inc/ -I src/peripherals/ -I src/boards/mcu/stm32/ -I src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Inc -I src/RAK811BreakBoard/cmsis/ -I src/RAK811BreakBoard/ -IRAK811_BreakBoard/src -I lib/system_utils -I RAK811_BreakBoard/src/boards/RAK811BreakBoard -I RAK811_BreakBoard/src/boards/RAK811BreakBoard/cmsis -I .piolibdeps/mbed-dev_ID2491/targets/TARGET_STM/TARGET_STM32L1/TARGET_MOTE_L152RC/device/ -I RAK811_BreakBoard/src/boards/mcu/stm32/cmsis/ -I RAK811_BreakBoard/src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Inc -I RAK811_BreakBoard/src/boards/mcu/stm32 -I RAK811_BreakBoard/src/system/ -I RAK811_BreakBoard/src/radio -I RAK811_BreakBoard/src/peripherals/ -I RAK811_BreakBoard/src/mac -I RAK811_BreakBoard/src/mac/region/ 24 | 25 | [env:wistrio] 26 | lib_dir = lib 27 | src_dir = src, src/RAK811BreakBoard/ 28 | lib_extra_dirs = crypto , radio/sx1276 , wakeup 29 | lib_deps = system_utils, obme280, wakeup 30 | platform = ststm32 31 | board = rak811 32 | framework=cmsis 33 | build_flags = -g -fno-builtin -D WISTRIO -D STM32L151xB -D STM32L151CBU6 -D REGION_EU868 -D USE_HAL_DRIVER -std=gnu99 -I src -I lib/wakeup -I lib/crypto -I lib/radio -I lib/radio/sx1276 -I src/mac -I src/usb/dfu/inc -I src/mac/region -I lib/system_utils/crypto -I src/boards/mcu/stm32/STM32_USB_Device_Library/Class/DFU/Inc/ -I src/boards/mcu/stm32/STM32_USB_Device_Library/Class/CDC/Inc/ -I src/usb/cdc/inc -I src/boards/mcu/stm32/STM32_USB_Device_Library/Core/Inc/ -I src/boards/mcu/stm32/STM32L0xx_HAL_Driver/Inc/ -I src/peripherals/ -I src/boards/mcu/stm32/ -I src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Inc -I src/RAK811BreakBoard/cmsis/ -I src/RAK811BreakBoard/ -IRAK811_BreakBoard/src -I lib/system_utils -I RAK811_BreakBoard/src/boards/RAK811BreakBoard -I RAK811_BreakBoard/src/boards/RAK811BreakBoard/cmsis -I .piolibdeps/mbed-dev_ID2491/targets/TARGET_STM/TARGET_STM32L1/TARGET_MOTE_L152RC/device/ -I RAK811_BreakBoard/src/boards/mcu/stm32/cmsis/ -I RAK811_BreakBoard/src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Inc -I RAK811_BreakBoard/src/boards/mcu/stm32 -I RAK811_BreakBoard/src/system/ -I RAK811_BreakBoard/src/radio -I RAK811_BreakBoard/src/peripherals/ -I RAK811_BreakBoard/src/mac -I RAK811_BreakBoard/src/mac/region/ 34 | -------------------------------------------------------------------------------- /rak811.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "core": "stm32", 4 | "cpu": "cortex-m3", 5 | "extra_flags": "-DSTM32L151xB -DSTM32L151CBU6", 6 | "hwids": [ 7 | [ 8 | "0x0429", 9 | "0x0003" 10 | ], 11 | [ 12 | "0x0429", 13 | "0x0004" 14 | ] 15 | ], 16 | "f_cpu": "32768000L", 17 | "mcu": "stm32l151cb", 18 | "variant": "stm32l151xba", 19 | "ldscript": "stm32l15xx6.ld" 20 | }, 21 | "frameworks": [ 22 | "mbed", 23 | "cmsis", 24 | "libopencm3", 25 | "stm32cube" 26 | ], 27 | "upload": { 28 | "maximum_ram_size": 32768, 29 | "maximum_size": 131072, 30 | "protocol": "" 31 | }, 32 | "name": "Rak811", 33 | "url": "http://www.rakwireless.com/en/download/RAK811%20Breakout%20Board/HardWare%20Design", 34 | "vendor": "RAK" 35 | } 36 | -------------------------------------------------------------------------------- /src/Commissioning.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2015 Semtech 8 | 9 | Description: End device commissioning parameters 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __LORA_COMMISSIONING_H__ 16 | #define __LORA_COMMISSIONING_H__ 17 | 18 | /*! 19 | * When set to 1 the application uses the Over-the-Air activation procedure 20 | * When set to 0 the application uses the Personalization activation procedure 21 | */ 22 | #define OVER_THE_AIR_ACTIVATION 1 23 | 24 | /*! 25 | * Indicates if the end-device is to be connected to a private or public network 26 | */ 27 | #define LORAWAN_PUBLIC_NETWORK true 28 | 29 | /*! 30 | * IEEE Organizationally Unique Identifier ( OUI ) (big endian) 31 | * \remark This is unique to a company or organization 32 | */ 33 | #define IEEE_OUI 0x60, 0xC5, 0xA8 34 | 35 | /*! 36 | * Mote device IEEE EUI (big endian) 37 | * 38 | * \remark In this application the value is automatically generated by calling 39 | * BoardGetUniqueId function 40 | */ 41 | #define LORAWAN_DEVICE_EUI { IEEE_OUI, 0xFF, 0xEE, 0x00, 0x00, 0x20 } 42 | 43 | /*! 44 | * Application IEEE EUI (big endian) 45 | */ 46 | #define LORAWAN_APPLICATION_EUI { 0x70, 0xB3, 0xd5, 0x7E, 0xD0, 0x00, 0x86, 0xE2 } 47 | //70b3d57ef00046a4 70B3D57E D0007DFA 48 | /*! 49 | * AES encryption/decryption cipher application key 50 | */ 51 | #define LORAWAN_APPLICATION_KEY { 0x19, 0xA1, 0xE6, 0xF6, 0x77, 0xC4, 0xBE, 0x5E, 0xAC, 0xDE, 0x57, 0x29, 0x1F, 0x86, 0x8C, 0x3B } 52 | //a6b08140dae1d795ebfa5a6dee1f4dbd 09A503D6256F9EF612A15181F583880A 53 | /*! 54 | * Current network ID 55 | */ 56 | #define LORAWAN_NETWORK_ID ( uint32_t )0 57 | 58 | /*! 59 | * Device address on the network (big endian) 60 | * 61 | * \remark In this application the value is automatically generated using 62 | * a pseudo random generator seeded with a value derived from 63 | * BoardUniqueId value if LORAWAN_DEVICE_ADDRESS is set to 0 64 | */ 65 | #define LORAWAN_DEVICE_ADDRESS ( uint32_t )0x00000000 66 | 67 | /*! 68 | * AES encryption/decryption cipher network session key 69 | */ 70 | #define LORAWAN_NWKSKEY { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C } 71 | 72 | /*! 73 | * AES encryption/decryption cipher application session key 74 | */ 75 | #define LORAWAN_APPSKEY { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C } 76 | 77 | #endif // __LORA_COMMISSIONING_H__ 78 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/BME680-board.h: -------------------------------------------------------------------------------- 1 | #ifndef __BME680_BOARD_H_ 2 | #define __BME680_BOARD_H_ 3 | 4 | int8_t BME680_Init( void ); 5 | int8_t BME680_read( int16_t * temprature, uint32_t * pressure, uint32_t * humidity, uint32_t * resistance); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/BME680-selftest.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2017 - 2018 Bosch Sensortec GmbH 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 10 | * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * Neither the name of the copyright holder nor the names of the 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER 23 | * OR CONTRIBUTORS BE LIABLE FOR ANY 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 25 | * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 33 | * 34 | * The information provided is believed to be accurate and reliable. 35 | * The copyright holder assumes no responsibility 36 | * for the consequences of use 37 | * of such information nor for any infringement of patents or 38 | * other rights of third parties which may result from its use. 39 | * No license is granted by implication or otherwise under any patent or 40 | * patent rights of the copyright holder. 41 | * 42 | * @file bme680_selftest.h 43 | * @date 16 May 2018 44 | * @version 3.5.3 45 | * @brief 46 | * 47 | */ 48 | 49 | /*! 50 | * @addtogroup bme680_selftest 51 | * @brief 52 | * @{*/ 53 | 54 | 55 | #ifndef BME680_SELFTEST_H_ 56 | #define BME680_SELFTEST_H_ 57 | 58 | #include "BME680.h" 59 | 60 | /*! CPP guard */ 61 | #ifdef __cplusplus 62 | extern "C" 63 | { 64 | #endif 65 | 66 | #define BME680_W_SELF_TEST_FAILED 3 67 | 68 | /*! 69 | * @brief Self-test API for the BME680 70 | * 71 | * @param[in] Device structure containing relevant information on how 72 | * to communicate with the sensor 73 | * 74 | * @return Error code 75 | * @retval 0 Success 76 | * @retval < 0 Error 77 | * @retval > 0 Warning 78 | */ 79 | int8_t bme680_self_test(struct bme680_dev *dev); 80 | 81 | /*! CPP guard */ 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* BME680_SELFTEST_H_ */ 87 | 88 | /** @}*/ 89 | 90 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/adc-board.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2016 Semtech 8 | 9 | Description: Board ADC driver implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | #include "adc-board.h" 17 | 18 | ADC_HandleTypeDef AdcHandle; 19 | 20 | void AdcMcuInit( Adc_t *obj, PinNames adcInput ) 21 | { 22 | AdcHandle.Instance = ( ADC_TypeDef* )ADC1_BASE; 23 | 24 | __HAL_RCC_ADC1_CLK_ENABLE( ); 25 | 26 | HAL_ADC_DeInit( &AdcHandle ); 27 | 28 | if( adcInput != NC ) 29 | { 30 | GpioInit( &obj->AdcInput, adcInput, PIN_ANALOGIC, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); 31 | } 32 | } 33 | 34 | void AdcMcuConfig( void ) 35 | { 36 | // Configure ADC 37 | AdcHandle.Init.Resolution = ADC_RESOLUTION_12B; 38 | AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT; 39 | AdcHandle.Init.ContinuousConvMode = DISABLE; 40 | AdcHandle.Init.DiscontinuousConvMode = DISABLE; 41 | AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; 42 | AdcHandle.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T6_TRGO; 43 | AdcHandle.Init.DMAContinuousRequests = DISABLE; 44 | AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV; 45 | AdcHandle.Init.NbrOfConversion = 1; 46 | AdcHandle.Init.LowPowerAutoWait = DISABLE; 47 | AdcHandle.Init.LowPowerAutoPowerOff = DISABLE; 48 | HAL_ADC_Init( &AdcHandle ); 49 | } 50 | 51 | uint16_t AdcMcuReadChannel( Adc_t *obj, uint32_t channel ) 52 | { 53 | ADC_ChannelConfTypeDef adcConf = { 0 }; 54 | uint16_t adcData = 0; 55 | 56 | // Enable HSI 57 | __HAL_RCC_HSI_ENABLE( ); 58 | 59 | // Wait till HSI is ready 60 | while( __HAL_RCC_GET_FLAG( RCC_FLAG_HSIRDY ) == RESET ) 61 | { 62 | } 63 | 64 | __HAL_RCC_ADC1_CLK_ENABLE( ); 65 | 66 | adcConf.Channel = channel; 67 | adcConf.Rank = ADC_REGULAR_RANK_1; 68 | adcConf.SamplingTime = ADC_SAMPLETIME_192CYCLES; 69 | 70 | HAL_ADC_ConfigChannel( &AdcHandle, &adcConf ); 71 | 72 | // Enable ADC1 73 | __HAL_ADC_ENABLE( &AdcHandle ); 74 | 75 | // Start ADC Software Conversion 76 | HAL_ADC_Start( &AdcHandle ); 77 | 78 | HAL_ADC_PollForConversion( &AdcHandle, HAL_MAX_DELAY ); 79 | 80 | adcData = HAL_ADC_GetValue( &AdcHandle ); 81 | 82 | __HAL_ADC_DISABLE( &AdcHandle ); 83 | 84 | if( ( adcConf.Channel == ADC_CHANNEL_TEMPSENSOR ) || ( adcConf.Channel == ADC_CHANNEL_VREFINT ) ) 85 | { 86 | HAL_ADC_DeInit( &AdcHandle ); 87 | } 88 | __HAL_RCC_ADC1_CLK_DISABLE( ); 89 | 90 | // Disable HSI 91 | __HAL_RCC_HSI_DISABLE( ); 92 | 93 | return adcData; 94 | } 95 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/adc-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2016 Semtech 8 | 9 | Description: Board ADC driver implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __ADC_MCU_H__ 16 | #define __ADC_MCU_H__ 17 | 18 | /*! 19 | * \brief Initializes the ADC object and MCU peripheral 20 | * 21 | * \param [IN] obj ADC object 22 | * \param [IN] adcInput ADC input pin 23 | */ 24 | void AdcMcuInit( Adc_t *obj, PinNames adcInput ); 25 | 26 | /*! 27 | * \brief Initializes the ADC internal parameters 28 | */ 29 | void AdcMcuConfig( void ); 30 | 31 | /*! 32 | * \brief Reads the value of the given channel 33 | * 34 | * \param [IN] obj ADC object 35 | * \param [IN] channel ADC input channel 36 | */ 37 | uint16_t AdcMcuReadChannel( Adc_t *obj, uint32_t channel ); 38 | 39 | #endif // __ADC_MCU_H__ 40 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/cmsis/stm32l151xb.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/RAK811BreakBoard/cmsis/stm32l151xb.sav -------------------------------------------------------------------------------- /src/RAK811BreakBoard/cmsis/stm32l151xba.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/RAK811BreakBoard/cmsis/stm32l151xba.h -------------------------------------------------------------------------------- /src/RAK811BreakBoard/cmsis/stm32l1xx.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/RAK811BreakBoard/cmsis/stm32l1xx.sav -------------------------------------------------------------------------------- /src/RAK811BreakBoard/eeprom-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Timer objects and scheduling management 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __EEPROM_MCU_H__ 16 | #define __EEPROM_MCU_H__ 17 | 18 | /*! 19 | * Writes the given buffer to the EEPROM at the specified address. 20 | * 21 | * \param[IN] addr EEPROM address to write to 22 | * \param[IN] buffer Pointer to the buffer to be written. 23 | * \param[IN] size Size of the buffer to be written. 24 | * \retval status [SUCCESS, FAIL] 25 | */ 26 | uint8_t EepromMcuWriteBuffer( uint16_t addr, uint8_t *buffer, uint16_t size ); 27 | 28 | /*! 29 | * Reads the EEPROM at the specified address to the given buffer. 30 | * 31 | * \param[IN] addr EEPROM address to read from 32 | * \param[OUT] buffer Pointer to the buffer to be written with read data. 33 | * \param[IN] size Size of the buffer to be read. 34 | * \retval status [SUCCESS, FAIL] 35 | */ 36 | uint8_t EepromMcuReadBuffer( uint16_t addr, uint8_t *buffer, uint16_t size ); 37 | 38 | /*! 39 | * Sets the device address. 40 | * 41 | * \remark Useful for I2C external EEPROMS 42 | * 43 | * \param[IN] addr External EEPROM address 44 | */ 45 | void EepromMcuSetDeviceAddr( uint8_t addr ); 46 | 47 | /*! 48 | * Gets the current device address. 49 | * 50 | * \remark Useful for I2C external EEPROMS 51 | * 52 | * \retval addr External EEPROM address 53 | */ 54 | uint8_t EepromMcuGetDeviceAddr( void ); 55 | 56 | #endif // __EEPROM_MCU_H__ 57 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/gpio-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Bleeper board GPIO driver implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __GPIO_MCU_H__ 16 | #define __GPIO_MCU_H__ 17 | 18 | /*! 19 | * \brief Initializes the given GPIO object 20 | * 21 | * \param [IN] obj Pointer to the GPIO object to be initialized 22 | * \param [IN] pin Pin name ( please look in pinName-board.h file ) 23 | * \param [IN] mode Pin mode [PIN_INPUT, PIN_OUTPUT, 24 | * PIN_ALTERNATE_FCT, PIN_ANALOGIC] 25 | * \param [IN] config Pin config [PIN_PUSH_PULL, PIN_OPEN_DRAIN] 26 | * \param [IN] type Pin type [PIN_NO_PULL, PIN_PULL_UP, PIN_PULL_DOWN] 27 | * \param [IN] value Default output value at initialization 28 | */ 29 | void GpioMcuInit( Gpio_t *obj, PinNames pin, PinModes mode, PinConfigs config, PinTypes type, uint32_t value ); 30 | 31 | /*! 32 | * \brief GPIO IRQ Initialization 33 | * 34 | * \param [IN] obj Pointer to the GPIO object to be initialized 35 | * \param [IN] irqMode IRQ mode [NO_IRQ, IRQ_RISING_EDGE, 36 | * IRQ_FALLING_EDGE, IRQ_RISING_FALLING_EDGE] 37 | * \param [IN] irqPriority IRQ priority [IRQ_VERY_LOW_PRIORITY, IRQ_LOW_PRIORITY 38 | * IRQ_MEDIUM_PRIORITY, IRQ_HIGH_PRIORITY 39 | * IRQ_VERY_HIGH_PRIORITY] 40 | * \param [IN] irqHandler Callback function pointer 41 | */ 42 | void GpioMcuSetInterrupt( Gpio_t *obj, IrqModes irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler ); 43 | 44 | /*! 45 | * \brief GPIO IRQ DeInitialization 46 | * 47 | * \param [IN] obj Pointer to the GPIO object to be de-initialized 48 | */ 49 | void GpioMcuRemoveInterrupt( Gpio_t *obj ); 50 | 51 | /*! 52 | * \brief Writes the given value to the GPIO output 53 | * 54 | * \param [IN] obj Pointer to the GPIO object 55 | * \param [IN] value New GPIO output value 56 | */ 57 | void GpioMcuWrite( Gpio_t *obj, uint32_t value ); 58 | 59 | /*! 60 | * \brief Toggle the value to the GPIO output 61 | * 62 | * \param [IN] obj Pointer to the GPIO object 63 | */ 64 | void GpioMcuToggle( Gpio_t *obj ); 65 | 66 | /*! 67 | * \brief Reads the current GPIO input value 68 | * 69 | * \param [IN] obj Pointer to the GPIO object 70 | * \retval value Current GPIO input value 71 | */ 72 | uint32_t GpioMcuRead( Gpio_t *obj ); 73 | 74 | #endif // __GPIO_MCU_H__ 75 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/gps-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Generic driver for GPS receiver 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __GPS_BOARD_H__ 16 | #define __GPS_BOARD_H__ 17 | 18 | /*! 19 | * Select the edge of the PPS signal which is used to start the 20 | * reception of data on the UART. Depending of the GPS, the PPS 21 | * signal may go low or high to indicate the presence of data 22 | */ 23 | typedef enum PpsTrigger_s 24 | { 25 | PpsTriggerIsRising = 0, 26 | PpsTriggerIsFalling, 27 | }PpsTrigger_t; 28 | 29 | /*! 30 | * \brief Low level handling of the PPS signal from the GPS receiver 31 | */ 32 | void GpsMcuOnPpsSignal( void ); 33 | 34 | /*! 35 | * \brief Invert the IRQ trigger edge on the PPS signal 36 | */ 37 | void GpsMcuInvertPpsTrigger( void ); 38 | 39 | /*! 40 | * \brief Low level Initialisation of the UART and IRQ for the GPS 41 | */ 42 | void GpsMcuInit( void ); 43 | 44 | /*! 45 | * \brief Switch ON the GPS 46 | */ 47 | void GpsMcuStart( void ); 48 | 49 | /*! 50 | * \brief Switch OFF the GPS 51 | */ 52 | void GpsMcuStop( void ); 53 | 54 | /*! 55 | * Updates the GPS status 56 | */ 57 | void GpsMcuProcess( void ); 58 | 59 | /*! 60 | * \brief IRQ handler for the UART receiver 61 | */ 62 | void GpsMcuIrqNotify( UartNotifyId_t id ); 63 | 64 | bool GpsMcuIsEnable(void); 65 | #endif // __GPS_BOARD_H__ 66 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/i2c-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Bleeper board I2C driver implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __I2C_MCU_H__ 16 | #define __I2C_MCU_H__ 17 | 18 | /*! 19 | * Operation Mode for the I2C 20 | */ 21 | typedef enum 22 | { 23 | MODE_I2C = 0, 24 | MODE_SMBUS_DEVICE, 25 | MODE_SMBUS_HOST 26 | }I2cMode; 27 | 28 | /*! 29 | * I2C signal duty cycle 30 | */ 31 | typedef enum 32 | { 33 | I2C_DUTY_CYCLE_2 = 0, 34 | I2C_DUTY_CYCLE_16_9 35 | }I2cDutyCycle; 36 | 37 | /*! 38 | * I2C select if the acknowledge in after the 7th or 10th bit 39 | */ 40 | typedef enum 41 | { 42 | I2C_ACK_ADD_7_BIT = 0, 43 | I2C_ACK_ADD_10_BIT 44 | }I2cAckAddrMode; 45 | 46 | /*! 47 | * Internal device address size 48 | */ 49 | typedef enum 50 | { 51 | I2C_ADDR_SIZE_8 = 0, 52 | I2C_ADDR_SIZE_16, 53 | }I2cAddrSize; 54 | 55 | /*! 56 | * \brief Initializes the I2C object and MCU peripheral 57 | * 58 | * \param [IN] obj I2C object 59 | * \param [IN] scl I2C Scl pin name to be used 60 | * \param [IN] sda I2C Sda pin name to be used 61 | */ 62 | void I2cMcuInit( I2c_t *obj, PinNames scl, PinNames sda ); 63 | 64 | /*! 65 | * \brief Initializes the I2C object and MCU peripheral 66 | * 67 | * \param [IN] obj I2C object 68 | * \param [IN] mode Mode of operation for the I2C Bus 69 | * \param [IN] dutyCycle Signal duty cycle 70 | * \param [IN] I2cAckEnable Enable or Disable to ack 71 | * \param [IN] AckAddrMode 7bit or 10 bit addressing 72 | * \param [IN] I2cFrequency I2C bus clock frequency 73 | */ 74 | void I2cMcuFormat( I2c_t *obj, I2cMode mode, I2cDutyCycle dutyCycle, bool I2cAckEnable, I2cAckAddrMode AckAddrMode, uint32_t I2cFrequency ); 75 | 76 | /*! 77 | * \brief DeInitializes the I2C object and MCU peripheral 78 | * 79 | * \param [IN] obj I2C object 80 | */ 81 | void I2cMcuDeInit( I2c_t *obj ); 82 | 83 | /*! 84 | * \brief Write several data to the I2C device 85 | * 86 | * \param [IN] obj I2C object 87 | * \param [IN] deviceAddr device address 88 | * \param [IN] addr register address 89 | * \param [IN] buffer data buffer to write 90 | * \param [IN] size number of data byte to write 91 | */ 92 | uint8_t I2cMcuWriteBuffer( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *buffer, uint16_t size ); 93 | 94 | /*! 95 | * \brief Read several data byte from the I2C device 96 | * 97 | * \param [IN] obj I2C object 98 | * \param [IN] deviceAddr device address 99 | * \param [IN] addr register address 100 | * \param [IN] buffer data buffer used to store the data read 101 | * \param [IN] size number of data byte to read 102 | */ 103 | uint8_t I2cMcuReadBuffer( I2c_t *obj, uint8_t deviceAddr, uint16_t addr, uint8_t *buffer, uint16_t size ); 104 | 105 | /*! 106 | * \brief Waits until the given device is in standby mode 107 | * 108 | * \param [IN] obj I2C object 109 | * \param [IN] deviceAddr device address 110 | */ 111 | uint8_t I2cMcuWaitStandbyState( I2c_t *obj, uint8_t deviceAddr ); 112 | 113 | /*! 114 | * \brief Sets the internal device address size 115 | * 116 | * \param [IN] obj I2C object 117 | * \param [IN] addrSize Internal address size 118 | */ 119 | void I2cSetAddrSize( I2c_t *obj, I2cAddrSize addrSize ); 120 | 121 | #endif // __I2C_MCU_H__ 122 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/pinName-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Bleeper STM32L151RD microcontroller pins definition 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __PIN_NAME_MCU_H__ 16 | #define __PIN_NAME_MCU_H__ 17 | 18 | /*! 19 | * STM32 Pin Names 20 | */ 21 | #define MCU_PINS \ 22 | PA_0 = 0, PA_1, PA_2, PA_3, PA_4, PA_5, PA_6, PA_7, PA_8, PA_9, PA_10, PA_11, PA_12, PA_13, PA_14, PA_15, \ 23 | PB_0, PB_1, PB_2, PB_3, PB_4, PB_5, PB_6, PB_7, PB_8, PB_9, PB_10, PB_11, PB_12, PB_13, PB_14, PB_15, \ 24 | PC_0, PC_1, PC_2, PC_3, PC_4, PC_5, PC_6, PC_7, PC_8, PC_9, PC_10, PC_11, PC_12, PC_13, PC_14, PC_15, \ 25 | PD_0, PD_1, PD_2, PD_3, PD_4, PD_5, PD_6, PD_7, PD_8, PD_9, PD_10, PD_11, PD_12, PD_13, PD_14, PD_15, \ 26 | PE_0, PE_1, PE_2, PE_3, PE_4, PE_5, PE_6, PE_7, PE_8, PE_9, PE_10, PE_11, PE_12, PE_13, PE_14, PE_15, \ 27 | PF_0, PF_1, PF_2, PF_3, PF_4, PF_5, PF_6, PF_7, PF_8, PF_9, PF_10, PF_11, PF_12, PF_13, PF_14, PF_15, \ 28 | PH_0, PH_1, PH_2, PH_3, PH_4, PH_5, PH_6, PH_7, PH_8, PH_9, PH_10, PH_11, PH_12, PH_13, PH_14, PH_15 29 | 30 | #endif // __PIN_NAME_MCU_H__ 31 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/pinName-ioe.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Bleeper STM32L151RD microcontroller pins definition 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __PIN_NAME_IOE_H__ 16 | #define __PIN_NAME_IOE_H__ 17 | 18 | // SX1509 Pin Names 19 | #define IOE_PINS \ 20 | IOE_0, IOE_1, IOE_2, IOE_3, IOE_4, IOE_5, IOE_6, IOE_7, \ 21 | IOE_8, IOE_9, IOE_10, IOE_11, IOE_12, IOE_13, IOE_14, IOE_15 22 | #endif // __PIN_NAME_IOE_H__ 23 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/rtc-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: MCU RTC timer and low power modes management 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __RTC_BOARD_H__ 16 | #define __RTC_BOARD_H__ 17 | 18 | /*! 19 | * \brief Timer time variable definition 20 | */ 21 | #ifndef TimerTime_t 22 | typedef uint32_t TimerTime_t; 23 | #endif 24 | 25 | /*! 26 | * \brief Initializes the RTC timer 27 | * 28 | * \remark The timer is based on the RTC 29 | */ 30 | void RtcInit( void ); 31 | 32 | /*! 33 | * \brief Start the RTC timer 34 | * 35 | * \remark The timer is based on the RTC Alarm running at 32.768KHz 36 | * 37 | * \param[IN] timeout Duration of the Timer 38 | */ 39 | void RtcSetTimeout( uint32_t timeout ); 40 | 41 | /*! 42 | * \brief Adjust the value of the timeout to handle wakeup time from Alarm and GPIO irq 43 | * 44 | * \param[IN] timeout Duration of the Timer without compensation for wakeup time 45 | * \retval new value for the Timeout with compensations 46 | */ 47 | TimerTime_t RtcGetAdjustedTimeoutValue( uint32_t timeout ); 48 | 49 | /*! 50 | * \brief Get the RTC timer value 51 | * 52 | * \retval RTC Timer value 53 | */ 54 | TimerTime_t RtcGetTimerValue( void ); 55 | 56 | /*! 57 | * \brief Get the RTC timer elapsed time since the last Alarm was set 58 | * 59 | * \retval RTC Elapsed time since the last alarm 60 | */ 61 | TimerTime_t RtcGetElapsedAlarmTime( void ); 62 | 63 | /*! 64 | * \brief Compute the timeout time of a future event in time 65 | * 66 | * \param[IN] futureEventInTime Value in time 67 | * \retval time Time between now and the futureEventInTime 68 | */ 69 | TimerTime_t RtcComputeFutureEventTime( TimerTime_t futureEventInTime ); 70 | 71 | /*! 72 | * \brief Compute the elapsed time since a fix event in time 73 | * 74 | * \param[IN] eventInTime Value in time 75 | * \retval elapsed Time since the eventInTime 76 | */ 77 | TimerTime_t RtcComputeElapsedTime( TimerTime_t eventInTime ); 78 | 79 | /*! 80 | * \brief This function blocks the MCU from going into Low Power mode 81 | * 82 | * \param [IN] status [true: Enable, false: Disable 83 | */ 84 | void BlockLowPowerDuringTask ( bool status ); 85 | 86 | /*! 87 | * \brief Sets the MCU into low power STOP mode 88 | */ 89 | void RtcEnterLowPowerStopMode( void ); 90 | 91 | /*! 92 | * \brief Restore the MCU to its normal operation mode 93 | */ 94 | void RtcRecoverMcuStatus( void ); 95 | 96 | #endif // __RTC_BOARD_H__ 97 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/rw_sys.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/RAK811BreakBoard/rw_sys.h -------------------------------------------------------------------------------- /src/RAK811BreakBoard/spi-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Bleeper board SPI driver implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __SPI_MCU_H__ 16 | #define __SPI_MCU_H__ 17 | 18 | /*! 19 | * SPI driver structure definition 20 | */ 21 | struct Spi_s 22 | { 23 | SPI_HandleTypeDef Spi; 24 | Gpio_t Mosi; 25 | Gpio_t Miso; 26 | Gpio_t Sclk; 27 | Gpio_t Nss; 28 | }; 29 | 30 | #endif // __SPI_MCU_H__ 31 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/sx1276-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: SX1276 driver specific target board functions implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __SX1276_ARCH_H__ 16 | #define __SX1276_ARCH_H__ 17 | 18 | /*! 19 | * \brief Radio hardware registers initialization definition 20 | * 21 | * \remark Can be automatically generated by the SX1276 GUI (not yet implemented) 22 | */ 23 | #define RADIO_INIT_REGISTERS_VALUE \ 24 | { \ 25 | { MODEM_FSK , REG_LNA , 0x23 },\ 26 | { MODEM_FSK , REG_RXCONFIG , 0x1E },\ 27 | { MODEM_FSK , REG_RSSICONFIG , 0xD2 },\ 28 | { MODEM_FSK , REG_AFCFEI , 0x01 },\ 29 | { MODEM_FSK , REG_PREAMBLEDETECT , 0xAA },\ 30 | { MODEM_FSK , REG_OSC , 0x07 },\ 31 | { MODEM_FSK , REG_SYNCCONFIG , 0x12 },\ 32 | { MODEM_FSK , REG_SYNCVALUE1 , 0xC1 },\ 33 | { MODEM_FSK , REG_SYNCVALUE2 , 0x94 },\ 34 | { MODEM_FSK , REG_SYNCVALUE3 , 0xC1 },\ 35 | { MODEM_FSK , REG_PACKETCONFIG1 , 0xD8 },\ 36 | { MODEM_FSK , REG_FIFOTHRESH , 0x8F },\ 37 | { MODEM_FSK , REG_IMAGECAL , 0x02 },\ 38 | { MODEM_FSK , REG_DIOMAPPING1 , 0x00 },\ 39 | { MODEM_FSK , REG_DIOMAPPING2 , 0x30 },\ 40 | { MODEM_LORA, REG_LR_PAYLOADMAXLENGTH, 0x40 },\ 41 | } \ 42 | 43 | #define RF_MID_BAND_THRESH 525000000 44 | 45 | /*! 46 | * \brief Initializes the radio I/Os pins interface 47 | */ 48 | void SX1276IoInit( void ); 49 | 50 | /*! 51 | * \brief Initializes DIO IRQ handlers 52 | * 53 | * \param [IN] irqHandlers Array containing the IRQ callback functions 54 | */ 55 | void SX1276IoIrqInit( DioIrqHandler **irqHandlers ); 56 | 57 | /*! 58 | * \brief De-initializes the radio I/Os pins interface. 59 | * 60 | * \remark Useful when going in MCU low power modes 61 | */ 62 | void SX1276IoDeInit( void ); 63 | 64 | /*! 65 | * \brief Sets the radio output power. 66 | * 67 | * \param [IN] power Sets the RF output power 68 | */ 69 | void SX1276SetRfTxPower( int8_t power ); 70 | 71 | /*! 72 | * \brief Gets the board PA selection configuration 73 | * 74 | * \param [IN] channel Channel frequency in Hz 75 | * \retval PaSelect RegPaConfig PaSelect value 76 | */ 77 | uint8_t SX1276GetPaSelect( uint32_t channel ); 78 | 79 | /*! 80 | * \brief Set the RF Switch I/Os pins in Low Power mode 81 | * 82 | * \param [IN] status enable or disable 83 | */ 84 | void SX1276SetAntSwLowPower( bool status ); 85 | 86 | /*! 87 | * \brief Initializes the RF Switch I/Os pins interface 88 | */ 89 | void SX1276AntSwInit( void ); 90 | 91 | /*! 92 | * \brief De-initializes the RF Switch I/Os pins interface 93 | * 94 | * \remark Needed to decrease the power consumption in MCU low power modes 95 | */ 96 | void SX1276AntSwDeInit( void ); 97 | 98 | /*! 99 | * \brief Controls the antenna switch if necessary. 100 | * 101 | * \remark see errata note 102 | * 103 | * \param [IN] opMode Current radio operating mode 104 | */ 105 | void SX1276SetAntSw( uint8_t opMode ); 106 | 107 | /*! 108 | * \brief Checks if the given RF frequency is supported by the hardware 109 | * 110 | * \param [IN] frequency RF frequency to be checked 111 | * \retval isSupported [true: supported, false: unsupported] 112 | */ 113 | bool SX1276CheckRfFrequency( uint32_t frequency ); 114 | 115 | /*! 116 | * Radio hardware and global parameters 117 | */ 118 | extern SX1276_t SX1276; 119 | 120 | #endif // __SX1276_ARCH_H__ 121 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/uart-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2016 Semtech 8 | 9 | Description: Board UART driver implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __UART_MCU_H__ 16 | #define __UART_MCU_H__ 17 | 18 | /*! 19 | * UART peripheral ID 20 | */ 21 | typedef enum 22 | { 23 | UART_1, 24 | UART_3, 25 | UART_COUNT, 26 | UART_USB_CDC = 255, 27 | }UartId_t; 28 | 29 | /*! 30 | * \brief Initializes the UART object and MCU peripheral 31 | * 32 | * \param [IN] obj UART object 33 | * \param [IN] tx UART Tx pin name to be used 34 | * \param [IN] rx UART Rx pin name to be used 35 | */ 36 | void UartMcuInit( Uart_t *obj, uint8_t uartId, PinNames tx, PinNames rx ); 37 | 38 | /*! 39 | * \brief Initializes the UART object and MCU peripheral 40 | * 41 | * \param [IN] obj UART object 42 | * \param [IN] mode Mode of operation for the UART 43 | * \param [IN] baudrate UART baudrate 44 | * \param [IN] wordLength packet length 45 | * \param [IN] stopBits stop bits setup 46 | * \param [IN] parity packet parity 47 | * \param [IN] flowCtrl UART flow control 48 | */ 49 | void UartMcuConfig( Uart_t *obj, UartMode_t mode, uint32_t baudrate, WordLength_t wordLength, StopBits_t stopBits, Parity_t parity, FlowCtrl_t flowCtrl ); 50 | 51 | /*! 52 | * \brief DeInitializes the UART object and MCU peripheral 53 | * 54 | * \param [IN] obj UART object 55 | */ 56 | void UartMcuDeInit( Uart_t *obj ); 57 | 58 | /*! 59 | * \brief Sends a character to the UART 60 | * 61 | * \param [IN] obj UART object 62 | * \param [IN] data Character to be sent 63 | * \retval status [0: OK, 1: Busy] 64 | */ 65 | uint8_t UartMcuPutChar( Uart_t *obj, uint8_t data ); 66 | 67 | /*! 68 | * \brief Sends a character to the UART 69 | * 70 | * \param [IN] obj UART object 71 | * \param [IN] data Characters to be sent 72 | * \param [IN] size number of characters to send 73 | * \retval status [0: OK, 1: Busy] 74 | */ 75 | uint8_t UartMcuPutBuffer( Uart_t *obj, uint8_t *data, uint16_t size ); 76 | 77 | /*! 78 | * \brief Gets a character from the UART 79 | * 80 | * \param [IN] obj UART object 81 | * \param [IN] data Received character 82 | * \retval status [0: OK, 1: Busy] 83 | */ 84 | uint8_t UartMcuGetChar( Uart_t *obj, uint8_t *data ); 85 | 86 | /*! 87 | * \brief Gets a character from the UART (blocking mode) 88 | * 89 | * \param [IN] obj UART object 90 | * \param [IN] data Received character 91 | * \param [IN] size number of characters to be received 92 | * \retval status [0: OK, 1: Busy] 93 | */ 94 | uint8_t UartMcuGetBuffer( Uart_t *obj, uint8_t *data, uint16_t size ); 95 | void UartFlush( Uart_t *obj); 96 | 97 | #endif // __UART_MCU_H__ 98 | -------------------------------------------------------------------------------- /src/RAK811BreakBoard/uart-usb-board.c: -------------------------------------------------------------------------------- 1 | #if 0 2 | /* 3 | / _____) _ | | 4 | ( (____ _____ ____ _| |_ _____ ____| |__ 5 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 6 | _____) ) ____| | | || |_| ____( (___| | | | 7 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 8 | (C)2013 Semtech 9 | 10 | Description: Bleeper board UART driver implementation 11 | 12 | License: Revised BSD License, see LICENSE.TXT file include in the project 13 | 14 | Maintainer: Miguel Luis and Gregory Cristian 15 | */ 16 | #include "board.h" 17 | 18 | #include "usbd_core.h" 19 | #include "usbd_desc.h" 20 | #include "usbd_cdc.h" 21 | #include "usbd_cdc_if.h" 22 | #include "uart-usb-board.h" 23 | 24 | /* USB handler declaration */ 25 | /* Handle for USB Full Speed IP */ 26 | //USBD_HandleTypeDef *hUsbDevice_0; 27 | 28 | USBD_HandleTypeDef hUsbDeviceFS; 29 | extern PCD_HandleTypeDef hpcd_USB_FS; 30 | 31 | void UartUsbInit( Uart_t *obj, uint8_t uartId, PinNames tx, PinNames rx ) 32 | { 33 | obj->UartId = uartId; 34 | 35 | __HAL_RCC_COMP_CLK_ENABLE( ); 36 | __HAL_RCC_SYSCFG_CLK_ENABLE( ); 37 | 38 | CDC_Set_Uart_Obj( obj ); 39 | 40 | /* Init Device Library, Add Supported Class and Start the library */ 41 | USBD_Init( &hUsbDeviceFS, &FS_Desc, DEVICE_FS ); 42 | 43 | USBD_RegisterClass( &hUsbDeviceFS, &USBD_CDC ); 44 | 45 | USBD_CDC_RegisterInterface( &hUsbDeviceFS, &USBD_Interface_fops_FS ); 46 | 47 | USBD_Start( &hUsbDeviceFS ); 48 | } 49 | 50 | void UartUsbConfig( Uart_t *obj, UartMode_t mode, uint32_t baudrate, WordLength_t wordLength, StopBits_t stopBits, Parity_t parity, FlowCtrl_t flowCtrl ) 51 | { 52 | 53 | } 54 | 55 | void UartUsbDeInit( Uart_t *obj ) 56 | { 57 | 58 | } 59 | 60 | uint8_t UartUsbIsUsbCableConnected( void ) 61 | { 62 | if( hUsbDeviceFS.dev_address == 0 ) 63 | { 64 | // USB is low Power mode meaning USB cable is not connected 65 | return 0; 66 | } 67 | else 68 | { 69 | // USB is in active mode meaning USB cable is connected 70 | return 1; 71 | } 72 | } 73 | 74 | uint8_t UartUsbPutBuffer( Uart_t *obj, uint8_t *buffer, uint16_t size ) 75 | { 76 | return CDC_Transmit_FS( buffer, size ); 77 | } 78 | 79 | uint8_t UartUsbPutChar( Uart_t *obj, uint8_t data ) 80 | { 81 | return UartUsbPutBuffer( obj, &data, 1 ); 82 | } 83 | 84 | uint8_t UartUsbGetChar( Uart_t *obj, uint8_t *data ) 85 | { 86 | if( IsFifoEmpty( &obj->FifoRx ) == false ) 87 | { 88 | BoardDisableIrq( ); 89 | *data = FifoPop( &obj->FifoRx ); 90 | BoardEnableIrq( ); 91 | return 0; 92 | } 93 | return 1; 94 | } 95 | 96 | void USB_LP_IRQHandler( void ) 97 | { 98 | HAL_PCD_IRQHandler( &hpcd_USB_FS ); 99 | } 100 | 101 | #ifdef __GNUC__ 102 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 103 | set to 'Yes') calls __io_putchar() */ 104 | int __io_putchar( int c ) 105 | #else /* __GNUC__ */ 106 | int fputc( int c, FILE *stream ) 107 | #endif 108 | { 109 | while( UartUsbPutChar( &UartUsb, c ) != 0 ); 110 | return c; 111 | } 112 | #endif -------------------------------------------------------------------------------- /src/RAK811BreakBoard/uart-usb-board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Bleeper board UART driver implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __UART_USB_H__ 16 | #define __UART_USB_H__ 17 | 18 | /*! 19 | * \brief Initializes the UART object and MCU peripheral 20 | * 21 | * \param [IN] obj UART object 22 | * \param [IN] tx UART Tx pin name to be used 23 | * \param [IN] rx UART Rx pin name to be used 24 | */ 25 | void UartUsbInit( Uart_t *obj, uint8_t uartId, PinNames tx, PinNames rx ); 26 | 27 | /*! 28 | * \brief Initializes the UART object and USB peripheral 29 | * 30 | * \param [IN] obj UART object 31 | * \param [IN] mode Mode of operation for the UART 32 | * \param [IN] baudrate UART baudrate 33 | * \param [IN] wordLength packet length 34 | * \param [IN] stopBits stop bits setup 35 | * \param [IN] parity packet parity 36 | * \param [IN] flowCtrl UART flow control 37 | */ 38 | void UartUsbConfig( Uart_t *obj, UartMode_t mode, uint32_t baudrate, WordLength_t wordLength, StopBits_t stopBits, Parity_t parity, FlowCtrl_t flowCtrl ); 39 | 40 | /*! 41 | * \brief DeInitializes the UART object and USB peripheral 42 | * 43 | * \param [IN] obj UART object 44 | */ 45 | void UartUsbDeInit( Uart_t *obj ); 46 | 47 | /*! 48 | * \brief Checks if the cable is connected or not 49 | * 50 | * \retval connected [0: Not connected, 1: Connected] 51 | */ 52 | uint8_t UartUsbIsUsbCableConnected( void ); 53 | 54 | /*! 55 | * \brief Sends a buffer to the UART 56 | * 57 | * \param [IN] obj UART object 58 | * \param [IN] buffer Buffer to be sent 59 | * \param [IN] size Buffer size 60 | * \retval status [0: OK, 1: Busy, 2: Fail] 61 | */ 62 | uint8_t UartUsbPutBuffer( Uart_t *obj, uint8_t *buffer, uint16_t size ); 63 | 64 | /*! 65 | * \brief Sends a character to the UART 66 | * 67 | * \param [IN] obj UART object 68 | * \param [IN] data Character to be sent 69 | * \retval status [0: OK, 1: Busy, 2: Fail] 70 | */ 71 | uint8_t UartUsbPutChar( Uart_t *obj, uint8_t data ); 72 | 73 | /*! 74 | * \brief Gets a character from the UART 75 | * 76 | * \param [IN] obj UART object 77 | * \param [IN] data Received character 78 | * \retval status [0: OK, 1: Busy, 2: Fail] 79 | */ 80 | uint8_t UartUsbGetChar( Uart_t *obj, uint8_t *data ); 81 | 82 | #endif // __UART_USB_H__ 83 | -------------------------------------------------------------------------------- /src/boards/RAK811BreakBoard/cmsis/arm-gcc/STM32L151XBA_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/boards/RAK811BreakBoard/cmsis/arm-gcc/STM32L151XBA_FLASH.ld -------------------------------------------------------------------------------- /src/boards/RAK811BreakBoard/cmsis/arm-gcc/STM32L151XB_FLASH.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/boards/RAK811BreakBoard/cmsis/arm-gcc/STM32L151XB_FLASH.ld -------------------------------------------------------------------------------- /src/boards/mcu/stm32/RTE_Components.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Auto generated Run-Time-Environment Component Configuration File 4 | * *** Do not modify ! *** 5 | * 6 | * Project: 'LoRaWAN' 7 | * Target: 'LoRaWAN Configuration' 8 | */ 9 | 10 | #ifndef RTE_COMPONENTS_H 11 | #define RTE_COMPONENTS_H 12 | 13 | 14 | #endif /* RTE_COMPONENTS_H */ 15 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Inc/mxconstants.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * File Name : mxconstants.h 4 | * Description : This file contains the common defines of the application 5 | ****************************************************************************** 6 | * 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __MXCONSTANT_H 35 | #define __MXCONSTANT_H 36 | /* Includes ------------------------------------------------------------------*/ 37 | 38 | /* USER CODE BEGIN Includes */ 39 | 40 | /* USER CODE END Includes */ 41 | 42 | /* Private define ------------------------------------------------------------*/ 43 | 44 | /* USER CODE BEGIN Private defines */ 45 | 46 | /* USER CODE END Private defines */ 47 | 48 | /** 49 | * @} 50 | */ 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | #endif /* __MXCONSTANT_H */ 57 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 58 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Inc/stm32_assert_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32_assert.h 4 | * @author MCD Application Team 5 | * @version V1.2.0 6 | * @date 01-July-2016 7 | * @brief STM32 assert template file. 8 | * This file should be copied to the application folder and renamed 9 | * to stm32_assert.h. 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | *

© COPYRIGHT(c) 2016 STMicroelectronics

14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | 40 | /* Define to prevent recursive inclusion -------------------------------------*/ 41 | #ifndef __STM32_ASSERT_H 42 | #define __STM32_ASSERT_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | /* Exported types ------------------------------------------------------------*/ 49 | /* Exported constants --------------------------------------------------------*/ 50 | /* Includes ------------------------------------------------------------------*/ 51 | /* Exported macro ------------------------------------------------------------*/ 52 | #ifdef USE_FULL_ASSERT 53 | /** 54 | * @brief The assert_param macro is used for function's parameters check. 55 | * @param expr: If expr is false, it calls assert_failed function 56 | * which reports the name of the source file and the source 57 | * line number of the call that failed. 58 | * If expr is true, it returns no value. 59 | * @retval None 60 | */ 61 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) 62 | /* Exported functions ------------------------------------------------------- */ 63 | void assert_failed(uint8_t* file, uint32_t line); 64 | #else 65 | #define assert_param(expr) ((void)0U) 66 | #endif /* USE_FULL_ASSERT */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* __STM32_ASSERT_H */ 73 | 74 | 75 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 76 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_cryp_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l1xx_hal_cryp_ex.h 4 | * @author MCD Application Team 5 | * @version V1.2.0 6 | * @date 01-July-2016 7 | * @brief Header file of CRYPEx HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32L1xx_HAL_CRYP_EX_H 40 | #define __STM32L1xx_HAL_CRYP_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if defined(STM32L162xC) || defined(STM32L162xCA) || defined(STM32L162xD) || defined(STM32L162xE) || defined(STM32L162xDX) 47 | 48 | /* Includes ------------------------------------------------------------------*/ 49 | #include "stm32l1xx_hal_def.h" 50 | 51 | /** @addtogroup STM32L1xx_HAL_Driver 52 | * @{ 53 | */ 54 | 55 | /** @addtogroup CRYPEx 56 | * @{ 57 | */ 58 | 59 | /* Exported types ------------------------------------------------------------*/ 60 | /* Exported constants --------------------------------------------------------*/ 61 | /* Exported functions --------------------------------------------------------*/ 62 | 63 | /** @addtogroup CRYPEx_Exported_Functions 64 | * @{ 65 | */ 66 | 67 | /** @addtogroup CRYPEx_Exported_Functions_Group1 68 | * @{ 69 | */ 70 | 71 | /* CallBack functions ********************************************************/ 72 | void HAL_CRYPEx_ComputationCpltCallback(CRYP_HandleTypeDef *hcryp); 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | #endif /* STM32L162xC || STM32L162xCA || STM32L162xD || STM32L162xE || STM32L162xDX*/ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | /** 89 | * @} 90 | */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __STM32L1xx_HAL_CRYP_EX_H */ 97 | 98 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 99 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l1xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @version V1.2.0 6 | * @date 01-July-2016 7 | * @brief Header file of PCD HAL module. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32L1xx_HAL_PCD_EX_H 40 | #define __STM32L1xx_HAL_PCD_EX_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Includes ------------------------------------------------------------------*/ 47 | #include "stm32l1xx_hal_def.h" 48 | 49 | /** @addtogroup STM32L1xx_HAL_Driver 50 | * @{ 51 | */ 52 | 53 | /** @addtogroup PCDEx 54 | * @{ 55 | */ 56 | 57 | /* Exported types ------------------------------------------------------------*/ 58 | /* Exported constants --------------------------------------------------------*/ 59 | /* Exported macros -----------------------------------------------------------*/ 60 | /* Internal macros -----------------------------------------------------------*/ 61 | /* Exported functions --------------------------------------------------------*/ 62 | /** @addtogroup PCDEx_Exported_Functions 63 | * @{ 64 | */ 65 | 66 | /** @addtogroup PCDEx_Exported_Functions_Group2 67 | * @{ 68 | */ 69 | 70 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, 71 | uint16_t ep_addr, 72 | uint16_t ep_kind, 73 | uint32_t pmaadress); 74 | /** 75 | * @} 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | 95 | #endif /* __STM32L1xx_HAL_PCD_EX_H */ 96 | 97 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 98 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_msp_template.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l1xx_hal_msp_template.c 4 | * @author MCD Application Team 5 | * @version V1.2.0 6 | * @date 01-July-2016 7 | * @brief HAL BSP module. 8 | * This file template is located in the HAL folder and should be copied 9 | * to the user folder. 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | *

© COPYRIGHT(c) 2016 STMicroelectronics

14 | * 15 | * Redistribution and use in source and binary forms, with or without modification, 16 | * are permitted provided that the following conditions are met: 17 | * 1. Redistributions of source code must retain the above copyright notice, 18 | * this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, 20 | * this list of conditions and the following disclaimer in the documentation 21 | * and/or other materials provided with the distribution. 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | * 37 | ****************************************************************************** 38 | */ 39 | 40 | /* Includes ------------------------------------------------------------------*/ 41 | #include "stm32l1xx_hal.h" 42 | 43 | /** @addtogroup STM32L1xx_HAL_Driver 44 | * @{ 45 | */ 46 | 47 | /** @defgroup HAL_MSP HAL_MSP 48 | * @brief HAL MSP module. 49 | * @{ 50 | */ 51 | 52 | /* Private typedef -----------------------------------------------------------*/ 53 | /* Private define ------------------------------------------------------------*/ 54 | /* Private macro -------------------------------------------------------------*/ 55 | /* Private variables ---------------------------------------------------------*/ 56 | /* Private function prototypes -----------------------------------------------*/ 57 | /* Private functions ---------------------------------------------------------*/ 58 | 59 | /** @defgroup HAL_MSP_Exported_Functions HAL MSP Exported Functions 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @brief Initializes the Global MSP. 65 | * @retval None 66 | */ 67 | void HAL_MspInit(void) 68 | { 69 | 70 | } 71 | 72 | /** 73 | * @brief DeInitializes the Global MSP. 74 | * @retval None 75 | */ 76 | void HAL_MspDeInit(void) 77 | { 78 | 79 | } 80 | 81 | /** 82 | * @brief Initializes the PPP MSP. 83 | * @retval None 84 | */ 85 | void HAL_PPP_MspInit(void) 86 | { 87 | 88 | } 89 | 90 | /** 91 | * @brief DeInitializes the PPP MSP. 92 | * @retval None 93 | */ 94 | void HAL_PPP_MspDeInit(void) 95 | { 96 | 97 | } 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 112 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Src/stm32l1xx_ll_pwr.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32l1xx_ll_pwr.c 4 | * @author MCD Application Team 5 | * @version V1.2.0 6 | * @date 01-July-2016 7 | * @brief PWR LL module driver. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | #if defined(USE_FULL_LL_DRIVER) 38 | 39 | /* Includes ------------------------------------------------------------------*/ 40 | #include "stm32l1xx_ll_pwr.h" 41 | #include "stm32l1xx_ll_bus.h" 42 | 43 | /** @addtogroup STM32L1xx_LL_Driver 44 | * @{ 45 | */ 46 | 47 | #if defined(PWR) 48 | 49 | /** @defgroup PWR_LL PWR 50 | * @{ 51 | */ 52 | 53 | /* Private types -------------------------------------------------------------*/ 54 | /* Private variables ---------------------------------------------------------*/ 55 | /* Private constants ---------------------------------------------------------*/ 56 | /* Private macros ------------------------------------------------------------*/ 57 | /* Private function prototypes -----------------------------------------------*/ 58 | 59 | /* Exported functions --------------------------------------------------------*/ 60 | /** @addtogroup PWR_LL_Exported_Functions 61 | * @{ 62 | */ 63 | 64 | /** @addtogroup PWR_LL_EF_Init 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @brief De-initialize the PWR registers to their default reset values. 70 | * @retval An ErrorStatus enumeration value: 71 | * - SUCCESS: PWR registers are de-initialized 72 | * - ERROR: not applicable 73 | */ 74 | ErrorStatus LL_PWR_DeInit(void) 75 | { 76 | /* Force reset of PWR clock */ 77 | LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_PWR); 78 | 79 | /* Release reset of PWR clock */ 80 | LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_PWR); 81 | 82 | return SUCCESS; 83 | } 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** 94 | * @} 95 | */ 96 | #endif /* defined(PWR) */ 97 | /** 98 | * @} 99 | */ 100 | 101 | #endif /* USE_FULL_LL_DRIVER */ 102 | 103 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 104 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header file for the usbd_req.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_REQUEST_H 30 | #define __USB_REQUEST_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_REQ 45 | * @brief header file for the usbd_req.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_REQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_REQ_Exported_Types 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_REQ_Exported_Macros 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_REQ_Exported_Variables 74 | * @{ 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 81 | * @{ 82 | */ 83 | 84 | USBD_StatusTypeDef USBD_StdDevReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 85 | USBD_StatusTypeDef USBD_StdItfReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 86 | USBD_StatusTypeDef USBD_StdEPReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 87 | 88 | 89 | void USBD_CtlError (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 90 | 91 | void USBD_ParseSetupRequest (USBD_SetupReqTypedef *req, uint8_t *pdata); 92 | 93 | void USBD_GetString (uint8_t *desc, uint8_t *unicode, uint16_t *len); 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __USB_REQUEST_H */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | 113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 114 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header file for the usbd_ioreq.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_IOREQ_H 30 | #define __USBD_IOREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | #include "usbd_core.h" 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_IOREQ 45 | * @brief header file for the usbd_ioreq.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_IOREQ_Exported_Types 58 | * @{ 59 | */ 60 | 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | 68 | /** @defgroup USBD_IOREQ_Exported_Macros 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_IOREQ_Exported_Variables 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 85 | * @{ 86 | */ 87 | 88 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 89 | uint8_t *buf, 90 | uint16_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 93 | uint8_t *pbuf, 94 | uint16_t len); 95 | 96 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 97 | uint8_t *pbuf, 98 | uint16_t len); 99 | 100 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 101 | uint8_t *pbuf, 102 | uint16_t len); 103 | 104 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev); 105 | 106 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev); 107 | 108 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , 109 | uint8_t epnum); 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* __USBD_IOREQ_H */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 129 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/cmsis/arm_const_structs.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 19. March 2015 5 | * $Revision: V.1.4.5 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_const_structs.h 9 | * 10 | * Description: This file has constant structs that are initialized for 11 | * user convenience. For example, some can be given as 12 | * arguments to the arm_cfft_f32() function. 13 | * 14 | * Target Processor: Cortex-M4/Cortex-M3 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * - Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * - Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in 23 | * the documentation and/or other materials provided with the 24 | * distribution. 25 | * - Neither the name of ARM LIMITED nor the names of its contributors 26 | * may be used to endorse or promote products derived from this 27 | * software without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 | * POSSIBILITY OF SUCH DAMAGE. 41 | * -------------------------------------------------------------------- */ 42 | 43 | #ifndef _ARM_CONST_STRUCTS_H 44 | #define _ARM_CONST_STRUCTS_H 45 | 46 | #include "arm_math.h" 47 | #include "arm_common_tables.h" 48 | 49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; 50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; 51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; 52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; 53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; 54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; 55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; 56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; 57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; 58 | 59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; 60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; 61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; 62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; 63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; 64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; 65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; 66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; 67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; 68 | 69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; 70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; 71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; 72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; 73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; 74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; 75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; 76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; 77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/cmsis/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/cmsis/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/cmsis/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/sysIrqHandlers.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Default IRQ handlers 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | 17 | /*! 18 | * \brief This function handles NMI exception. 19 | * \param None 20 | * \retval None 21 | */ 22 | void NMI_Handler( void ) 23 | { 24 | } 25 | 26 | /*! 27 | * \brief This function handles Hard Fault exception. 28 | * \param None 29 | * \retval None 30 | */ 31 | #if defined( HARD_FAULT_HANDLER_ENABLED ) 32 | void HardFault_Handler_C( unsigned int *args ) 33 | { 34 | volatile unsigned int stacked_r0; 35 | volatile unsigned int stacked_r1; 36 | volatile unsigned int stacked_r2; 37 | volatile unsigned int stacked_r3; 38 | volatile unsigned int stacked_r12; 39 | volatile unsigned int stacked_lr; 40 | volatile unsigned int stacked_pc; 41 | volatile unsigned int stacked_psr; 42 | 43 | stacked_r0 = ( ( unsigned long) args[0] ); 44 | stacked_r1 = ( ( unsigned long) args[1] ); 45 | stacked_r2 = ( ( unsigned long) args[2] ); 46 | stacked_r3 = ( ( unsigned long) args[3] ); 47 | 48 | stacked_r12 = ( ( unsigned long) args[4] ); 49 | stacked_lr = ( ( unsigned long) args[5] ); 50 | stacked_pc = ( ( unsigned long) args[6] ); 51 | stacked_psr = ( ( unsigned long) args[7] ); 52 | 53 | ( void )stacked_r0; 54 | ( void )stacked_r1; 55 | ( void )stacked_r2; 56 | ( void )stacked_r3; 57 | 58 | ( void )stacked_r12; 59 | ( void )stacked_lr ; 60 | ( void )stacked_pc ; 61 | ( void )stacked_psr; 62 | 63 | while( 1 ); 64 | } 65 | 66 | #if defined(__CC_ARM) 67 | __asm void HardFault_Handler(void) 68 | { 69 | TST LR, #4 70 | ITE EQ 71 | MRSEQ r0, MSP 72 | MRSNE r0, PSP 73 | B __cpp(HardFault_Handler_C) 74 | } 75 | #elif defined(__ICCARM__) 76 | void HardFault_Handler(void) 77 | { 78 | __asm("TST LR, #4"); 79 | __asm("ITE EQ"); 80 | __asm("MRSEQ r0, MSP"); 81 | __asm("MRSNE r0, PSP"); 82 | __asm("B HardFault_Handler_C"); 83 | } 84 | #elif defined(__GNUC__) 85 | void HardFault_Handler(void) 86 | { 87 | __asm volatile( "TST LR, #4" ); 88 | __asm volatile( "ITE EQ" ); 89 | __asm volatile( "MRSEQ R0, MSP" ); 90 | __asm volatile( "MRSNE R0, PSP" ); 91 | __asm volatile( "B HardFault_Handler_C" ); 92 | } 93 | #else 94 | #warning Not supported compiler type 95 | #endif 96 | 97 | #endif 98 | 99 | /*! 100 | * \brief This function handles Memory Manage exception. 101 | * \param None 102 | * \retval None 103 | */ 104 | void MemManage_Handler( void ) 105 | { 106 | /* Go to infinite loop when Memory Manage exception occurs */ 107 | while ( 1 ) 108 | { 109 | } 110 | } 111 | 112 | /*! 113 | * \brief This function handles Bus Fault exception. 114 | * \param None 115 | * \retval None 116 | */ 117 | void BusFault_Handler( void ) 118 | { 119 | /* Go to infinite loop when Bus Fault exception occurs */ 120 | while ( 1 ) 121 | { 122 | } 123 | } 124 | 125 | /*! 126 | * \brief This function handles Usage Fault exception. 127 | * \param None 128 | * \retval None 129 | */ 130 | void UsageFault_Handler( void ) 131 | { 132 | /* Go to infinite loop when Usage Fault exception occurs */ 133 | while ( 1 ) 134 | { 135 | } 136 | } 137 | 138 | /*! 139 | * \brief This function handles Debug Monitor exception. 140 | * \param None 141 | * \retval None 142 | */ 143 | void DebugMon_Handler( void ) 144 | { 145 | } 146 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/utilities.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Helper functions implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include 16 | #include 17 | #include "board.h" 18 | #include "utilities.h" 19 | 20 | /*! 21 | * Redefinition of rand() and srand() standard C functions. 22 | * These functions are redefined in order to get the same behavior across 23 | * different compiler toolchains implementations. 24 | */ 25 | // Standard random functions redefinition start 26 | #define RAND_LOCAL_MAX 2147483647L 27 | 28 | static uint32_t next = 1; 29 | 30 | int32_t rand1( void ) 31 | { 32 | return ( ( next = next * 1103515245L + 12345L ) % RAND_LOCAL_MAX ); 33 | } 34 | 35 | void srand1( uint32_t seed ) 36 | { 37 | next = seed; 38 | } 39 | // Standard random functions redefinition end 40 | 41 | int32_t randr( int32_t min, int32_t max ) 42 | { 43 | return ( int32_t )rand1( ) % ( max - min + 1 ) + min; 44 | } 45 | 46 | void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size ) 47 | { 48 | while( size-- ) 49 | { 50 | *dst++ = *src++; 51 | } 52 | } 53 | 54 | void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size ) 55 | { 56 | dst = dst + ( size - 1 ); 57 | while( size-- ) 58 | { 59 | *dst-- = *src++; 60 | } 61 | } 62 | 63 | void memset1( uint8_t *dst, uint8_t value, uint16_t size ) 64 | { 65 | while( size-- ) 66 | { 67 | *dst++ = value; 68 | } 69 | } 70 | 71 | int8_t Nibble2HexChar( uint8_t a ) 72 | { 73 | if( a < 10 ) 74 | { 75 | return '0' + a; 76 | } 77 | else if( a < 16 ) 78 | { 79 | return 'A' + ( a - 10 ); 80 | } 81 | else 82 | { 83 | return '?'; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/boards/mcu/stm32/utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Helper functions implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __UTILITIES_H__ 16 | #define __UTILITIES_H__ 17 | 18 | /*! 19 | * \brief Returns the minimum value between a and b 20 | * 21 | * \param [IN] a 1st value 22 | * \param [IN] b 2nd value 23 | * \retval minValue Minimum value 24 | */ 25 | #define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) 26 | 27 | /*! 28 | * \brief Returns the maximum value between a and b 29 | * 30 | * \param [IN] a 1st value 31 | * \param [IN] b 2nd value 32 | * \retval maxValue Maximum value 33 | */ 34 | #define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) 35 | 36 | /*! 37 | * \brief Returns 2 raised to the power of n 38 | * 39 | * \param [IN] n power value 40 | * \retval result of raising 2 to the power n 41 | */ 42 | #define POW2( n ) ( 1 << n ) 43 | 44 | /*! 45 | * \brief Initializes the pseudo random generator initial value 46 | * 47 | * \param [IN] seed Pseudo random generator initial value 48 | */ 49 | void srand1( uint32_t seed ); 50 | 51 | /*! 52 | * \brief Computes a random number between min and max 53 | * 54 | * \param [IN] min range minimum value 55 | * \param [IN] max range maximum value 56 | * \retval random random value in range min..max 57 | */ 58 | int32_t randr( int32_t min, int32_t max ); 59 | 60 | /*! 61 | * \brief Copies size elements of src array to dst array 62 | * 63 | * \remark STM32 Standard memcpy function only works on pointers that are aligned 64 | * 65 | * \param [OUT] dst Destination array 66 | * \param [IN] src Source array 67 | * \param [IN] size Number of bytes to be copied 68 | */ 69 | void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size ); 70 | 71 | /*! 72 | * \brief Copies size elements of src array to dst array reversing the byte order 73 | * 74 | * \param [OUT] dst Destination array 75 | * \param [IN] src Source array 76 | * \param [IN] size Number of bytes to be copied 77 | */ 78 | void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size ); 79 | 80 | /*! 81 | * \brief Set size elements of dst array with value 82 | * 83 | * \remark STM32 Standard memset function only works on pointers that are aligned 84 | * 85 | * \param [OUT] dst Destination array 86 | * \param [IN] value Default value 87 | * \param [IN] size Number of bytes to be copied 88 | */ 89 | void memset1( uint8_t *dst, uint8_t value, uint16_t size ); 90 | 91 | /*! 92 | * \brief Converts a nibble to an hexadecimal character 93 | * 94 | * \param [IN] a Nibble to be converted 95 | * \retval hexChar Converted hexadecimal character 96 | */ 97 | int8_t Nibble2HexChar( uint8_t a ); 98 | 99 | #endif // __UTILITIES_H__ 100 | -------------------------------------------------------------------------------- /src/mac/LoRaMacTest.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LoRaMacTest.h 3 | * 4 | * \brief LoRa MAC layer test function implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \defgroup LORAMACTEST LoRa MAC layer test function implementation 32 | * This module specifies the API implementation of test function of the LoRaMAC layer. 33 | * The functions in this file are only for testing purposes only. 34 | * \{ 35 | */ 36 | #ifndef __LORAMACTEST_H__ 37 | #define __LORAMACTEST_H__ 38 | 39 | /*! 40 | * \brief Enabled or disables the reception windows 41 | * 42 | * \details This is a test function. It shall be used for testing purposes only. 43 | * Changing this attribute may lead to a non-conformance LoRaMac operation. 44 | * 45 | * \param [IN] enable - Enabled or disables the reception windows 46 | */ 47 | void LoRaMacTestRxWindowsOn( bool enable ); 48 | 49 | /*! 50 | * \brief Enables the MIC field test 51 | * 52 | * \details This is a test function. It shall be used for testing purposes only. 53 | * Changing this attribute may lead to a non-conformance LoRaMac operation. 54 | * 55 | * \param [IN] txPacketCounter - Fixed Tx packet counter value 56 | */ 57 | void LoRaMacTestSetMic( uint16_t txPacketCounter ); 58 | 59 | /*! 60 | * \brief Enabled or disables the duty cycle 61 | * 62 | * \details This is a test function. It shall be used for testing purposes only. 63 | * Changing this attribute may lead to a non-conformance LoRaMac operation. 64 | * 65 | * \param [IN] enable - Enabled or disables the duty cycle 66 | */ 67 | void LoRaMacTestSetDutyCycleOn( bool enable ); 68 | 69 | /*! 70 | * \brief Sets the channel index 71 | * 72 | * \details This is a test function. It shall be used for testing purposes only. 73 | * Changing this attribute may lead to a non-conformance LoRaMac operation. 74 | * 75 | * \param [IN] channel - Channel index 76 | */ 77 | void LoRaMacTestSetChannel( uint8_t channel ); 78 | 79 | /*! \} defgroup LORAMACTEST */ 80 | 81 | #endif // __LORAMACTEST_H__ 82 | -------------------------------------------------------------------------------- /src/peripherals/gpio-ioe.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: IO expander driver implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __GPIO_IOE_H__ 16 | #define __GPIO_IOE_H__ 17 | 18 | /*! 19 | * \brief Initializes the given GPIO object 20 | * 21 | * \param [IN] obj Pointer to the GPIO object to be initialized 22 | * \param [IN] pin Pin name ( please look in pinName-board.h file ) 23 | * \param [IN] mode Pin mode [PIN_INPUT, PIN_OUTPUT, 24 | * PIN_ALTERNATE_FCT, PIN_ANALOGIC] 25 | * \param [IN] config Pin config [PIN_PUSH_PULL, PIN_OPEN_DRAIN] 26 | * \param [IN] type Pin type [PIN_NO_PULL, PIN_PULL_UP, PIN_PULL_DOWN] 27 | * \param [IN] value Default output value at initialization 28 | */ 29 | void GpioIoeInit( Gpio_t *obj, PinNames pin, PinModes mode, PinConfigs config, PinTypes type, uint32_t value ); 30 | 31 | /*! 32 | * \brief GPIO IRQ Initialization 33 | * 34 | * \param [IN] obj Pointer to the GPIO object to be initialized 35 | * \param [IN] irqMode IRQ mode [NO_IRQ, IRQ_RISING_EDGE, 36 | * IRQ_FALLING_EDGE, IRQ_RISING_FALLING_EDGE] 37 | * \param [IN] irqPriority IRQ priority [IRQ_VERY_LOW_PRIORITY, IRQ_LOW_PRIORITY 38 | * IRQ_MEDIUM_PRIORITY, IRQ_HIGH_PRIORITY 39 | * IRQ_VERY_HIGH_PRIORITY] 40 | * \param [IN] irqHandler Callback function pointer 41 | */ 42 | void GpioIoeSetInterrupt( Gpio_t *obj, IrqModes irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler ); 43 | 44 | /*! 45 | * \brief Writes the given value to the GPIO output 46 | * 47 | * \param [IN] obj Pointer to the GPIO object 48 | * \param [IN] value New GPIO output value 49 | */ 50 | void GpioIoeWrite( Gpio_t *obj, uint32_t value ); 51 | 52 | /*! 53 | * \brief Reads the current GPIO input value 54 | * 55 | * \param [IN] obj Pointer to the GPIO object 56 | * \retval value Current GPIO input value 57 | */ 58 | uint32_t GpioIoeRead( Gpio_t *obj ); 59 | 60 | /*! 61 | * \brief GpioIoeInterruptHandler callback function. 62 | */ 63 | void GpioIoeInterruptHandler( void ); 64 | 65 | #endif // __GPIO_IOE_H__ 66 | -------------------------------------------------------------------------------- /src/peripherals/mag3110.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Driver for the MAG3110 Magnetometer 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | #include "mag3110.h" 17 | 18 | static uint8_t I2cDeviceAddr = 0; 19 | static bool MAG3110Initialized = false; 20 | 21 | uint8_t MAG3110Init( void ) 22 | { 23 | uint8_t regVal = 0; 24 | 25 | MAG3110SetDeviceAddr( MAG3110_I2C_ADDRESS ); 26 | 27 | if( MAG3110Initialized == false ) 28 | { 29 | MAG3110Initialized = true; 30 | 31 | MAG3110Read( MAG3110_ID, ®Val ); 32 | if( regVal != 0xC4 ) // Fixed Device ID Number = 0xC4 33 | { 34 | return FAIL; 35 | } 36 | 37 | MAG3110Reset( ); 38 | } 39 | return SUCCESS; 40 | } 41 | 42 | uint8_t MAG3110Reset( void ) 43 | { 44 | if( MAG3110Write( 0x11, 0x10 ) == SUCCESS ) // Reset the MAG3110 with CTRL_REG2 45 | { 46 | return SUCCESS; 47 | } 48 | return FAIL; 49 | } 50 | 51 | uint8_t MAG3110Write( uint8_t addr, uint8_t data ) 52 | { 53 | return MAG3110WriteBuffer( addr, &data, 1 ); 54 | } 55 | 56 | uint8_t MAG3110WriteBuffer( uint8_t addr, uint8_t *data, uint8_t size ) 57 | { 58 | return I2cWriteBuffer( &I2c, I2cDeviceAddr << 1, addr, data, size ); 59 | } 60 | 61 | uint8_t MAG3110Read( uint8_t addr, uint8_t *data ) 62 | { 63 | return MAG3110ReadBuffer( addr, data, 1 ); 64 | } 65 | 66 | uint8_t MAG3110ReadBuffer( uint8_t addr, uint8_t *data, uint8_t size ) 67 | { 68 | return I2cReadBuffer( &I2c, I2cDeviceAddr << 1, addr, data, size ); 69 | } 70 | 71 | void MAG3110SetDeviceAddr( uint8_t addr ) 72 | { 73 | I2cDeviceAddr = addr; 74 | } 75 | 76 | uint8_t MAG3110GetDeviceAddr( void ) 77 | { 78 | return I2cDeviceAddr; 79 | } 80 | -------------------------------------------------------------------------------- /src/peripherals/mag3110.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Driver for the MAG3110 Magnetometer 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __MAG3110_H__ 16 | #define __MAG3110_H__ 17 | 18 | /*! 19 | * MAG3110 I2C address 20 | */ 21 | #define MAG3110_I2C_ADDRESS 0x0E 22 | 23 | /*! 24 | * MAG3110 Registers 25 | */ 26 | #define MAG3110_ID 0x07 27 | 28 | /*! 29 | * \brief Initializes the device 30 | * 31 | * \retval status [SUCCESS, FAIL] 32 | */ 33 | uint8_t MAG3110Init( void ); 34 | 35 | /*! 36 | * \brief Resets the device 37 | * 38 | * \retval status [SUCCESS, FAIL] 39 | */ 40 | uint8_t MAG3110Reset( void ); 41 | 42 | /*! 43 | * \brief Writes a byte at specified address in the device 44 | * 45 | * \param [IN]: addr 46 | * \param [IN]: data 47 | * \retval status [SUCCESS, FAIL] 48 | */ 49 | uint8_t MAG3110Write( uint8_t addr, uint8_t data ); 50 | 51 | /*! 52 | * \brief Writes a buffer at specified address in the device 53 | * 54 | * \param [IN]: addr 55 | * \param [IN]: data 56 | * \param [IN]: size 57 | * \retval status [SUCCESS, FAIL] 58 | */ 59 | uint8_t MAG3110WriteBuffer( uint8_t addr, uint8_t *data, uint8_t size ); 60 | 61 | /*! 62 | * \brief Reads a byte at specified address in the device 63 | * 64 | * \param [IN]: addr 65 | * \param [OUT]: data 66 | * \retval status [SUCCESS, FAIL] 67 | */ 68 | uint8_t MAG3110Read( uint8_t addr, uint8_t *data ); 69 | 70 | /*! 71 | * \brief Reads a buffer at specified address in the device 72 | * 73 | * \param [IN]: addr 74 | * \param [OUT]: data 75 | * \param [IN]: size 76 | * \retval status [SUCCESS, FAIL] 77 | */ 78 | uint8_t MAG3110ReadBuffer( uint8_t addr, uint8_t *data, uint8_t size ); 79 | 80 | /*! 81 | * \brief Sets the I2C device slave address 82 | * 83 | * \param [IN]: addr 84 | */ 85 | void MAG3110SetDeviceAddr( uint8_t addr ); 86 | 87 | /*! 88 | * \brief Gets the I2C device slave address 89 | * 90 | * \retval: addr Current device slave address 91 | */ 92 | uint8_t MAG3110GetDeviceAddr( void ); 93 | 94 | #endif // __MAG3110_H__ 95 | -------------------------------------------------------------------------------- /src/peripherals/mma8451.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Driver for the MMA8451 Accelerometer 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __MMA8451_H__ 16 | #define __MMA8451_H__ 17 | 18 | /* 19 | * MMA8451 I2C address 20 | */ 21 | #define MMA8451_I2C_ADDRESS 0x1C 22 | 23 | /* 24 | * MMA8451 Registers 25 | */ 26 | #define MMA8451_STATUS 0x00 // 27 | #define MMA8451_OUT_X_MSB 0x01 // 28 | #define MMA8451_SYSMOD 0x0B // 29 | #define MMA8451_INT_SOURCE 0x0C // 30 | #define MMA8451_ID 0x0D // 31 | #define MMA8451_PL_STATUS 0x10 // 32 | #define MMA8451_PL_CFG 0x11 // 33 | #define MMA8451_PL_COUNT 0x12 // Orientation debounce 34 | #define MMA8451_PL_BF_ZCOMP 0x13 // 35 | #define MMA8451_PL_THS_REG 0x14 // 36 | #define MMA8451_FF_MT_SRC 0x16 // 37 | #define MMA8451_TRANSIENT_CFG 0x1D // Transient enable 38 | #define MMA8451_TRANSIENT_SRC 0x1E // Transient read/clear interrupt 39 | #define MMA8451_TRANSIENT_THS 0x1F // Transient threshold 40 | #define MMA8451_TRANSIENT_COUNT 0x20 // Transient debounce 41 | #define MMA8451_PULSE_SRC 0x22 // 42 | #define MMA8451_CTRL_REG1 0x2A // 43 | #define MMA8451_CTRL_REG2 0x2B // 44 | #define MMA8451_CTRL_REG3 0x2C // Interrupt control 45 | #define MMA8451_CTRL_REG4 0x2D // Interrupt enable 46 | #define MMA8451_CTRL_REG5 0x2E // Interrupt pin selection 47 | 48 | /*! 49 | * \brief Initializes the device 50 | * 51 | * \retval status [SUCCESS, FAIL] 52 | */ 53 | uint8_t MMA8451Init( void ); 54 | 55 | /*! 56 | * \brief Resets the device 57 | * 58 | * \retval status [SUCCESS, FAIL] 59 | */ 60 | uint8_t MMA8451Reset( void ); 61 | 62 | /*! 63 | * \brief Initializes the orientation detection 64 | */ 65 | void MMA8451OrientDetect( void ); 66 | 67 | /*! 68 | * \brief Gets the orientation state. 69 | * 70 | * \retval orientation Bit 6 [1: Horizontal, 0: Vertical] 71 | * Bit 0 [1: Face down, 0: Face up] 72 | * Other bits don't care. 73 | */ 74 | uint8_t MMA8451GetOrientation( void ); 75 | 76 | #endif // __MMA8451_H__ 77 | -------------------------------------------------------------------------------- /src/peripherals/mpl3115.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/peripherals/mpl3115.c -------------------------------------------------------------------------------- /src/peripherals/pam7q.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2016 Semtech 8 | 9 | Description: Driver for the SX1509 IO expander 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | #include "pam7q.h" 17 | 18 | static uint8_t I2cDeviceAddr = 0; 19 | 20 | void PAM7QInit( void ) 21 | { 22 | PAM7QSetDeviceAddr( PAM7Q_I2C_ADDRESS ); 23 | } 24 | 25 | bool PAM7QGetGpsData( uint8_t *nmeaString, uint8_t *nmeaStringSize, uint16_t nmeaMaxStringSize ) 26 | { 27 | uint8_t status; 28 | uint16_t pendingBytes; 29 | bool result = false; 30 | 31 | *nmeaStringSize = 0; 32 | 33 | status = PAM7QReadBuffer( MESSAGE_SIZE_1, nmeaString, 2 ); 34 | 35 | if( status == SUCCESS ) 36 | { 37 | // build a 16bit number 38 | pendingBytes = ( uint16_t )( ( nmeaString[0] << 8 ) | nmeaString[1] ); 39 | 40 | // check for invalid length 41 | if( pendingBytes == 0xFFFF ) 42 | { 43 | pendingBytes = 0; 44 | } 45 | // just to buffer size 46 | if( pendingBytes > ( nmeaMaxStringSize - 1 ) ) 47 | { 48 | pendingBytes = nmeaMaxStringSize - 1; 49 | } 50 | 51 | // read pending data from GPS module 52 | status = PAM7QReadBuffer( PAYLOAD, nmeaString, pendingBytes ); 53 | 54 | // make sure the string is terminated 55 | if( status == SUCCESS ) 56 | { 57 | nmeaString[pendingBytes] = 0x00; 58 | 59 | // copy length indication to argument 60 | *nmeaStringSize = pendingBytes; 61 | 62 | // return success only if there is data to process 63 | if( pendingBytes > 0 ) 64 | { 65 | result = true; 66 | } 67 | } 68 | } 69 | return result; 70 | } 71 | 72 | uint8_t PAM7QGetDeviceAddr( void ) 73 | { 74 | return I2cDeviceAddr; 75 | } 76 | 77 | void PAM7QSetDeviceAddr( uint8_t addr ) 78 | { 79 | I2cDeviceAddr = addr; 80 | } 81 | 82 | uint8_t PAM7QWrite( uint8_t addr, uint8_t data ) 83 | { 84 | return PAM7QWriteBuffer( addr, &data, 1 ); 85 | } 86 | 87 | uint8_t PAM7QWriteBuffer( uint8_t addr, uint8_t *data, uint8_t size ) 88 | { 89 | return I2cWriteBuffer( &I2c, I2cDeviceAddr << 1, addr, data, size ); 90 | } 91 | 92 | uint8_t PAM7QRead( uint8_t addr, uint8_t *data ) 93 | { 94 | return PAM7QReadBuffer( addr, data, 1 ); 95 | } 96 | 97 | uint8_t PAM7QReadBuffer( uint8_t addr, uint8_t *data, uint8_t size ) 98 | { 99 | return I2cReadBuffer( &I2c, I2cDeviceAddr << 1, addr, data, size ); 100 | } 101 | -------------------------------------------------------------------------------- /src/peripherals/pam7q.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2016 Semtech 8 | 9 | Description: Driver for the SX1509 IO expander 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __PAM7Q_H__ 16 | #define __PAM7Q_H__ 17 | 18 | void PAM7QInit( void ); 19 | 20 | uint8_t PAM7QGetDeviceAddr( void ); 21 | 22 | void PAM7QSetDeviceAddr( uint8_t addr ); 23 | 24 | bool PAM7QGetGpsData( uint8_t *nmeaString, uint8_t *nmeaStringSize, uint16_t nmeaMaxStringSize ); 25 | 26 | uint8_t PAM7QWrite( uint8_t addr, uint8_t data ); 27 | 28 | uint8_t PAM7QWriteBuffer( uint8_t addr, uint8_t *data, uint8_t size ); 29 | 30 | uint8_t PAM7QRead( uint8_t addr, uint8_t *data ); 31 | 32 | uint8_t PAM7QReadBuffer( uint8_t addr, uint8_t *data, uint8_t size ); 33 | 34 | void GpsMcuOnPpsSignal( void ); 35 | 36 | /* 37 | * MPL3115A2 I2C address 38 | */ 39 | #define PAM7Q_I2C_ADDRESS 0x42 40 | 41 | #define MESSAGE_SIZE_1 0xFD 42 | #define MESSAGE_SIZE_2 0xFE 43 | 44 | #define PAYLOAD 0xFF 45 | 46 | 47 | #endif // __PAM7Q_H__ 48 | 49 | -------------------------------------------------------------------------------- /src/peripherals/selector.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Hex coder selector driver implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | 17 | #include "selector.h" 18 | #if 0 19 | uint8_t SelectorGetValue( void ) 20 | { 21 | /*! 22 | * Hex coder selector GPIO pins objects 23 | */ 24 | Gpio_t Sel1; 25 | Gpio_t Sel2; 26 | Gpio_t Sel3; 27 | Gpio_t Sel4; 28 | 29 | uint8_t i = 0; 30 | uint8_t j = 0; 31 | uint8_t k = 255; 32 | 33 | // Active 34 | GpioInit( &Sel1, SEL_1, PIN_INPUT, PIN_PUSH_PULL, PIN_PULL_UP, 0 ); 35 | GpioInit( &Sel2, SEL_2, PIN_INPUT, PIN_PUSH_PULL, PIN_PULL_UP, 0 ); 36 | GpioInit( &Sel3, SEL_3, PIN_INPUT, PIN_PUSH_PULL, PIN_PULL_UP, 0 ); 37 | GpioInit( &Sel4, SEL_4, PIN_INPUT, PIN_PUSH_PULL, PIN_PULL_UP, 0 ); 38 | 39 | do 40 | { 41 | j = i; 42 | k = j; 43 | // 1 ms delay between checks 44 | DelayMs( 1 ); 45 | i = !GpioRead( &Sel1 ); 46 | i += 2 * !GpioRead( &Sel2 ); 47 | i += 4 * !GpioRead( &Sel3 ); 48 | i += 8 * !GpioRead( &Sel4 ); 49 | } while( ( i != j ) && ( i != k ) ); // Waits for 3 successive values to be equal 50 | 51 | // Sleep 52 | GpioInit( &Sel1, SEL_1, PIN_OUTPUT, PIN_OPEN_DRAIN, PIN_NO_PULL, 0 ); 53 | GpioInit( &Sel2, SEL_2, PIN_OUTPUT, PIN_OPEN_DRAIN, PIN_NO_PULL, 0 ); 54 | GpioInit( &Sel3, SEL_3, PIN_OUTPUT, PIN_OPEN_DRAIN, PIN_NO_PULL, 0 ); 55 | GpioInit( &Sel4, SEL_4, PIN_OUTPUT, PIN_OPEN_DRAIN, PIN_NO_PULL, 0 ); 56 | 57 | return i; 58 | } 59 | #endif -------------------------------------------------------------------------------- /src/peripherals/selector.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Hex coder selector driver implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __SELECTOR_H__ 16 | #define __SELECTOR_H__ 17 | 18 | /*! 19 | * Gets the current hex coder selector position 20 | * 21 | * \retval position Hex coder current position ( On error position = 255 ) 22 | */ 23 | uint8_t SelectorGetValue( void ); 24 | 25 | #endif // __SELECTOR_H__ 26 | -------------------------------------------------------------------------------- /src/peripherals/sx1509.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Driver for the SX1509 IO expander 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | #include "sx1509.h" 17 | 18 | static uint8_t I2cDeviceAddr = 0; 19 | 20 | static bool SX1509Initialized = false; 21 | 22 | void SX1509Init( void ) 23 | { 24 | if( SX1509Initialized == false ) 25 | { 26 | SX1509SetDeviceAddr( SX1509_I2C_ADDRESS ); 27 | SX1509Initialized = true; 28 | 29 | SX1509Reset( ); 30 | } 31 | } 32 | 33 | uint8_t SX1509Reset( ) 34 | { 35 | if( SX1509Write( RegReset, 0x12 ) == SUCCESS ) 36 | { 37 | if( SX1509Write( RegReset, 0x34 ) == SUCCESS ) 38 | { 39 | return SUCCESS; 40 | } 41 | } 42 | return FAIL; 43 | } 44 | 45 | uint8_t SX1509Write( uint8_t addr, uint8_t data ) 46 | { 47 | return SX1509WriteBuffer( addr, &data, 1 ); 48 | } 49 | 50 | uint8_t SX1509WriteBuffer( uint8_t addr, uint8_t *data, uint8_t size ) 51 | { 52 | return I2cWriteBuffer( &I2c, I2cDeviceAddr << 1, addr, data, size ); 53 | } 54 | 55 | uint8_t SX1509Read( uint8_t addr, uint8_t *data ) 56 | { 57 | return SX1509ReadBuffer( addr, data, 1 ); 58 | } 59 | 60 | uint8_t SX1509ReadBuffer( uint8_t addr, uint8_t *data, uint8_t size ) 61 | { 62 | return I2cReadBuffer( &I2c, I2cDeviceAddr << 1, addr, data, size ); 63 | } 64 | 65 | void SX1509SetDeviceAddr( uint8_t addr ) 66 | { 67 | I2cDeviceAddr = addr; 68 | } 69 | 70 | uint8_t SX1509GetDeviceAddr( void ) 71 | { 72 | return I2cDeviceAddr; 73 | } 74 | -------------------------------------------------------------------------------- /src/peripherals/sx9500.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Driver for the SX9500 proximity sensor 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "board.h" 16 | #include "sx9500.h" 17 | 18 | static uint8_t I2cDeviceAddr = 0; 19 | 20 | static bool SX9500Initialized = false; 21 | 22 | uint8_t SX9500Init( void ) 23 | { 24 | uint8_t regVal = 0; 25 | 26 | SX9500SetDeviceAddr( SX9500_I2C_ADDRESS ); 27 | 28 | if( SX9500Initialized == false ) 29 | { 30 | SX9500Initialized = true; 31 | 32 | SX9500Read( SX9500_REG_PROXCTRL0, ®Val ); 33 | if( regVal != 0x0F ) 34 | { 35 | return FAIL; 36 | } 37 | 38 | SX9500Reset( ); 39 | } 40 | return SUCCESS; 41 | } 42 | 43 | uint8_t SX9500Reset( ) 44 | { 45 | if( SX9500Write( SX9500_REG_RESET, SX9500_RESET_CMD ) == SUCCESS ) 46 | { 47 | return SUCCESS; 48 | } 49 | return FAIL; 50 | } 51 | 52 | uint8_t SX9500Write( uint8_t addr, uint8_t data ) 53 | { 54 | return SX9500WriteBuffer( addr, &data, 1 ); 55 | } 56 | 57 | uint8_t SX9500WriteBuffer( uint8_t addr, uint8_t *data, uint8_t size ) 58 | { 59 | return I2cWriteBuffer( &I2c, I2cDeviceAddr << 1, addr, data, size ); 60 | } 61 | 62 | uint8_t SX9500Read( uint8_t addr, uint8_t *data ) 63 | { 64 | return SX9500ReadBuffer( addr, data, 1 ); 65 | } 66 | 67 | uint8_t SX9500ReadBuffer( uint8_t addr, uint8_t *data, uint8_t size ) 68 | { 69 | return I2cReadBuffer( &I2c, I2cDeviceAddr << 1, addr, data, size ); 70 | } 71 | 72 | void SX9500SetDeviceAddr( uint8_t addr ) 73 | { 74 | I2cDeviceAddr = addr; 75 | } 76 | 77 | uint8_t SX9500GetDeviceAddr( void ) 78 | { 79 | return I2cDeviceAddr; 80 | } 81 | 82 | void SX9500LockUntilDetection( void ) 83 | { 84 | uint8_t val = 0; 85 | 86 | SX9500Write( SX9500_REG_RESET, SX9500_RESET_CMD ); 87 | SX9500Read( SX9500_REG_IRQSRC, &val ); 88 | SX9500Read( SX9500_REG_STAT, &val ); 89 | 90 | SX9500Write( SX9500_REG_PROXCTRL0, 0x0F ); 91 | SX9500Write( SX9500_REG_PROXCTRL1, 0x43 ); 92 | SX9500Write( SX9500_REG_PROXCTRL2, 0x77 ); 93 | SX9500Write( SX9500_REG_PROXCTRL3, 0x01 ); 94 | SX9500Write( SX9500_REG_PROXCTRL4, 0x30 ); 95 | SX9500Write( SX9500_REG_PROXCTRL5, 0x0F ); 96 | SX9500Write( SX9500_REG_PROXCTRL6, 0x04 ); 97 | SX9500Write( SX9500_REG_PROXCTRL7, 0x40 ); 98 | SX9500Write( SX9500_REG_PROXCTRL8, 0x00 ); 99 | SX9500Write( SX9500_REG_IRQMSK, 0x60 ); 100 | 101 | val = 0; 102 | 103 | while( ( val & 0xF0 ) == 0x00 ) 104 | { 105 | SX9500Read( SX9500_REG_STAT, &val ); 106 | } 107 | 108 | SX9500Read( SX9500_REG_STAT, &val ); 109 | SX9500Read( SX9500_REG_IRQSRC, &val ); 110 | } 111 | -------------------------------------------------------------------------------- /src/peripherals/sx9500.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Driver for the SX9500 proximity sensor 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __SX9500_H__ 16 | #define __SX9500_H__ 17 | 18 | #define SX9500_I2C_ADDRESS 0x28 19 | 20 | #define SX9500_REG_IRQSRC 0x00 21 | #define SX9500_REG_STAT 0x01 22 | #define SX9500_REG_IRQMSK 0x03 23 | #define SX9500_REG_PROXCTRL0 0x06 24 | #define SX9500_REG_PROXCTRL1 0x07 25 | #define SX9500_REG_PROXCTRL2 0x08 26 | #define SX9500_REG_PROXCTRL3 0x09 27 | #define SX9500_REG_PROXCTRL4 0x0A 28 | #define SX9500_REG_PROXCTRL5 0x0B 29 | #define SX9500_REG_PROXCTRL6 0x0C 30 | #define SX9500_REG_PROXCTRL7 0x0D 31 | #define SX9500_REG_PROXCTRL8 0x0E 32 | #define SX9500_REG_SENSORSEL 0x20 33 | #define SX9500_REG_USEMSB 0x21 34 | #define SX9500_REG_USELSB 0x22 35 | #define SX9500_REG_AVGMSB 0x23 36 | #define SX9500_REG_AVGLSB 0x24 37 | #define SX9500_REG_DIFFMSB 0x25 38 | #define SX9500_REG_DIFFLSB 0x26 39 | #define SX9500_REG_OFFSETMSB 0x27 40 | #define SX9500_REG_OFFSETLSB 0x28 41 | #define SX9500_REG_RESET 0x7F 42 | 43 | #define SX9500_RESET_CMD 0xDE 44 | 45 | uint8_t SX9500Init( void ); 46 | 47 | /*! 48 | * \brief Resets the device 49 | * 50 | * \retval status [OK, ERROR, UNSUPPORTED] 51 | */ 52 | uint8_t SX9500Reset( void ); 53 | 54 | /*! 55 | * \brief Writes a byte at specified address in the device 56 | * 57 | * \param [IN]: addr 58 | * \param [IN]: data 59 | * \retval status [OK, ERROR, UNSUPPORTED] 60 | */ 61 | uint8_t SX9500Write( uint8_t addr, uint8_t data ); 62 | 63 | /*! 64 | * \brief Writes a buffer at specified address in the device 65 | * 66 | * \param [IN]: addr 67 | * \param [IN]: data 68 | * \param [IN]: size 69 | * \retval status [OK, ERROR, UNSUPPORTED] 70 | */ 71 | uint8_t SX9500WriteBuffer( uint8_t addr, uint8_t *data, uint8_t size ); 72 | 73 | /*! 74 | * \brief Reads a byte at specified address in the device 75 | * 76 | * \param [IN]: addr 77 | * \param [OUT]: data 78 | * \retval status [OK, ERROR, UNSUPPORTED] 79 | */ 80 | uint8_t SX9500Read( uint8_t addr, uint8_t *data ); 81 | 82 | /*! 83 | * \brief Reads a buffer at specified address in the device 84 | * 85 | * \param [IN]: addr 86 | * \param [OUT]: data 87 | * \param [IN]: size 88 | * \retval status [OK, ERROR, UNSUPPORTED] 89 | */ 90 | uint8_t SX9500ReadBuffer( uint8_t addr, uint8_t *data, uint8_t size ); 91 | 92 | /*! 93 | * \brief Sets the I2C device slave address 94 | * 95 | * \param [IN]: addr 96 | */ 97 | void SX9500SetDeviceAddr( uint8_t addr ); 98 | 99 | /*! 100 | * \brief Gets the I2C device slave address 101 | * 102 | * \retval: addr Current device slave address 103 | */ 104 | uint8_t SX9500GetDeviceAddr( void ); 105 | 106 | /*! 107 | * \brief Goes into a loop until a successful capacitive proximity detection 108 | */ 109 | void SX9500LockUntilDetection( void ); 110 | 111 | #endif // __SX1509_H__ 112 | -------------------------------------------------------------------------------- /src/swo.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #ifdef TRACE_SWO 4 | void SWO_Init(uint32_t portBits, uint32_t cpuCoreFreqHz); 5 | void SWO_PrintString(const char *s); 6 | void SWO_PrintChar(char c); 7 | #else 8 | void SWO_Init(uint32_t portBits, uint32_t cpuCoreFreqHz); 9 | void SWO_PrintString(const char *s); 10 | void SWO_PrintChar(char c); 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /src/test_wakeup.cpp: -------------------------------------------------------------------------------- 1 | #include "WakeUp.h" 2 | #include "stm32l1xx_ll_pwr.h" 3 | #include "stm32l1xx_hal_pwr.h" 4 | 5 | // https://community.st.com/thread/46727-no-interrupts-in-low-power-stm32l151 6 | 7 | extern "C" void test_wakeup() { 8 | //Set wakeup time for 2 seconds 9 | WakeUp::set_ms(2000); 10 | 11 | //Enter deepsleep, the program won't go beyond this point until it is woken up 12 | HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFE); 13 | //LL_PWR_SetPowerMode(LL_PWR_MODE_STANDBY); 14 | //deepsleep(); 15 | } -------------------------------------------------------------------------------- /src/usb/cdc/inc/usbd_cdc_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_cdc_if.h 4 | * @brief : Header for usbd_cdc_if file. 5 | ****************************************************************************** 6 | * COPYRIGHT(c) 2016 STMicroelectronics 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | ****************************************************************************** 31 | */ 32 | 33 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __USBD_CDC_IF_H 35 | #define __USBD_CDC_IF_H 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | /* Includes ------------------------------------------------------------------*/ 41 | #include "usbd_cdc.h" 42 | /* USER CODE BEGIN INCLUDE */ 43 | /* USER CODE END INCLUDE */ 44 | 45 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_CDC_IF 50 | * @brief header 51 | * @{ 52 | */ 53 | 54 | /** @defgroup USBD_CDC_IF_Exported_Defines 55 | * @{ 56 | */ 57 | /* USER CODE BEGIN EXPORTED_DEFINES */ 58 | /* USER CODE END EXPORTED_DEFINES */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup USBD_CDC_IF_Exported_Types 65 | * @{ 66 | */ 67 | /* USER CODE BEGIN EXPORTED_TYPES */ 68 | /* USER CODE END EXPORTED_TYPES */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup USBD_CDC_IF_Exported_Macros 75 | * @{ 76 | */ 77 | /* USER CODE BEGIN EXPORTED_MACRO */ 78 | /* USER CODE END EXPORTED_MACRO */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_AUDIO_IF_Exported_Variables 85 | * @{ 86 | */ 87 | extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS; 88 | 89 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 90 | /* USER CODE END EXPORTED_VARIABLES */ 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | /** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype 97 | * @{ 98 | */ 99 | void CDC_Set_Uart_Obj(Uart_t *obj); 100 | 101 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len); 102 | 103 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 104 | /* USER CODE END EXPORTED_FUNCTIONS */ 105 | /** 106 | * @} 107 | */ 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | #endif /* __USBD_CDC_IF_H */ 122 | 123 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 124 | -------------------------------------------------------------------------------- /src/usb/cdc/inc/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : usbd_desc.h 4 | * @version : v1.0_Cube 5 | * @brief : Header for usbd_desc file. 6 | ****************************************************************************** 7 | * COPYRIGHT(c) 2016 STMicroelectronics 8 | * 9 | * Redistribution and use in source and binary forms, with or without modification, 10 | * are permitted provided that the following conditions are met: 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | ****************************************************************************** 32 | */ 33 | 34 | /* Define to prevent recursive inclusion -------------------------------------*/ 35 | #ifndef __USBD_DESC__H__ 36 | #define __USBD_DESC__H__ 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | /* Includes ------------------------------------------------------------------*/ 42 | #include "usbd_def.h" 43 | 44 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USB_DESC 49 | * @brief general defines for the usb device library file 50 | * @{ 51 | */ 52 | 53 | /** @defgroup USB_DESC_Exported_Defines 54 | * @{ 55 | */ 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | /** @defgroup USBD_DESC_Exported_TypesDefinitions 62 | * @{ 63 | */ 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup USBD_DESC_Exported_Macros 69 | * @{ 70 | */ 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_DESC_Exported_Variables 76 | * @{ 77 | */ 78 | extern USBD_DescriptorsTypeDef FS_Desc; 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype 84 | * @{ 85 | */ 86 | 87 | /** 88 | * @} 89 | */ 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* __USBD_DESC_H */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 104 | -------------------------------------------------------------------------------- /src/usb/dfu/inc/usbd_conf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/usb/dfu/inc/usbd_conf.h -------------------------------------------------------------------------------- /src/usb/dfu/inc/usbd_desc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/usb/dfu/inc/usbd_desc.h -------------------------------------------------------------------------------- /src/usb/dfu/inc/usbd_dfu_flash.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/usb/dfu/inc/usbd_dfu_flash.h -------------------------------------------------------------------------------- /src/usb/dfu/src/usbd_dfu_flash.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/src/usb/dfu/src/usbd_dfu_flash.c -------------------------------------------------------------------------------- /stm32flash_src/AUTHORS: -------------------------------------------------------------------------------- 1 | Authors ordered by first contribution. 2 | 3 | Geoffrey McRae 4 | Bret Olmsted 5 | Tormod Volden 6 | Jakob Malm 7 | Reuben Dowle 8 | Matthias Kubisch 9 | Paul Fertser 10 | Daniel Strnad 11 | Jérémie Rapin 12 | Christian Pointner 13 | Mats Erik Andersson 14 | Alexey Borovik 15 | Antonio Borneo 16 | Armin van der Togt 17 | Brian Silverman 18 | Georg Hofmann 19 | Luis Rodrigues 20 | Jeff Epler 21 | Alexander O. Anisimov 22 | Seth LaForge 23 | Johan Hellman 24 | Matthias Weisser 25 | Tilman Sauerbeck 26 | Mateusz Spychała 27 | Ernst Schwab 28 | -------------------------------------------------------------------------------- /stm32flash_src/Android.mk: -------------------------------------------------------------------------------- 1 | TOP_LOCAL_PATH := $(call my-dir) 2 | 3 | include $(call all-named-subdir-makefiles, parsers) 4 | 5 | LOCAL_PATH := $(TOP_LOCAL_PATH) 6 | 7 | include $(CLEAR_VARS) 8 | LOCAL_MODULE := stm32flash 9 | LOCAL_SRC_FILES := \ 10 | dev_table.c \ 11 | i2c.c \ 12 | init.c \ 13 | main.c \ 14 | port.c \ 15 | serial_common.c \ 16 | serial_platform.c \ 17 | stm32.c \ 18 | utils.c 19 | LOCAL_STATIC_LIBRARIES := libparsers 20 | include $(BUILD_EXECUTABLE) 21 | -------------------------------------------------------------------------------- /stm32flash_src/HOWTO: -------------------------------------------------------------------------------- 1 | Add new interfaces: 2 | ===================================================================== 3 | Current version 0.4 supports the following interfaces: 4 | - UART Windows (either "COMn" and "\\.\COMn"); 5 | - UART posix/Linux (e.g. "/dev/ttyUSB0"); 6 | - I2C Linux through standard driver "i2c-dev" (e.g. "/dev/i2c-n"). 7 | 8 | Starting from version 0.4, the back-end of stm32flash is modular and 9 | ready to be expanded to support new interfaces. 10 | I'm planning adding SPI on Linux through standard driver "spidev". 11 | You are invited to contribute with more interfaces. 12 | 13 | To add a new interface you need to add a new file, populate the struct 14 | port_interface (check at the end of files i2c.c, serial_posix.c and 15 | serial_w32.c) and provide the relative functions to operate on the 16 | interface: open/close, read/write, get_cfg_str and the optional gpio. 17 | The include the new drive in Makefile and register the new struct 18 | port_interface in file port.c in struct port_interface *ports[]. 19 | 20 | There are several USB-I2C adapter in the market, each providing its 21 | own libraries to communicate with the I2C bus. 22 | Could be interesting to provide as back-end a bridge between stm32flash 23 | and such libraries (I have no plan on this item). 24 | 25 | 26 | Add new STM32 devices: 27 | ===================================================================== 28 | Add a new line in file dev_table.c, in table devices[]. 29 | The fields of the table are listed in stm32.h, struct stm32_dev. 30 | 31 | 32 | Cross compile on Linux host for Windows target with MinGW: 33 | ===================================================================== 34 | I'm using a 64 bit Arch Linux machines, and I usually run: 35 | make CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar 36 | -------------------------------------------------------------------------------- /stm32flash_src/INSTALL: -------------------------------------------------------------------------------- 1 | 2 | Building stm32flash 3 | 4 | A set of static makefiles is provided that should work on most operating 5 | systems with a standard build environment, for instance GNU make and gcc. 6 | 7 | 1. Build executable 8 | 9 | make 10 | 11 | 2. Install executable and manual page (optional) 12 | 13 | make install 14 | 15 | The install location base can be set with the PREFIX flag (default 16 | is /usr/local), e.g. make install PREFIX=/opt 17 | -------------------------------------------------------------------------------- /stm32flash_src/Makefile: -------------------------------------------------------------------------------- 1 | PREFIX = /usr/local 2 | CFLAGS += -Wall -Werror -g 3 | 4 | INSTALL = install 5 | 6 | OBJS = dev_table.o \ 7 | i2c.o \ 8 | init.o \ 9 | main.o \ 10 | port.o \ 11 | serial_common.o \ 12 | serial_platform.o \ 13 | stm32.o \ 14 | utils.o 15 | 16 | LIBOBJS = parsers/parsers.a 17 | 18 | all: stm32flash 19 | 20 | serial_platform.o: serial_posix.c serial_w32.c 21 | 22 | parsers/parsers.a: force 23 | cd parsers && $(MAKE) parsers.a 24 | 25 | stm32flash: $(OBJS) $(LIBOBJS) 26 | $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBOBJS) 27 | 28 | clean: 29 | rm -f $(OBJS) stm32flash 30 | cd parsers && $(MAKE) $@ 31 | 32 | install: all 33 | $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin 34 | $(INSTALL) -m 755 stm32flash $(DESTDIR)$(PREFIX)/bin 35 | $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/man/man1 36 | $(INSTALL) -m 644 stm32flash.1 $(DESTDIR)$(PREFIX)/share/man/man1 37 | 38 | force: 39 | 40 | .PHONY: all clean install force 41 | -------------------------------------------------------------------------------- /stm32flash_src/README.md: -------------------------------------------------------------------------------- 1 | # stm32flash 2 | 3 | stm32flash (https://sourceforge.net/projects/stm32flash/) with some fixes, including: 4 | * support for manually erasing more than 255 flash pages 5 | * support for writing/reading EEPROM on STM32L0 and STM32L1 6 | * support for erasing necessary flash pages only with -E option 7 | 8 | From here, 9 | https://github.com/unwireddevices/stm32flash 10 | 11 | I added the RAK811 STM32L device that I have in dev_table as it did not support page erase 12 | 13 | To program flash memory: 14 | stm32flash -b 230400 -E -w file.hex COMxx 15 | 16 | To program EEPROM memory: 17 | stm32flash -b 230400 -S 0x08080000 -w file.bin COMxx 18 | 19 | P.S. Default UART baud rate is 115200 bps. Speeds up to 921600 bps were tested with CP2102 based USB-UART adapter. Even higher 3000000 bps speed should be possible with FT232R, althought it is not guaranteed by AN3155 that speed over 115200 bps will work. 20 | -------------------------------------------------------------------------------- /stm32flash_src/TODO: -------------------------------------------------------------------------------- 1 | 2 | AUTHORS: 3 | - Add contributors from Geoffrey's commits 4 | 5 | -------------------------------------------------------------------------------- /stm32flash_src/file.flash: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/stm32flash_src/file.flash -------------------------------------------------------------------------------- /stm32flash_src/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/stm32flash_src/firmware.bin -------------------------------------------------------------------------------- /stm32flash_src/init.h: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2010 Geoffrey McRae 4 | Copyright (C) 2013 Antonio Borneo 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | 22 | #ifndef _INIT_H 23 | #define _INIT_H 24 | 25 | #include "stm32.h" 26 | #include "port.h" 27 | 28 | int init_bl_entry(struct port_interface *port, const char *seq); 29 | int init_bl_exit(stm32_t *stm, struct port_interface *port, const char *seq); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /stm32flash_src/parsers/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_MODULE := libparsers 5 | LOCAL_SRC_FILES := binary.c hex.c 6 | include $(BUILD_STATIC_LIBRARY) 7 | -------------------------------------------------------------------------------- /stm32flash_src/parsers/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CFLAGS += -Wall -g 3 | 4 | all: parsers.a 5 | 6 | parsers.a: binary.o hex.o 7 | $(AR) rc $@ binary.o hex.o 8 | 9 | clean: 10 | rm -f *.o parsers.a 11 | 12 | .PHONY: all clean 13 | -------------------------------------------------------------------------------- /stm32flash_src/parsers/binary.c: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2010 Geoffrey McRae 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (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, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "binary.h" 28 | 29 | typedef struct { 30 | int fd; 31 | char write; 32 | struct stat stat; 33 | } binary_t; 34 | 35 | void* binary_init() { 36 | return calloc(sizeof(binary_t), 1); 37 | } 38 | 39 | parser_err_t binary_open(void *storage, const char *filename, const char write) { 40 | binary_t *st = storage; 41 | if (write) { 42 | if (filename[0] == '-') 43 | st->fd = 1; 44 | else 45 | st->fd = open( 46 | filename, 47 | #ifndef __WIN32__ 48 | O_WRONLY | O_CREAT | O_TRUNC, 49 | #else 50 | O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 51 | #endif 52 | #ifndef __WIN32__ 53 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH 54 | #else 55 | 0 56 | #endif 57 | ); 58 | st->stat.st_size = 0; 59 | } else { 60 | if (filename[0] == '-') { 61 | st->fd = 0; 62 | } else { 63 | if (stat(filename, &st->stat) != 0) 64 | return PARSER_ERR_INVALID_FILE; 65 | st->fd = open(filename, 66 | #ifndef __WIN32__ 67 | O_RDONLY 68 | #else 69 | O_RDONLY | O_BINARY 70 | #endif 71 | ); 72 | } 73 | } 74 | 75 | st->write = write; 76 | return st->fd == -1 ? PARSER_ERR_SYSTEM : PARSER_ERR_OK; 77 | } 78 | 79 | parser_err_t binary_close(void *storage) { 80 | binary_t *st = storage; 81 | 82 | if (st->fd) close(st->fd); 83 | free(st); 84 | return PARSER_ERR_OK; 85 | } 86 | 87 | unsigned int binary_size(void *storage) { 88 | binary_t *st = storage; 89 | return st->stat.st_size; 90 | } 91 | 92 | parser_err_t binary_read(void *storage, void *data, unsigned int *len) { 93 | binary_t *st = storage; 94 | unsigned int left = *len; 95 | if (st->write) return PARSER_ERR_WRONLY; 96 | 97 | ssize_t r; 98 | while(left > 0) { 99 | r = read(st->fd, data, left); 100 | /* If there is no data to read at all, return OK, but with zero read */ 101 | if (r == 0 && left == *len) { 102 | *len = 0; 103 | return PARSER_ERR_OK; 104 | } 105 | if (r <= 0) return PARSER_ERR_SYSTEM; 106 | left -= r; 107 | data += r; 108 | } 109 | 110 | *len = *len - left; 111 | return PARSER_ERR_OK; 112 | } 113 | 114 | parser_err_t binary_write(void *storage, void *data, unsigned int len) { 115 | binary_t *st = storage; 116 | if (!st->write) return PARSER_ERR_RDONLY; 117 | 118 | ssize_t r; 119 | while(len > 0) { 120 | r = write(st->fd, data, len); 121 | if (r < 1) return PARSER_ERR_SYSTEM; 122 | st->stat.st_size += r; 123 | 124 | len -= r; 125 | data += r; 126 | } 127 | 128 | return PARSER_ERR_OK; 129 | } 130 | 131 | parser_t PARSER_BINARY = { 132 | "Raw BINARY", 133 | binary_init, 134 | binary_open, 135 | binary_close, 136 | binary_size, 137 | binary_read, 138 | binary_write 139 | }; 140 | 141 | -------------------------------------------------------------------------------- /stm32flash_src/parsers/binary.h: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2010 Geoffrey McRae 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (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, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | 21 | #ifndef _PARSER_BINARY_H 22 | #define _PARSER_BINARY_H 23 | 24 | #include "parser.h" 25 | 26 | extern parser_t PARSER_BINARY; 27 | #endif 28 | -------------------------------------------------------------------------------- /stm32flash_src/parsers/hex.h: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2010 Geoffrey McRae 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (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, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | 21 | #ifndef _PARSER_HEX_H 22 | #define _PARSER_HEX_H 23 | 24 | #include "parser.h" 25 | 26 | extern parser_t PARSER_HEX; 27 | #endif 28 | -------------------------------------------------------------------------------- /stm32flash_src/parsers/parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2010 Geoffrey McRae 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (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, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | 21 | #ifndef _H_PARSER 22 | #define _H_PARSER 23 | 24 | enum parser_err { 25 | PARSER_ERR_OK, 26 | PARSER_ERR_SYSTEM, 27 | PARSER_ERR_INVALID_FILE, 28 | PARSER_ERR_WRONLY, 29 | PARSER_ERR_RDONLY 30 | }; 31 | typedef enum parser_err parser_err_t; 32 | 33 | struct parser { 34 | const char *name; 35 | void* (*init )(); /* initialise the parser */ 36 | parser_err_t (*open )(void *storage, const char *filename, const char write); /* open the file for read|write */ 37 | parser_err_t (*close)(void *storage); /* close and free the parser */ 38 | unsigned int (*size )(void *storage); /* get the total data size */ 39 | parser_err_t (*read )(void *storage, void *data, unsigned int *len); /* read a block of data */ 40 | parser_err_t (*write)(void *storage, void *data, unsigned int len); /* write a block of data */ 41 | }; 42 | typedef struct parser parser_t; 43 | 44 | static inline const char* parser_errstr(parser_err_t err) { 45 | switch(err) { 46 | case PARSER_ERR_OK : return "OK"; 47 | case PARSER_ERR_SYSTEM : return "System Error"; 48 | case PARSER_ERR_INVALID_FILE: return "Invalid File"; 49 | case PARSER_ERR_WRONLY : return "Parser can only write"; 50 | case PARSER_ERR_RDONLY : return "Parser can only read"; 51 | default: 52 | return "Unknown Error"; 53 | } 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /stm32flash_src/port.c: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2014 Antonio Borneo 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (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, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include "serial.h" 24 | #include "port.h" 25 | 26 | 27 | extern struct port_interface port_serial; 28 | extern struct port_interface port_i2c; 29 | 30 | static struct port_interface *ports[] = { 31 | &port_serial, 32 | &port_i2c, 33 | NULL, 34 | }; 35 | 36 | 37 | port_err_t port_open(struct port_options *ops, struct port_interface **outport) 38 | { 39 | int ret; 40 | static struct port_interface **port; 41 | 42 | for (port = ports; *port; port++) { 43 | ret = (*port)->open(*port, ops); 44 | if (ret == PORT_ERR_NODEV) 45 | continue; 46 | if (ret == PORT_ERR_OK) 47 | break; 48 | fprintf(stderr, "Error probing interface \"%s\"\n", 49 | (*port)->name); 50 | } 51 | if (*port == NULL) { 52 | fprintf(stderr, "Cannot handle device \"%s\"\n", 53 | ops->device); 54 | return PORT_ERR_UNKNOWN; 55 | } 56 | 57 | *outport = *port; 58 | return PORT_ERR_OK; 59 | } 60 | -------------------------------------------------------------------------------- /stm32flash_src/port.h: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2014 Antonio Borneo 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (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, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | 21 | #ifndef _H_PORT 22 | #define _H_PORT 23 | 24 | typedef enum { 25 | PORT_ERR_OK = 0, 26 | PORT_ERR_NODEV, /* No such device */ 27 | PORT_ERR_TIMEDOUT, /* Operation timed out */ 28 | PORT_ERR_UNKNOWN, 29 | } port_err_t; 30 | 31 | /* flags */ 32 | #define PORT_BYTE (1 << 0) /* byte (not frame) oriented */ 33 | #define PORT_GVR_ETX (1 << 1) /* cmd GVR returns protection status */ 34 | #define PORT_CMD_INIT (1 << 2) /* use INIT cmd to autodetect speed */ 35 | #define PORT_RETRY (1 << 3) /* allowed read() retry after timeout */ 36 | #define PORT_STRETCH_W (1 << 4) /* warning for no-stretching commands */ 37 | 38 | /* all options and flags used to open and configure an interface */ 39 | struct port_options { 40 | const char *device; 41 | serial_baud_t baudRate; 42 | const char *serial_mode; 43 | int bus_addr; 44 | int rx_frame_max; 45 | int tx_frame_max; 46 | }; 47 | 48 | /* 49 | * Specify the length of reply for command GET 50 | * This is helpful for frame-oriented protocols, e.g. i2c, to avoid time 51 | * consuming try-fail-timeout-retry operation. 52 | * On byte-oriented protocols, i.e. UART, this information would be skipped 53 | * after read the first byte, so not needed. 54 | */ 55 | struct varlen_cmd { 56 | uint8_t version; 57 | uint8_t length; 58 | }; 59 | 60 | struct port_interface { 61 | const char *name; 62 | unsigned flags; 63 | port_err_t (*open)(struct port_interface *port, struct port_options *ops); 64 | port_err_t (*close)(struct port_interface *port); 65 | port_err_t (*read)(struct port_interface *port, void *buf, size_t nbyte); 66 | port_err_t (*write)(struct port_interface *port, void *buf, size_t nbyte); 67 | port_err_t (*gpio)(struct port_interface *port, serial_gpio_t n, int level); 68 | const char *(*get_cfg_str)(struct port_interface *port); 69 | struct varlen_cmd *cmd_get_reply; 70 | void *private; 71 | }; 72 | 73 | port_err_t port_open(struct port_options *ops, struct port_interface **outport); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /stm32flash_src/protocol.txt: -------------------------------------------------------------------------------- 1 | The communication protocol used by ST bootloader is documented in following ST 2 | application notes, depending on communication port. 3 | 4 | In current version of stm32flash are supported only UART and I2C ports. 5 | 6 | * AN3154: CAN protocol used in the STM32 bootloader 7 | http://www.st.com/web/en/resource/technical/document/application_note/CD00264321.pdf 8 | 9 | * AN3155: USART protocol used in the STM32(TM) bootloader 10 | http://www.st.com/web/en/resource/technical/document/application_note/CD00264342.pdf 11 | 12 | * AN4221: I2C protocol used in the STM32 bootloader 13 | http://www.st.com/web/en/resource/technical/document/application_note/DM00072315.pdf 14 | 15 | * AN4286: SPI protocol used in the STM32 bootloader 16 | http://www.st.com/web/en/resource/technical/document/application_note/DM00081379.pdf 17 | 18 | Boot mode selection for STM32 is documented in ST application note AN2606, available in ST website: 19 | http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf 20 | -------------------------------------------------------------------------------- /stm32flash_src/serial.h: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2010 Geoffrey McRae 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (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, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | 21 | #ifndef _SERIAL_H 22 | #define _SERIAL_H 23 | 24 | typedef struct serial serial_t; 25 | 26 | typedef enum { 27 | SERIAL_PARITY_NONE, 28 | SERIAL_PARITY_EVEN, 29 | SERIAL_PARITY_ODD, 30 | 31 | SERIAL_PARITY_INVALID 32 | } serial_parity_t; 33 | 34 | typedef enum { 35 | SERIAL_BITS_5, 36 | SERIAL_BITS_6, 37 | SERIAL_BITS_7, 38 | SERIAL_BITS_8, 39 | 40 | SERIAL_BITS_INVALID 41 | } serial_bits_t; 42 | 43 | typedef enum { 44 | SERIAL_BAUD_1200, 45 | SERIAL_BAUD_1800, 46 | SERIAL_BAUD_2400, 47 | SERIAL_BAUD_4800, 48 | SERIAL_BAUD_9600, 49 | SERIAL_BAUD_19200, 50 | SERIAL_BAUD_38400, 51 | SERIAL_BAUD_57600, 52 | SERIAL_BAUD_115200, 53 | SERIAL_BAUD_128000, 54 | SERIAL_BAUD_230400, 55 | SERIAL_BAUD_256000, 56 | SERIAL_BAUD_460800, 57 | SERIAL_BAUD_500000, 58 | SERIAL_BAUD_576000, 59 | SERIAL_BAUD_921600, 60 | SERIAL_BAUD_1000000, 61 | SERIAL_BAUD_1500000, 62 | SERIAL_BAUD_2000000, 63 | SERIAL_BAUD_3000000, 64 | 65 | SERIAL_BAUD_INVALID 66 | } serial_baud_t; 67 | 68 | typedef enum { 69 | SERIAL_STOPBIT_1, 70 | SERIAL_STOPBIT_2, 71 | 72 | SERIAL_STOPBIT_INVALID 73 | } serial_stopbit_t; 74 | 75 | typedef enum { 76 | GPIO_RTS = 1, 77 | GPIO_DTR, 78 | GPIO_BRK, 79 | } serial_gpio_t; 80 | 81 | /* common helper functions */ 82 | serial_baud_t serial_get_baud(const unsigned int baud); 83 | unsigned int serial_get_baud_int(const serial_baud_t baud); 84 | serial_bits_t serial_get_bits(const char *mode); 85 | unsigned int serial_get_bits_int(const serial_bits_t bits); 86 | serial_parity_t serial_get_parity(const char *mode); 87 | char serial_get_parity_str(const serial_parity_t parity); 88 | serial_stopbit_t serial_get_stopbit(const char *mode); 89 | unsigned int serial_get_stopbit_int(const serial_stopbit_t stopbit); 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /stm32flash_src/serial_platform.c: -------------------------------------------------------------------------------- 1 | #if defined(__WIN32__) || defined(__CYGWIN__) 2 | # include "serial_w32.c" 3 | #else 4 | # include "serial_posix.c" 5 | #endif 6 | -------------------------------------------------------------------------------- /stm32flash_src/stm32.h: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2010 Geoffrey McRae 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (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, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | 21 | #ifndef _STM32_H 22 | #define _STM32_H 23 | 24 | #include 25 | #include "serial.h" 26 | 27 | #define STM32_MAX_RX_FRAME 256 /* cmd read memory */ 28 | #define STM32_MAX_TX_FRAME (1 + 256 + 1) /* cmd write memory */ 29 | 30 | #define STM32_MAX_PAGES 0x0000ffff 31 | #define STM32_MASS_ERASE 0x00100000 /* > 2 x max_pages */ 32 | 33 | typedef enum { 34 | STM32_ERR_OK = 0, 35 | STM32_ERR_UNKNOWN, /* Generic error */ 36 | STM32_ERR_NACK, 37 | STM32_ERR_NO_CMD, /* Command not available in bootloader */ 38 | } stm32_err_t; 39 | 40 | typedef enum { 41 | F_NO_ME = 1 << 0, /* Mass-Erase not supported */ 42 | F_OBLL = 1 << 1, /* OBL_LAUNCH required */ 43 | } flags_t; 44 | 45 | typedef struct stm32 stm32_t; 46 | typedef struct stm32_cmd stm32_cmd_t; 47 | typedef struct stm32_dev stm32_dev_t; 48 | 49 | struct stm32 { 50 | const serial_t *serial; 51 | struct port_interface *port; 52 | uint8_t bl_version; 53 | uint8_t version; 54 | uint8_t option1, option2; 55 | uint16_t pid; 56 | stm32_cmd_t *cmd; 57 | const stm32_dev_t *dev; 58 | }; 59 | 60 | struct stm32_dev { 61 | uint16_t id; 62 | const char *name; 63 | uint32_t ram_start, ram_end; 64 | uint32_t fl_start, fl_end; 65 | uint16_t fl_pps; // pages per sector 66 | uint32_t *fl_ps; // page size 67 | uint32_t opt_start, opt_end; 68 | uint32_t mem_start, mem_end; 69 | uint32_t eeprom_start, eeprom_end; 70 | uint32_t flags; 71 | }; 72 | 73 | stm32_t *stm32_init(struct port_interface *port, const char init); 74 | void stm32_close(stm32_t *stm); 75 | stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address, 76 | uint8_t data[], unsigned int len); 77 | stm32_err_t stm32_write_memory(const stm32_t *stm, uint32_t address, 78 | const uint8_t data[], unsigned int len); 79 | stm32_err_t stm32_wunprot_memory(const stm32_t *stm); 80 | stm32_err_t stm32_wprot_memory(const stm32_t *stm); 81 | stm32_err_t stm32_erase_memory(const stm32_t *stm, uint32_t spage, 82 | uint32_t pages); 83 | stm32_err_t stm32_go(const stm32_t *stm, uint32_t address); 84 | stm32_err_t stm32_reset_device(const stm32_t *stm); 85 | stm32_err_t stm32_readprot_memory(const stm32_t *stm); 86 | stm32_err_t stm32_runprot_memory(const stm32_t *stm); 87 | stm32_err_t stm32_crc_memory(const stm32_t *stm, uint32_t address, 88 | uint32_t length, uint32_t *crc); 89 | stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address, 90 | uint32_t length, uint32_t *crc); 91 | uint32_t stm32_sw_crc(uint32_t crc, uint8_t *buf, unsigned int len); 92 | 93 | #endif 94 | 95 | -------------------------------------------------------------------------------- /stm32flash_src/stm32flash.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ebiroll/RAK811_BreakBoard/85f5b215fd3ffcfb8eae7216ab5d79801753d7a9/stm32flash_src/stm32flash.exe -------------------------------------------------------------------------------- /stm32flash_src/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2010 Geoffrey McRae 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (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, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include 21 | #include "utils.h" 22 | 23 | /* detect CPU endian */ 24 | char cpu_le() { 25 | const uint32_t cpu_le_test = 0x12345678; 26 | return ((const unsigned char*)&cpu_le_test)[0] == 0x78; 27 | } 28 | 29 | uint32_t be_u32(const uint32_t v) { 30 | if (cpu_le()) 31 | return ((v & 0xFF000000) >> 24) | 32 | ((v & 0x00FF0000) >> 8) | 33 | ((v & 0x0000FF00) << 8) | 34 | ((v & 0x000000FF) << 24); 35 | return v; 36 | } 37 | 38 | uint32_t le_u32(const uint32_t v) { 39 | if (!cpu_le()) 40 | return ((v & 0xFF000000) >> 24) | 41 | ((v & 0x00FF0000) >> 8) | 42 | ((v & 0x0000FF00) << 8) | 43 | ((v & 0x000000FF) << 24); 44 | return v; 45 | } 46 | -------------------------------------------------------------------------------- /stm32flash_src/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | stm32flash - Open Source ST STM32 flash program for *nix 3 | Copyright (C) 2010 Geoffrey McRae 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either version 2 8 | of the License, or (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, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | 21 | #ifndef _H_UTILS 22 | #define _H_UTILS 23 | 24 | #include 25 | 26 | char cpu_le(); 27 | uint32_t be_u32(const uint32_t v); 28 | uint32_t le_u32(const uint32_t v); 29 | 30 | #endif 31 | --------------------------------------------------------------------------------