├── VERSION ├── bin ├── pgw_fw_uart.hex ├── pgw_fw_usb.dfu └── pgw_fw_usb.hex ├── readme.md └── src ├── DebugConfig └── Pico_STM32F401RETx.dbgconf ├── GettingStarted.html ├── MAIN ├── board.cpp ├── board.h ├── cmdUSB.cpp ├── cmdUSB.h └── main.cpp ├── Pico.cpdsc ├── SX1308HAL ├── inc │ ├── loragw_hal.h │ ├── loragw_radio.h │ ├── loragw_reg.h │ └── sx1308.h └── src │ ├── loragw_hal.cpp │ ├── loragw_reg.cpp │ └── sx1308.cpp ├── buildstartup_stm32f401xe.lst ├── mbed-dev.lib ├── mbed-dev ├── api │ ├── AnalogIn.h │ ├── AnalogOut.h │ ├── BusIn.h │ ├── BusInOut.h │ ├── BusOut.h │ ├── CAN.h │ ├── CThunk.h │ ├── CallChain.h │ ├── Callback.h │ ├── CircularBuffer.h │ ├── DigitalIn.h │ ├── DigitalInOut.h │ ├── DigitalOut.h │ ├── DirHandle.h │ ├── Ethernet.h │ ├── FileBase.h │ ├── FileHandle.h │ ├── FileLike.h │ ├── FilePath.h │ ├── FileSystemLike.h │ ├── FunctionPointer.h │ ├── I2C.h │ ├── I2CSlave.h │ ├── InterruptIn.h │ ├── InterruptManager.h │ ├── LocalFileSystem.h │ ├── LowPowerTicker.h │ ├── LowPowerTimeout.h │ ├── LowPowerTimer.h │ ├── PlatformMutex.h │ ├── PortIn.h │ ├── PortInOut.h │ ├── PortOut.h │ ├── PwmOut.h │ ├── RawSerial.h │ ├── SPI.h │ ├── SPISlave.h │ ├── Serial.h │ ├── SerialBase.h │ ├── SingletonPtr.h │ ├── Stream.h │ ├── Ticker.h │ ├── Timeout.h │ ├── Timer.h │ ├── TimerEvent.h │ ├── Transaction.h │ ├── can_helper.h │ ├── critical.h │ ├── mbed.h │ ├── mbed_assert.h │ ├── mbed_debug.h │ ├── mbed_error.h │ ├── mbed_interface.h │ ├── mbed_mem_trace.h │ ├── mbed_stats.h │ ├── platform.h │ ├── rtc_time.h │ ├── semihost_api.h │ ├── toolchain.h │ └── wait_api.h ├── common │ ├── AnalogIn.cpp │ ├── BusIn.cpp │ ├── BusInOut.cpp │ ├── BusOut.cpp │ ├── CAN.cpp │ ├── CallChain.cpp │ ├── Ethernet.cpp │ ├── FileBase.cpp │ ├── FileLike.cpp │ ├── FilePath.cpp │ ├── FileSystemLike.cpp │ ├── I2C.cpp │ ├── I2CSlave.cpp │ ├── InterruptIn.cpp │ ├── InterruptManager.cpp │ ├── LocalFileSystem.cpp │ ├── RawSerial.cpp │ ├── SPI.cpp │ ├── SPISlave.cpp │ ├── Serial.cpp │ ├── SerialBase.cpp │ ├── Stream.cpp │ ├── Ticker.cpp │ ├── Timeout.cpp │ ├── Timer.cpp │ ├── TimerEvent.cpp │ ├── mbed_alloc_wrappers.cpp │ ├── mbed_assert.c │ ├── mbed_board.c │ ├── mbed_critical.c │ ├── mbed_error.c │ ├── mbed_gpio.c │ ├── mbed_interface.c │ ├── mbed_lp_ticker_api.c │ ├── mbed_mem_trace.c │ ├── mbed_pinmap_common.c │ ├── mbed_rtc_time.cpp │ ├── mbed_semihost_api.c │ ├── mbed_ticker_api.c │ ├── mbed_us_ticker_api.c │ ├── mbed_wait_api.c │ └── retarget.cpp ├── hal │ ├── analogin_api.h │ ├── analogout_api.h │ ├── buffer.h │ ├── can_api.h │ ├── dma_api.h │ ├── ethernet_api.h │ ├── gpio_api.h │ ├── gpio_irq_api.h │ ├── i2c_api.h │ ├── lp_ticker_api.h │ ├── pinmap.h │ ├── port_api.h │ ├── pwmout_api.h │ ├── rtc_api.h │ ├── serial_api.h │ ├── sleep_api.h │ ├── spi_api.h │ ├── storage_abstraction │ │ ├── Driver_Common.h │ │ └── Driver_Storage.h │ ├── ticker_api.h │ └── us_ticker_api.h ├── module.json ├── targets.json └── targets │ ├── cmsis │ ├── TARGET_STM │ │ └── TARGET_STM32F4 │ │ │ ├── TARGET_NUCLEO_F401RE │ │ │ ├── TOOLCHAIN_ARM_STD │ │ │ │ ├── startup_stm32f401xe.S │ │ │ │ ├── stm32f401xe.sct │ │ │ │ └── sys.cpp │ │ │ ├── cmsis.h │ │ │ ├── cmsis_nvic.c │ │ │ ├── cmsis_nvic.h │ │ │ ├── hal_tick.c │ │ │ ├── hal_tick.h │ │ │ ├── stm32f401xc.h │ │ │ ├── stm32f401xe.h │ │ │ ├── stm32f4xx.h │ │ │ ├── stm32f4xx_hal_conf.h │ │ │ ├── system_stm32f4xx.c │ │ │ └── system_stm32f4xx.h │ │ │ ├── stm32_hal_legacy.h │ │ │ ├── stm32f4xx_hal.c │ │ │ ├── stm32f4xx_hal.h │ │ │ ├── stm32f4xx_hal_adc.c │ │ │ ├── stm32f4xx_hal_adc.h │ │ │ ├── stm32f4xx_hal_adc_ex.c │ │ │ ├── stm32f4xx_hal_adc_ex.h │ │ │ ├── stm32f4xx_hal_can.c │ │ │ ├── stm32f4xx_hal_can.h │ │ │ ├── stm32f4xx_hal_cec.c │ │ │ ├── stm32f4xx_hal_cec.h │ │ │ ├── stm32f4xx_hal_conf_template.h │ │ │ ├── stm32f4xx_hal_cortex.c │ │ │ ├── stm32f4xx_hal_cortex.h │ │ │ ├── stm32f4xx_hal_crc.c │ │ │ ├── stm32f4xx_hal_crc.h │ │ │ ├── stm32f4xx_hal_cryp.c │ │ │ ├── stm32f4xx_hal_cryp.h │ │ │ ├── stm32f4xx_hal_cryp_ex.c │ │ │ ├── stm32f4xx_hal_cryp_ex.h │ │ │ ├── stm32f4xx_hal_dac.c │ │ │ ├── stm32f4xx_hal_dac.h │ │ │ ├── stm32f4xx_hal_dac_ex.c │ │ │ ├── stm32f4xx_hal_dac_ex.h │ │ │ ├── stm32f4xx_hal_dcmi.c │ │ │ ├── stm32f4xx_hal_dcmi.h │ │ │ ├── stm32f4xx_hal_dcmi_ex.c │ │ │ ├── stm32f4xx_hal_dcmi_ex.h │ │ │ ├── stm32f4xx_hal_def.h │ │ │ ├── stm32f4xx_hal_dfsdm.c │ │ │ ├── stm32f4xx_hal_dfsdm.h │ │ │ ├── stm32f4xx_hal_dma.c │ │ │ ├── stm32f4xx_hal_dma.h │ │ │ ├── stm32f4xx_hal_dma2d.c │ │ │ ├── stm32f4xx_hal_dma2d.h │ │ │ ├── stm32f4xx_hal_dma_ex.c │ │ │ ├── stm32f4xx_hal_dma_ex.h │ │ │ ├── stm32f4xx_hal_dsi.c │ │ │ ├── stm32f4xx_hal_dsi.h │ │ │ ├── stm32f4xx_hal_eth.c │ │ │ ├── stm32f4xx_hal_eth.h │ │ │ ├── stm32f4xx_hal_flash.c │ │ │ ├── stm32f4xx_hal_flash.h │ │ │ ├── stm32f4xx_hal_flash_ex.c │ │ │ ├── stm32f4xx_hal_flash_ex.h │ │ │ ├── stm32f4xx_hal_flash_ramfunc.c │ │ │ ├── stm32f4xx_hal_flash_ramfunc.h │ │ │ ├── stm32f4xx_hal_fmpi2c.c │ │ │ ├── stm32f4xx_hal_fmpi2c.h │ │ │ ├── stm32f4xx_hal_fmpi2c_ex.c │ │ │ ├── stm32f4xx_hal_fmpi2c_ex.h │ │ │ ├── stm32f4xx_hal_gpio.c │ │ │ ├── stm32f4xx_hal_gpio.h │ │ │ ├── stm32f4xx_hal_gpio_ex.h │ │ │ ├── stm32f4xx_hal_hash.c │ │ │ ├── stm32f4xx_hal_hash.h │ │ │ ├── stm32f4xx_hal_hash_ex.c │ │ │ ├── stm32f4xx_hal_hash_ex.h │ │ │ ├── stm32f4xx_hal_hcd.c │ │ │ ├── stm32f4xx_hal_hcd.h │ │ │ ├── stm32f4xx_hal_i2c.c │ │ │ ├── stm32f4xx_hal_i2c.h │ │ │ ├── stm32f4xx_hal_i2c_ex.c │ │ │ ├── stm32f4xx_hal_i2c_ex.h │ │ │ ├── stm32f4xx_hal_i2s.c │ │ │ ├── stm32f4xx_hal_i2s.h │ │ │ ├── stm32f4xx_hal_i2s_ex.c │ │ │ ├── stm32f4xx_hal_i2s_ex.h │ │ │ ├── stm32f4xx_hal_irda.c │ │ │ ├── stm32f4xx_hal_irda.h │ │ │ ├── stm32f4xx_hal_iwdg.c │ │ │ ├── stm32f4xx_hal_iwdg.h │ │ │ ├── stm32f4xx_hal_lptim.c │ │ │ ├── stm32f4xx_hal_lptim.h │ │ │ ├── stm32f4xx_hal_ltdc.c │ │ │ ├── stm32f4xx_hal_ltdc.h │ │ │ ├── stm32f4xx_hal_ltdc_ex.c │ │ │ ├── stm32f4xx_hal_ltdc_ex.h │ │ │ ├── stm32f4xx_hal_msp_template.c │ │ │ ├── stm32f4xx_hal_nand.c │ │ │ ├── stm32f4xx_hal_nand.h │ │ │ ├── stm32f4xx_hal_nor.c │ │ │ ├── stm32f4xx_hal_nor.h │ │ │ ├── stm32f4xx_hal_pccard.c │ │ │ ├── stm32f4xx_hal_pccard.h │ │ │ ├── stm32f4xx_hal_pcd.c │ │ │ ├── stm32f4xx_hal_pcd.h │ │ │ ├── stm32f4xx_hal_pcd_ex.c │ │ │ ├── stm32f4xx_hal_pcd_ex.h │ │ │ ├── stm32f4xx_hal_pwr.c │ │ │ ├── stm32f4xx_hal_pwr.h │ │ │ ├── stm32f4xx_hal_pwr_ex.c │ │ │ ├── stm32f4xx_hal_pwr_ex.h │ │ │ ├── stm32f4xx_hal_qspi.c │ │ │ ├── stm32f4xx_hal_qspi.h │ │ │ ├── stm32f4xx_hal_rcc.c │ │ │ ├── stm32f4xx_hal_rcc.h │ │ │ ├── stm32f4xx_hal_rcc_ex.c │ │ │ ├── stm32f4xx_hal_rcc_ex.h │ │ │ ├── stm32f4xx_hal_rng.c │ │ │ ├── stm32f4xx_hal_rng.h │ │ │ ├── stm32f4xx_hal_rtc.c │ │ │ ├── stm32f4xx_hal_rtc.h │ │ │ ├── stm32f4xx_hal_rtc_ex.c │ │ │ ├── stm32f4xx_hal_rtc_ex.h │ │ │ ├── stm32f4xx_hal_sai.c │ │ │ ├── stm32f4xx_hal_sai.h │ │ │ ├── stm32f4xx_hal_sai_ex.c │ │ │ ├── stm32f4xx_hal_sai_ex.h │ │ │ ├── stm32f4xx_hal_sd.c │ │ │ ├── stm32f4xx_hal_sd.h │ │ │ ├── stm32f4xx_hal_sdram.c │ │ │ ├── stm32f4xx_hal_sdram.h │ │ │ ├── stm32f4xx_hal_smartcard.c │ │ │ ├── stm32f4xx_hal_smartcard.h │ │ │ ├── stm32f4xx_hal_spdifrx.c │ │ │ ├── stm32f4xx_hal_spdifrx.h │ │ │ ├── stm32f4xx_hal_spi.c │ │ │ ├── stm32f4xx_hal_spi.h │ │ │ ├── stm32f4xx_hal_sram.c │ │ │ ├── stm32f4xx_hal_sram.h │ │ │ ├── stm32f4xx_hal_tim.c │ │ │ ├── stm32f4xx_hal_tim.h │ │ │ ├── stm32f4xx_hal_tim_ex.c │ │ │ ├── stm32f4xx_hal_tim_ex.h │ │ │ ├── stm32f4xx_hal_uart.c │ │ │ ├── stm32f4xx_hal_uart.h │ │ │ ├── stm32f4xx_hal_uart.h~RF3f84dd03.TMP │ │ │ ├── stm32f4xx_hal_usart.c │ │ │ ├── stm32f4xx_hal_usart.h │ │ │ ├── stm32f4xx_hal_wwdg.c │ │ │ ├── stm32f4xx_hal_wwdg.h │ │ │ ├── stm32f4xx_ll_fmc.c │ │ │ ├── stm32f4xx_ll_fmc.h │ │ │ ├── stm32f4xx_ll_fsmc.c │ │ │ ├── stm32f4xx_ll_fsmc.h │ │ │ ├── stm32f4xx_ll_sdmmc.c │ │ │ ├── stm32f4xx_ll_sdmmc.h │ │ │ ├── stm32f4xx_ll_usb.c │ │ │ └── stm32f4xx_ll_usb.h │ ├── arm_common_tables.h │ ├── arm_const_structs.h │ ├── arm_math.h │ ├── core_ca9.h │ ├── core_caFunc.h │ ├── core_caInstr.h │ ├── core_ca_mmu.h │ ├── core_cm0.h │ ├── core_cm0plus.h │ ├── core_cm3.h │ ├── core_cm4.h │ ├── core_cm4_simd.h │ ├── core_cm7.h │ ├── core_cmFunc.h │ ├── core_cmInstr.h │ ├── core_cmSecureAccess.h │ ├── core_cmSimd.h │ ├── core_sc000.h │ └── core_sc300.h │ └── hal │ └── TARGET_STM │ └── TARGET_STM32F4 │ ├── PeripheralPins.h │ ├── TARGET_NUCLEO_F401RE │ ├── PeripheralNames.h │ ├── PeripheralPins.c │ ├── PinNames.h │ ├── PortNames.h │ └── objects.h │ ├── analogin_api.c │ ├── analogout_api.c │ ├── can_api.c │ ├── common_objects.h │ ├── device.h │ ├── entropy_hardware_poll.c │ ├── gpio_api.c │ ├── gpio_irq_api.c │ ├── gpio_object.h │ ├── i2c_api.c │ ├── mbed_overrides.c │ ├── pinmap.c │ ├── port_api.c │ ├── pwmout_api.c │ ├── rtc_api.c │ ├── serial_api.c │ ├── sleep.c │ ├── spi_api.c │ └── us_ticker.c ├── mbed_config.h ├── pgw.map ├── pgw.uvoptx ├── pgw.uvprojx └── usb_cdc ├── Inc ├── mxconstants.h ├── stm32f4xx_hal_conf.h ├── stm32f4xx_it.h ├── usb_device.h ├── usbd_cdc.h ├── usbd_cdc_if.h ├── usbd_conf.h ├── usbd_core.h ├── usbd_ctlreq.h ├── usbd_def.h ├── usbd_desc.h └── usbd_ioreq.h ├── Src ├── stm32f4xx_it.cpp ├── usb_device.cpp ├── usbd_cdc.cpp ├── usbd_cdc_if.cpp ├── usbd_conf.cpp ├── usbd_core.cpp ├── usbd_ctlreq.cpp ├── usbd_desc.cpp └── usbd_ioreq.cpp └── mbed-dev ├── api ├── AnalogIn.h ├── AnalogOut.h ├── BusIn.h ├── BusInOut.h ├── BusOut.h ├── CAN.h ├── CThunk.h ├── CallChain.h ├── Callback.h ├── CircularBuffer.h ├── DigitalIn.h ├── DigitalInOut.h ├── DigitalOut.h ├── DirHandle.h ├── Ethernet.h ├── FileBase.h ├── FileHandle.h ├── FileLike.h ├── FilePath.h ├── FileSystemLike.h ├── FunctionPointer.h ├── I2C.h ├── I2CSlave.h ├── InterruptIn.h ├── InterruptManager.h ├── LocalFileSystem.h ├── LowPowerTicker.h ├── LowPowerTimeout.h ├── LowPowerTimer.h ├── PlatformMutex.h ├── PortIn.h ├── PortInOut.h ├── PortOut.h ├── PwmOut.h ├── RawSerial.h ├── Ticker.h ├── can_helper.h ├── critical.h ├── mbed.h ├── mbed_assert.h ├── mbed_debug.h ├── mbed_error.h ├── mbed_interface.h ├── mbed_mem_trace.h ├── mbed_stats.h ├── platform.h ├── rtc_time.h └── semihost_api.h ├── module.json ├── targets.json └── targets ├── cmsis └── TARGET_STM │ └── TARGET_STM32F4 │ ├── TARGET_NUCLEO_F401RE │ ├── TOOLCHAIN_ARM_STD │ │ ├── startup_stm32f401xe.S │ │ ├── stm32f401xe.sct │ │ └── sys.cpp │ ├── cmsis.h │ ├── cmsis_nvic.c │ ├── cmsis_nvic.h │ ├── hal_tick.c │ ├── hal_tick.h │ ├── stm32f401xc.h │ ├── stm32f4xx.h │ ├── stm32f4xx_hal_conf.h │ ├── system_stm32f4xx.c │ └── system_stm32f4xx.h │ ├── stm32_hal_legacy.h │ ├── stm32f4xx_hal_cec.c │ ├── stm32f4xx_hal_flash_ramfunc.c │ ├── stm32f4xx_hal_flash_ramfunc.h │ ├── stm32f4xx_hal_fmpi2c.c │ ├── stm32f4xx_hal_fmpi2c.h │ ├── stm32f4xx_hal_fmpi2c_ex.c │ ├── stm32f4xx_hal_fmpi2c_ex.h │ ├── stm32f4xx_hal_gpio.c │ ├── stm32f4xx_hal_gpio.h │ ├── stm32f4xx_hal_gpio_ex.h │ ├── stm32f4xx_hal_hash.c │ ├── stm32f4xx_hal_hash.h │ ├── stm32f4xx_hal_hash_ex.c │ ├── stm32f4xx_hal_hash_ex.h │ ├── stm32f4xx_hal_hcd.c │ ├── stm32f4xx_hal_hcd.h │ ├── stm32f4xx_hal_i2c.c │ ├── stm32f4xx_hal_i2c.h │ ├── stm32f4xx_hal_i2c_ex.c │ ├── stm32f4xx_hal_i2c_ex.h │ ├── stm32f4xx_hal_i2s.c │ ├── stm32f4xx_hal_i2s.h │ ├── stm32f4xx_hal_i2s_ex.c │ ├── stm32f4xx_hal_i2s_ex.h │ ├── stm32f4xx_hal_irda.c │ ├── stm32f4xx_hal_irda.h │ ├── stm32f4xx_hal_iwdg.c │ ├── stm32f4xx_hal_iwdg.h │ ├── stm32f4xx_hal_lptim.c │ ├── stm32f4xx_hal_lptim.h │ ├── stm32f4xx_hal_ltdc.c │ ├── stm32f4xx_hal_ltdc.h │ ├── stm32f4xx_hal_ltdc_ex.c │ ├── stm32f4xx_hal_ltdc_ex.h │ ├── stm32f4xx_hal_msp_template.c │ ├── stm32f4xx_hal_nand.c │ ├── stm32f4xx_hal_nand.h │ ├── stm32f4xx_hal_nor.c │ ├── stm32f4xx_hal_nor.h │ ├── stm32f4xx_hal_pccard.c │ ├── stm32f4xx_hal_pccard.h │ ├── stm32f4xx_hal_pcd.c │ ├── stm32f4xx_hal_pcd.h │ ├── stm32f4xx_hal_pcd_ex.c │ ├── stm32f4xx_hal_pcd_ex.h │ ├── stm32f4xx_hal_pwr.c │ ├── stm32f4xx_hal_pwr.h │ ├── stm32f4xx_hal_pwr_ex.c │ ├── stm32f4xx_hal_pwr_ex.h │ ├── stm32f4xx_hal_qspi.c │ ├── stm32f4xx_hal_qspi.h │ ├── stm32f4xx_hal_rcc.c │ ├── stm32f4xx_hal_rcc.h │ ├── stm32f4xx_hal_rcc_ex.c │ ├── stm32f4xx_hal_rcc_ex.h │ ├── stm32f4xx_hal_rng.c │ ├── stm32f4xx_hal_rng.h │ ├── stm32f4xx_hal_rtc.c │ ├── stm32f4xx_hal_rtc.h │ ├── stm32f4xx_hal_rtc_ex.c │ ├── stm32f4xx_hal_rtc_ex.h │ ├── stm32f4xx_hal_sai.c │ ├── stm32f4xx_hal_sai.h │ ├── stm32f4xx_hal_sai_ex.c │ ├── stm32f4xx_hal_sai_ex.h │ ├── stm32f4xx_hal_sd.c │ ├── stm32f4xx_hal_sd.h │ ├── stm32f4xx_hal_sdram.c │ ├── stm32f4xx_hal_sdram.h │ ├── stm32f4xx_hal_smartcard.c │ ├── stm32f4xx_hal_smartcard.h │ ├── stm32f4xx_hal_spdifrx.c │ ├── stm32f4xx_hal_spdifrx.h │ ├── stm32f4xx_hal_spi.c │ ├── stm32f4xx_hal_spi.h │ ├── stm32f4xx_hal_sram.c │ ├── stm32f4xx_hal_sram.h │ ├── stm32f4xx_hal_tim.c │ ├── stm32f4xx_hal_tim.h │ ├── stm32f4xx_hal_tim_ex.c │ ├── stm32f4xx_hal_tim_ex.h │ ├── stm32f4xx_hal_uart.c │ ├── stm32f4xx_hal_uart.h │ ├── stm32f4xx_hal_usart.c │ ├── stm32f4xx_hal_usart.h │ ├── stm32f4xx_hal_wwdg.c │ ├── stm32f4xx_hal_wwdg.h │ ├── stm32f4xx_ll_fmc.c │ ├── stm32f4xx_ll_fmc.h │ ├── stm32f4xx_ll_fsmc.c │ ├── stm32f4xx_ll_fsmc.h │ ├── stm32f4xx_ll_sdmmc.c │ ├── stm32f4xx_ll_sdmmc.h │ ├── stm32f4xx_ll_usb.c │ └── stm32f4xx_ll_usb.h └── hal └── TARGET_STM └── TARGET_STM32F4 ├── PeripheralPins.h ├── TARGET_NUCLEO_F401RE ├── PeripheralNames.h ├── PeripheralPins.c ├── PinNames.h ├── PortNames.h └── objects.h ├── analogin_api.c ├── analogout_api.c ├── can_api.c ├── common_objects.h ├── device.h ├── entropy_hardware_poll.c ├── gpio_api.c ├── gpio_irq_api.c ├── gpio_object.h ├── i2c_api.c ├── mbed_overrides.c ├── pinmap.c ├── port_api.c ├── pwmout_api.c ├── rtc_api.c ├── serial_api.c ├── sleep.c ├── spi_api.c └── us_ticker.c /VERSION: -------------------------------------------------------------------------------- 1 | 0.2.1 2 | -------------------------------------------------------------------------------- /bin/pgw_fw_usb.dfu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lora-net/picoGW_mcu/9aec67e25356e8980e7aac2be7f03f30450b816c/bin/pgw_fw_usb.dfu -------------------------------------------------------------------------------- /src/DebugConfig/Pico_STM32F401RETx.dbgconf: -------------------------------------------------------------------------------- 1 | // <<< Use Configuration Wizard in Context Menu >>> 2 | 3 | // Debug MCU Configuration 4 | // DBG_SLEEP Debug Sleep Mode 5 | // DBG_STOP Debug Stop Mode 6 | // DBG_STANDBY Debug Standby Mode 7 | // 8 | DbgMCU_CR = 0x00000007; 9 | 10 | // Debug MCU APB1 Freeze 11 | // DBG_TIM2_STOP Timer 2 Stopped when Core is halted 12 | // DBG_TIM3_STOP Timer 3 Stopped when Core is halted 13 | // DBG_TIM4_STOP Timer 4 Stopped when Core is halted 14 | // DBG_TIM5_STOP Timer 5 Stopped when Core is halted 15 | // DBG_RTC_STOP RTC Stopped when Core is halted 16 | // DBG_WWDG_STOP Window Watchdog Stopped when Core is halted 17 | // DBG_IWDG_STOP Independent Watchdog Stopped when Core is halted 18 | // DBG_I2C1_SMBUS_TIMEOUT I2C1 SMBUS Timeout Mode Stopped when Core is halted 19 | // DBG_I2C2_SMBUS_TIMEOUT I2C2 SMBUS Timeout Mode Stopped when Core is halted 20 | // DBG_I2C3_SMBUS_TIMEOUT I2C3 SMBUS Timeout Mode Stopped when Core is halted 21 | // 22 | DbgMCU_APB1_Fz = 0x00000000; 23 | 24 | 25 | // Debug MCU APB2 Freeze 26 | // DBG_TIM1_STOP Timer 1 Stopped when Core is halted 27 | // DBG_TIM9_STOP Timer 9 Stopped when Core is halted 28 | // DBG_TIM10_STOP Timer 10 Stopped when Core is halted 29 | // DBG_TIM11_STOP Timer 11 Stopped when Core is halted 30 | // 31 | DbgMCU_APB2_Fz = 0x00000000; 32 | 33 | // <<< end of configuration section >>> -------------------------------------------------------------------------------- /src/GettingStarted.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 10 | Page Redirection 11 | 12 | 13 | If you are not redirected automatically, please follow the 14 | link to the online exporter documentation 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/MAIN/board.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2017 Semtech 8 | */ 9 | 10 | #include "board.h" 11 | #include "mbed.h" 12 | 13 | #ifndef USE_UART 14 | Serial pc(PB_6, PB_7); 15 | #endif 16 | 17 | #ifdef V2 18 | SX1308 Sx1308(PA_4, PA_7, PA_6, PA_5, PB_4, PA_3); 19 | DigitalOut FEM_EN(PB_0); // enable ldo 2V for PA 20 | DigitalOut RADIO_RST (PA_0); // reset sx1257 but sx1257 deliver HSE clk for stm32 so use HSI clk before to reset sx1257 21 | DigitalOut HSCLKEN (PB_2); // clk to switch off the correlators 22 | #endif 23 | #ifdef V1 24 | SX1308 Sx1308(PA_4, PA_7, PA_6, PA_5, PB_1, PA_3); 25 | DigitalOut RADIO_RST (PA_0); 26 | DigitalOut HSCLKEN (PB_14); 27 | #endif 28 | 29 | void FLASH_Prog( uint32_t Address, uint8_t Data ) { 30 | HAL_FLASH_Unlock(); 31 | __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR); 32 | FLASH_Erase_Sector(FLASH_SECTOR_4, VOLTAGE_RANGE_3); //sector4 0x8010000 0x801FFFF 33 | HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Address, Data); 34 | HAL_FLASH_Lock(); 35 | } 36 | -------------------------------------------------------------------------------- /src/MAIN/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2017 Semtech 8 | */ 9 | #ifndef BOARD_H 10 | #define BOARD_H 11 | 12 | #include "mbed.h" 13 | #include "SX1308.h" 14 | 15 | //#define USE_UART 1 16 | 17 | #define BOOTLOADER_ADDR 0x1FFF0004 18 | #define GOTO_BOOTLOADER 0x10 19 | 20 | #define DATA_EEPROM_BASE ( ( uint32_t )0x8011000U ) /*!< DATA_EEPROM base address in the alias region */ 21 | #define DATA_EEPROM_END ( ( uint32_t )DATA_EEPROM_BASE + 2048 ) /*!< DATA EEPROM end address in the alias region */ 22 | 23 | extern SX1308 Sx1308; 24 | 25 | #ifndef USE_UART 26 | extern Serial pc; 27 | #endif 28 | 29 | extern DigitalOut HSCLKEN ; 30 | extern DigitalOut RADIO_RST ; 31 | #ifdef V2 32 | extern DigitalOut FEM_EN; 33 | #endif 34 | 35 | extern void FLASH_Prog( uint32_t Address, uint8_t Data ); 36 | #endif 37 | -------------------------------------------------------------------------------- /src/MAIN/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | / ____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2017 Semtech 8 | 9 | */ 10 | 11 | #include "mbed.h" 12 | #include "usb_device.h" 13 | #include "usbd_cdc_if.h" 14 | #include "string.h" 15 | #include "CmdUSB.h" 16 | #include "board.h" 17 | 18 | #include "loragw_reg.h" 19 | 20 | CMDMANAGER CmdManager(PA_9, PA_10); 21 | 22 | void Error_Handler(void); 23 | 24 | #if DEBUG_MAIN == 1 25 | #define DEBUG_MSG(str) pc.printf(str) 26 | #define DEBUG_PRINTF(fmt, args...) pc.printf("%s:%d: "fmt, __FUNCTION__, __LINE__, args) 27 | #define DEBUG_ARRAY(a,b,c) for(a=0;a!=0;){} 28 | #define CHECK_NULL(a) if(a==NULL){return LGW_HAL_ERROR;} 29 | #else 30 | #define DEBUG_MSG(str) 31 | #define DEBUG_PRINTF(fmt, args...) 32 | #define DEBUG_ARRAY(a,b,c) for(a=0;a!=0;){} 33 | #define CHECK_NULL(a) if(a==NULL){return LGW_HAL_ERROR;} 34 | #endif 35 | 36 | void Error_Handler(void) { 37 | DEBUG_MSG("error\n"); 38 | } 39 | 40 | int main(void) { 41 | 42 | uint8_t dataflash; 43 | 44 | /* Check if it is requested to jump to the bootloader (for reflashing...) */ 45 | dataflash = *(uint8_t *)DATA_EEPROM_BASE; 46 | if (dataflash == GOTO_BOOTLOADER) { 47 | FLASH_Prog(DATA_EEPROM_BASE, 0xFF); 48 | ((void (*)(void)) * ((uint32_t*) BOOTLOADER_ADDR))(); 49 | } 50 | 51 | /* Initialize the concentrator */ 52 | lgw_connect(); 53 | CmdManager.Init(); 54 | 55 | /* Wait for commands coming from host */ 56 | while (1) { 57 | CmdManager.ReceiveCmd(); 58 | if (CmdManager.DecodeCmd()) { 59 | CmdManager.TransmitCmd(); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/SX1308HAL/inc/loragw_radio.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2017 Semtech-Cycleo 8 | 9 | Description: 10 | Functions used to handle LoRa concentrator radios. 11 | 12 | License: Revised BSD License, see LICENSE.TXT file include in the project 13 | 14 | */ 15 | 16 | #ifndef _LORAGW_RADIO_H 17 | #define _LORAGW_RADIO_H 18 | 19 | /* -------------------------------------------------------------------------- */ 20 | /* --- DEPENDANCIES --------------------------------------------------------- */ 21 | 22 | #include /* C99 types */ 23 | #include /* bool type */ 24 | 25 | /* -------------------------------------------------------------------------- */ 26 | /* --- PUBLIC CONSTANTS ----------------------------------------------------- */ 27 | 28 | #define LGW_REG_SUCCESS 0 29 | #define LGW_REG_ERROR -1 30 | 31 | #define SX125x_32MHz_FRAC 15625 /* irreductible fraction for PLL register caculation */ 32 | 33 | /* -------------------------------------------------------------------------- */ 34 | /* --- PUBLIC CONSTANTS ----------------------------------------------------- */ 35 | 36 | enum lgw_sx127x_rxbw_e { 37 | LGW_SX127X_RXBW_2K6_HZ, 38 | LGW_SX127X_RXBW_3K1_HZ, 39 | LGW_SX127X_RXBW_3K9_HZ, 40 | LGW_SX127X_RXBW_5K2_HZ, 41 | LGW_SX127X_RXBW_6K3_HZ, 42 | LGW_SX127X_RXBW_7K8_HZ, 43 | LGW_SX127X_RXBW_10K4_HZ, 44 | LGW_SX127X_RXBW_12K5_HZ, 45 | LGW_SX127X_RXBW_15K6_HZ, 46 | LGW_SX127X_RXBW_20K8_HZ, 47 | LGW_SX127X_RXBW_25K_HZ, 48 | LGW_SX127X_RXBW_31K3_HZ, 49 | LGW_SX127X_RXBW_41K7_HZ, 50 | LGW_SX127X_RXBW_50K_HZ, 51 | LGW_SX127X_RXBW_62K5_HZ, 52 | LGW_SX127X_RXBW_83K3_HZ, 53 | LGW_SX127X_RXBW_100K_HZ, 54 | LGW_SX127X_RXBW_125K_HZ, 55 | LGW_SX127X_RXBW_166K7_HZ, 56 | LGW_SX127X_RXBW_200K_HZ, 57 | LGW_SX127X_RXBW_250K_HZ 58 | }; 59 | 60 | /* -------------------------------------------------------------------------- */ 61 | /* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */ 62 | 63 | int lgw_setup_sx125x(uint8_t rf_chain, uint8_t rf_clkout, bool rf_enable, uint8_t rf_radio_type, uint32_t freq_hz); 64 | 65 | int lgw_setup_sx127x(uint32_t frequency, uint8_t modulation, enum lgw_sx127x_rxbw_e rxbw_khz, int8_t rssi_offset); 66 | 67 | int lgw_sx127x_reg_w(uint8_t address, uint8_t reg_value); 68 | 69 | int lgw_sx127x_reg_r(uint8_t address, uint8_t *reg_value); 70 | 71 | 72 | #endif 73 | /* --- EOF ------------------------------------------------------------------ */ 74 | -------------------------------------------------------------------------------- /src/SX1308HAL/inc/sx1308.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2017 Semtech 8 | */ 9 | 10 | #ifndef SX1308_H 11 | #define SX1308_H 12 | 13 | #include "mbed.h" 14 | 15 | class SX1308 { 16 | 17 | public: 18 | SX1308(PinName slaveSelectPin, PinName mosi, PinName miso, PinName sclk, PinName interrupt, PinName Reset); 19 | virtual bool init(); 20 | void dig_reset(); 21 | void spiWrite(uint8_t reg, uint8_t val); 22 | void spiWriteBurstF(uint8_t reg, uint8_t * val, int size); 23 | void spiWriteBurst(uint8_t reg, uint8_t * val, int size); 24 | void spiWriteBurstM(uint8_t reg, uint8_t * val, int size); 25 | void spiWriteBurstE(uint8_t reg, uint8_t * val, int size); 26 | uint8_t spiRead(uint8_t reg); 27 | uint8_t spiReadBurstF(uint8_t reg, uint8_t *data, int size); 28 | uint8_t spiReadBurstM(uint8_t reg, uint8_t *data, int size); 29 | uint8_t spiReadBurstE(uint8_t reg, uint8_t *data, int size); 30 | uint8_t spiReadBurst(uint8_t reg, uint8_t *data, int size); 31 | volatile uint8_t waittxend; 32 | uint8_t txongoing; 33 | Timer timerstm32ref; 34 | uint32_t offtmstpstm32; 35 | uint32_t offtmstpstm32ref; 36 | bool firsttx; 37 | 38 | private: 39 | void isr0(); 40 | uint8_t _interruptPin; 41 | DigitalOut _slaveSelectPin; 42 | DigitalOut _reset; 43 | SPI _spi; 44 | InterruptIn _interrupt; 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/mbed-dev.lib: -------------------------------------------------------------------------------- 1 | http://mbed.org/users/mbed_official/code/mbed-dev/#30b64687e01f 2 | -------------------------------------------------------------------------------- /src/mbed-dev/api/FileBase.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FILEBASE_H 17 | #define MBED_FILEBASE_H 18 | 19 | typedef int FILEHANDLE; 20 | 21 | #include 22 | 23 | #if defined(__ARMCC_VERSION) || defined(__ICCARM__) 24 | # define O_RDONLY 0 25 | # define O_WRONLY 1 26 | # define O_RDWR 2 27 | # define O_CREAT 0x0200 28 | # define O_TRUNC 0x0400 29 | # define O_APPEND 0x0008 30 | 31 | # define NAME_MAX 255 32 | 33 | typedef int mode_t; 34 | typedef int ssize_t; 35 | typedef long off_t; 36 | 37 | #else 38 | # include 39 | # include 40 | # include 41 | #endif 42 | 43 | #include "platform.h" 44 | #include "SingletonPtr.h" 45 | #include "PlatformMutex.h" 46 | 47 | namespace mbed { 48 | 49 | typedef enum { 50 | FilePathType, 51 | FileSystemPathType 52 | } PathType; 53 | 54 | class FileBase { 55 | public: 56 | FileBase(const char *name, PathType t); 57 | 58 | virtual ~FileBase(); 59 | 60 | const char* getName(void); 61 | PathType getPathType(void); 62 | 63 | static FileBase *lookup(const char *name, unsigned int len); 64 | 65 | static FileBase *get(int n); 66 | 67 | /* disallow copy constructor and assignment operators */ 68 | private: 69 | static FileBase *_head; 70 | static SingletonPtr _mutex; 71 | 72 | FileBase *_next; 73 | const char * const _name; 74 | const PathType _path_type; 75 | FileBase(const FileBase&); 76 | FileBase & operator = (const FileBase&); 77 | }; 78 | 79 | } // namespace mbed 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/mbed-dev/api/FileLike.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FILELIKE_H 17 | #define MBED_FILELIKE_H 18 | 19 | #include "FileBase.h" 20 | #include "FileHandle.h" 21 | 22 | namespace mbed { 23 | 24 | /* Class FileLike 25 | * A file-like object is one that can be opened with fopen by 26 | * fopen("/name", mode). It is intersection of the classes Base and 27 | * FileHandle. 28 | * 29 | * @Note Synchronization level: Set by subclass 30 | */ 31 | class FileLike : public FileHandle, public FileBase { 32 | 33 | public: 34 | /* Constructor FileLike 35 | * 36 | * Variables 37 | * name - The name to use to open the file. 38 | */ 39 | FileLike(const char *name); 40 | 41 | virtual ~FileLike(); 42 | 43 | }; 44 | 45 | } // namespace mbed 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/mbed-dev/api/FilePath.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FILEPATH_H 17 | #define MBED_FILEPATH_H 18 | 19 | #include "platform.h" 20 | 21 | #include "FileSystemLike.h" 22 | #include "FileLike.h" 23 | 24 | namespace mbed { 25 | 26 | class FilePath { 27 | public: 28 | FilePath(const char* file_path); 29 | 30 | const char* fileName(void); 31 | 32 | bool isFileSystem(void); 33 | FileSystemLike* fileSystem(void); 34 | 35 | bool isFile(void); 36 | FileLike* file(void); 37 | bool exists(void); 38 | 39 | private: 40 | const char* file_name; 41 | FileBase* fb; 42 | }; 43 | 44 | } // namespace mbed 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/mbed-dev/api/FunctionPointer.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FUNCTIONPOINTER_H 17 | #define MBED_FUNCTIONPOINTER_H 18 | 19 | #include "Callback.h" 20 | #include "toolchain.h" 21 | #include 22 | #include 23 | 24 | namespace mbed { 25 | 26 | 27 | // Declarations for backwards compatibility 28 | // To be foward compatible, code should adopt the Callback class 29 | template 30 | class FunctionPointerArg1 : public Callback { 31 | public: 32 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 33 | "FunctionPointerArg1 has been replaced by Callback") 34 | FunctionPointerArg1(R (*function)(A1) = 0) 35 | : Callback(function) {} 36 | 37 | template 38 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 39 | "FunctionPointerArg1 has been replaced by Callback") 40 | FunctionPointerArg1(T *object, R (T::*member)(A1)) 41 | : Callback(object, member) {} 42 | 43 | R (*get_function())(A1) { 44 | return *reinterpret_cast(this); 45 | } 46 | }; 47 | 48 | template 49 | class FunctionPointerArg1 : public Callback { 50 | public: 51 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 52 | "FunctionPointer has been replaced by Callback") 53 | FunctionPointerArg1(R (*function)() = 0) 54 | : Callback(function) {} 55 | 56 | template 57 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 58 | "FunctionPointer has been replaced by Callback") 59 | FunctionPointerArg1(T *object, R (T::*member)()) 60 | : Callback(object, member) {} 61 | 62 | R (*get_function())() { 63 | return *reinterpret_cast(this); 64 | } 65 | }; 66 | 67 | typedef FunctionPointerArg1 FunctionPointer; 68 | 69 | 70 | } // namespace mbed 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/mbed-dev/api/LowPowerTicker.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_LOWPOWERTICKER_H 17 | #define MBED_LOWPOWERTICKER_H 18 | 19 | #include "platform.h" 20 | #include "Ticker.h" 21 | 22 | #if DEVICE_LOWPOWERTIMER 23 | 24 | #include "lp_ticker_api.h" 25 | 26 | namespace mbed { 27 | 28 | /** Low Power Ticker 29 | * 30 | * @Note Synchronization level: Interrupt safe 31 | */ 32 | class LowPowerTicker : public Ticker { 33 | 34 | public: 35 | LowPowerTicker() : Ticker(get_lp_ticker_data()) { 36 | } 37 | 38 | virtual ~LowPowerTicker() { 39 | } 40 | }; 41 | 42 | } // namespace mbed 43 | 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/mbed-dev/api/LowPowerTimeout.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_LOWPOWERTIMEOUT_H 17 | #define MBED_LOWPOWERTIMEOUT_H 18 | 19 | #include "platform.h" 20 | 21 | #if DEVICE_LOWPOWERTIMER 22 | 23 | #include "lp_ticker_api.h" 24 | #include "LowPowerTicker.h" 25 | 26 | namespace mbed { 27 | 28 | /** Low Power Timout 29 | * 30 | * @Note Synchronization level: Interrupt safe 31 | */ 32 | class LowPowerTimeout : public LowPowerTicker { 33 | 34 | private: 35 | virtual void handler(void) { 36 | _function.call(); 37 | } 38 | }; 39 | 40 | } 41 | 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/mbed-dev/api/LowPowerTimer.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_LOWPOWERTIMER_H 17 | #define MBED_LOWPOWERTIMER_H 18 | 19 | #include "platform.h" 20 | #include "Timer.h" 21 | 22 | #if DEVICE_LOWPOWERTIMER 23 | 24 | #include "lp_ticker_api.h" 25 | 26 | namespace mbed { 27 | 28 | /** Low power timer 29 | * 30 | * @Note Synchronization level: Interrupt safe 31 | */ 32 | class LowPowerTimer : public Timer { 33 | 34 | public: 35 | LowPowerTimer() : Timer(get_lp_ticker_data()) { 36 | } 37 | 38 | }; 39 | 40 | } // namespace mbed 41 | 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/mbed-dev/api/PlatformMutex.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef PLATFORM_MUTEX_H 17 | #define PLATFORM_MUTEX_H 18 | 19 | #ifdef MBED_CONF_RTOS_PRESENT 20 | #include "Mutex.h" 21 | typedef rtos::Mutex PlatformMutex; 22 | #else 23 | /** A stub mutex for when an RTOS is not present 24 | */ 25 | class PlatformMutex { 26 | public: 27 | PlatformMutex() { 28 | // Stub 29 | 30 | } 31 | ~PlatformMutex() { 32 | // Stub 33 | } 34 | 35 | void lock() { 36 | // Do nothing 37 | } 38 | 39 | void unlock() { 40 | // Do nothing 41 | } 42 | }; 43 | 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/mbed-dev/api/PortIn.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_PORTIN_H 17 | #define MBED_PORTIN_H 18 | 19 | #include "platform.h" 20 | 21 | #if DEVICE_PORTIN 22 | 23 | #include "port_api.h" 24 | #include "critical.h" 25 | 26 | namespace mbed { 27 | 28 | /** A multiple pin digital input 29 | * 30 | * @Note Synchronization level: Interrupt safe 31 | * 32 | * Example: 33 | * @code 34 | * // Switch on an LED if any of mbed pins 21-26 is high 35 | * 36 | * #include "mbed.h" 37 | * 38 | * PortIn p(Port2, 0x0000003F); // p21-p26 39 | * DigitalOut ind(LED4); 40 | * 41 | * int main() { 42 | * while(1) { 43 | * int pins = p.read(); 44 | * if(pins) { 45 | * ind = 1; 46 | * } else { 47 | * ind = 0; 48 | * } 49 | * } 50 | * } 51 | * @endcode 52 | */ 53 | class PortIn { 54 | public: 55 | 56 | /** Create an PortIn, connected to the specified port 57 | * 58 | * @param port Port to connect to (Port0-Port5) 59 | * @param mask A bitmask to identify which bits in the port should be included (0 - ignore) 60 | */ 61 | PortIn(PortName port, int mask = 0xFFFFFFFF) { 62 | core_util_critical_section_enter(); 63 | port_init(&_port, port, mask, PIN_INPUT); 64 | core_util_critical_section_exit(); 65 | } 66 | 67 | /** Read the value currently output on the port 68 | * 69 | * @returns 70 | * An integer with each bit corresponding to associated port pin setting 71 | */ 72 | int read() { 73 | return port_read(&_port); 74 | } 75 | 76 | /** Set the input pin mode 77 | * 78 | * @param mode PullUp, PullDown, PullNone, OpenDrain 79 | */ 80 | void mode(PinMode mode) { 81 | core_util_critical_section_enter(); 82 | port_mode(&_port, mode); 83 | core_util_critical_section_exit(); 84 | } 85 | 86 | /** A shorthand for read() 87 | */ 88 | operator int() { 89 | return read(); 90 | } 91 | 92 | private: 93 | port_t _port; 94 | }; 95 | 96 | } // namespace mbed 97 | 98 | #endif 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /src/mbed-dev/api/Serial.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_SERIAL_H 17 | #define MBED_SERIAL_H 18 | 19 | #include "platform.h" 20 | 21 | #if DEVICE_SERIAL 22 | 23 | #include "Stream.h" 24 | #include "SerialBase.h" 25 | #include "PlatformMutex.h" 26 | #include "serial_api.h" 27 | 28 | namespace mbed { 29 | 30 | /** A serial port (UART) for communication with other serial devices 31 | * 32 | * Can be used for Full Duplex communication, or Simplex by specifying 33 | * one pin as NC (Not Connected) 34 | * 35 | * @Note Synchronization level: Thread safe 36 | * 37 | * Example: 38 | * @code 39 | * // Print "Hello World" to the PC 40 | * 41 | * #include "mbed.h" 42 | * 43 | * Serial pc(USBTX, USBRX); 44 | * 45 | * int main() { 46 | * pc.printf("Hello World\n"); 47 | * } 48 | * @endcode 49 | */ 50 | class Serial : public SerialBase, public Stream { 51 | 52 | public: 53 | #if DEVICE_SERIAL_ASYNCH 54 | using SerialBase::read; 55 | using SerialBase::write; 56 | #endif 57 | 58 | /** Create a Serial port, connected to the specified transmit and receive pins 59 | * 60 | * @param tx Transmit pin 61 | * @param rx Receive pin 62 | * 63 | * @note 64 | * Either tx or rx may be specified as NC if unused 65 | */ 66 | Serial(PinName tx, PinName rx, const char *name=NULL); 67 | 68 | protected: 69 | virtual int _getc(); 70 | virtual int _putc(int c); 71 | virtual void lock(); 72 | virtual void unlock(); 73 | 74 | PlatformMutex _mutex; 75 | }; 76 | 77 | } // namespace mbed 78 | 79 | #endif 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/mbed-dev/api/Stream.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_STREAM_H 17 | #define MBED_STREAM_H 18 | 19 | #include "platform.h" 20 | #include "FileLike.h" 21 | #include 22 | 23 | namespace mbed { 24 | 25 | extern void mbed_set_unbuffered_stream(FILE *_file); 26 | extern int mbed_getc(FILE *_file); 27 | extern char* mbed_gets(char *s, int size, FILE *_file); 28 | 29 | /** File stream 30 | * 31 | * @Note Synchronization level: Set by subclass 32 | */ 33 | class Stream : public FileLike { 34 | 35 | public: 36 | Stream(const char *name=NULL); 37 | virtual ~Stream(); 38 | 39 | int putc(int c); 40 | int puts(const char *s); 41 | int getc(); 42 | char *gets(char *s, int size); 43 | int printf(const char* format, ...); 44 | int scanf(const char* format, ...); 45 | int vprintf(const char* format, std::va_list args); 46 | int vscanf(const char* format, std::va_list args); 47 | 48 | operator std::FILE*() {return _file;} 49 | 50 | protected: 51 | virtual int close(); 52 | virtual ssize_t write(const void* buffer, size_t length); 53 | virtual ssize_t read(void* buffer, size_t length); 54 | virtual off_t lseek(off_t offset, int whence); 55 | virtual int isatty(); 56 | virtual int fsync(); 57 | virtual off_t flen(); 58 | 59 | virtual int _putc(int c) = 0; 60 | virtual int _getc() = 0; 61 | 62 | std::FILE *_file; 63 | 64 | /* disallow copy constructor and assignment operators */ 65 | private: 66 | Stream(const Stream&); 67 | Stream & operator = (const Stream&); 68 | }; 69 | 70 | } // namespace mbed 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/mbed-dev/api/Timeout.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_TIMEOUT_H 17 | #define MBED_TIMEOUT_H 18 | 19 | #include "Ticker.h" 20 | 21 | namespace mbed { 22 | 23 | /** A Timeout is used to call a function at a point in the future 24 | * 25 | * You can use as many seperate Timeout objects as you require. 26 | * 27 | * @Note Synchronization level: Interrupt safe 28 | * 29 | * Example: 30 | * @code 31 | * // Blink until timeout. 32 | * 33 | * #include "mbed.h" 34 | * 35 | * Timeout timeout; 36 | * DigitalOut led(LED1); 37 | * 38 | * int on = 1; 39 | * 40 | * void attimeout() { 41 | * on = 0; 42 | * } 43 | * 44 | * int main() { 45 | * timeout.attach(&attimeout, 5); 46 | * while(on) { 47 | * led = !led; 48 | * wait(0.2); 49 | * } 50 | * } 51 | * @endcode 52 | */ 53 | class Timeout : public Ticker { 54 | 55 | protected: 56 | virtual void handler(); 57 | }; 58 | 59 | } // namespace mbed 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/mbed-dev/api/Timer.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_TIMER_H 17 | #define MBED_TIMER_H 18 | 19 | #include "platform.h" 20 | #include "ticker_api.h" 21 | 22 | namespace mbed { 23 | 24 | /** A general purpose timer 25 | * 26 | * @Note Synchronization level: Interrupt safe 27 | * 28 | * Example: 29 | * @code 30 | * // Count the time to toggle a LED 31 | * 32 | * #include "mbed.h" 33 | * 34 | * Timer timer; 35 | * DigitalOut led(LED1); 36 | * int begin, end; 37 | * 38 | * int main() { 39 | * timer.start(); 40 | * begin = timer.read_us(); 41 | * led = !led; 42 | * end = timer.read_us(); 43 | * printf("Toggle the led takes %d us", end - begin); 44 | * } 45 | * @endcode 46 | */ 47 | class Timer { 48 | 49 | public: 50 | Timer(); 51 | Timer(const ticker_data_t *data); 52 | 53 | /** Start the timer 54 | */ 55 | void start(); 56 | 57 | /** Stop the timer 58 | */ 59 | void stop(); 60 | 61 | /** Reset the timer to 0. 62 | * 63 | * If it was already counting, it will continue 64 | */ 65 | void reset(); 66 | 67 | /** Get the time passed in seconds 68 | */ 69 | float read(); 70 | 71 | /** Get the time passed in mili-seconds 72 | */ 73 | int read_ms(); 74 | 75 | /** Get the time passed in micro-seconds 76 | */ 77 | int read_us(); 78 | 79 | /** An operator shorthand for read() 80 | */ 81 | operator float(); 82 | 83 | protected: 84 | int slicetime(); 85 | int _running; // whether the timer is running 86 | unsigned int _start; // the start time of the latest slice 87 | int _time; // any accumulated time from previous slices 88 | const ticker_data_t *_ticker_data; 89 | }; 90 | 91 | } // namespace mbed 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /src/mbed-dev/api/TimerEvent.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_TIMEREVENT_H 17 | #define MBED_TIMEREVENT_H 18 | 19 | #include "ticker_api.h" 20 | #include "us_ticker_api.h" 21 | 22 | namespace mbed { 23 | 24 | /** Base abstraction for timer interrupts 25 | * 26 | * @Note Synchronization level: Interrupt safe 27 | */ 28 | class TimerEvent { 29 | public: 30 | TimerEvent(); 31 | TimerEvent(const ticker_data_t *data); 32 | 33 | /** The handler registered with the underlying timer interrupt 34 | */ 35 | static void irq(uint32_t id); 36 | 37 | /** Destruction removes it... 38 | */ 39 | virtual ~TimerEvent(); 40 | 41 | protected: 42 | // The handler called to service the timer event of the derived class 43 | virtual void handler() = 0; 44 | 45 | // insert in to linked list 46 | void insert(timestamp_t timestamp); 47 | 48 | // remove from linked list, if in it 49 | void remove(); 50 | 51 | ticker_event_t event; 52 | 53 | const ticker_data_t *_ticker_data; 54 | }; 55 | 56 | } // namespace mbed 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/mbed-dev/api/Transaction.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_TRANSACTION_H 17 | #define MBED_TRANSACTION_H 18 | 19 | #include "platform.h" 20 | #include "FunctionPointer.h" 21 | 22 | namespace mbed { 23 | 24 | /** Transaction structure 25 | */ 26 | typedef struct { 27 | void *tx_buffer; /**< Tx buffer */ 28 | size_t tx_length; /**< Length of Tx buffer*/ 29 | void *rx_buffer; /**< Rx buffer */ 30 | size_t rx_length; /**< Length of Rx buffer */ 31 | uint32_t event; /**< Event for a transaction */ 32 | event_callback_t callback; /**< User's callback */ 33 | uint8_t width; /**< Buffer's word width (8, 16, 32, 64) */ 34 | } transaction_t; 35 | 36 | /** Transaction class defines a transaction. 37 | * 38 | * @Note Synchronization level: Not protected 39 | */ 40 | template 41 | class Transaction { 42 | public: 43 | Transaction(Class *tpointer, const transaction_t& transaction) : _obj(tpointer), _data(transaction) { 44 | } 45 | 46 | Transaction() : _obj(), _data() { 47 | } 48 | 49 | ~Transaction() { 50 | } 51 | 52 | /** Get object's instance for the transaction 53 | * 54 | * @return The object which was stored 55 | */ 56 | Class* get_object() { 57 | return _obj; 58 | } 59 | 60 | /** Get the transaction 61 | * 62 | * @return The transaction which was stored 63 | */ 64 | transaction_t* get_transaction() { 65 | return &_data; 66 | } 67 | 68 | private: 69 | Class* _obj; 70 | transaction_t _data; 71 | }; 72 | 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/mbed-dev/api/can_helper.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_CAN_HELPER_H 17 | #define MBED_CAN_HELPER_H 18 | 19 | #if DEVICE_CAN 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | enum CANFormat { 26 | CANStandard = 0, 27 | CANExtended = 1, 28 | CANAny = 2 29 | }; 30 | typedef enum CANFormat CANFormat; 31 | 32 | enum CANType { 33 | CANData = 0, 34 | CANRemote = 1 35 | }; 36 | typedef enum CANType CANType; 37 | 38 | struct CAN_Message { 39 | unsigned int id; // 29 bit identifier 40 | unsigned char data[8]; // Data field 41 | unsigned char len; // Length of data field in bytes 42 | CANFormat format; // 0 - STANDARD, 1- EXTENDED IDENTIFIER 43 | CANType type; // 0 - DATA FRAME, 1 - REMOTE FRAME 44 | }; 45 | typedef struct CAN_Message CAN_Message; 46 | 47 | #ifdef __cplusplus 48 | }; 49 | #endif 50 | 51 | #endif 52 | 53 | #endif // MBED_CAN_HELPER_H 54 | -------------------------------------------------------------------------------- /src/mbed-dev/api/mbed.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_H 17 | #define MBED_H 18 | 19 | #define MBED_LIBRARY_VERSION 126 20 | 21 | #if MBED_CONF_RTOS_PRESENT 22 | #include "rtos/rtos.h" 23 | #endif 24 | 25 | #if MBED_CONF_NSAPI_PRESENT 26 | #include "network-socket/nsapi.h" 27 | #endif 28 | 29 | #include "toolchain.h" 30 | #include "platform.h" 31 | 32 | // Useful C libraries 33 | #include 34 | #include 35 | 36 | // mbed Debug libraries 37 | #include "mbed_error.h" 38 | #include "mbed_interface.h" 39 | #include "mbed_assert.h" 40 | 41 | // mbed Peripheral components 42 | #include "DigitalIn.h" 43 | #include "DigitalOut.h" 44 | #include "DigitalInOut.h" 45 | #include "BusIn.h" 46 | #include "BusOut.h" 47 | #include "BusInOut.h" 48 | #include "PortIn.h" 49 | #include "PortInOut.h" 50 | #include "PortOut.h" 51 | #include "AnalogIn.h" 52 | #include "AnalogOut.h" 53 | #include "PwmOut.h" 54 | #include "Serial.h" 55 | #include "SPI.h" 56 | #include "SPISlave.h" 57 | #include "I2C.h" 58 | #include "I2CSlave.h" 59 | #include "Ethernet.h" 60 | #include "CAN.h" 61 | #include "RawSerial.h" 62 | 63 | // mbed Internal components 64 | #include "Timer.h" 65 | #include "Ticker.h" 66 | #include "Timeout.h" 67 | #include "LowPowerTimeout.h" 68 | #include "LowPowerTicker.h" 69 | #include "LowPowerTimer.h" 70 | #include "LocalFileSystem.h" 71 | #include "InterruptIn.h" 72 | #include "wait_api.h" 73 | #include "sleep_api.h" 74 | #include "rtc_time.h" 75 | 76 | // mbed Non-hardware components 77 | #include "Callback.h" 78 | #include "FunctionPointer.h" 79 | 80 | using namespace mbed; 81 | using namespace std; 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /src/mbed-dev/api/mbed_assert.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_ASSERT_H 17 | #define MBED_ASSERT_H 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /** Internal mbed assert function which is invoked when MBED_ASSERT macro failes. 24 | * This function is active only if NDEBUG is not defined prior to including this 25 | * assert header file. 26 | * In case of MBED_ASSERT failing condition, error() is called with the assertation message. 27 | * @param expr Expresion to be checked. 28 | * @param file File where assertation failed. 29 | * @param line Failing assertation line number. 30 | */ 31 | void mbed_assert_internal(const char *expr, const char *file, int line); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #ifdef NDEBUG 38 | #define MBED_ASSERT(expr) ((void)0) 39 | 40 | #else 41 | #define MBED_ASSERT(expr) \ 42 | do { \ 43 | if (!(expr)) { \ 44 | mbed_assert_internal(#expr, __FILE__, __LINE__); \ 45 | } \ 46 | } while (0) 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/mbed-dev/api/mbed_debug.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_DEBUG_H 17 | #define MBED_DEBUG_H 18 | #include "device.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #if DEVICE_STDIO_MESSAGES 25 | #include 26 | #include 27 | 28 | /** Output a debug message 29 | * 30 | * @param format printf-style format string, followed by variables 31 | */ 32 | static inline void debug(const char *format, ...) { 33 | va_list args; 34 | va_start(args, format); 35 | vfprintf(stderr, format, args); 36 | va_end(args); 37 | } 38 | 39 | /** Conditionally output a debug message 40 | * 41 | * NOTE: If the condition is constant false (!= 1) and the compiler optimization 42 | * level is greater than 0, then the whole function will be compiled away. 43 | * 44 | * @param condition output only if condition is true (== 1) 45 | * @param format printf-style format string, followed by variables 46 | */ 47 | static inline void debug_if(int condition, const char *format, ...) { 48 | if (condition == 1) { 49 | va_list args; 50 | va_start(args, format); 51 | vfprintf(stderr, format, args); 52 | va_end(args); 53 | } 54 | } 55 | 56 | #else 57 | static inline void debug(const char *format, ...) {} 58 | static inline void debug_if(int condition, const char *format, ...) {} 59 | 60 | #endif 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/mbed-dev/api/mbed_error.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_ERROR_H 17 | #define MBED_ERROR_H 18 | 19 | /** To generate a fatal compile-time error, you can use the pre-processor #error directive. 20 | * 21 | * @code 22 | * #error "That shouldn't have happened!" 23 | * @endcode 24 | * 25 | * If the compiler evaluates this line, it will report the error and stop the compile. 26 | * 27 | * For example, you could use this to check some user-defined compile-time variables: 28 | * 29 | * @code 30 | * #define NUM_PORTS 7 31 | * #if (NUM_PORTS > 4) 32 | * #error "NUM_PORTS must be less than 4" 33 | * #endif 34 | * @endcode 35 | * 36 | * Reporting Run-Time Errors: 37 | * To generate a fatal run-time error, you can use the mbed error() function. 38 | * 39 | * @code 40 | * error("That shouldn't have happened!"); 41 | * @endcode 42 | * 43 | * If the mbed running the program executes this function, it will print the 44 | * message via the USB serial port, and then die with the blue lights of death! 45 | * 46 | * The message can use printf-style formatting, so you can report variables in the 47 | * message too. For example, you could use this to check a run-time condition: 48 | * 49 | * @code 50 | * if(x >= 5) { 51 | * error("expected x to be less than 5, but got %d", x); 52 | * } 53 | * #endcode 54 | */ 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | void error(const char* format, ...); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/mbed-dev/api/mbed_stats.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2016-2016 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_STATS_H 17 | #define MBED_STATS_H 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef struct { 24 | uint32_t current_size; /**< Bytes allocated currently. */ 25 | uint32_t max_size; /**< Max bytes allocated at a given time. */ 26 | uint32_t total_size; /**< Cumulative sum of bytes ever allocated. */ 27 | uint32_t alloc_cnt; /**< Current number of allocations. */ 28 | uint32_t alloc_fail_cnt; /**< Number of failed allocations. */ 29 | } mbed_stats_heap_t; 30 | 31 | /** 32 | * Fill the passed in structure with heap stats. 33 | */ 34 | void mbed_stats_heap_get(mbed_stats_heap_t *stats); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/mbed-dev/api/platform.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_PLATFORM_H 17 | #define MBED_PLATFORM_H 18 | 19 | #include "device.h" 20 | #include "PinNames.h" 21 | #include "PeripheralNames.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/mbed-dev/api/wait_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_WAIT_API_H 17 | #define MBED_WAIT_API_H 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /** Generic wait functions. 24 | * 25 | * These provide simple NOP type wait capabilities. 26 | * 27 | * Example: 28 | * @code 29 | * #include "mbed.h" 30 | * 31 | * DigitalOut heartbeat(LED1); 32 | * 33 | * int main() { 34 | * while (1) { 35 | * heartbeat = 1; 36 | * wait(0.5); 37 | * heartbeat = 0; 38 | * wait(0.5); 39 | * } 40 | * } 41 | */ 42 | 43 | /** Waits for a number of seconds, with microsecond resolution (within 44 | * the accuracy of single precision floating point). 45 | * 46 | * @param s number of seconds to wait 47 | */ 48 | void wait(float s); 49 | 50 | /** Waits a number of milliseconds. 51 | * 52 | * @param ms the whole number of milliseconds to wait 53 | */ 54 | void wait_ms(int ms); 55 | 56 | /** Waits a number of microseconds. 57 | * 58 | * @param us the whole number of microseconds to wait 59 | */ 60 | void wait_us(int us); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/mbed-dev/common/AnalogIn.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "mbed.h" 18 | 19 | #include "AnalogIn.h" 20 | 21 | #if DEVICE_ANALOGIN 22 | 23 | namespace mbed { 24 | 25 | SingletonPtr AnalogIn::_mutex; 26 | 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/mbed-dev/common/BusIn.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "BusIn.h" 17 | #include "mbed_assert.h" 18 | 19 | namespace mbed { 20 | 21 | BusIn::BusIn(PinName p0, PinName p1, PinName p2, PinName p3, PinName p4, PinName p5, PinName p6, PinName p7, PinName p8, PinName p9, PinName p10, PinName p11, PinName p12, PinName p13, PinName p14, PinName p15) { 22 | PinName pins[16] = {p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15}; 23 | 24 | // No lock needed in the constructor 25 | _nc_mask = 0; 26 | for (int i=0; i<16; i++) { 27 | _pin[i] = (pins[i] != NC) ? new DigitalIn(pins[i]) : 0; 28 | if (pins[i] != NC) { 29 | _nc_mask |= (1 << i); 30 | } 31 | } 32 | } 33 | 34 | BusIn::BusIn(PinName pins[16]) { 35 | // No lock needed in the constructor 36 | _nc_mask = 0; 37 | for (int i=0; i<16; i++) { 38 | _pin[i] = (pins[i] != NC) ? new DigitalIn(pins[i]) : 0; 39 | if (pins[i] != NC) { 40 | _nc_mask |= (1 << i); 41 | } 42 | } 43 | } 44 | 45 | BusIn::~BusIn() { 46 | // No lock needed in the destructor 47 | for (int i=0; i<16; i++) { 48 | if (_pin[i] != 0) { 49 | delete _pin[i]; 50 | } 51 | } 52 | } 53 | 54 | int BusIn::read() { 55 | int v = 0; 56 | lock(); 57 | for (int i=0; i<16; i++) { 58 | if (_pin[i] != 0) { 59 | v |= _pin[i]->read() << i; 60 | } 61 | } 62 | unlock(); 63 | return v; 64 | } 65 | 66 | void BusIn::mode(PinMode pull) { 67 | lock(); 68 | for (int i=0; i<16; i++) { 69 | if (_pin[i] != 0) { 70 | _pin[i]->mode(pull); 71 | } 72 | } 73 | unlock(); 74 | } 75 | 76 | void BusIn::lock() { 77 | _mutex.lock(); 78 | } 79 | 80 | void BusIn::unlock() { 81 | _mutex.unlock(); 82 | } 83 | 84 | BusIn::operator int() { 85 | // Underlying read is thread safe 86 | return read(); 87 | } 88 | 89 | DigitalIn& BusIn::operator[] (int index) { 90 | // No lock needed since _pin is not modified outside the constructor 91 | MBED_ASSERT(index >= 0 && index <= 16); 92 | MBED_ASSERT(_pin[index]); 93 | return *_pin[index]; 94 | } 95 | 96 | } // namespace mbed 97 | -------------------------------------------------------------------------------- /src/mbed-dev/common/Ethernet.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "Ethernet.h" 17 | 18 | #if DEVICE_ETHERNET 19 | 20 | #include "ethernet_api.h" 21 | 22 | namespace mbed { 23 | 24 | Ethernet::Ethernet() { 25 | ethernet_init(); 26 | } 27 | 28 | Ethernet::~Ethernet() { 29 | ethernet_free(); 30 | } 31 | 32 | int Ethernet::write(const char *data, int size) { 33 | return ethernet_write(data, size); 34 | } 35 | 36 | int Ethernet::send() { 37 | return ethernet_send(); 38 | } 39 | 40 | int Ethernet::receive() { 41 | return ethernet_receive(); 42 | } 43 | 44 | int Ethernet::read(char *data, int size) { 45 | return ethernet_read(data, size); 46 | } 47 | 48 | void Ethernet::address(char *mac) { 49 | return ethernet_address(mac); 50 | } 51 | 52 | int Ethernet::link() { 53 | return ethernet_link(); 54 | } 55 | 56 | void Ethernet::set_link(Mode mode) { 57 | int speed = -1; 58 | int duplex = 0; 59 | 60 | switch(mode) { 61 | case AutoNegotiate : speed = -1; duplex = 0; break; 62 | case HalfDuplex10 : speed = 0; duplex = 0; break; 63 | case FullDuplex10 : speed = 0; duplex = 1; break; 64 | case HalfDuplex100 : speed = 1; duplex = 0; break; 65 | case FullDuplex100 : speed = 1; duplex = 1; break; 66 | } 67 | 68 | ethernet_set_link(speed, duplex); 69 | } 70 | 71 | } // namespace mbed 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/mbed-dev/common/FileLike.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "FileLike.h" 17 | 18 | namespace mbed { 19 | 20 | FileLike::FileLike(const char *name) : FileHandle(), FileBase(name, FilePathType) { 21 | 22 | } 23 | 24 | FileLike::~FileLike() { 25 | 26 | } 27 | 28 | } // namespace mbed 29 | -------------------------------------------------------------------------------- /src/mbed-dev/common/FilePath.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "FilePath.h" 17 | 18 | namespace mbed { 19 | 20 | FilePath::FilePath(const char* file_path) : file_name(NULL), fb(NULL) { 21 | if ((file_path[0] != '/') || (file_path[1] == 0)) return; 22 | 23 | const char* file_system = &file_path[1]; 24 | file_name = file_system; 25 | int len = 0; 26 | while (true) { 27 | char c = *file_name; 28 | if (c == '/') { // end of object name 29 | file_name++; // point to one char after the '/' 30 | break; 31 | } 32 | if (c == 0) { // end of object name, with no filename 33 | break; 34 | } 35 | len++; 36 | file_name++; 37 | } 38 | 39 | fb = FileBase::lookup(file_system, len); 40 | } 41 | 42 | const char* FilePath::fileName(void) { 43 | return file_name; 44 | } 45 | 46 | bool FilePath::isFileSystem(void) { 47 | if (NULL == fb) 48 | return false; 49 | return (fb->getPathType() == FileSystemPathType); 50 | } 51 | 52 | FileSystemLike* FilePath::fileSystem(void) { 53 | if (isFileSystem()) { 54 | return (FileSystemLike*)fb; 55 | } 56 | return NULL; 57 | } 58 | 59 | bool FilePath::isFile(void) { 60 | if (NULL == fb) 61 | return false; 62 | return (fb->getPathType() == FilePathType); 63 | } 64 | 65 | FileLike* FilePath::file(void) { 66 | if (isFile()) { 67 | return (FileLike*)fb; 68 | } 69 | return NULL; 70 | } 71 | 72 | bool FilePath::exists(void) { 73 | return fb != NULL; 74 | } 75 | 76 | } // namespace mbed 77 | -------------------------------------------------------------------------------- /src/mbed-dev/common/I2CSlave.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "I2CSlave.h" 17 | 18 | #if DEVICE_I2CSLAVE 19 | 20 | namespace mbed { 21 | 22 | I2CSlave::I2CSlave(PinName sda, PinName scl) : _i2c() { 23 | i2c_init(&_i2c, sda, scl); 24 | i2c_frequency(&_i2c, 100000); 25 | i2c_slave_mode(&_i2c, 1); 26 | } 27 | 28 | void I2CSlave::frequency(int hz) { 29 | i2c_frequency(&_i2c, hz); 30 | } 31 | 32 | void I2CSlave::address(int address) { 33 | int addr = (address & 0xFF) | 1; 34 | i2c_slave_address(&_i2c, 0, addr, 0); 35 | } 36 | 37 | int I2CSlave::receive(void) { 38 | return i2c_slave_receive(&_i2c); 39 | } 40 | 41 | int I2CSlave::read(char *data, int length) { 42 | return i2c_slave_read(&_i2c, data, length) != length; 43 | } 44 | 45 | int I2CSlave::read(void) { 46 | return i2c_byte_read(&_i2c, 0); 47 | } 48 | 49 | int I2CSlave::write(const char *data, int length) { 50 | return i2c_slave_write(&_i2c, data, length) != length; 51 | } 52 | 53 | int I2CSlave::write(int data) { 54 | return i2c_byte_write(&_i2c, data); 55 | } 56 | 57 | void I2CSlave::stop(void) { 58 | i2c_stop(&_i2c); 59 | } 60 | 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/mbed-dev/common/RawSerial.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "RawSerial.h" 17 | #include "wait_api.h" 18 | #include 19 | 20 | #if DEVICE_SERIAL 21 | 22 | #define STRING_STACK_LIMIT 120 23 | 24 | namespace mbed { 25 | 26 | RawSerial::RawSerial(PinName tx, PinName rx) : SerialBase(tx, rx) { 27 | // No lock needed in the constructor 28 | } 29 | 30 | int RawSerial::getc() { 31 | lock(); 32 | int ret = _base_getc(); 33 | unlock(); 34 | return ret; 35 | } 36 | 37 | int RawSerial::putc(int c) { 38 | lock(); 39 | int ret = _base_putc(c); 40 | unlock(); 41 | return ret; 42 | } 43 | 44 | int RawSerial::puts(const char *str) { 45 | lock(); 46 | while (*str) 47 | putc(*str ++); 48 | unlock(); 49 | return 0; 50 | } 51 | 52 | // Experimental support for printf in RawSerial. No Stream inheritance 53 | // means we can't call printf() directly, so we use sprintf() instead. 54 | // We only call malloc() for the sprintf() buffer if the buffer 55 | // length is above a certain threshold, otherwise we use just the stack. 56 | int RawSerial::printf(const char *format, ...) { 57 | lock(); 58 | std::va_list arg; 59 | va_start(arg, format); 60 | // ARMCC microlib does not properly handle a size of 0. 61 | // As a workaround supply a dummy buffer with a size of 1. 62 | char dummy_buf[1]; 63 | int len = vsnprintf(dummy_buf, sizeof(dummy_buf), format, arg); 64 | if (len < STRING_STACK_LIMIT) { 65 | char temp[STRING_STACK_LIMIT]; 66 | vsprintf(temp, format, arg); 67 | puts(temp); 68 | } else { 69 | char *temp = new char[len + 1]; 70 | vsprintf(temp, format, arg); 71 | puts(temp); 72 | delete[] temp; 73 | } 74 | va_end(arg); 75 | unlock(); 76 | return len; 77 | } 78 | 79 | /** Acquire exclusive access to this serial port 80 | */ 81 | void RawSerial::lock() { 82 | // No lock used - external synchronization required 83 | } 84 | 85 | /** Release exclusive access to this serial port 86 | */ 87 | void RawSerial::unlock() { 88 | // No lock used - external synchronization required 89 | } 90 | 91 | } // namespace mbed 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /src/mbed-dev/common/SPISlave.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "SPISlave.h" 17 | 18 | #if DEVICE_SPISLAVE 19 | 20 | namespace mbed { 21 | 22 | SPISlave::SPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel) : 23 | _spi(), 24 | _bits(8), 25 | _mode(0), 26 | _hz(1000000) 27 | { 28 | spi_init(&_spi, mosi, miso, sclk, ssel); 29 | spi_format(&_spi, _bits, _mode, 1); 30 | spi_frequency(&_spi, _hz); 31 | } 32 | 33 | void SPISlave::format(int bits, int mode) { 34 | _bits = bits; 35 | _mode = mode; 36 | spi_format(&_spi, _bits, _mode, 1); 37 | } 38 | 39 | void SPISlave::frequency(int hz) { 40 | _hz = hz; 41 | spi_frequency(&_spi, _hz); 42 | } 43 | 44 | int SPISlave::receive(void) { 45 | return(spi_slave_receive(&_spi)); 46 | } 47 | 48 | int SPISlave::read(void) { 49 | return(spi_slave_read(&_spi)); 50 | } 51 | 52 | void SPISlave::reply(int value) { 53 | spi_slave_write(&_spi, value); 54 | } 55 | 56 | } // namespace mbed 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/mbed-dev/common/Serial.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "Serial.h" 17 | #include "wait_api.h" 18 | 19 | #if DEVICE_SERIAL 20 | 21 | namespace mbed { 22 | 23 | Serial::Serial(PinName tx, PinName rx, const char *name) : SerialBase(tx, rx), Stream(name) { 24 | } 25 | 26 | int Serial::_getc() { 27 | // Mutex is already held 28 | return _base_getc(); 29 | } 30 | 31 | int Serial::_putc(int c) { 32 | // Mutex is already held 33 | return _base_putc(c); 34 | } 35 | 36 | void Serial::lock() { 37 | _mutex.lock(); 38 | } 39 | 40 | void Serial::unlock() { 41 | _mutex.unlock(); 42 | } 43 | 44 | } // namespace mbed 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/mbed-dev/common/Ticker.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "Ticker.h" 17 | 18 | #include "TimerEvent.h" 19 | #include "FunctionPointer.h" 20 | #include "ticker_api.h" 21 | #include "critical.h" 22 | 23 | namespace mbed { 24 | 25 | void Ticker::detach() { 26 | core_util_critical_section_enter(); 27 | remove(); 28 | _function.attach(0); 29 | core_util_critical_section_exit(); 30 | } 31 | 32 | void Ticker::setup(timestamp_t t) { 33 | core_util_critical_section_enter(); 34 | remove(); 35 | _delay = t; 36 | insert(_delay + ticker_read(_ticker_data)); 37 | core_util_critical_section_exit(); 38 | } 39 | 40 | void Ticker::handler() { 41 | insert(event.timestamp + _delay); 42 | _function.call(); 43 | } 44 | 45 | } // namespace mbed 46 | -------------------------------------------------------------------------------- /src/mbed-dev/common/Timeout.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "Timeout.h" 17 | 18 | namespace mbed { 19 | 20 | void Timeout::handler() { 21 | _function.call(); 22 | } 23 | 24 | } // namespace mbed 25 | -------------------------------------------------------------------------------- /src/mbed-dev/common/Timer.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "Timer.h" 17 | #include "ticker_api.h" 18 | #include "us_ticker_api.h" 19 | #include "critical.h" 20 | 21 | namespace mbed { 22 | 23 | Timer::Timer() : _running(), _start(), _time(), _ticker_data(get_us_ticker_data()) { 24 | reset(); 25 | } 26 | 27 | Timer::Timer(const ticker_data_t *data) : _running(), _start(), _time(), _ticker_data(data) { 28 | reset(); 29 | } 30 | 31 | void Timer::start() { 32 | core_util_critical_section_enter(); 33 | if (!_running) { 34 | _start = ticker_read(_ticker_data); 35 | _running = 1; 36 | } 37 | core_util_critical_section_exit(); 38 | } 39 | 40 | void Timer::stop() { 41 | core_util_critical_section_enter(); 42 | _time += slicetime(); 43 | _running = 0; 44 | core_util_critical_section_exit(); 45 | } 46 | 47 | int Timer::read_us() { 48 | core_util_critical_section_enter(); 49 | int time = _time + slicetime(); 50 | core_util_critical_section_exit(); 51 | return time; 52 | } 53 | 54 | float Timer::read() { 55 | return (float)read_us() / 1000000.0f; 56 | } 57 | 58 | int Timer::read_ms() { 59 | return read_us() / 1000; 60 | } 61 | 62 | int Timer::slicetime() { 63 | core_util_critical_section_enter(); 64 | int ret = 0; 65 | if (_running) { 66 | ret = ticker_read(_ticker_data) - _start; 67 | } 68 | core_util_critical_section_exit(); 69 | return ret; 70 | } 71 | 72 | void Timer::reset() { 73 | core_util_critical_section_enter(); 74 | _start = ticker_read(_ticker_data); 75 | _time = 0; 76 | core_util_critical_section_exit(); 77 | } 78 | 79 | Timer::operator float() { 80 | return read(); 81 | } 82 | 83 | } // namespace mbed 84 | -------------------------------------------------------------------------------- /src/mbed-dev/common/TimerEvent.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "TimerEvent.h" 17 | #include "cmsis.h" 18 | 19 | #include 20 | #include "ticker_api.h" 21 | #include "us_ticker_api.h" 22 | 23 | namespace mbed { 24 | 25 | TimerEvent::TimerEvent() : event(), _ticker_data(get_us_ticker_data()) { 26 | ticker_set_handler(_ticker_data, (&TimerEvent::irq)); 27 | } 28 | 29 | TimerEvent::TimerEvent(const ticker_data_t *data) : event(), _ticker_data(data) { 30 | ticker_set_handler(_ticker_data, (&TimerEvent::irq)); 31 | } 32 | 33 | void TimerEvent::irq(uint32_t id) { 34 | TimerEvent *timer_event = (TimerEvent*)id; 35 | timer_event->handler(); 36 | } 37 | 38 | TimerEvent::~TimerEvent() { 39 | remove(); 40 | } 41 | 42 | // insert in to linked list 43 | void TimerEvent::insert(timestamp_t timestamp) { 44 | ticker_insert_event(_ticker_data, &event, timestamp, (uint32_t)this); 45 | } 46 | 47 | void TimerEvent::remove() { 48 | ticker_remove_event(_ticker_data, &event); 49 | } 50 | 51 | } // namespace mbed 52 | -------------------------------------------------------------------------------- /src/mbed-dev/common/mbed_assert.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "mbed_assert.h" 17 | #include "device.h" 18 | 19 | #include "mbed_interface.h" 20 | #include "critical.h" 21 | 22 | void mbed_assert_internal(const char *expr, const char *file, int line) 23 | { 24 | core_util_critical_section_enter(); 25 | mbed_error_printf("mbed assertation failed: %s, file: %s, line %d \n", expr, file, line); 26 | mbed_die(); 27 | } 28 | -------------------------------------------------------------------------------- /src/mbed-dev/common/mbed_board.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include "gpio_api.h" 18 | #include "wait_api.h" 19 | #include "toolchain.h" 20 | #include "mbed_interface.h" 21 | #include "critical.h" 22 | #include "serial_api.h" 23 | 24 | #if DEVICE_SERIAL 25 | extern int stdio_uart_inited; 26 | extern serial_t stdio_uart; 27 | #endif 28 | 29 | WEAK void mbed_die(void) { 30 | #if !defined (NRF51_H) && !defined(TARGET_EFM32) 31 | core_util_critical_section_enter(); 32 | #endif 33 | #if (DEVICE_ERROR_RED == 1) 34 | gpio_t led_red; gpio_init_out(&led_red, LED_RED); 35 | #elif (DEVICE_ERROR_PATTERN == 1) 36 | gpio_t led_1; gpio_init_out(&led_1, LED1); 37 | gpio_t led_2; gpio_init_out(&led_2, LED2); 38 | gpio_t led_3; gpio_init_out(&led_3, LED3); 39 | gpio_t led_4; gpio_init_out(&led_4, LED4); 40 | #endif 41 | 42 | while (1) { 43 | #if (DEVICE_ERROR_RED == 1) 44 | gpio_write(&led_red, 1); 45 | 46 | #elif (DEVICE_ERROR_PATTERN == 1) 47 | gpio_write(&led_1, 1); 48 | gpio_write(&led_2, 0); 49 | gpio_write(&led_3, 0); 50 | gpio_write(&led_4, 1); 51 | #endif 52 | 53 | wait_ms(150); 54 | 55 | #if (DEVICE_ERROR_RED == 1) 56 | gpio_write(&led_red, 0); 57 | 58 | #elif (DEVICE_ERROR_PATTERN == 1) 59 | gpio_write(&led_1, 0); 60 | gpio_write(&led_2, 1); 61 | gpio_write(&led_3, 1); 62 | gpio_write(&led_4, 0); 63 | #endif 64 | 65 | wait_ms(150); 66 | } 67 | } 68 | 69 | void mbed_error_printf(const char* format, ...) { 70 | va_list arg; 71 | va_start(arg, format); 72 | mbed_error_vfprintf(format, arg); 73 | va_end(arg); 74 | } 75 | 76 | void mbed_error_vfprintf(const char * format, va_list arg) { 77 | #if DEVICE_SERIAL 78 | core_util_critical_section_enter(); 79 | char buffer[128]; 80 | int size = vsprintf(buffer, format, arg); 81 | if (size > 0) { 82 | if (!stdio_uart_inited) { 83 | serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX); 84 | } 85 | for (int i = 0; i < size; i++) { 86 | serial_putc(&stdio_uart, buffer[i]); 87 | } 88 | } 89 | core_util_critical_section_exit(); 90 | #endif 91 | } 92 | -------------------------------------------------------------------------------- /src/mbed-dev/common/mbed_error.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include "device.h" 19 | #include "toolchain.h" 20 | #include "mbed_error.h" 21 | #include "mbed_interface.h" 22 | #if DEVICE_STDIO_MESSAGES 23 | #include 24 | #endif 25 | 26 | WEAK void error(const char* format, ...) { 27 | va_list arg; 28 | va_start(arg, format); 29 | mbed_error_vfprintf(format, arg); 30 | va_end(arg); 31 | exit(1); 32 | } 33 | -------------------------------------------------------------------------------- /src/mbed-dev/common/mbed_gpio.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "gpio_api.h" 17 | 18 | static inline void _gpio_init_in(gpio_t* gpio, PinName pin, PinMode mode) 19 | { 20 | gpio_init(gpio, pin); 21 | if (pin != NC) { 22 | gpio_dir(gpio, PIN_INPUT); 23 | gpio_mode(gpio, mode); 24 | } 25 | } 26 | 27 | static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int value) 28 | { 29 | gpio_init(gpio, pin); 30 | if (pin != NC) { 31 | gpio_write(gpio, value); 32 | gpio_dir(gpio, PIN_OUTPUT); 33 | gpio_mode(gpio, mode); 34 | } 35 | } 36 | 37 | void gpio_init_in(gpio_t* gpio, PinName pin) { 38 | gpio_init_in_ex(gpio, pin, PullDefault); 39 | } 40 | 41 | void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode) { 42 | _gpio_init_in(gpio, pin, mode); 43 | } 44 | 45 | void gpio_init_out(gpio_t* gpio, PinName pin) { 46 | gpio_init_out_ex(gpio, pin, 0); 47 | } 48 | 49 | void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value) { 50 | _gpio_init_out(gpio, pin, PullNone, value); 51 | } 52 | 53 | void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) { 54 | if (direction == PIN_INPUT) { 55 | _gpio_init_in(gpio, pin, mode); 56 | if (pin != NC) 57 | gpio_write(gpio, value); // we prepare the value in case it is switched later 58 | } else { 59 | _gpio_init_out(gpio, pin, mode, value); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/mbed-dev/common/mbed_lp_ticker_api.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "lp_ticker_api.h" 17 | 18 | #if DEVICE_LOWPOWERTIMER 19 | 20 | static ticker_event_queue_t events; 21 | 22 | static const ticker_interface_t lp_interface = { 23 | .init = lp_ticker_init, 24 | .read = lp_ticker_read, 25 | .disable_interrupt = lp_ticker_disable_interrupt, 26 | .clear_interrupt = lp_ticker_clear_interrupt, 27 | .set_interrupt = lp_ticker_set_interrupt, 28 | }; 29 | 30 | static const ticker_data_t lp_data = { 31 | .interface = &lp_interface, 32 | .queue = &events, 33 | }; 34 | 35 | const ticker_data_t* get_lp_ticker_data(void) 36 | { 37 | return &lp_data; 38 | } 39 | 40 | void lp_ticker_irq_handler(void) 41 | { 42 | ticker_irq_handler(&lp_data); 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/mbed-dev/common/mbed_pinmap_common.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "pinmap.h" 17 | #include "mbed_error.h" 18 | 19 | void pinmap_pinout(PinName pin, const PinMap *map) { 20 | if (pin == NC) 21 | return; 22 | 23 | while (map->pin != NC) { 24 | if (map->pin == pin) { 25 | pin_function(pin, map->function); 26 | 27 | pin_mode(pin, PullNone); 28 | return; 29 | } 30 | map++; 31 | } 32 | error("could not pinout"); 33 | } 34 | 35 | uint32_t pinmap_merge(uint32_t a, uint32_t b) { 36 | // both are the same (inc both NC) 37 | if (a == b) 38 | return a; 39 | 40 | // one (or both) is not connected 41 | if (a == (uint32_t)NC) 42 | return b; 43 | if (b == (uint32_t)NC) 44 | return a; 45 | 46 | // mis-match error case 47 | error("pinmap mis-match"); 48 | return (uint32_t)NC; 49 | } 50 | 51 | uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) { 52 | while (map->pin != NC) { 53 | if (map->pin == pin) 54 | return map->peripheral; 55 | map++; 56 | } 57 | return (uint32_t)NC; 58 | } 59 | 60 | uint32_t pinmap_peripheral(PinName pin, const PinMap* map) { 61 | uint32_t peripheral = (uint32_t)NC; 62 | 63 | if (pin == (PinName)NC) 64 | return (uint32_t)NC; 65 | peripheral = pinmap_find_peripheral(pin, map); 66 | if ((uint32_t)NC == peripheral) // no mapping available 67 | error("pinmap not found for peripheral"); 68 | return peripheral; 69 | } 70 | 71 | uint32_t pinmap_find_function(PinName pin, const PinMap* map) { 72 | while (map->pin != NC) { 73 | if (map->pin == pin) 74 | return map->function; 75 | map++; 76 | } 77 | return (uint32_t)NC; 78 | } 79 | 80 | uint32_t pinmap_function(PinName pin, const PinMap* map) { 81 | uint32_t function = (uint32_t)NC; 82 | 83 | if (pin == (PinName)NC) 84 | return (uint32_t)NC; 85 | function = pinmap_find_function(pin, map); 86 | if ((uint32_t)NC == function) // no mapping available 87 | error("pinmap not found for function"); 88 | return function; 89 | } 90 | -------------------------------------------------------------------------------- /src/mbed-dev/common/mbed_us_ticker_api.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "us_ticker_api.h" 17 | 18 | static ticker_event_queue_t events; 19 | 20 | static const ticker_interface_t us_interface = { 21 | .init = us_ticker_init, 22 | .read = us_ticker_read, 23 | .disable_interrupt = us_ticker_disable_interrupt, 24 | .clear_interrupt = us_ticker_clear_interrupt, 25 | .set_interrupt = us_ticker_set_interrupt, 26 | }; 27 | 28 | static const ticker_data_t us_data = { 29 | .interface = &us_interface, 30 | .queue = &events, 31 | }; 32 | 33 | const ticker_data_t* get_us_ticker_data(void) 34 | { 35 | return &us_data; 36 | } 37 | 38 | void us_ticker_irq_handler(void) 39 | { 40 | ticker_irq_handler(&us_data); 41 | } 42 | -------------------------------------------------------------------------------- /src/mbed-dev/common/mbed_wait_api.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "wait_api.h" 17 | #include "us_ticker_api.h" 18 | 19 | void wait(float s) { 20 | wait_us(s * 1000000.0f); 21 | } 22 | 23 | void wait_ms(int ms) { 24 | wait_us(ms * 1000); 25 | } 26 | 27 | void wait_us(int us) { 28 | uint32_t start = us_ticker_read(); 29 | while ((us_ticker_read() - start) < (uint32_t)us); 30 | } 31 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/analogin_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_ANALOGIN_API_H 17 | #define MBED_ANALOGIN_API_H 18 | 19 | #include "device.h" 20 | 21 | #if DEVICE_ANALOGIN 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** Analogin hal structure. analogin_s is declared in the target's hal 28 | */ 29 | typedef struct analogin_s analogin_t; 30 | 31 | /** 32 | * \defgroup hal_analogin Analogin hal functions 33 | * @{ 34 | */ 35 | 36 | /** Initialize the analogin peripheral 37 | * 38 | * Configures the pin used by analogin. 39 | * @param obj The analogin object to initialize 40 | * @param pin The analogin pin name 41 | */ 42 | void analogin_init(analogin_t *obj, PinName pin); 43 | 44 | /** Read the input voltage, represented as a float in the range [0.0, 1.0] 45 | * 46 | * @param obj The analogin object 47 | * @return A floating value representing the current input voltage 48 | */ 49 | float analogin_read(analogin_t *obj); 50 | 51 | /** Read the value from analogin pin, represented as an unsigned 16bit value 52 | * 53 | * @param obj The analogin object 54 | * @return An unsigned 16bit value representing the current input voltage 55 | */ 56 | uint16_t analogin_read_u16(analogin_t *obj); 57 | 58 | /**@}*/ 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/analogout_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_ANALOGOUT_API_H 17 | #define MBED_ANALOGOUT_API_H 18 | 19 | #include "device.h" 20 | 21 | #if DEVICE_ANALOGOUT 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** Analogout hal structure. dac_s is declared in the target's hal 28 | */ 29 | typedef struct dac_s dac_t; 30 | 31 | /** 32 | * \defgroup hal_analogout Analogout hal functions 33 | * @{ 34 | */ 35 | 36 | /** Initialize the analogout peripheral 37 | * 38 | * Configures the pin used by analogout. 39 | * @param obj The analogout object to initialize 40 | * @param pin The analogout pin name 41 | */ 42 | void analogout_init(dac_t *obj, PinName pin); 43 | 44 | /** Release the analogout object 45 | * 46 | * Note: This is not currently used in the mbed-drivers 47 | * @param obj The analogout object 48 | */ 49 | void analogout_free(dac_t *obj); 50 | 51 | /** Set the output voltage, specified as a percentage (float) 52 | * 53 | * @param obj The analogin object 54 | * @param value The floating-point output voltage to be set 55 | */ 56 | void analogout_write(dac_t *obj, float value); 57 | 58 | /** Set the output voltage, specified as unsigned 16-bit 59 | * 60 | * @param obj The analogin object 61 | * @param value The unsigned 16-bit output voltage to be set 62 | */ 63 | void analogout_write_u16(dac_t *obj, uint16_t value); 64 | 65 | /** Read the current voltage value on the pin 66 | * 67 | * @param obj The analogin object 68 | * @return A floating-point value representing the current voltage on the pin, 69 | * measured as a percentage 70 | */ 71 | float analogout_read(dac_t *obj); 72 | 73 | /** Read the current voltage value on the pin, as a normalized unsigned 16bit value 74 | * 75 | * @param obj The analogin object 76 | * @return An unsigned 16-bit value representing the current voltage on the pin 77 | */ 78 | uint16_t analogout_read_u16(dac_t *obj); 79 | 80 | /**@}*/ 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/buffer.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2014-2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_BUFFER_H 17 | #define MBED_BUFFER_H 18 | 19 | #include 20 | 21 | /** Generic buffer structure 22 | */ 23 | typedef struct buffer_s { 24 | void *buffer; /**< the pointer to a buffer */ 25 | size_t length; /**< the buffer length */ 26 | size_t pos; /**< actual buffer position */ 27 | uint8_t width; /**< The buffer unit width (8, 16, 32, 64), used for proper *buffer casting */ 28 | } buffer_t; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/can_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2016 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_CAN_API_H 17 | #define MBED_CAN_API_H 18 | 19 | #include "device.h" 20 | 21 | #if DEVICE_CAN 22 | 23 | #include "PinNames.h" 24 | #include "PeripheralNames.h" 25 | #include "can_helper.h" 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | typedef enum { 32 | IRQ_RX, 33 | IRQ_TX, 34 | IRQ_ERROR, 35 | IRQ_OVERRUN, 36 | IRQ_WAKEUP, 37 | IRQ_PASSIVE, 38 | IRQ_ARB, 39 | IRQ_BUS, 40 | IRQ_READY 41 | } CanIrqType; 42 | 43 | 44 | typedef enum { 45 | MODE_RESET, 46 | MODE_NORMAL, 47 | MODE_SILENT, 48 | MODE_TEST_LOCAL, 49 | MODE_TEST_GLOBAL, 50 | MODE_TEST_SILENT 51 | } CanMode; 52 | 53 | typedef void (*can_irq_handler)(uint32_t id, CanIrqType type); 54 | 55 | typedef struct can_s can_t; 56 | 57 | void can_init (can_t *obj, PinName rd, PinName td); 58 | void can_free (can_t *obj); 59 | int can_frequency(can_t *obj, int hz); 60 | 61 | void can_irq_init (can_t *obj, can_irq_handler handler, uint32_t id); 62 | void can_irq_free (can_t *obj); 63 | void can_irq_set (can_t *obj, CanIrqType irq, uint32_t enable); 64 | 65 | int can_write (can_t *obj, CAN_Message, int cc); 66 | int can_read (can_t *obj, CAN_Message *msg, int handle); 67 | int can_mode (can_t *obj, CanMode mode); 68 | int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle); 69 | void can_reset (can_t *obj); 70 | unsigned char can_rderror (can_t *obj); 71 | unsigned char can_tderror (can_t *obj); 72 | void can_monitor (can_t *obj, int silent); 73 | 74 | #ifdef __cplusplus 75 | }; 76 | #endif 77 | 78 | #endif // MBED_CAN_API_H 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/dma_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2014-2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_DMA_API_H 17 | #define MBED_DMA_API_H 18 | 19 | #include 20 | 21 | #define DMA_ERROR_OUT_OF_CHANNELS (-1) 22 | 23 | typedef enum { 24 | DMA_USAGE_NEVER, 25 | DMA_USAGE_OPPORTUNISTIC, 26 | DMA_USAGE_ALWAYS, 27 | DMA_USAGE_TEMPORARY_ALLOCATED, 28 | DMA_USAGE_ALLOCATED 29 | } DMAUsage; 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | void dma_init(void); 36 | 37 | int dma_channel_allocate(uint32_t capabilities); 38 | 39 | int dma_channel_free(int channelid); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/ethernet_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_ETHERNET_API_H 17 | #define MBED_ETHERNET_API_H 18 | 19 | #include "device.h" 20 | 21 | #if DEVICE_ETHERNET 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | // Connection constants 28 | 29 | int ethernet_init(void); 30 | void ethernet_free(void); 31 | 32 | // write size bytes from data to ethernet buffer 33 | // return num bytes written 34 | // or -1 if size is too big 35 | int ethernet_write(const char *data, int size); 36 | 37 | // send ethernet write buffer, returning the packet size sent 38 | int ethernet_send(void); 39 | 40 | // recieve from ethernet buffer, returning packet size, or 0 if no packet 41 | int ethernet_receive(void); 42 | 43 | // read size bytes in to data, return actual num bytes read (0..size) 44 | // if data == NULL, throw the bytes away 45 | int ethernet_read(char *data, int size); 46 | 47 | // get the ethernet address 48 | void ethernet_address(char *mac); 49 | 50 | // see if the link is up 51 | int ethernet_link(void); 52 | 53 | // force link settings 54 | void ethernet_set_link(int speed, int duplex); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/gpio_irq_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_GPIO_IRQ_API_H 17 | #define MBED_GPIO_IRQ_API_H 18 | 19 | #include "device.h" 20 | 21 | #if DEVICE_INTERRUPTIN 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** GPIO IRQ events 28 | */ 29 | typedef enum { 30 | IRQ_NONE, 31 | IRQ_RISE, 32 | IRQ_FALL 33 | } gpio_irq_event; 34 | 35 | /** GPIO IRQ HAL structure. gpio_irq_s is declared in the target's HAL 36 | */ 37 | typedef struct gpio_irq_s gpio_irq_t; 38 | 39 | typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event); 40 | 41 | /** 42 | * \defgroup hal_gpioirq GPIO IRQ HAL functions 43 | * @{ 44 | */ 45 | 46 | /** Initialize the GPIO IRQ pin 47 | * 48 | * @param obj The GPIO object to initialize 49 | * @param pin The GPIO pin name 50 | * @param handler The handler to be attached to GPIO IRQ 51 | * @param id The object ID (id != 0, 0 is reserved) 52 | * @return -1 if pin is NC, 0 otherwise 53 | */ 54 | int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id); 55 | 56 | /** Release the GPIO IRQ PIN 57 | * 58 | * @param obj The gpio object 59 | */ 60 | void gpio_irq_free(gpio_irq_t *obj); 61 | 62 | /** Enable/disable pin IRQ event 63 | * 64 | * @param obj The GPIO object 65 | * @param event The GPIO IRQ event 66 | * @param enable The enable flag 67 | */ 68 | void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable); 69 | 70 | /** Enable GPIO IRQ 71 | * 72 | * This is target dependent, as it might enable the entire port or just a pin 73 | * @param obj The GPIO object 74 | */ 75 | void gpio_irq_enable(gpio_irq_t *obj); 76 | 77 | /** Disable GPIO IRQ 78 | * 79 | * This is target dependent, as it might disable the entire port or just a pin 80 | * @param obj The GPIO object 81 | */ 82 | void gpio_irq_disable(gpio_irq_t *obj); 83 | 84 | /**@}*/ 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/lp_ticker_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_LPTICKER_API_H 17 | #define MBED_LPTICKER_API_H 18 | 19 | #include "device.h" 20 | 21 | #if DEVICE_LOWPOWERTIMER 22 | 23 | #include "ticker_api.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /** 30 | * \defgroup hal_LpTicker Low Power Ticker Functions 31 | * @{ 32 | */ 33 | 34 | /** Get low power ticker's data 35 | * 36 | * @return The low power ticker data 37 | */ 38 | const ticker_data_t* get_lp_ticker_data(void); 39 | 40 | /** The wrapper for ticker_irq_handler, to pass lp ticker's data 41 | * 42 | */ 43 | void lp_ticker_irq_handler(void); 44 | 45 | /* HAL lp ticker */ 46 | 47 | /** Initialize the low power ticker 48 | * 49 | */ 50 | void lp_ticker_init(void); 51 | 52 | /** Read the current counter 53 | * 54 | * @return The current timer's counter value in microseconds 55 | */ 56 | uint32_t lp_ticker_read(void); 57 | 58 | /** Set interrupt for specified timestamp 59 | * 60 | * @param timestamp The time in microseconds to be set 61 | */ 62 | void lp_ticker_set_interrupt(timestamp_t timestamp); 63 | 64 | /** Disable low power ticker interrupt 65 | * 66 | */ 67 | void lp_ticker_disable_interrupt(void); 68 | 69 | /** Clear the low power ticker interrupt 70 | * 71 | */ 72 | void lp_ticker_clear_interrupt(void); 73 | 74 | /**@}*/ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/pinmap.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_PINMAP_H 17 | #define MBED_PINMAP_H 18 | 19 | #include "PinNames.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct { 26 | PinName pin; 27 | int peripheral; 28 | int function; 29 | } PinMap; 30 | 31 | void pin_function(PinName pin, int function); 32 | void pin_mode (PinName pin, PinMode mode); 33 | 34 | uint32_t pinmap_peripheral(PinName pin, const PinMap* map); 35 | uint32_t pinmap_function(PinName pin, const PinMap* map); 36 | uint32_t pinmap_merge (uint32_t a, uint32_t b); 37 | void pinmap_pinout (PinName pin, const PinMap *map); 38 | uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map); 39 | uint32_t pinmap_find_function(PinName pin, const PinMap* map); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/port_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_PORTMAP_H 17 | #define MBED_PORTMAP_H 18 | 19 | #include "device.h" 20 | 21 | #if DEVICE_PORTIN || DEVICE_PORTOUT 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** Port HAL structure. port_s is declared in the target's HAL 28 | */ 29 | typedef struct port_s port_t; 30 | 31 | /** 32 | * \defgroup hal_port Port HAL functions 33 | * @{ 34 | */ 35 | 36 | /** Get the pin name from the port's pin number 37 | * 38 | * @param port The port name 39 | * @param pin_n The pin number within the specified port 40 | * @return The pin name for the port's pin number 41 | */ 42 | PinName port_pin(PortName port, int pin_n); 43 | 44 | /** Initilize the port 45 | * 46 | * @param obj The port object to initialize 47 | * @param port The port name 48 | * @param mask The bitmask to identify which bits in the port should be included (0 - ignore) 49 | * @param dir The port direction 50 | */ 51 | void port_init(port_t *obj, PortName port, int mask, PinDirection dir); 52 | 53 | /** Set the input port mode 54 | * 55 | * @param obj The port object 56 | * @param mode THe port mode to be set 57 | */ 58 | void port_mode(port_t *obj, PinMode mode); 59 | 60 | /** Set port direction (in/out) 61 | * 62 | * @param obj The port object 63 | * @param dir The port direction to be set 64 | */ 65 | void port_dir(port_t *obj, PinDirection dir); 66 | 67 | /** Write value to the port 68 | * 69 | * @param obj The port object 70 | * @param value The value to be set 71 | */ 72 | void port_write(port_t *obj, int value); 73 | 74 | /** Read the current value on the port 75 | * 76 | * @param obj The port object 77 | * @return An integer with each bit corresponding to an associated port pin setting 78 | */ 79 | int port_read(port_t *obj); 80 | 81 | /**@}*/ 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/rtc_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_RTC_API_H 17 | #define MBED_RTC_API_H 18 | 19 | #include "device.h" 20 | 21 | #if DEVICE_RTC 22 | 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /** 30 | * \defgroup hal_rtc RTC hal functions 31 | * @{ 32 | */ 33 | 34 | /** Initialize the RTC peripheral 35 | * 36 | */ 37 | void rtc_init(void); 38 | 39 | /** Deinitialize RTC 40 | * 41 | * TODO: The function is not used by rtc api in mbed-drivers. 42 | */ 43 | void rtc_free(void); 44 | 45 | /** Get the RTC enable status 46 | * 47 | * @retval 0 disabled 48 | * @retval 1 enabled 49 | */ 50 | int rtc_isenabled(void); 51 | 52 | /** Get the current time from the RTC peripheral 53 | * 54 | * @return The current time 55 | */ 56 | time_t rtc_read(void); 57 | 58 | /** Set the current time to the RTC peripheral 59 | * 60 | * @param t The current time to be set 61 | */ 62 | void rtc_write(time_t t); 63 | 64 | /**@}*/ 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/sleep_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_SLEEP_API_H 17 | #define MBED_SLEEP_API_H 18 | 19 | #include "device.h" 20 | 21 | #if DEVICE_SLEEP 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** Send the microcontroller to sleep 28 | * 29 | * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the 30 | * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates 31 | * dynamic power used by the processor, memory systems and buses. The processor, peripheral and 32 | * memory state are maintained, and the peripherals continue to work and can generate interrupts. 33 | * 34 | * The processor can be woken up by any internal peripheral interrupt or external pin interrupt. 35 | * 36 | * @note 37 | * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. 38 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be 39 | * able to access the LocalFileSystem 40 | */ 41 | void sleep(void); 42 | 43 | /** Send the microcontroller to deep sleep 44 | * 45 | * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode 46 | * has the same sleep features as sleep plus it powers down peripherals and clocks. All state 47 | * is still maintained. 48 | * 49 | * The processor can only be woken up by an external interrupt on a pin or a watchdog timer. 50 | * 51 | * @note 52 | * The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored. 53 | * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be 54 | * able to access the LocalFileSystem 55 | */ 56 | void deepsleep(void); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/storage_abstraction/Driver_Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2016, ARM Limited, All Rights Reserved 3 | * SPDX-License-Identifier: Apache-2.0 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | * not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef __DRIVER_COMMON_H 19 | #define __DRIVER_COMMON_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #define ARM_DRIVER_VERSION_MAJOR_MINOR(major,minor) (((major) << 8) | (minor)) 26 | 27 | /** 28 | \brief Driver Version 29 | */ 30 | typedef struct _ARM_DRIVER_VERSION { 31 | uint16_t api; ///< API version 32 | uint16_t drv; ///< Driver version 33 | } ARM_DRIVER_VERSION; 34 | 35 | /* General return codes */ 36 | #define ARM_DRIVER_OK 0 ///< Operation succeeded 37 | #define ARM_DRIVER_ERROR -1 ///< Unspecified error 38 | #define ARM_DRIVER_ERROR_BUSY -2 ///< Driver is busy 39 | #define ARM_DRIVER_ERROR_TIMEOUT -3 ///< Timeout occurred 40 | #define ARM_DRIVER_ERROR_UNSUPPORTED -4 ///< Operation not supported 41 | #define ARM_DRIVER_ERROR_PARAMETER -5 ///< Parameter error 42 | #define ARM_DRIVER_ERROR_SPECIFIC -6 ///< Start of driver specific errors 43 | 44 | /** 45 | \brief General power states 46 | */ 47 | typedef enum _ARM_POWER_STATE { 48 | ARM_POWER_OFF, ///< Power off: no operation possible 49 | ARM_POWER_LOW, ///< Low Power mode: retain state, detect and signal wake-up events 50 | ARM_POWER_FULL ///< Power on: full operation at maximum performance 51 | } ARM_POWER_STATE; 52 | 53 | #endif /* __DRIVER_COMMON_H */ 54 | -------------------------------------------------------------------------------- /src/mbed-dev/hal/us_ticker_api.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_US_TICKER_API_H 17 | #define MBED_US_TICKER_API_H 18 | 19 | #include 20 | #include "ticker_api.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** 27 | * \defgroup hal_UsTicker Microseconds Ticker Functions 28 | * @{ 29 | */ 30 | 31 | /** Get ticker's data 32 | * 33 | * @return The low power ticker data 34 | */ 35 | const ticker_data_t* get_us_ticker_data(void); 36 | 37 | 38 | /** The wrapper for ticker_irq_handler, to pass us ticker's data 39 | * 40 | */ 41 | void us_ticker_irq_handler(void); 42 | 43 | /* HAL us ticker */ 44 | 45 | /** Initialize the ticker 46 | * 47 | */ 48 | void us_ticker_init(void); 49 | 50 | /** Read the current counter 51 | * 52 | * @return The current timer's counter value in microseconds 53 | */ 54 | uint32_t us_ticker_read(void); 55 | 56 | /** Set interrupt for specified timestamp 57 | * 58 | * @param timestamp The time in microseconds to be set 59 | */ 60 | void us_ticker_set_interrupt(timestamp_t timestamp); 61 | 62 | /** Disable us ticker interrupt 63 | * 64 | */ 65 | void us_ticker_disable_interrupt(void); 66 | 67 | /** Clear us ticker interrupt 68 | * 69 | */ 70 | void us_ticker_clear_interrupt(void); 71 | 72 | /**@}*/ 73 | 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/mbed-dev/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mbed-classic", 3 | "version": "0.0.1", 4 | "description": "mbed core SDK (for mbed 2.0, *not* mbedOS)", 5 | "keywords": [ 6 | "mbed" 7 | ], 8 | "author": "Bogdan Marinescu ", 9 | "repository": { 10 | "url": "git@github.com:mbedmicro/mbed.git", 11 | "type": "git" 12 | }, 13 | "homepage": "https://github.com/mbedmicro/mbed", 14 | "licenses": [ 15 | { 16 | "url": "https://spdx.org/licenses/Apache-2.0", 17 | "type": "Apache-2.0" 18 | } 19 | ], 20 | "extraIncludes": [ 21 | "api", 22 | "hal", 23 | "targets/hal", 24 | "targets/cmsis" 25 | ], 26 | "dependencies": { 27 | }, 28 | "targetDependencies": { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/stm32f401xe.sct: -------------------------------------------------------------------------------- 1 | ; Scatter-Loading Description File 2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3 | ; Copyright (c) 2014, STMicroelectronics 4 | ; All rights reserved. 5 | ; 6 | ; Redistribution and use in source and binary forms, with or without 7 | ; modification, are permitted provided that the following conditions are met: 8 | ; 9 | ; 1. Redistributions of source code must retain the above copyright notice, 10 | ; this list of conditions and the following disclaimer. 11 | ; 2. Redistributions in binary form must reproduce the above copyright notice, 12 | ; this list of conditions and the following disclaimer in the documentation 13 | ; and/or other materials provided with the distribution. 14 | ; 3. Neither the name of STMicroelectronics nor the names of its contributors 15 | ; may be used to endorse or promote products derived from this software 16 | ; without specific prior written permission. 17 | ; 18 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 29 | 30 | ; STM32F401RE: 384KB FLASH + 96KB SRAM 31 | LR_IROM1 0x08000000 0x60000 { ; load region size_region 32 | 33 | ER_IROM1 0x08000000 0x60000 { ; load address = execution address 34 | *.o (RESET, +First) 35 | *(InRoot$$Sections) 36 | .ANY (+RO) 37 | } 38 | 39 | ; Total: 101 vectors = 404 bytes (0x194) to be reserved in RAM 40 | RW_IRAM1 (0x20000000+0x194) (0x18000-0x194) { ; RW data 41 | .ANY (+RW +ZI) 42 | } 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/sys.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library - stackheap 2 | * Setup a fixed single stack/heap memory model, 3 | * between the top of the RW/ZI region and the stackpointer 4 | ******************************************************************************* 5 | * Copyright (c) 2014, STMicroelectronics 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 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 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | #include 39 | 40 | extern char Image$$RW_IRAM1$$ZI$$Limit[]; 41 | 42 | extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) { 43 | uint32_t zi_limit = (uint32_t)Image$$RW_IRAM1$$ZI$$Limit; 44 | uint32_t sp_limit = __current_sp(); 45 | 46 | zi_limit = (zi_limit + 7) & ~0x7; // ensure zi_limit is 8-byte aligned 47 | 48 | struct __initial_stackheap r; 49 | r.heap_base = zi_limit; 50 | r.heap_limit = sp_limit; 51 | return r; 52 | } 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/cmsis.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * A generic CMSIS include header 3 | ******************************************************************************* 4 | * Copyright (c) 2014, STMicroelectronics 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 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 | #ifndef MBED_CMSIS_H 33 | #define MBED_CMSIS_H 34 | 35 | #include "stm32f4xx.h" 36 | #include "cmsis_nvic.h" 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/cmsis_nvic.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * CMSIS-style functionality to support dynamic vectors 3 | ******************************************************************************* 4 | * Copyright (c) 2014, STMicroelectronics 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 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 | #ifndef MBED_CMSIS_NVIC_H 33 | #define MBED_CMSIS_NVIC_H 34 | 35 | // STM32F401RE 36 | // CORE: 16 vectors = 64 bytes from 0x00 to 0x3F 37 | // MCU Peripherals: 85 vectors = 340 bytes from 0x40 to ... 38 | // Total: 101 vectors = 404 bytes (0x194) to be reserved in RAM 39 | #define NVIC_NUM_VECTORS 101 40 | #define NVIC_USER_IRQ_OFFSET 16 41 | 42 | #include "cmsis.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector); 49 | uint32_t NVIC_GetVector(IRQn_Type IRQn); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/hal_tick.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file hal_tick.h 4 | * @author MCD Application Team 5 | * @brief Initialization of HAL tick 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2014 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | #ifndef __HAL_TICK_H 36 | #define __HAL_TICK_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | #include "stm32f4xx.h" 43 | #include "cmsis_nvic.h" 44 | 45 | #define TIM_MST TIM5 46 | #define TIM_MST_IRQ TIM5_IRQn 47 | #define TIM_MST_RCC __TIM5_CLK_ENABLE() 48 | 49 | #define TIM_MST_RESET_ON __TIM5_FORCE_RESET() 50 | #define TIM_MST_RESET_OFF __TIM5_RELEASE_RESET() 51 | 52 | #define HAL_TICK_DELAY (1000) // 1 ms 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif // __HAL_TICK_H 59 | 60 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 61 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_dma2d.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lora-net/picoGW_mcu/9aec67e25356e8980e7aac2be7f03f30450b816c/src/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_dma2d.c -------------------------------------------------------------------------------- /src/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_ltdc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lora-net/picoGW_mcu/9aec67e25356e8980e7aac2be7f03f30450b816c/src/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_ltdc.c -------------------------------------------------------------------------------- /src/mbed-dev/targets/cmsis/core_caInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_caInstr.h 3 | * @brief CMSIS Cortex-A9 Core Peripheral Access Layer Header File 4 | * @version 5 | * @date 04. December 2012 6 | * 7 | * @note 8 | * 9 | ******************************************************************************/ 10 | /* Copyright (c) 2009 - 2012 ARM LIMITED 11 | 12 | All rights reserved. 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions are met: 15 | - Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | - Redistributions in binary form must reproduce the above copyright 18 | notice, this list of conditions and the following disclaimer in the 19 | documentation and/or other materials provided with the distribution. 20 | - Neither the name of ARM nor the names of its contributors may be used 21 | to endorse or promote products derived from this software without 22 | 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 27 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 28 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | POSSIBILITY OF SUCH DAMAGE. 35 | ---------------------------------------------------------------------------*/ 36 | 37 | #ifndef __CORE_CAINSTR_H__ 38 | #define __CORE_CAINSTR_H__ 39 | 40 | #define __CORTEX_M 0x3 41 | #include "core_cmInstr.h" 42 | #undef __CORTEX_M 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/PeripheralPins.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | ******************************************************************************* 3 | * Copyright (c) 2014, STMicroelectronics 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ******************************************************************************* 29 | */ 30 | 31 | #ifndef MBED_PERIPHERALPINS_H 32 | #define MBED_PERIPHERALPINS_H 33 | 34 | #include "pinmap.h" 35 | #include "PeripheralNames.h" 36 | 37 | //*** ADC *** 38 | 39 | extern const PinMap PinMap_ADC[]; 40 | 41 | //*** DAC *** 42 | 43 | extern const PinMap PinMap_DAC[]; 44 | 45 | //*** I2C *** 46 | 47 | extern const PinMap PinMap_I2C_SDA[]; 48 | extern const PinMap PinMap_I2C_SCL[]; 49 | 50 | //*** PWM *** 51 | 52 | extern const PinMap PinMap_PWM[]; 53 | 54 | //*** SERIAL *** 55 | 56 | extern const PinMap PinMap_UART_TX[]; 57 | extern const PinMap PinMap_UART_RX[]; 58 | extern const PinMap PinMap_UART_RTS[]; 59 | extern const PinMap PinMap_UART_CTS[]; 60 | 61 | //*** SPI *** 62 | 63 | extern const PinMap PinMap_SPI_MOSI[]; 64 | extern const PinMap PinMap_SPI_MISO[]; 65 | extern const PinMap PinMap_SPI_SCLK[]; 66 | extern const PinMap PinMap_SPI_SSEL[]; 67 | 68 | //*** CAN *** 69 | extern const PinMap PinMap_CAN_RD[]; 70 | extern const PinMap PinMap_CAN_TD[]; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/PortNames.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | ******************************************************************************* 3 | * Copyright (c) 2014, STMicroelectronics 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ******************************************************************************* 29 | */ 30 | #ifndef MBED_PORTNAMES_H 31 | #define MBED_PORTNAMES_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | typedef enum { 38 | PortA = 0, 39 | PortB = 1, 40 | PortC = 2, 41 | PortD = 3, 42 | PortE = 4, 43 | PortH = 7 44 | } PortName; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/common_objects.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | ******************************************************************************* 3 | * Copyright (c) 2016, STMicroelectronics 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ******************************************************************************* 29 | */ 30 | #ifndef MBED_COMMON_OBJECTS_H 31 | #define MBED_COMMON_OBJECTS_H 32 | 33 | #include "cmsis.h" 34 | #include "PortNames.h" 35 | #include "PeripheralNames.h" 36 | #include "PinNames.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | struct pwmout_s { 43 | PWMName pwm; 44 | PinName pin; 45 | uint32_t prescaler; 46 | uint32_t period; 47 | uint32_t pulse; 48 | uint8_t channel; 49 | uint8_t inverted; 50 | }; 51 | 52 | struct serial_s { 53 | UARTName uart; 54 | int index; 55 | uint32_t baudrate; 56 | uint32_t databits; 57 | uint32_t stopbits; 58 | uint32_t parity; 59 | PinName pin_tx; 60 | PinName pin_rx; 61 | #if DEVICE_SERIAL_ASYNCH 62 | uint32_t events; 63 | #endif 64 | #if DEVICE_SERIAL_FC 65 | uint32_t hw_flow_ctl; 66 | PinName pin_rts; 67 | PinName pin_cts; 68 | #endif 69 | }; 70 | 71 | #include "gpio_object.h" 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif 78 | 79 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/device.h: -------------------------------------------------------------------------------- 1 | // The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches. 2 | // Check the 'features' section of the target description in 'targets.json' for more details. 3 | /* mbed Microcontroller Library 4 | ******************************************************************************* 5 | * Copyright (c) 2014, STMicroelectronics 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 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 | #ifndef MBED_DEVICE_H 33 | #define MBED_DEVICE_H 34 | 35 | //======================================= 36 | #define DEVICE_ID_LENGTH 24 37 | 38 | #include "objects.h" 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/mbed_overrides.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2014, STMicroelectronics 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include "cmsis.h" 29 | #include "us_ticker_api.h" 30 | 31 | // This function is called after RAM initialization and before main. 32 | void mbed_sdk_init() 33 | { 34 | // Update the SystemCoreClock variable. 35 | SystemCoreClockUpdate(); 36 | // Need to restart HAL driver after the RAM is initialized 37 | HAL_Init(); 38 | } 39 | 40 | /** 41 | * @brief This function provides accurate delay (in milliseconds) based 42 | * on variable incremented. 43 | * @note This function is the modified version of the __weak version contained in 44 | * stm32f4xx_hal.c, using us_ticker 45 | * @param Delay: specifies the delay time length, in milliseconds. 46 | * @retval None 47 | */ 48 | void HAL_Delay(__IO uint32_t Delay) 49 | { 50 | uint32_t start = us_ticker_read(); 51 | while ((us_ticker_read() - start) < (uint32_t)(Delay * 1000)); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/sleep.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | ******************************************************************************* 3 | * Copyright (c) 2014, STMicroelectronics 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ******************************************************************************* 29 | */ 30 | #include "sleep_api.h" 31 | #if DEVICE_SLEEP 32 | 33 | #include "cmsis.h" 34 | 35 | 36 | void sleep(void) { 37 | // Stop HAL systick 38 | HAL_SuspendTick(); 39 | // Request to enter SLEEP mode 40 | HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); 41 | // Restart HAL systick 42 | HAL_ResumeTick(); 43 | } 44 | 45 | void deepsleep(void) 46 | { 47 | // Request to enter STOP mode with regulator in low power mode 48 | HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); 49 | 50 | // After wake-up from STOP reconfigure the PLL 51 | SetSysClock(); 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/us_ticker.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015, STMicroelectronics 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include 29 | #include "us_ticker_api.h" 30 | #include "PeripheralNames.h" 31 | 32 | #ifdef TARGET_STM32F469 33 | #define TIM_MST TIM2 34 | #else 35 | #define TIM_MST TIM5 36 | #endif 37 | 38 | static TIM_HandleTypeDef TimMasterHandle; 39 | static int us_ticker_inited = 0; 40 | 41 | void us_ticker_init(void) 42 | { 43 | if (us_ticker_inited) return; 44 | us_ticker_inited = 1; 45 | 46 | TimMasterHandle.Instance = TIM_MST; 47 | 48 | HAL_InitTick(0); // The passed value is not used 49 | } 50 | 51 | uint32_t us_ticker_read() 52 | { 53 | if (!us_ticker_inited) us_ticker_init(); 54 | return TIM_MST->CNT; 55 | } 56 | 57 | void us_ticker_set_interrupt(timestamp_t timestamp) 58 | { 59 | // Set new output compare value 60 | __HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_1, (uint32_t)timestamp); 61 | // Enable IT 62 | __HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1); 63 | } 64 | 65 | void us_ticker_disable_interrupt(void) 66 | { 67 | __HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC1); 68 | } 69 | 70 | void us_ticker_clear_interrupt(void) 71 | { 72 | __HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1); 73 | } 74 | -------------------------------------------------------------------------------- /src/mbed_config.h: -------------------------------------------------------------------------------- 1 | // Automatically generated configuration file. 2 | // DO NOT EDIT, content will be overwritten. 3 | 4 | #ifndef __MBED_CONFIG_DATA__ 5 | #define __MBED_CONFIG_DATA__ 6 | 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/usb_cdc/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/usb_cdc/Inc/usb_device.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file : USB_DEVICE 4 | * @version : v1.0_Cube 5 | * @brief : Header for usb_device 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 | /* Define to prevent recursive inclusion -------------------------------------*/ 34 | #ifndef __usb_device_H 35 | #define __usb_device_H 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /* Includes ------------------------------------------------------------------*/ 41 | #include "stm32f4xx.h" 42 | #include "stm32f4xx_hal.h" 43 | #include "usbd_def.h" 44 | 45 | extern USBD_HandleTypeDef hUsbDeviceFS; 46 | 47 | /* USB_Device init function */ 48 | void MX_USB_DEVICE_Init(void); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | #endif /*__usb_device_H */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 64 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/FileBase.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FILEBASE_H 17 | #define MBED_FILEBASE_H 18 | 19 | typedef int FILEHANDLE; 20 | 21 | #include 22 | 23 | #if defined(__ARMCC_VERSION) || defined(__ICCARM__) 24 | # define O_RDONLY 0 25 | # define O_WRONLY 1 26 | # define O_RDWR 2 27 | # define O_CREAT 0x0200 28 | # define O_TRUNC 0x0400 29 | # define O_APPEND 0x0008 30 | 31 | # define NAME_MAX 255 32 | 33 | typedef int mode_t; 34 | typedef int ssize_t; 35 | typedef long off_t; 36 | 37 | #else 38 | # include 39 | # include 40 | # include 41 | #endif 42 | 43 | #include "platform.h" 44 | #include "SingletonPtr.h" 45 | #include "PlatformMutex.h" 46 | 47 | namespace mbed { 48 | 49 | typedef enum { 50 | FilePathType, 51 | FileSystemPathType 52 | } PathType; 53 | 54 | class FileBase { 55 | public: 56 | FileBase(const char *name, PathType t); 57 | 58 | virtual ~FileBase(); 59 | 60 | const char* getName(void); 61 | PathType getPathType(void); 62 | 63 | static FileBase *lookup(const char *name, unsigned int len); 64 | 65 | static FileBase *get(int n); 66 | 67 | /* disallow copy constructor and assignment operators */ 68 | private: 69 | static FileBase *_head; 70 | static SingletonPtr _mutex; 71 | 72 | FileBase *_next; 73 | const char * const _name; 74 | const PathType _path_type; 75 | FileBase(const FileBase&); 76 | FileBase & operator = (const FileBase&); 77 | }; 78 | 79 | } // namespace mbed 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/FileLike.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FILELIKE_H 17 | #define MBED_FILELIKE_H 18 | 19 | #include "FileBase.h" 20 | #include "FileHandle.h" 21 | 22 | namespace mbed { 23 | 24 | /* Class FileLike 25 | * A file-like object is one that can be opened with fopen by 26 | * fopen("/name", mode). It is intersection of the classes Base and 27 | * FileHandle. 28 | * 29 | * @Note Synchronization level: Set by subclass 30 | */ 31 | class FileLike : public FileHandle, public FileBase { 32 | 33 | public: 34 | /* Constructor FileLike 35 | * 36 | * Variables 37 | * name - The name to use to open the file. 38 | */ 39 | FileLike(const char *name); 40 | 41 | virtual ~FileLike(); 42 | 43 | }; 44 | 45 | } // namespace mbed 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/FilePath.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FILEPATH_H 17 | #define MBED_FILEPATH_H 18 | 19 | #include "platform.h" 20 | 21 | #include "FileSystemLike.h" 22 | #include "FileLike.h" 23 | 24 | namespace mbed { 25 | 26 | class FilePath { 27 | public: 28 | FilePath(const char* file_path); 29 | 30 | const char* fileName(void); 31 | 32 | bool isFileSystem(void); 33 | FileSystemLike* fileSystem(void); 34 | 35 | bool isFile(void); 36 | FileLike* file(void); 37 | bool exists(void); 38 | 39 | private: 40 | const char* file_name; 41 | FileBase* fb; 42 | }; 43 | 44 | } // namespace mbed 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/FunctionPointer.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_FUNCTIONPOINTER_H 17 | #define MBED_FUNCTIONPOINTER_H 18 | 19 | #include "Callback.h" 20 | #include "toolchain.h" 21 | #include 22 | #include 23 | 24 | namespace mbed { 25 | 26 | 27 | // Declarations for backwards compatibility 28 | // To be foward compatible, code should adopt the Callback class 29 | template 30 | class FunctionPointerArg1 : public Callback { 31 | public: 32 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 33 | "FunctionPointerArg1 has been replaced by Callback") 34 | FunctionPointerArg1(R (*function)(A1) = 0) 35 | : Callback(function) {} 36 | 37 | template 38 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 39 | "FunctionPointerArg1 has been replaced by Callback") 40 | FunctionPointerArg1(T *object, R (T::*member)(A1)) 41 | : Callback(object, member) {} 42 | 43 | R (*get_function())(A1) { 44 | return *reinterpret_cast(this); 45 | } 46 | }; 47 | 48 | template 49 | class FunctionPointerArg1 : public Callback { 50 | public: 51 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 52 | "FunctionPointer has been replaced by Callback") 53 | FunctionPointerArg1(R (*function)() = 0) 54 | : Callback(function) {} 55 | 56 | template 57 | MBED_DEPRECATED_SINCE("mbed-os-5.1", 58 | "FunctionPointer has been replaced by Callback") 59 | FunctionPointerArg1(T *object, R (T::*member)()) 60 | : Callback(object, member) {} 61 | 62 | R (*get_function())() { 63 | return *reinterpret_cast(this); 64 | } 65 | }; 66 | 67 | typedef FunctionPointerArg1 FunctionPointer; 68 | 69 | 70 | } // namespace mbed 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/LowPowerTicker.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_LOWPOWERTICKER_H 17 | #define MBED_LOWPOWERTICKER_H 18 | 19 | #include "platform.h" 20 | #include "Ticker.h" 21 | 22 | #if DEVICE_LOWPOWERTIMER 23 | 24 | #include "lp_ticker_api.h" 25 | 26 | namespace mbed { 27 | 28 | /** Low Power Ticker 29 | * 30 | * @Note Synchronization level: Interrupt safe 31 | */ 32 | class LowPowerTicker : public Ticker { 33 | 34 | public: 35 | LowPowerTicker() : Ticker(get_lp_ticker_data()) { 36 | } 37 | 38 | virtual ~LowPowerTicker() { 39 | } 40 | }; 41 | 42 | } // namespace mbed 43 | 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/LowPowerTimeout.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_LOWPOWERTIMEOUT_H 17 | #define MBED_LOWPOWERTIMEOUT_H 18 | 19 | #include "platform.h" 20 | 21 | #if DEVICE_LOWPOWERTIMER 22 | 23 | #include "lp_ticker_api.h" 24 | #include "LowPowerTicker.h" 25 | 26 | namespace mbed { 27 | 28 | /** Low Power Timout 29 | * 30 | * @Note Synchronization level: Interrupt safe 31 | */ 32 | class LowPowerTimeout : public LowPowerTicker { 33 | 34 | private: 35 | virtual void handler(void) { 36 | _function.call(); 37 | } 38 | }; 39 | 40 | } 41 | 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/LowPowerTimer.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2015 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_LOWPOWERTIMER_H 17 | #define MBED_LOWPOWERTIMER_H 18 | 19 | #include "platform.h" 20 | #include "Timer.h" 21 | 22 | #if DEVICE_LOWPOWERTIMER 23 | 24 | #include "lp_ticker_api.h" 25 | 26 | namespace mbed { 27 | 28 | /** Low power timer 29 | * 30 | * @Note Synchronization level: Interrupt safe 31 | */ 32 | class LowPowerTimer : public Timer { 33 | 34 | public: 35 | LowPowerTimer() : Timer(get_lp_ticker_data()) { 36 | } 37 | 38 | }; 39 | 40 | } // namespace mbed 41 | 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/PlatformMutex.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef PLATFORM_MUTEX_H 17 | #define PLATFORM_MUTEX_H 18 | 19 | #ifdef MBED_CONF_RTOS_PRESENT 20 | #include "Mutex.h" 21 | typedef rtos::Mutex PlatformMutex; 22 | #else 23 | /** A stub mutex for when an RTOS is not present 24 | */ 25 | class PlatformMutex { 26 | public: 27 | PlatformMutex() { 28 | // Stub 29 | 30 | } 31 | ~PlatformMutex() { 32 | // Stub 33 | } 34 | 35 | void lock() { 36 | // Do nothing 37 | } 38 | 39 | void unlock() { 40 | // Do nothing 41 | } 42 | }; 43 | 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/PortIn.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_PORTIN_H 17 | #define MBED_PORTIN_H 18 | 19 | #include "platform.h" 20 | 21 | #if DEVICE_PORTIN 22 | 23 | #include "port_api.h" 24 | #include "critical.h" 25 | 26 | namespace mbed { 27 | 28 | /** A multiple pin digital input 29 | * 30 | * @Note Synchronization level: Interrupt safe 31 | * 32 | * Example: 33 | * @code 34 | * // Switch on an LED if any of mbed pins 21-26 is high 35 | * 36 | * #include "mbed.h" 37 | * 38 | * PortIn p(Port2, 0x0000003F); // p21-p26 39 | * DigitalOut ind(LED4); 40 | * 41 | * int main() { 42 | * while(1) { 43 | * int pins = p.read(); 44 | * if(pins) { 45 | * ind = 1; 46 | * } else { 47 | * ind = 0; 48 | * } 49 | * } 50 | * } 51 | * @endcode 52 | */ 53 | class PortIn { 54 | public: 55 | 56 | /** Create an PortIn, connected to the specified port 57 | * 58 | * @param port Port to connect to (Port0-Port5) 59 | * @param mask A bitmask to identify which bits in the port should be included (0 - ignore) 60 | */ 61 | PortIn(PortName port, int mask = 0xFFFFFFFF) { 62 | core_util_critical_section_enter(); 63 | port_init(&_port, port, mask, PIN_INPUT); 64 | core_util_critical_section_exit(); 65 | } 66 | 67 | /** Read the value currently output on the port 68 | * 69 | * @returns 70 | * An integer with each bit corresponding to associated port pin setting 71 | */ 72 | int read() { 73 | return port_read(&_port); 74 | } 75 | 76 | /** Set the input pin mode 77 | * 78 | * @param mode PullUp, PullDown, PullNone, OpenDrain 79 | */ 80 | void mode(PinMode mode) { 81 | core_util_critical_section_enter(); 82 | port_mode(&_port, mode); 83 | core_util_critical_section_exit(); 84 | } 85 | 86 | /** A shorthand for read() 87 | */ 88 | operator int() { 89 | return read(); 90 | } 91 | 92 | private: 93 | port_t _port; 94 | }; 95 | 96 | } // namespace mbed 97 | 98 | #endif 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/can_helper.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_CAN_HELPER_H 17 | #define MBED_CAN_HELPER_H 18 | 19 | #if DEVICE_CAN 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | enum CANFormat { 26 | CANStandard = 0, 27 | CANExtended = 1, 28 | CANAny = 2 29 | }; 30 | typedef enum CANFormat CANFormat; 31 | 32 | enum CANType { 33 | CANData = 0, 34 | CANRemote = 1 35 | }; 36 | typedef enum CANType CANType; 37 | 38 | struct CAN_Message { 39 | unsigned int id; // 29 bit identifier 40 | unsigned char data[8]; // Data field 41 | unsigned char len; // Length of data field in bytes 42 | CANFormat format; // 0 - STANDARD, 1- EXTENDED IDENTIFIER 43 | CANType type; // 0 - DATA FRAME, 1 - REMOTE FRAME 44 | }; 45 | typedef struct CAN_Message CAN_Message; 46 | 47 | #ifdef __cplusplus 48 | }; 49 | #endif 50 | 51 | #endif 52 | 53 | #endif // MBED_CAN_HELPER_H 54 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/mbed.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_H 17 | #define MBED_H 18 | 19 | #define MBED_LIBRARY_VERSION 126 20 | 21 | #if MBED_CONF_RTOS_PRESENT 22 | #include "rtos/rtos.h" 23 | #endif 24 | 25 | #if MBED_CONF_NSAPI_PRESENT 26 | #include "network-socket/nsapi.h" 27 | #endif 28 | 29 | #include "toolchain.h" 30 | #include "platform.h" 31 | 32 | // Useful C libraries 33 | #include 34 | #include 35 | 36 | // mbed Debug libraries 37 | #include "mbed_error.h" 38 | #include "mbed_interface.h" 39 | #include "mbed_assert.h" 40 | 41 | // mbed Peripheral components 42 | #include "DigitalIn.h" 43 | #include "DigitalOut.h" 44 | #include "DigitalInOut.h" 45 | #include "BusIn.h" 46 | #include "BusOut.h" 47 | #include "BusInOut.h" 48 | #include "PortIn.h" 49 | #include "PortInOut.h" 50 | #include "PortOut.h" 51 | #include "AnalogIn.h" 52 | #include "AnalogOut.h" 53 | #include "PwmOut.h" 54 | #include "Serial.h" 55 | #include "SPI.h" 56 | #include "SPISlave.h" 57 | #include "I2C.h" 58 | #include "I2CSlave.h" 59 | #include "Ethernet.h" 60 | #include "CAN.h" 61 | #include "RawSerial.h" 62 | 63 | // mbed Internal components 64 | #include "Timer.h" 65 | #include "Ticker.h" 66 | #include "Timeout.h" 67 | #include "LowPowerTimeout.h" 68 | #include "LowPowerTicker.h" 69 | #include "LowPowerTimer.h" 70 | #include "LocalFileSystem.h" 71 | #include "InterruptIn.h" 72 | #include "wait_api.h" 73 | #include "sleep_api.h" 74 | #include "rtc_time.h" 75 | 76 | // mbed Non-hardware components 77 | #include "Callback.h" 78 | #include "FunctionPointer.h" 79 | 80 | using namespace mbed; 81 | using namespace std; 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/mbed_assert.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_ASSERT_H 17 | #define MBED_ASSERT_H 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /** Internal mbed assert function which is invoked when MBED_ASSERT macro failes. 24 | * This function is active only if NDEBUG is not defined prior to including this 25 | * assert header file. 26 | * In case of MBED_ASSERT failing condition, error() is called with the assertation message. 27 | * @param expr Expresion to be checked. 28 | * @param file File where assertation failed. 29 | * @param line Failing assertation line number. 30 | */ 31 | void mbed_assert_internal(const char *expr, const char *file, int line); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #ifdef NDEBUG 38 | #define MBED_ASSERT(expr) ((void)0) 39 | 40 | #else 41 | #define MBED_ASSERT(expr) \ 42 | do { \ 43 | if (!(expr)) { \ 44 | mbed_assert_internal(#expr, __FILE__, __LINE__); \ 45 | } \ 46 | } while (0) 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/mbed_debug.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_DEBUG_H 17 | #define MBED_DEBUG_H 18 | #include "device.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #if DEVICE_STDIO_MESSAGES 25 | #include 26 | #include 27 | 28 | /** Output a debug message 29 | * 30 | * @param format printf-style format string, followed by variables 31 | */ 32 | static inline void debug(const char *format, ...) { 33 | va_list args; 34 | va_start(args, format); 35 | vfprintf(stderr, format, args); 36 | va_end(args); 37 | } 38 | 39 | /** Conditionally output a debug message 40 | * 41 | * NOTE: If the condition is constant false (!= 1) and the compiler optimization 42 | * level is greater than 0, then the whole function will be compiled away. 43 | * 44 | * @param condition output only if condition is true (== 1) 45 | * @param format printf-style format string, followed by variables 46 | */ 47 | static inline void debug_if(int condition, const char *format, ...) { 48 | if (condition == 1) { 49 | va_list args; 50 | va_start(args, format); 51 | vfprintf(stderr, format, args); 52 | va_end(args); 53 | } 54 | } 55 | 56 | #else 57 | static inline void debug(const char *format, ...) {} 58 | static inline void debug_if(int condition, const char *format, ...) {} 59 | 60 | #endif 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/mbed_error.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_ERROR_H 17 | #define MBED_ERROR_H 18 | 19 | /** To generate a fatal compile-time error, you can use the pre-processor #error directive. 20 | * 21 | * @code 22 | * #error "That shouldn't have happened!" 23 | * @endcode 24 | * 25 | * If the compiler evaluates this line, it will report the error and stop the compile. 26 | * 27 | * For example, you could use this to check some user-defined compile-time variables: 28 | * 29 | * @code 30 | * #define NUM_PORTS 7 31 | * #if (NUM_PORTS > 4) 32 | * #error "NUM_PORTS must be less than 4" 33 | * #endif 34 | * @endcode 35 | * 36 | * Reporting Run-Time Errors: 37 | * To generate a fatal run-time error, you can use the mbed error() function. 38 | * 39 | * @code 40 | * error("That shouldn't have happened!"); 41 | * @endcode 42 | * 43 | * If the mbed running the program executes this function, it will print the 44 | * message via the USB serial port, and then die with the blue lights of death! 45 | * 46 | * The message can use printf-style formatting, so you can report variables in the 47 | * message too. For example, you could use this to check a run-time condition: 48 | * 49 | * @code 50 | * if(x >= 5) { 51 | * error("expected x to be less than 5, but got %d", x); 52 | * } 53 | * #endcode 54 | */ 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | void error(const char* format, ...); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/mbed_stats.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2016-2016 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_STATS_H 17 | #define MBED_STATS_H 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef struct { 24 | uint32_t current_size; /**< Bytes allocated currently. */ 25 | uint32_t max_size; /**< Max bytes allocated at a given time. */ 26 | uint32_t total_size; /**< Cumulative sum of bytes ever allocated. */ 27 | uint32_t alloc_cnt; /**< Current number of allocations. */ 28 | uint32_t alloc_fail_cnt; /**< Number of failed allocations. */ 29 | } mbed_stats_heap_t; 30 | 31 | /** 32 | * Fill the passed in structure with heap stats. 33 | */ 34 | void mbed_stats_heap_get(mbed_stats_heap_t *stats); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/api/platform.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2006-2013 ARM Limited 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef MBED_PLATFORM_H 17 | #define MBED_PLATFORM_H 18 | 19 | #include "device.h" 20 | #include "PinNames.h" 21 | #include "PeripheralNames.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mbed-classic", 3 | "version": "0.0.1", 4 | "description": "mbed core SDK (for mbed 2.0, *not* mbedOS)", 5 | "keywords": [ 6 | "mbed" 7 | ], 8 | "author": "Bogdan Marinescu ", 9 | "repository": { 10 | "url": "git@github.com:mbedmicro/mbed.git", 11 | "type": "git" 12 | }, 13 | "homepage": "https://github.com/mbedmicro/mbed", 14 | "licenses": [ 15 | { 16 | "url": "https://spdx.org/licenses/Apache-2.0", 17 | "type": "Apache-2.0" 18 | } 19 | ], 20 | "extraIncludes": [ 21 | "api", 22 | "hal", 23 | "targets/hal", 24 | "targets/cmsis" 25 | ], 26 | "dependencies": { 27 | }, 28 | "targetDependencies": { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/stm32f401xe.sct: -------------------------------------------------------------------------------- 1 | ; Scatter-Loading Description File 2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3 | ; Copyright (c) 2014, STMicroelectronics 4 | ; All rights reserved. 5 | ; 6 | ; Redistribution and use in source and binary forms, with or without 7 | ; modification, are permitted provided that the following conditions are met: 8 | ; 9 | ; 1. Redistributions of source code must retain the above copyright notice, 10 | ; this list of conditions and the following disclaimer. 11 | ; 2. Redistributions in binary form must reproduce the above copyright notice, 12 | ; this list of conditions and the following disclaimer in the documentation 13 | ; and/or other materials provided with the distribution. 14 | ; 3. Neither the name of STMicroelectronics nor the names of its contributors 15 | ; may be used to endorse or promote products derived from this software 16 | ; without specific prior written permission. 17 | ; 18 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | ; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 29 | 30 | ; STM32F401RE: 512KB FLASH + 96KB SRAM 31 | LR_IROM1 0x08000000 0x80000 { ; load region size_region 32 | 33 | ER_IROM1 0x08000000 0x80000 { ; load address = execution address 34 | *.o (RESET, +First) 35 | *(InRoot$$Sections) 36 | .ANY (+RO) 37 | } 38 | 39 | ; Total: 101 vectors = 404 bytes (0x194) to be reserved in RAM 40 | RW_IRAM1 (0x20000000+0x194) (0x18000-0x194) { ; RW data 41 | .ANY (+RW +ZI) 42 | } 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/TOOLCHAIN_ARM_STD/sys.cpp: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library - stackheap 2 | * Setup a fixed single stack/heap memory model, 3 | * between the top of the RW/ZI region and the stackpointer 4 | ******************************************************************************* 5 | * Copyright (c) 2014, STMicroelectronics 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 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 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | #include 39 | 40 | extern char Image$$RW_IRAM1$$ZI$$Limit[]; 41 | 42 | extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) { 43 | uint32_t zi_limit = (uint32_t)Image$$RW_IRAM1$$ZI$$Limit; 44 | uint32_t sp_limit = __current_sp(); 45 | 46 | zi_limit = (zi_limit + 7) & ~0x7; // ensure zi_limit is 8-byte aligned 47 | 48 | struct __initial_stackheap r; 49 | r.heap_base = zi_limit; 50 | r.heap_limit = sp_limit; 51 | return r; 52 | } 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/cmsis.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * A generic CMSIS include header 3 | ******************************************************************************* 4 | * Copyright (c) 2014, STMicroelectronics 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 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 | #ifndef MBED_CMSIS_H 33 | #define MBED_CMSIS_H 34 | 35 | #include "stm32f4xx.h" 36 | #include "cmsis_nvic.h" 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/cmsis_nvic.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * CMSIS-style functionality to support dynamic vectors 3 | ******************************************************************************* 4 | * Copyright (c) 2014, STMicroelectronics 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 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 | #ifndef MBED_CMSIS_NVIC_H 33 | #define MBED_CMSIS_NVIC_H 34 | 35 | // STM32F401RE 36 | // CORE: 16 vectors = 64 bytes from 0x00 to 0x3F 37 | // MCU Peripherals: 85 vectors = 340 bytes from 0x40 to ... 38 | // Total: 101 vectors = 404 bytes (0x194) to be reserved in RAM 39 | #define NVIC_NUM_VECTORS 101 40 | #define NVIC_USER_IRQ_OFFSET 16 41 | 42 | #include "cmsis.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector); 49 | uint32_t NVIC_GetVector(IRQn_Type IRQn); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/hal_tick.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file hal_tick.h 4 | * @author MCD Application Team 5 | * @brief Initialization of HAL tick 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2014 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | #ifndef __HAL_TICK_H 36 | #define __HAL_TICK_H 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | #include "stm32f4xx.h" 43 | #include "cmsis_nvic.h" 44 | 45 | #define TIM_MST TIM5 46 | #define TIM_MST_IRQ TIM5_IRQn 47 | #define TIM_MST_RCC __TIM5_CLK_ENABLE() 48 | 49 | #define TIM_MST_RESET_ON __TIM5_FORCE_RESET() 50 | #define TIM_MST_RESET_OFF __TIM5_RELEASE_RESET() 51 | 52 | #define HAL_TICK_DELAY (1000) // 1 ms 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif // __HAL_TICK_H 59 | 60 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 61 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_ltdc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lora-net/picoGW_mcu/9aec67e25356e8980e7aac2be7f03f30450b816c/src/usb_cdc/mbed-dev/targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_ltdc.c -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/PeripheralPins.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | ******************************************************************************* 3 | * Copyright (c) 2014, STMicroelectronics 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ******************************************************************************* 29 | */ 30 | 31 | #ifndef MBED_PERIPHERALPINS_H 32 | #define MBED_PERIPHERALPINS_H 33 | 34 | #include "pinmap.h" 35 | #include "PeripheralNames.h" 36 | 37 | //*** ADC *** 38 | 39 | extern const PinMap PinMap_ADC[]; 40 | 41 | //*** DAC *** 42 | 43 | extern const PinMap PinMap_DAC[]; 44 | 45 | //*** I2C *** 46 | 47 | extern const PinMap PinMap_I2C_SDA[]; 48 | extern const PinMap PinMap_I2C_SCL[]; 49 | 50 | //*** PWM *** 51 | 52 | extern const PinMap PinMap_PWM[]; 53 | 54 | //*** SERIAL *** 55 | 56 | extern const PinMap PinMap_UART_TX[]; 57 | extern const PinMap PinMap_UART_RX[]; 58 | extern const PinMap PinMap_UART_RTS[]; 59 | extern const PinMap PinMap_UART_CTS[]; 60 | 61 | //*** SPI *** 62 | 63 | extern const PinMap PinMap_SPI_MOSI[]; 64 | extern const PinMap PinMap_SPI_MISO[]; 65 | extern const PinMap PinMap_SPI_SCLK[]; 66 | extern const PinMap PinMap_SPI_SSEL[]; 67 | 68 | //*** CAN *** 69 | extern const PinMap PinMap_CAN_RD[]; 70 | extern const PinMap PinMap_CAN_TD[]; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F401RE/PortNames.h: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | ******************************************************************************* 3 | * Copyright (c) 2014, STMicroelectronics 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ******************************************************************************* 29 | */ 30 | #ifndef MBED_PORTNAMES_H 31 | #define MBED_PORTNAMES_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | typedef enum { 38 | PortA = 0, 39 | PortB = 1, 40 | PortC = 2, 41 | PortD = 3, 42 | PortE = 4, 43 | PortH = 7 44 | } PortName; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #endif 50 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/device.h: -------------------------------------------------------------------------------- 1 | // The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches. 2 | // Check the 'features' section of the target description in 'targets.json' for more details. 3 | /* mbed Microcontroller Library 4 | ******************************************************************************* 5 | * Copyright (c) 2014, STMicroelectronics 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 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 | #ifndef MBED_DEVICE_H 33 | #define MBED_DEVICE_H 34 | 35 | //======================================= 36 | #define DEVICE_ID_LENGTH 24 37 | 38 | #include "objects.h" 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/mbed_overrides.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | * Copyright (c) 2014, STMicroelectronics 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #include "cmsis.h" 29 | #include "us_ticker_api.h" 30 | 31 | // This function is called after RAM initialization and before main. 32 | void mbed_sdk_init() 33 | { 34 | // Update the SystemCoreClock variable. 35 | SystemCoreClockUpdate(); 36 | // Need to restart HAL driver after the RAM is initialized 37 | HAL_Init(); 38 | } 39 | 40 | /** 41 | * @brief This function provides accurate delay (in milliseconds) based 42 | * on variable incremented. 43 | * @note This function is the modified version of the __weak version contained in 44 | * stm32f4xx_hal.c, using us_ticker 45 | * @param Delay: specifies the delay time length, in milliseconds. 46 | * @retval None 47 | */ 48 | void HAL_Delay(__IO uint32_t Delay) 49 | { 50 | uint32_t start = us_ticker_read(); 51 | while ((us_ticker_read() - start) < (uint32_t)(Delay * 1000)); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/usb_cdc/mbed-dev/targets/hal/TARGET_STM/TARGET_STM32F4/sleep.c: -------------------------------------------------------------------------------- 1 | /* mbed Microcontroller Library 2 | ******************************************************************************* 3 | * Copyright (c) 2014, STMicroelectronics 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, 12 | * this list of conditions and the following disclaimer in the documentation 13 | * and/or other materials provided with the distribution. 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ******************************************************************************* 29 | */ 30 | #include "sleep_api.h" 31 | #if DEVICE_SLEEP 32 | 33 | #include "cmsis.h" 34 | 35 | 36 | void sleep(void) { 37 | // Stop HAL systick 38 | HAL_SuspendTick(); 39 | // Request to enter SLEEP mode 40 | HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); 41 | // Restart HAL systick 42 | HAL_ResumeTick(); 43 | } 44 | 45 | void deepsleep(void) 46 | { 47 | // Request to enter STOP mode with regulator in low power mode 48 | HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); 49 | 50 | // After wake-up from STOP reconfigure the PLL 51 | SetSysClock(); 52 | } 53 | 54 | #endif 55 | --------------------------------------------------------------------------------