Repository: scottalford75/Remora Branch: main Commit: 09d7e2416da4 Files: 813 Total size: 3.7 MB Directory structure: gitextract_caxq2qkb/ ├── .gitignore ├── Firmware/ │ ├── ConfigSamples/ │ │ ├── BTT_Octopus/ │ │ │ ├── OCTOPUS_ENDER3/ │ │ │ │ └── config.txt │ │ │ └── OCTOPUS_xyz/ │ │ │ └── config.txt │ │ ├── BTT_SKRv13/ │ │ │ └── config.txt │ │ ├── BTT_SKRv14/ │ │ │ ├── SKRv14_3dp/ │ │ │ │ └── config.txt │ │ │ ├── SKRv14_TMC2209/ │ │ │ │ └── config.txt │ │ │ └── SKRv14_xyz/ │ │ │ └── config.txt │ │ ├── BTT_SKRv2/ │ │ │ ├── SKRv2_TMC2209/ │ │ │ │ └── config.txt │ │ │ ├── SKRv2_ender3/ │ │ │ │ └── config.txt │ │ │ └── SKRv2_xyz/ │ │ │ └── config.txt │ │ ├── Fysetc_Spider/ │ │ │ └── config.txt │ │ ├── Fysetc_Spider_King/ │ │ │ └── config.txt │ │ ├── Hypercube-evolution/ │ │ │ └── config.txt │ │ ├── MKS_Monster8/ │ │ │ └── config.txt │ │ ├── MKS_Robin_E3/ │ │ │ └── Robin_E3/ │ │ │ └── config.txt │ │ ├── MKS_Sbase/ │ │ │ └── MKS Sbase/ │ │ │ ├── Ender3/ │ │ │ │ └── config.txt-Ender3 │ │ │ └── config.txt │ │ └── TMC2209 Example/ │ │ ├── SKRv14_TMC2209/ │ │ │ └── config.txt │ │ └── SKRv2_TMC2209/ │ │ └── config.txt │ └── FirmwareSource/ │ ├── .gitignore │ ├── Remora-OS5/ │ │ ├── .gitignore │ │ ├── .mbed │ │ ├── MODDMA.lib │ │ ├── README.md │ │ ├── SoftwareSerial/ │ │ │ ├── SoftwareSerial.cpp │ │ │ └── SoftwareSerial.h │ │ ├── TARGET_OCTOPUS_429/ │ │ │ ├── PeripheralNames.h │ │ │ ├── PeripheralPins.c │ │ │ ├── PinNames.h │ │ │ └── system_clock.c │ │ ├── TARGET_OCTOPUS_446/ │ │ │ ├── PeripheralNames.h │ │ │ ├── PeripheralPins.c │ │ │ ├── PinNames.h │ │ │ └── system_clock.c │ │ ├── TARGET_ROBIN_E3/ │ │ │ ├── PeripheralNames.h │ │ │ ├── PeripheralPins.c │ │ │ ├── PinNames.h │ │ │ └── system_clock.c │ │ ├── TARGET_SKRV1_4/ │ │ │ ├── drivers/ │ │ │ │ ├── comms/ │ │ │ │ │ ├── MODDMA/ │ │ │ │ │ │ ├── .hg/ │ │ │ │ │ │ │ ├── 00changelog.i │ │ │ │ │ │ │ ├── branch │ │ │ │ │ │ │ ├── cache/ │ │ │ │ │ │ │ │ ├── branch2-base │ │ │ │ │ │ │ │ ├── rbc-names-v1 │ │ │ │ │ │ │ │ ├── rbc-revs-v1 │ │ │ │ │ │ │ │ └── tags2-visible │ │ │ │ │ │ │ ├── dirstate │ │ │ │ │ │ │ ├── hgrc │ │ │ │ │ │ │ ├── requires │ │ │ │ │ │ │ ├── store/ │ │ │ │ │ │ │ │ ├── 00changelog.i │ │ │ │ │ │ │ │ ├── 00manifest.i │ │ │ │ │ │ │ │ ├── data/ │ │ │ │ │ │ │ │ │ ├── _c_o_n_f_i_g.h.i │ │ │ │ │ │ │ │ │ ├── _change_log.c.i │ │ │ │ │ │ │ │ │ ├── _d_a_t_a_l_u_t_s.cpp.i │ │ │ │ │ │ │ │ │ ├── _i_n_i_t.cpp.i │ │ │ │ │ │ │ │ │ ├── _m_o_d_d_m_a.cpp.i │ │ │ │ │ │ │ │ │ ├── _m_o_d_d_m_a.h.i │ │ │ │ │ │ │ │ │ ├── _s_e_t_u_p.cpp.i │ │ │ │ │ │ │ │ │ ├── example1.cpp.i │ │ │ │ │ │ │ │ │ ├── example1.h.i │ │ │ │ │ │ │ │ │ ├── example2.cpp.i │ │ │ │ │ │ │ │ │ ├── example2.h.i │ │ │ │ │ │ │ │ │ ├── example3.h.i │ │ │ │ │ │ │ │ │ ├── example4.h.i │ │ │ │ │ │ │ │ │ └── iomacros.h.i │ │ │ │ │ │ │ │ └── fncache │ │ │ │ │ │ │ ├── thgstatus │ │ │ │ │ │ │ └── wcache/ │ │ │ │ │ │ │ └── manifestfulltextcache │ │ │ │ │ │ ├── CONFIG.h │ │ │ │ │ │ ├── ChangeLog.c │ │ │ │ │ │ ├── DATALUTS.cpp │ │ │ │ │ │ ├── INIT.cpp │ │ │ │ │ │ ├── MODDMA.cpp │ │ │ │ │ │ ├── MODDMA.h │ │ │ │ │ │ ├── SETUP.cpp │ │ │ │ │ │ ├── example1.h │ │ │ │ │ │ ├── example2.h │ │ │ │ │ │ ├── example3.h │ │ │ │ │ │ ├── example4.h │ │ │ │ │ │ └── iomacros.h │ │ │ │ │ ├── MODDMA.lib │ │ │ │ │ ├── RemoraComms.cpp │ │ │ │ │ └── RemoraComms.h │ │ │ │ ├── pin/ │ │ │ │ │ ├── pin.cpp │ │ │ │ │ └── pin.h │ │ │ │ └── qei/ │ │ │ │ ├── qeiDriver.cpp │ │ │ │ └── qeiDriver.h │ │ │ └── thread/ │ │ │ ├── createThreads.h │ │ │ ├── interrupt.cpp │ │ │ ├── interrupt.h │ │ │ ├── irqHandlers.h │ │ │ ├── pruThread.cpp │ │ │ ├── pruThread.h │ │ │ ├── qeiInterrupt.cpp │ │ │ ├── qeiInterrupt.h │ │ │ ├── timer.cpp │ │ │ └── timer.h │ │ ├── TARGET_SKRV2/ │ │ │ ├── PeripheralNames.h │ │ │ ├── PeripheralPins.c │ │ │ ├── PinNames.h │ │ │ └── system_clock.c │ │ ├── TARGET_SKR_MINI_E3/ │ │ │ ├── PeripheralNames.h │ │ │ ├── PeripheralPins.c │ │ │ ├── PinNames.h │ │ │ └── system_clock.c │ │ ├── TARGET_STM32F1/ │ │ │ ├── drivers/ │ │ │ │ ├── comms/ │ │ │ │ │ ├── RemoraComms.cpp │ │ │ │ │ └── RemoraComms.h │ │ │ │ ├── pin/ │ │ │ │ │ ├── pin.cpp │ │ │ │ │ └── pin.h │ │ │ │ └── qei/ │ │ │ │ ├── qeiDriver.cpp │ │ │ │ └── qeiDriver.h │ │ │ └── thread/ │ │ │ ├── createThreads.h │ │ │ ├── interrupt.cpp │ │ │ ├── interrupt.h │ │ │ ├── irqHandlers.h │ │ │ ├── pruThread.cpp │ │ │ ├── pruThread.h │ │ │ ├── timer.cpp │ │ │ └── timer.h │ │ ├── TARGET_STM32F103xC/ │ │ │ ├── device/ │ │ │ │ ├── TOOLCHAIN_ARM/ │ │ │ │ │ ├── startup_stm32f103xe.S │ │ │ │ │ └── stm32f103xe.sct │ │ │ │ ├── cmsis_nvic.h │ │ │ │ ├── stm32f103xe.h │ │ │ │ ├── stm32f1xx.h │ │ │ │ ├── system_stm32f1xx.h │ │ │ │ └── us_ticker_data.h │ │ │ └── objects.h │ │ ├── TARGET_STM32F4/ │ │ │ ├── drivers/ │ │ │ │ ├── SDIO/ │ │ │ │ │ ├── SDIOBlockDevice.cpp │ │ │ │ │ ├── SDIOBlockDevice.h │ │ │ │ │ ├── sdio_device.c │ │ │ │ │ └── sdio_device.h │ │ │ │ ├── comms/ │ │ │ │ │ ├── RemoraComms.cpp │ │ │ │ │ └── RemoraComms.h │ │ │ │ ├── pin/ │ │ │ │ │ ├── pin.cpp │ │ │ │ │ └── pin.h │ │ │ │ └── qei/ │ │ │ │ ├── qeiDriver.cpp │ │ │ │ └── qeiDriver.h │ │ │ └── thread/ │ │ │ ├── createThreads.h │ │ │ ├── interrupt.cpp │ │ │ ├── interrupt.h │ │ │ ├── irqHandlers.h │ │ │ ├── pruThread.cpp │ │ │ ├── pruThread.h │ │ │ ├── timer.cpp │ │ │ └── timer.h │ │ ├── TMCStepper/ │ │ │ ├── .hg/ │ │ │ │ ├── 00changelog.i │ │ │ │ ├── branch │ │ │ │ ├── cache/ │ │ │ │ │ ├── branch2-base │ │ │ │ │ ├── rbc-names-v1 │ │ │ │ │ ├── rbc-revs-v1 │ │ │ │ │ └── tags2-visible │ │ │ │ ├── dirstate │ │ │ │ ├── hgrc │ │ │ │ ├── requires │ │ │ │ ├── store/ │ │ │ │ │ ├── 00changelog.i │ │ │ │ │ ├── 00manifest.i │ │ │ │ │ ├── data/ │ │ │ │ │ │ ├── _c_h_o_p_c_o_n_f.cpp.i │ │ │ │ │ │ ├── _d_r_v___s_t_a_t_u_s.cpp.i │ │ │ │ │ │ ├── _g_c_o_n_f.cpp.i │ │ │ │ │ │ ├── _i_h_o_l_d___i_r_u_n.cpp.i │ │ │ │ │ │ ├── _p_w_m_c_o_n_f.cpp.i │ │ │ │ │ │ ├── _t_m_c2208__bitfields.h.i │ │ │ │ │ │ ├── _t_m_c2208_stepper.cpp.i │ │ │ │ │ │ ├── _t_m_c2209__bitfields.h.i │ │ │ │ │ │ ├── _t_m_c2209_stepper.cpp.i │ │ │ │ │ │ ├── _t_m_c___m_a_c_r_o_s.h.i │ │ │ │ │ │ ├── _t_m_c_stepper.cpp.i │ │ │ │ │ │ └── _t_m_c_stepper.h.i │ │ │ │ │ └── fncache │ │ │ │ ├── thgstatus │ │ │ │ └── wcache/ │ │ │ │ └── manifestfulltextcache │ │ │ ├── CHOPCONF.cpp │ │ │ ├── COOLCONF.cpp │ │ │ ├── DRV_STATUS.cpp │ │ │ ├── GCONF.cpp │ │ │ ├── IHOLD_IRUN.cpp │ │ │ ├── PWMCONF.cpp │ │ │ ├── TMC2208Stepper.cpp │ │ │ ├── TMC2208_bitfields.h │ │ │ ├── TMC2209Stepper.cpp │ │ │ ├── TMC2209_bitfields.h │ │ │ ├── TMCStepper.cpp │ │ │ ├── TMCStepper.h │ │ │ └── TMC_MACROS.h │ │ ├── WIZnetInterface-OS5/ │ │ │ ├── .hg/ │ │ │ │ ├── 00changelog.i │ │ │ │ ├── branch │ │ │ │ ├── cache/ │ │ │ │ │ ├── branch2-base │ │ │ │ │ ├── rbc-names-v1 │ │ │ │ │ ├── rbc-revs-v1 │ │ │ │ │ └── tags2-visible │ │ │ │ ├── dirstate │ │ │ │ ├── hgrc │ │ │ │ ├── requires │ │ │ │ ├── store/ │ │ │ │ │ ├── 00changelog.i │ │ │ │ │ ├── 00manifest.i │ │ │ │ │ ├── data/ │ │ │ │ │ │ ├── _socket/ │ │ │ │ │ │ │ ├── _d_h_c_p_client.cpp.i │ │ │ │ │ │ │ ├── _d_h_c_p_client.h.i │ │ │ │ │ │ │ ├── _d_n_s_client.cpp.i │ │ │ │ │ │ │ ├── _d_n_s_client.h.i │ │ │ │ │ │ │ ├── _endpoint.cpp.i │ │ │ │ │ │ │ ├── _endpoint.h.i │ │ │ │ │ │ │ ├── _t_c_p_socket_connection.cpp.i │ │ │ │ │ │ │ ├── _t_c_p_socket_connection.h.i │ │ │ │ │ │ │ ├── _t_c_p_socket_server.cpp.i │ │ │ │ │ │ │ ├── _t_c_p_socket_server.h.i │ │ │ │ │ │ │ ├── _w_i_znet___socket.cpp.i │ │ │ │ │ │ │ ├── _w_i_znet___socket.h.i │ │ │ │ │ │ │ ├── _w_i_znet___u_d_p_socket.cpp.i │ │ │ │ │ │ │ ├── _w_i_znet___u_d_p_socket.h.i │ │ │ │ │ │ │ ├── dnsname.h.i │ │ │ │ │ │ │ └── pico__string.h.i │ │ │ │ │ │ ├── _w_i_znet_interface.cpp.i │ │ │ │ │ │ ├── _w_i_znet_interface.h.i │ │ │ │ │ │ ├── arch/ │ │ │ │ │ │ │ ├── ext/ │ │ │ │ │ │ │ │ ├── _w5500.cpp.i │ │ │ │ │ │ │ │ └── _w5500.h.i │ │ │ │ │ │ │ └── int/ │ │ │ │ │ │ │ ├── _w7500x__toe.cpp.i │ │ │ │ │ │ │ └── _w7500x__toe.h.i │ │ │ │ │ │ └── eth__arch.h.i │ │ │ │ │ └── fncache │ │ │ │ └── wcache/ │ │ │ │ └── manifestfulltextcache │ │ │ ├── Socket/ │ │ │ │ ├── DHCPClient.cpp │ │ │ │ ├── DHCPClient.h │ │ │ │ ├── DNSClient.cpp │ │ │ │ ├── DNSClient.h │ │ │ │ ├── Endpoint.cpp │ │ │ │ ├── Endpoint.h │ │ │ │ ├── TCPSocketConnection.cpp │ │ │ │ ├── TCPSocketConnection.h │ │ │ │ ├── TCPSocketServer.cpp │ │ │ │ ├── TCPSocketServer.h │ │ │ │ ├── WIZnet_Socket.cpp │ │ │ │ ├── WIZnet_Socket.h │ │ │ │ ├── WIZnet_UDPSocket.cpp │ │ │ │ ├── WIZnet_UDPSocket.h │ │ │ │ ├── dnsname.h │ │ │ │ └── pico_string.h │ │ │ ├── WIZnetInterface.cpp │ │ │ ├── WIZnetInterface.h │ │ │ ├── arch/ │ │ │ │ ├── ext/ │ │ │ │ │ ├── W5500.cpp │ │ │ │ │ └── W5500.h │ │ │ │ └── int/ │ │ │ │ ├── W7500x_toe.cpp │ │ │ │ └── W7500x_toe.h │ │ │ └── eth_arch.h │ │ ├── WIZnetInterface-OS5.lib │ │ ├── configuration.h │ │ ├── custom_targets.json │ │ ├── drivers/ │ │ │ └── softPwm/ │ │ │ ├── softPwm.cpp │ │ │ └── softPwm.h │ │ ├── extern.h │ │ ├── lib/ │ │ │ └── ArduinoJson6/ │ │ │ ├── ArduinoJson/ │ │ │ │ ├── Array/ │ │ │ │ │ ├── ArrayFunctions.hpp │ │ │ │ │ ├── ArrayImpl.hpp │ │ │ │ │ ├── ArrayIterator.hpp │ │ │ │ │ ├── ArrayRef.hpp │ │ │ │ │ ├── ArrayShortcuts.hpp │ │ │ │ │ ├── ElementProxy.hpp │ │ │ │ │ └── Utilities.hpp │ │ │ │ ├── Collection/ │ │ │ │ │ ├── CollectionData.hpp │ │ │ │ │ └── CollectionImpl.hpp │ │ │ │ ├── Configuration.hpp │ │ │ │ ├── Deserialization/ │ │ │ │ │ ├── ArduinoStreamReader.hpp │ │ │ │ │ ├── CharPointerReader.hpp │ │ │ │ │ ├── DeserializationError.hpp │ │ │ │ │ ├── FlashStringReader.hpp │ │ │ │ │ ├── IteratorReader.hpp │ │ │ │ │ ├── NestingLimit.hpp │ │ │ │ │ ├── StdStreamReader.hpp │ │ │ │ │ └── deserialize.hpp │ │ │ │ ├── Document/ │ │ │ │ │ ├── BasicJsonDocument.hpp │ │ │ │ │ ├── DynamicJsonDocument.hpp │ │ │ │ │ ├── JsonDocument.hpp │ │ │ │ │ └── StaticJsonDocument.hpp │ │ │ │ ├── Json/ │ │ │ │ │ ├── EscapeSequence.hpp │ │ │ │ │ ├── JsonDeserializer.hpp │ │ │ │ │ ├── JsonSerializer.hpp │ │ │ │ │ ├── PrettyJsonSerializer.hpp │ │ │ │ │ ├── TextFormatter.hpp │ │ │ │ │ └── Utf8.hpp │ │ │ │ ├── Memory/ │ │ │ │ │ ├── Alignment.hpp │ │ │ │ │ ├── MemoryPool.hpp │ │ │ │ │ ├── StringBuilder.hpp │ │ │ │ │ └── StringSlot.hpp │ │ │ │ ├── Misc/ │ │ │ │ │ ├── SerializedValue.hpp │ │ │ │ │ └── Visitable.hpp │ │ │ │ ├── MsgPack/ │ │ │ │ │ ├── MsgPackDeserializer.hpp │ │ │ │ │ ├── MsgPackSerializer.hpp │ │ │ │ │ ├── endianess.hpp │ │ │ │ │ └── ieee754.hpp │ │ │ │ ├── Namespace.hpp │ │ │ │ ├── Numbers/ │ │ │ │ │ ├── Float.hpp │ │ │ │ │ ├── FloatParts.hpp │ │ │ │ │ ├── FloatTraits.hpp │ │ │ │ │ ├── Integer.hpp │ │ │ │ │ ├── convertNumber.hpp │ │ │ │ │ ├── parseFloat.hpp │ │ │ │ │ ├── parseInteger.hpp │ │ │ │ │ └── parseNumber.hpp │ │ │ │ ├── Object/ │ │ │ │ │ ├── MemberProxy.hpp │ │ │ │ │ ├── ObjectFunctions.hpp │ │ │ │ │ ├── ObjectImpl.hpp │ │ │ │ │ ├── ObjectIterator.hpp │ │ │ │ │ ├── ObjectRef.hpp │ │ │ │ │ ├── ObjectShortcuts.hpp │ │ │ │ │ └── Pair.hpp │ │ │ │ ├── Operators/ │ │ │ │ │ ├── VariantCasts.hpp │ │ │ │ │ ├── VariantComparisons.hpp │ │ │ │ │ ├── VariantOperators.hpp │ │ │ │ │ ├── VariantOr.hpp │ │ │ │ │ └── VariantShortcuts.hpp │ │ │ │ ├── Polyfills/ │ │ │ │ │ ├── alias_cast.hpp │ │ │ │ │ ├── assert.hpp │ │ │ │ │ ├── attributes.hpp │ │ │ │ │ ├── ctype.hpp │ │ │ │ │ ├── gsl/ │ │ │ │ │ │ └── not_null.hpp │ │ │ │ │ ├── limits.hpp │ │ │ │ │ ├── math.hpp │ │ │ │ │ ├── mpl/ │ │ │ │ │ │ └── max.hpp │ │ │ │ │ ├── type_traits/ │ │ │ │ │ │ ├── conditional.hpp │ │ │ │ │ │ ├── enable_if.hpp │ │ │ │ │ │ ├── integral_constant.hpp │ │ │ │ │ │ ├── is_array.hpp │ │ │ │ │ │ ├── is_base_of.hpp │ │ │ │ │ │ ├── is_const.hpp │ │ │ │ │ │ ├── is_floating_point.hpp │ │ │ │ │ │ ├── is_integral.hpp │ │ │ │ │ │ ├── is_same.hpp │ │ │ │ │ │ ├── is_signed.hpp │ │ │ │ │ │ ├── is_unsigned.hpp │ │ │ │ │ │ ├── make_unsigned.hpp │ │ │ │ │ │ ├── remove_const.hpp │ │ │ │ │ │ ├── remove_reference.hpp │ │ │ │ │ │ └── type_identity.hpp │ │ │ │ │ ├── type_traits.hpp │ │ │ │ │ └── utility.hpp │ │ │ │ ├── Serialization/ │ │ │ │ │ ├── DummyWriter.hpp │ │ │ │ │ ├── DynamicStringWriter.hpp │ │ │ │ │ ├── StaticStringWriter.hpp │ │ │ │ │ ├── StreamWriter.hpp │ │ │ │ │ ├── measure.hpp │ │ │ │ │ └── serialize.hpp │ │ │ │ ├── StringStorage/ │ │ │ │ │ ├── StringCopier.hpp │ │ │ │ │ ├── StringMover.hpp │ │ │ │ │ └── StringStorage.hpp │ │ │ │ ├── Strings/ │ │ │ │ │ ├── ArduinoStringAdapter.hpp │ │ │ │ │ ├── ConstRamStringAdapter.hpp │ │ │ │ │ ├── FlashStringAdapter.hpp │ │ │ │ │ ├── RamStringAdapter.hpp │ │ │ │ │ ├── SizedFlashStringAdapter.hpp │ │ │ │ │ ├── SizedRamStringAdapter.hpp │ │ │ │ │ ├── StlStringAdapter.hpp │ │ │ │ │ ├── String.hpp │ │ │ │ │ └── StringAdapters.hpp │ │ │ │ ├── Variant/ │ │ │ │ │ ├── SlotFunctions.hpp │ │ │ │ │ ├── VariantAs.hpp │ │ │ │ │ ├── VariantAsImpl.hpp │ │ │ │ │ ├── VariantContent.hpp │ │ │ │ │ ├── VariantData.hpp │ │ │ │ │ ├── VariantFunctions.hpp │ │ │ │ │ ├── VariantImpl.hpp │ │ │ │ │ ├── VariantRef.hpp │ │ │ │ │ ├── VariantSlot.hpp │ │ │ │ │ └── VariantTo.hpp │ │ │ │ ├── compatibility.hpp │ │ │ │ └── version.hpp │ │ │ ├── ArduinoJson.h │ │ │ └── ArduinoJson.hpp │ │ ├── main.cpp │ │ ├── mbed-os.lib │ │ ├── mbed_app.json │ │ ├── modules/ │ │ │ ├── blink/ │ │ │ │ ├── blink.cpp │ │ │ │ └── blink.h │ │ │ ├── debug/ │ │ │ │ ├── debug.cpp │ │ │ │ └── debug.h │ │ │ ├── digipot/ │ │ │ │ ├── DigipotBase.h │ │ │ │ ├── mcp4451.cpp │ │ │ │ └── mcp4451.h │ │ │ ├── digitalPin/ │ │ │ │ ├── digitalPin.cpp │ │ │ │ └── digitalPin.h │ │ │ ├── eStop/ │ │ │ │ ├── eStop.cpp │ │ │ │ └── eStop.h │ │ │ ├── encoder/ │ │ │ │ ├── encoder.cpp │ │ │ │ └── encoder.h │ │ │ ├── module.cpp │ │ │ ├── module.h │ │ │ ├── motorPower/ │ │ │ │ ├── motorPower.cpp │ │ │ │ └── motorPower.h │ │ │ ├── pwm/ │ │ │ │ ├── hardwarePwm.cpp │ │ │ │ ├── hardwarePwm.h │ │ │ │ ├── pwm.cpp │ │ │ │ └── pwm.h │ │ │ ├── qei/ │ │ │ │ ├── qei.cpp │ │ │ │ └── qei.h │ │ │ ├── rcservo/ │ │ │ │ ├── rcservo.cpp │ │ │ │ └── rcservo.h │ │ │ ├── resetPin/ │ │ │ │ ├── resetPin.cpp │ │ │ │ └── resetPin.h │ │ │ ├── stepgen/ │ │ │ │ ├── stepgen.cpp │ │ │ │ └── stepgen.h │ │ │ ├── switch/ │ │ │ │ ├── switch.cpp │ │ │ │ └── switch.h │ │ │ ├── temperature/ │ │ │ │ ├── temperature.cpp │ │ │ │ └── temperature.h │ │ │ └── tmc/ │ │ │ ├── tmc.h │ │ │ ├── tmc2208.cpp │ │ │ └── tmc2209.cpp │ │ ├── remora.h │ │ ├── sensors/ │ │ │ ├── tempSensor.h │ │ │ └── thermistor/ │ │ │ ├── thermistor.cpp │ │ │ └── thermistor.h │ │ ├── thread/ │ │ │ ├── timerInterrupt.cpp │ │ │ └── timerInterrupt.h │ │ └── update_mks_robin.py │ └── Remora-OS6/ │ ├── README.md │ ├── SoftwareSerial/ │ │ ├── SoftwareSerial.cpp │ │ └── SoftwareSerial.h │ ├── TARGET_MANTA8/ │ │ ├── PeripheralNames.h │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_MONSTER8/ │ │ ├── PeripheralNames.h │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_OCTOPUS_429/ │ │ ├── PeripheralNames.h │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_OCTOPUS_446/ │ │ ├── PeripheralNames.h │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_ROBIN_3/ │ │ ├── PeripheralNames.h │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_ROBIN_E3/ │ │ ├── PeripheralNames.h │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_SKRV1_4/ │ │ ├── drivers/ │ │ │ ├── comms/ │ │ │ │ ├── RemoraComms.cpp │ │ │ │ └── RemoraComms.h │ │ │ ├── pin/ │ │ │ │ ├── pin.cpp │ │ │ │ └── pin.h │ │ │ └── qei/ │ │ │ ├── qeiDriver.cpp │ │ │ └── qeiDriver.h │ │ └── thread/ │ │ ├── createThreads.h │ │ ├── interrupt.cpp │ │ ├── interrupt.h │ │ ├── irqHandlers.h │ │ ├── pruThread.cpp │ │ ├── pruThread.h │ │ ├── qeiInterrupt.cpp │ │ ├── qeiInterrupt.h │ │ ├── timer.cpp │ │ └── timer.h │ ├── TARGET_SKRV2/ │ │ ├── PeripheralNames.h │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_SKRV3/ │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_SKR_MINI_E3/ │ │ ├── PeripheralNames.h │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_SPIDER/ │ │ ├── PeripheralNames.h │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_SPIDER_KING/ │ │ ├── PeripheralNames.h │ │ ├── PeripheralPins.c │ │ ├── PinNames.h │ │ └── system_clock.c │ ├── TARGET_STM32F1/ │ │ ├── drivers/ │ │ │ ├── comms/ │ │ │ │ ├── RemoraComms.cpp │ │ │ │ └── RemoraComms.h │ │ │ ├── pin/ │ │ │ │ ├── pin.cpp │ │ │ │ └── pin.h │ │ │ └── qei/ │ │ │ ├── qeiDriver.cpp │ │ │ └── qeiDriver.h │ │ └── thread/ │ │ ├── createThreads.h │ │ ├── interrupt.cpp │ │ ├── interrupt.h │ │ ├── irqHandlers.h │ │ ├── pruThread.cpp │ │ ├── pruThread.h │ │ ├── timer.cpp │ │ └── timer.h │ ├── TARGET_STM32F4/ │ │ ├── drivers/ │ │ │ ├── SDIO/ │ │ │ │ ├── SDIOBlockDevice.cpp │ │ │ │ ├── SDIOBlockDevice.h │ │ │ │ ├── sdio_device.c │ │ │ │ └── sdio_device.h │ │ │ ├── comms/ │ │ │ │ ├── RemoraComms.cpp │ │ │ │ └── RemoraComms.h │ │ │ ├── pin/ │ │ │ │ ├── pin.cpp │ │ │ │ └── pin.h │ │ │ └── qei/ │ │ │ ├── qeiDriver.cpp │ │ │ └── qeiDriver.h │ │ └── thread/ │ │ ├── createThreads.h │ │ ├── interrupt.cpp │ │ ├── interrupt.h │ │ ├── irqHandlers.h │ │ ├── pruThread.cpp │ │ ├── pruThread.h │ │ ├── timer.cpp │ │ └── timer.h │ ├── TARGET_STM32G0/ │ │ ├── drivers/ │ │ │ ├── comms/ │ │ │ │ ├── RemoraComms.cpp │ │ │ │ └── RemoraComms.h │ │ │ ├── pin/ │ │ │ │ ├── pin.cpp │ │ │ │ └── pin.h │ │ │ └── qei/ │ │ │ ├── qeiDriver.cpp │ │ │ └── qeiDriver.h │ │ └── thread/ │ │ ├── createThreads.h │ │ ├── interrupt.cpp │ │ ├── interrupt.h │ │ ├── irqHandlers.h │ │ ├── pruThread.cpp │ │ ├── pruThread.h │ │ ├── timer.cpp │ │ └── timer.h │ ├── TARGET_STM32H7/ │ │ ├── drivers/ │ │ │ ├── SDIO/ │ │ │ │ ├── SDIOBlockDevice.cpp │ │ │ │ ├── SDIOBlockDevice.h │ │ │ │ ├── sdio_device.c │ │ │ │ └── sdio_device.h │ │ │ ├── comms/ │ │ │ │ ├── RemoraComms.cpp │ │ │ │ └── RemoraComms.h │ │ │ ├── pin/ │ │ │ │ ├── pin.cpp │ │ │ │ └── pin.h │ │ │ └── qei/ │ │ │ ├── qeiDriver.cpp │ │ │ └── qeiDriver.h │ │ └── thread/ │ │ ├── createThreads.h │ │ ├── interrupt.cpp │ │ ├── interrupt.h │ │ ├── irqHandlers.h │ │ ├── pruThread.cpp │ │ ├── pruThread.h │ │ ├── timer.cpp │ │ └── timer.h │ ├── TMCStepper/ │ │ ├── CHOPCONF.cpp │ │ ├── COOLCONF.cpp │ │ ├── DRV_STATUS.cpp │ │ ├── GCONF.cpp │ │ ├── IHOLD_IRUN.cpp │ │ ├── PWMCONF.cpp │ │ ├── TMC2208Stepper.cpp │ │ ├── TMC2208_bitfields.h │ │ ├── TMC2209Stepper.cpp │ │ ├── TMC2209_bitfields.h │ │ ├── TMCStepper.cpp │ │ ├── TMCStepper.h │ │ └── TMC_MACROS.h │ ├── configuration.h │ ├── custom_targets.json │ ├── drivers/ │ │ └── softPwm/ │ │ ├── softPwm.cpp │ │ └── softPwm.h │ ├── extern.h │ ├── lib/ │ │ └── ArduinoJson6/ │ │ ├── ArduinoJson/ │ │ │ ├── Array/ │ │ │ │ ├── ArrayFunctions.hpp │ │ │ │ ├── ArrayImpl.hpp │ │ │ │ ├── ArrayIterator.hpp │ │ │ │ ├── ArrayRef.hpp │ │ │ │ ├── ArrayShortcuts.hpp │ │ │ │ ├── ElementProxy.hpp │ │ │ │ └── Utilities.hpp │ │ │ ├── Collection/ │ │ │ │ ├── CollectionData.hpp │ │ │ │ └── CollectionImpl.hpp │ │ │ ├── Configuration.hpp │ │ │ ├── Deserialization/ │ │ │ │ ├── ArduinoStreamReader.hpp │ │ │ │ ├── CharPointerReader.hpp │ │ │ │ ├── DeserializationError.hpp │ │ │ │ ├── FlashStringReader.hpp │ │ │ │ ├── IteratorReader.hpp │ │ │ │ ├── NestingLimit.hpp │ │ │ │ ├── StdStreamReader.hpp │ │ │ │ └── deserialize.hpp │ │ │ ├── Document/ │ │ │ │ ├── BasicJsonDocument.hpp │ │ │ │ ├── DynamicJsonDocument.hpp │ │ │ │ ├── JsonDocument.hpp │ │ │ │ └── StaticJsonDocument.hpp │ │ │ ├── Json/ │ │ │ │ ├── EscapeSequence.hpp │ │ │ │ ├── JsonDeserializer.hpp │ │ │ │ ├── JsonSerializer.hpp │ │ │ │ ├── PrettyJsonSerializer.hpp │ │ │ │ ├── TextFormatter.hpp │ │ │ │ └── Utf8.hpp │ │ │ ├── Memory/ │ │ │ │ ├── Alignment.hpp │ │ │ │ ├── MemoryPool.hpp │ │ │ │ ├── StringBuilder.hpp │ │ │ │ └── StringSlot.hpp │ │ │ ├── Misc/ │ │ │ │ ├── SerializedValue.hpp │ │ │ │ └── Visitable.hpp │ │ │ ├── MsgPack/ │ │ │ │ ├── MsgPackDeserializer.hpp │ │ │ │ ├── MsgPackSerializer.hpp │ │ │ │ ├── endianess.hpp │ │ │ │ └── ieee754.hpp │ │ │ ├── Namespace.hpp │ │ │ ├── Numbers/ │ │ │ │ ├── Float.hpp │ │ │ │ ├── FloatParts.hpp │ │ │ │ ├── FloatTraits.hpp │ │ │ │ ├── Integer.hpp │ │ │ │ ├── convertNumber.hpp │ │ │ │ ├── parseFloat.hpp │ │ │ │ ├── parseInteger.hpp │ │ │ │ └── parseNumber.hpp │ │ │ ├── Object/ │ │ │ │ ├── MemberProxy.hpp │ │ │ │ ├── ObjectFunctions.hpp │ │ │ │ ├── ObjectImpl.hpp │ │ │ │ ├── ObjectIterator.hpp │ │ │ │ ├── ObjectRef.hpp │ │ │ │ ├── ObjectShortcuts.hpp │ │ │ │ └── Pair.hpp │ │ │ ├── Operators/ │ │ │ │ ├── VariantCasts.hpp │ │ │ │ ├── VariantComparisons.hpp │ │ │ │ ├── VariantOperators.hpp │ │ │ │ ├── VariantOr.hpp │ │ │ │ └── VariantShortcuts.hpp │ │ │ ├── Polyfills/ │ │ │ │ ├── alias_cast.hpp │ │ │ │ ├── assert.hpp │ │ │ │ ├── attributes.hpp │ │ │ │ ├── ctype.hpp │ │ │ │ ├── gsl/ │ │ │ │ │ └── not_null.hpp │ │ │ │ ├── limits.hpp │ │ │ │ ├── math.hpp │ │ │ │ ├── mpl/ │ │ │ │ │ └── max.hpp │ │ │ │ ├── type_traits/ │ │ │ │ │ ├── conditional.hpp │ │ │ │ │ ├── enable_if.hpp │ │ │ │ │ ├── integral_constant.hpp │ │ │ │ │ ├── is_array.hpp │ │ │ │ │ ├── is_base_of.hpp │ │ │ │ │ ├── is_const.hpp │ │ │ │ │ ├── is_floating_point.hpp │ │ │ │ │ ├── is_integral.hpp │ │ │ │ │ ├── is_same.hpp │ │ │ │ │ ├── is_signed.hpp │ │ │ │ │ ├── is_unsigned.hpp │ │ │ │ │ ├── make_unsigned.hpp │ │ │ │ │ ├── remove_const.hpp │ │ │ │ │ ├── remove_reference.hpp │ │ │ │ │ └── type_identity.hpp │ │ │ │ ├── type_traits.hpp │ │ │ │ └── utility.hpp │ │ │ ├── Serialization/ │ │ │ │ ├── DummyWriter.hpp │ │ │ │ ├── DynamicStringWriter.hpp │ │ │ │ ├── StaticStringWriter.hpp │ │ │ │ ├── StreamWriter.hpp │ │ │ │ ├── measure.hpp │ │ │ │ └── serialize.hpp │ │ │ ├── StringStorage/ │ │ │ │ ├── StringCopier.hpp │ │ │ │ ├── StringMover.hpp │ │ │ │ └── StringStorage.hpp │ │ │ ├── Strings/ │ │ │ │ ├── ArduinoStringAdapter.hpp │ │ │ │ ├── ConstRamStringAdapter.hpp │ │ │ │ ├── FlashStringAdapter.hpp │ │ │ │ ├── RamStringAdapter.hpp │ │ │ │ ├── SizedFlashStringAdapter.hpp │ │ │ │ ├── SizedRamStringAdapter.hpp │ │ │ │ ├── StlStringAdapter.hpp │ │ │ │ ├── String.hpp │ │ │ │ └── StringAdapters.hpp │ │ │ ├── Variant/ │ │ │ │ ├── SlotFunctions.hpp │ │ │ │ ├── VariantAs.hpp │ │ │ │ ├── VariantAsImpl.hpp │ │ │ │ ├── VariantContent.hpp │ │ │ │ ├── VariantData.hpp │ │ │ │ ├── VariantFunctions.hpp │ │ │ │ ├── VariantImpl.hpp │ │ │ │ ├── VariantRef.hpp │ │ │ │ ├── VariantSlot.hpp │ │ │ │ └── VariantTo.hpp │ │ │ ├── compatibility.hpp │ │ │ └── version.hpp │ │ ├── ArduinoJson.h │ │ └── ArduinoJson.hpp │ ├── main.cpp │ ├── mbed-os.lib │ ├── mbed_app.json │ ├── modules/ │ │ ├── blink/ │ │ │ ├── blink.cpp │ │ │ └── blink.h │ │ ├── debug/ │ │ │ ├── debug.cpp │ │ │ └── debug.h │ │ ├── digipot/ │ │ │ ├── DigipotBase.h │ │ │ ├── mcp4451.cpp │ │ │ └── mcp4451.h │ │ ├── digitalPin/ │ │ │ ├── digitalPin.cpp │ │ │ └── digitalPin.h │ │ ├── eStop/ │ │ │ ├── eStop.cpp │ │ │ └── eStop.h │ │ ├── encoder/ │ │ │ ├── encoder.cpp │ │ │ └── encoder.h │ │ ├── module.cpp │ │ ├── module.h │ │ ├── motorPower/ │ │ │ ├── motorPower.cpp │ │ │ └── motorPower.h │ │ ├── pwm/ │ │ │ ├── hardwarePwm.cpp │ │ │ ├── hardwarePwm.h │ │ │ ├── pwm.cpp │ │ │ └── pwm.h │ │ ├── qei/ │ │ │ ├── qei.cpp │ │ │ └── qei.h │ │ ├── rcservo/ │ │ │ ├── rcservo.cpp │ │ │ └── rcservo.h │ │ ├── resetPin/ │ │ │ ├── resetPin.cpp │ │ │ └── resetPin.h │ │ ├── stepgen/ │ │ │ ├── stepgen.cpp │ │ │ └── stepgen.h │ │ ├── switch/ │ │ │ ├── switch.cpp │ │ │ └── switch.h │ │ ├── temperature/ │ │ │ ├── temperature.cpp │ │ │ └── temperature.h │ │ └── tmc/ │ │ ├── tmc.h │ │ ├── tmc2208.cpp │ │ └── tmc2209.cpp │ ├── remora.h │ ├── sensors/ │ │ ├── tempSensor.h │ │ └── thermistor/ │ │ ├── thermistor.cpp │ │ └── thermistor.h │ ├── thread/ │ │ ├── timerInterrupt.cpp │ │ └── timerInterrupt.h │ └── update_mks_robin.py ├── LinuxCNC/ │ ├── Components/ │ │ ├── NVMPG/ │ │ │ └── nvmpg.c │ │ ├── PIDcontroller/ │ │ │ ├── PIDcontroller.c │ │ │ └── PIDcontroller.md │ │ ├── PRUencoder/ │ │ │ └── PRUencoder.c │ │ ├── README.md │ │ ├── Remora/ │ │ │ ├── bcm2835.c │ │ │ ├── bcm2835.h │ │ │ ├── remora.h │ │ │ └── remora_lpc.c │ │ ├── Remora-eth/ │ │ │ ├── remora-eth-3.0.c │ │ │ └── remora-eth-3.0.h │ │ └── Remora-spi/ │ │ ├── bcm2835.c │ │ ├── bcm2835.h │ │ ├── dtcboards.h │ │ ├── gpiochip_rp1.c │ │ ├── gpiochip_rp1.h │ │ ├── remora-spi.c │ │ ├── remora.h │ │ ├── rp1lib.c │ │ ├── rp1lib.h │ │ ├── spi-dw.c │ │ └── spi-dw.h │ ├── ConfigSamples/ │ │ ├── ender3/ │ │ │ ├── 3D_printer_panel.xml │ │ │ ├── 3Dprinter.hal │ │ │ ├── custom_postgui.hal │ │ │ ├── ender3.hal │ │ │ ├── ender3.ini │ │ │ ├── gcode2ngc.py │ │ │ ├── linuxcnc.var │ │ │ ├── linuxcnc.var.bak │ │ │ ├── postgui_call_list.hal │ │ │ ├── probe-results.txt │ │ │ ├── pyvcp_options.hal │ │ │ └── tool.tbl │ │ ├── hypercube/ │ │ │ ├── 3D_printer_panel.xml │ │ │ ├── 3Dprinter.hal │ │ │ ├── autosave.halscope │ │ │ ├── compensation.py │ │ │ ├── custom_postgui.hal │ │ │ ├── gcode2ngc.py │ │ │ ├── hypercube.hal │ │ │ ├── hypercube.ini │ │ │ ├── hypercube.pref │ │ │ ├── linuxcnc.var │ │ │ ├── linuxcnc.var.bak │ │ │ ├── postgui_call_list.hal │ │ │ ├── probe-results.txt │ │ │ ├── pyvcp_options.hal │ │ │ ├── tool.tbl │ │ │ └── tool.tbl.bak │ │ ├── remora-closed-loop/ │ │ │ ├── .qtpyvcp-messages.json │ │ │ ├── 3D_printer_panel.xml │ │ │ ├── 3Dprinter.hal │ │ │ ├── autosave.halscope │ │ │ ├── compensation.py │ │ │ ├── custom_postgui.hal │ │ │ ├── encoder-fb.halscope │ │ │ ├── linuxcnc.var │ │ │ ├── linuxcnc.var.bak │ │ │ ├── my.halshow │ │ │ ├── postgui_call_list.hal │ │ │ ├── probe-results.txt │ │ │ ├── pyvcp_options.hal │ │ │ ├── remora.hal │ │ │ ├── remora.ini │ │ │ ├── remora.pref │ │ │ └── tool.tbl │ │ ├── remora-eth/ │ │ │ ├── 3D_printer_panel.xml │ │ │ ├── 3Dprinter.hal │ │ │ ├── autosave.halscope │ │ │ ├── custom_postgui.hal │ │ │ ├── gcode2ngc.py │ │ │ ├── linuxcnc.var │ │ │ ├── linuxcnc.var.bak │ │ │ ├── postgui_call_list.hal │ │ │ ├── probe-results.txt │ │ │ ├── pyvcp_options.hal │ │ │ ├── remora-eth.hal │ │ │ ├── remora-eth.ini │ │ │ └── tool.tbl │ │ ├── remora-octopus/ │ │ │ ├── Remora-XY.prefs │ │ │ ├── axis.ngc │ │ │ ├── custom_postgui.hal │ │ │ ├── halshow.preferences │ │ │ ├── linuxcnc.var │ │ │ ├── linuxcnc.var.bak │ │ │ ├── postgui_call_list.hal │ │ │ ├── remora-xyz.hal │ │ │ ├── remora-xyz.ini │ │ │ ├── tool.tbl │ │ │ └── usercommand_regularmac_800.py │ │ └── remora-xyz/ │ │ ├── custom_postgui.hal │ │ ├── postgui_call_list.hal │ │ ├── remora-xyz.hal │ │ ├── remora-xyz.ini │ │ └── tool.tbl │ └── README.md └── README.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA.lib Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/ChangeLog.c Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/CONFIG.h Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/DATALUTS.cpp Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/example1.h Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/example2.h Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/example3.h Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/example4.h Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/INIT.cpp Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/iomacros.h Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/MODDMA.cpp Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/MODDMA.h Firmware/FirmwareSource/Remora-OS6/TARGET_SKRV1_4/drivers/comms/MODDMA/SETUP.cpp Firmware/FirmwareSource/Remora-OS6/.mbed ================================================ FILE: Firmware/ConfigSamples/BTT_Octopus/OCTOPUS_ENDER3/config.txt ================================================ { "Board": "BIGTREETECH OCTOPUS", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "PC_15" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X DRIVER0 - Joint 0 step generator", "Joint Number": 0, "Step Pin": "PF_13", "Direction Pin": "PF_12", "Enable Pin": "PF_14" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y DRIVER1 - Joint 1 step generator", "Joint Number": 1, "Step Pin": "PG_0", "Direction Pin": "PG_1", "Enable Pin": "PF_15" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z DRIVER2 - Joint 2 step generator", "Joint Number": 2, "Step Pin": "PF_11", "Direction Pin": "PG_3", "Enable Pin": "PG_5" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 DRIVER3 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "PG_4", "Direction Pin": "PC_1", "Enable Pin": "PA_0" }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min DIAG0", "Pin": "PG_6", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max DIAG4", "Pin": "PG_12", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min DIAG1", "Pin": "PG_9", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max DIAG5", "Pin": "PG_13", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min DIAG2", "Pin": "PG_10", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max DIAG6", "Pin": "PG_14", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Heated Bed tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "PF_3", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Bed heater PWM", "SP[i]": 0, "PWM Pin": "PA_1" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Ext 0 temperature sensor", "PV[i]": 1, "Sensor": "Thermistor", "Thermistor": { "Pin": "PF_4", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Ext0 heater PWM", "SP[i]": 1, "PWM Pin": "PA_2" }, { "Thread": "Servo", "Type": "PWM", "Comment": "Ext0 part cooling fan PWM FAN0", "SP[i]": 2, "PWM Max": 128, "PWM Pin": "PA_8" }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe bltouch according to marlin", "SP[i]": 3, "Servo Pin": "PB_6" } ] } ================================================ FILE: Firmware/ConfigSamples/BTT_Octopus/OCTOPUS_xyz/config.txt ================================================ { "Board": "BIGTREETECH OCTOPUS", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "PC_15" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "PF_13", "Direction Pin": "PF_12", "Enable Pin": "PF_14" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "PG_0", "Direction Pin": "PG_1", "Enable Pin": "PF_15" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "PF_11", "Direction Pin": "PG_3", "Enable Pin": "PG_5" } ] } ================================================ FILE: Firmware/ConfigSamples/BTT_SKRv13/config.txt ================================================ { "Board": "BIGTREETECH SKR v1.3 & v1.4", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "1.31" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "2.2", "Direction Pin": "2.6", "Enable Pin": "2.1" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "0.19", "Direction Pin": "0.20", "Enable Pin": "2.08" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "0.22", "Direction Pin": "2.11", "Enable Pin": "0.21" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "2.13", "Direction Pin": "0.11", "Enable Pin": "2.12" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Extruder tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.23", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe", "SP[i]": 3, "Servo Pin": "2.0" }, { "Thread": "Base", "Type": "Encoder", "Comment": "Encoder", "PV[i]": 2, "ChA Pin": "1.20", "ChB Pin": "1.22" }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "1.29", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max", "Pin": "1.28", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "1.27", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max", "Pin": "1.26", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "1.25", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max", "Pin": "1.24", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Switch", "Comment": "Extruder fan switch", "Pin": "0.0", "Mode": "On", "PV[i]": 0, "SP": 25.5 } ] } ================================================ FILE: Firmware/ConfigSamples/BTT_SKRv14/SKRv14_3dp/config.txt ================================================ { "Board": "BIGTREETECH SKR v1.4", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "1.31" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "2.2", "Direction Pin": "2.6", "Enable Pin": "2.1" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "X - Joint 0 TMC driver", "RX pin": "1.10", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "0.19", "Direction Pin": "0.20", "Enable Pin": "2.08" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "Y - Joint 1 TMC driver", "RX pin": "1.9", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "0.22", "Direction Pin": "2.11", "Enable Pin": "0.21" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "Z - Joint 2 TMC driver", "RX pin": "1.8", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "2.13", "Direction Pin": "0.11", "Enable Pin": "2.12" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "E0 - Joint 3 TMC driver", "RX pin": "1.4", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E1 - Joint 4 step generator", "Joint Number": 4, "Step Pin": "1.15", "Direction Pin": "1.14", "Enable Pin": "1.16" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "E1 - Joint 4 TMC driver", "RX pin": "1.1", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Servo", "Type": "PWM", "Comment": "Bed heater PWM", "SP[i]": 0, "PWM Pin": "2.5" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Bed tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.25", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Hotend 0 heater PWM", "SP[i]": 1, "PWM Pin": "2.7" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Hotend 0 tenperature sensor", "PV[i]": 1, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.24", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Hotend 1 heater PWM", "SP[i]": 2, "PWM Pin": "2.4" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Hotend 1 tenperature sensor", "PV[i]": 2, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.23", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "1.29", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "1.28", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "1.27", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "E0DET", "Pin": "1.26", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "E1DET", "Pin": "1.25", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "PWRDET", "Pin": "1.0", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Probe", "Pin": "0.10", "Mode": "Input", "Data Bit": 6 }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe", "SP[i]": 3, "Servo Pin": "2.0" }, { "Thread": "Servo", "Type": "Switch", "Comment": "Extruder fan switch", "Pin": "0.0", "Mode": "On", "PV[i]": 1, "SP": 25.5 } ] } ================================================ FILE: Firmware/ConfigSamples/BTT_SKRv14/SKRv14_TMC2209/config.txt ================================================ { "Board": "BIGTREETECH SKR v1.4", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "1.31" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "2.2", "Direction Pin": "2.6", "Enable Pin": "2.1" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "X - Joint 0 TMC driver", "RX pin": "1.10", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "0.19", "Direction Pin": "0.20", "Enable Pin": "2.08" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "Y - Joint 1 TMC driver", "RX pin": "1.9", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "0.22", "Direction Pin": "2.11", "Enable Pin": "0.21" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "Z - Joint 2 TMC driver", "RX pin": "1.8", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "2.13", "Direction Pin": "0.11", "Enable Pin": "2.12" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "E0 - Joint 3 TMC driver", "RX pin": "1.4", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E1 - Joint 4 step generator", "Joint Number": 4, "Step Pin": "1.15", "Direction Pin": "1.14", "Enable Pin": "1.16" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "E1 - Joint 4 TMC driver", "RX pin": "1.1", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Servo", "Type": "PWM", "Comment": "Bed heater PWM", "SP[i]": 0, "PWM Pin": "2.5" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Bed tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.25", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Hotend 0 heater PWM", "SP[i]": 1, "PWM Pin": "2.7" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Hotend 0 tenperature sensor", "PV[i]": 1, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.24", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Hotend 1 heater PWM", "SP[i]": 2, "PWM Pin": "2.4" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Hotend 1 tenperature sensor", "PV[i]": 2, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.23", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "1.29", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "1.28", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "1.27", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "E0DET", "Pin": "1.26", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "E1DET", "Pin": "1.25", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "PWRDET", "Pin": "1.0", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Probe", "Pin": "0.10", "Mode": "Input", "Data Bit": 6 }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe", "SP[i]": 3, "Servo Pin": "2.0" }, { "Thread": "Servo", "Type": "Switch", "Comment": "Extruder fan switch", "Pin": "0.0", "Mode": "On", "PV[i]": 1, "SP": 25.5 } ] } ================================================ FILE: Firmware/ConfigSamples/BTT_SKRv14/SKRv14_xyz/config.txt ================================================ { "Board": "BIGTREETECH SKR v1.3 & v1.4", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "1.31" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "2.2", "Direction Pin": "2.6", "Enable Pin": "2.1" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "0.19", "Direction Pin": "0.20", "Enable Pin": "2.08" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "0.22", "Direction Pin": "2.11", "Enable Pin": "0.21" } ] } ================================================ FILE: Firmware/ConfigSamples/BTT_SKRv2/SKRv2_TMC2209/config.txt ================================================ { "Board": "BIGTREETECH SKR v2", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "PC_4" }, { "Thread": "On load", "Type": "Motor Power", "Comment": "Enable motor power SKR2", "Pin": "PC_13" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "PE_2", "Direction Pin": "PE_1", "Enable Pin": "PE_3" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "X - Joint 0 TMC driver", "RX pin": "PE_0", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "PD_5", "Direction Pin": "PD_4", "Enable Pin": "PD_6" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "Y - Joint 1 TMC driver", "RX pin": "PD_3", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "PA_15", "Direction Pin": "PA_8", "Enable Pin": "PD_1" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "Z - Joint 2 TMC driver", "RX pin": "PD_0", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "PD_15", "Direction Pin": "PD_14", "Enable Pin": "PC_7" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "E0 - Joint 3 TMC driver", "RX pin": "PC_6", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E1 - Joint 4 step generator", "Joint Number": 4, "Step Pin": "PD_11", "Direction Pin": "PD_10", "Enable Pin": "PD_13" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "E1 - Joint 4 TMC driver", "RX pin": "PD_12", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "PC_1", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max", "Pin": "PC_2", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "PC_3", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max", "Pin": "PA_0", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "PC_0", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max", "Pin": "PC_15", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Switch", "Comment": "Extruder fan switch", "Pin": "PB_7", "Mode": "On", "PV[i]": 0, "SP": 25.5 } ] } ================================================ FILE: Firmware/ConfigSamples/BTT_SKRv2/SKRv2_ender3/config.txt ================================================ { "Board": "BIGTREETECH SKR v2", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "PC_4" }, { "Thread": "On load", "Type": "Motor Power", "Comment": "Enable motor power SKR2", "Pin": "PC_13" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "PE_2", "Direction Pin": "PE_1", "Enable Pin": "PE_3" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "PD_5", "Direction Pin": "PD_4", "Enable Pin": "PD_6" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "PA_15", "Direction Pin": "PA_8", "Enable Pin": "PD_1" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "PD_15", "Direction Pin": "PD_14", "Enable Pin": "PC_7" }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "PC_1", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max", "Pin": "PC_2", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "PC_3", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max", "Pin": "PA_0", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "PC_0", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max", "Pin": "PC_15", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Heated Bed tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "PA_1", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Bed heater PWM", "SP[i]": 0, "PWM Pin": "PD_7" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Ext 0 temperature sensor", "PV[i]": 1, "Sensor": "Thermistor", "Thermistor": { "Pin": "PA_2", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Ext0 heater PWM", "SP[i]": 1, "PWM Pin": "PB_3" }, { "Thread": "Servo", "Type": "PWM", "Comment": "Ext0 part cooling fan PWM FAN0", "SP[i]": 2, "PWM Max": 128, "PWM Pin": "PB_7" }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe bltouch according to marlin", "SP[i]": 3, "Servo Pin": "PE_5" } ] } ================================================ FILE: Firmware/ConfigSamples/BTT_SKRv2/SKRv2_xyz/config.txt ================================================ { "Board": "BIGTREETECH SKR v2", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "PC_4" }, { "Thread": "On load", "Type": "Motor Power", "Comment": "Enable motor power SKR2", "Pin": "PC_13" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "PE_2", "Direction Pin": "PE_1", "Enable Pin": "PE_3" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "PD_5", "Direction Pin": "PD_4", "Enable Pin": "PD_6" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "PA_15", "Direction Pin": "PA_8", "Enable Pin": "PD_1" }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "PC_1", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max", "Pin": "PC_2", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "PC_3", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max", "Pin": "PA_0", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "PC_0", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max", "Pin": "PC_15", "Mode": "Input", "Data Bit": 5 } ] } ================================================ FILE: Firmware/ConfigSamples/Fysetc_Spider/config.txt ================================================ { "Board": "FYSETC SPIDER", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "PC_7" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X M1 - Joint 0 step generator", "Joint Number": 0, "Step Pin": "PE_11", "Direction Pin": "PE_10", "Enable Pin": "PE_9" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y M2 - Joint 1 step generator", "Joint Number": 1, "Step Pin": "PD_8", "Direction Pin": "PB_12", "Enable Pin": "PD_9" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z M3 - Joint 2 step generator", "Joint Number": 2, "Step Pin": "PD_14", "Direction Pin": "PD_13", "Enable Pin": "PD_15" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 M4 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "PD_5", "Direction Pin": "PD_6", "Enable Pin": "PD_4" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E1 M5 - Joint 4 step generator", "Joint Number": 4, "Step Pin": "PE_6", "Direction Pin": "PC_13", "Enable Pin": "PE_5" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E2 M6 - Joint 5 step generator", "Joint Number": 5, "Step Pin": "PE_2", "Direction Pin": "PE_4", "Enable Pin": "PE_3" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E3 M7 - Joint 6 step generator", "Joint Number": 6, "Step Pin": "PD_12", "Direction Pin": "PC_4", "Enable Pin": "PE_8" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E4 M8 - Joint 7 step generator", "Joint Number": 7, "Step Pin": "PE_1", "Direction Pin": "PE_0", "Enable Pin": "PC_5" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Extruder tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "PC_0", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min X-DIAG", "Pin": "PB_14", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max E0-DIAG", "Pin": "PA_1", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min Y-DIAG", "Pin": "PB_13", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max E1-DIAG", "Pin": "PA_2", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min Z-DIAG", "Pin": "PA_0", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max E2-DIAG", "Pin": "PA_3", "Mode": "Input", "Data Bit": 5 } ] } ================================================ FILE: Firmware/ConfigSamples/Fysetc_Spider_King/config.txt ================================================ { "Board": "FYSETC SPIDER KING", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "PB_11" } { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "PE_2", "Direction Pin": "PE_1", "Enable Pin": "PE_3" }, { "Thread": "On load", "Type": "TMC stepper", "Comment": "X - Joint 0 TMC driver", "Driver": "2209", "RX pin": "PE_0", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "PD_5", "Direction Pin": "PD_4", "Enable Pin": "PD_6" }, { "Thread": "On load", "Type": "TMC stepper", "Comment": "Y - Joint 1 TMC driver", "Driver": "2209", "RX pin": "PD_3", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 } ] } ================================================ FILE: Firmware/ConfigSamples/Hypercube-evolution/config.txt ================================================ { "Board": "MKS SBASE v1.3", "Modules":[ { "Thread": "On load", "Type": "MCP4451", "Comment": "Digipot for joints 0 - 3", "I2C SDA pin": "0.0", "I2C SCL pin": "0.1", "I2C address": 0, "Max current": 2.0, "Factor": 113.33, "Current 0": 0.8, "Current 1": 0.8, "Current 2": 0.8, "Current 3": 0.8 }, { "Thread": "On load", "Type": "MCP4451", "Comment": "Digipot for joints 4 - 7", "I2C SDA pin": "0.0", "I2C SCL pin": "0.1", "I2C address": 2, "Max current": 2.0, "Factor": 113.33, "Current 0": 0.8, "Current 1": 0.8, "Current 2": 0.8, "Current 3": 0.8 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "2.0", "Direction Pin": "0.5", "Enable Pin": "0.4" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "2.1", "Direction Pin": "0.11", "Enable Pin": "0.10" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z1 - Joint 2 step generator", "Joint Number": 2, "Step Pin": "2.2", "Direction Pin": "0.20", "Enable Pin": "0.19" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z2 - Joint 2 step generator", "Joint Number": 3, "Step Pin": "2.3", "Direction Pin": "0.22", "Enable Pin": "0.21" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E - Joint 3 step generator", "Joint Number": 4, "Step Pin": "2.8", "Direction Pin": "2.13", "Enable Pin": "4.29" }, { "Thread": "Servo", "Type": "Blink", "Pin": "1.18", "Frequency": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "1.24", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max", "Pin": "1.25", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "1.26", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max", "Pin": "1.27", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "1.28", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max", "Pin": "1.29", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Heated Bed tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.23", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Bed heater PWM", "SP[i]": 0, "PWM Pin": "2.5" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Ext 0 temperature sensor", "PV[i]": 1, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.24", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Ext0 heater PWM", "SP[i]": 1, "PWM Pin": "2.7" }, { "Thread": "Servo", "Type": "PWM", "Comment": "Ext0 part cooling fan PWM", "SP[i]": 2, "PWM Max": 128, "PWM Pin": "2.4" }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe", "SP[i]": 3, "Servo Pin": "1.23" }, { "Thread": "Servo", "Type": "Switch", "Comment": "Extruder fan switch", "Pin": "1.22", "Mode": "On", "PV[i]": 1, "SP": 35.0 } ] } ================================================ FILE: Firmware/ConfigSamples/MKS_Monster8/config.txt ================================================ { "Board": "MKS MONSTER8", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin USE BTN_EN2", "Pin": "PE_8" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "PC_14", "Direction Pin": "PC_13", "Enable Pin": "PC_15" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "PE_5", "Direction Pin": "PE_4", "Enable Pin": "PC_15" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "PE_1", "Direction Pin": "PE_0", "Enable Pin": "PE_2" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 DRIVER3 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "PB_5", "Direction Pin": "PB_4", "Enable Pin": "PB_6" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E1 DRIVER4 - Joint 4 step generator", "Joint Number": 4, "Step Pin": "PD_6", "Direction Pin": "PD_5", "Enable Pin": "PD_7" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E2 DRIVER5 - Joint 5 step generator", "Joint Number": 5, "Step Pin": "PD_2", "Direction Pin": "PD_1", "Enable Pin": "PD_3" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E3 DRIVER6 - Joint 6 step generator", "Joint Number": 6, "Step Pin": "PC_7", "Direction Pin": "PC_6", "Enable Pin": "PC_8" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E4 DRIVER7 - Joint 7 step generator", "Joint Number": 7, "Step Pin": "PD_13", "Direction Pin": "PD_12", "Enable Pin": "PD_14" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Extruder tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "PC_1", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe bltouch according to marlin", "SP[i]": 3, "Servo Pin": "PB_6" }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min ", "Pin": "PA_14", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max ", "Pin": "PA_13", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min ", "Pin": "PA_15", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max ", "Pin": "PC_5", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min ", "Pin": "PB_13", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max ", "Pin": "PB_12", "Mode": "Input", "Data Bit": 5 } ] } ================================================ FILE: Firmware/ConfigSamples/MKS_Robin_E3/Robin_E3/config.txt ================================================ { "Board": "Mks Robin E3", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "PC_5" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "PC_0", "Direction Pin": "PB_2", "Enable Pin": "PC_13" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "PC_2", "Direction Pin": "PB_9", "Enable Pin": "PB_12" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "PC_14", "Direction Pin": "PC_15", "Enable Pin": "PB_8" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "PB_4", "Direction Pin": "PB_3", "Enable Pin": "PB_5" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Extruder tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "PA_0", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe", "SP[i]": 3, "Servo Pin": "PA_3" }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "PA_12", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "PA_11", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "PC_6", "Mode": "Input", "Data Bit": 4 } ] } ================================================ FILE: Firmware/ConfigSamples/MKS_Sbase/MKS Sbase/Ender3/config.txt-Ender3 ================================================ { "Board": "MKS SBASE v1.3", "Modules":[ { "Thread": "On load", "Type": "MCP4451", "Comment": "Digipot for joints 0 - 3", "I2C SDA pin": "0.0", "I2C SCL pin": "0.1", "I2C address": 0, "Max current": 2.0, "Factor": 113.33, "Current 0": 0.8, "Current 1": 0.8, "Current 2": 0.8, "Current 3": 0.8 }, { "Thread": "On load", "Type": "MCP4451", "Comment": "Digipot for joints 4 - 7", "I2C SDA pin": "0.0", "I2C SCL pin": "0.1", "I2C address": 2, "Max current": 2.0, "Factor": 113.33, "Current 0": 0.8, "Current 1": 0.8, "Current 2": 0.8, "Current 3": 0.8 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "2.0", "Direction Pin": "0.5", "Enable Pin": "0.4" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "2.1", "Direction Pin": "0.11", "Enable Pin": "0.10" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "2.2", "Direction Pin": "0.20", "Enable Pin": "0.19" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E - Joint 3 step generator", "Joint Number": 3, "Step Pin": "2.3", "Direction Pin": "0.22", "Enable Pin": "0.21" }, { "Thread": "Servo", "Type": "Blink", "Pin": "1.18", "Frequency": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "1.24", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max", "Pin": "1.25", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "1.26", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max", "Pin": "1.27", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "1.28", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max", "Pin": "1.29", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Heated Bed tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.23", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Bed heater PWM", "SP[i]": 0, "PWM Pin": "2.5" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Ext 0 temperature sensor", "PV[i]": 1, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.24", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Ext0 heater PWM", "SP[i]": 1, "PWM Pin": "2.7" }, { "Thread": "Servo", "Type": "PWM", "Comment": "Ext0 part cooling fan PWM on FAN", "SP[i]": 2, "PWM Max": 128, "PWM Pin": "2.4" }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe", "SP[i]": 3, "Servo Pin": "1.23" }, { "Thread": "Servo", "Type": "Switch", "Comment": "Extruder fan switch on E2", "Pin": "2.6", "Mode": "On", "PV[i]": 1, "SP": 35.0 } ] } ================================================ FILE: Firmware/ConfigSamples/MKS_Sbase/MKS Sbase/config.txt ================================================ { "Board": "MKS SBASE v1.3", "Modules":[ { "Thread": "On load", "Type": "MCP4451", "Comment": "Digipot for joints 0 - 3", "I2C SDA pin": "0.0", "I2C SCL pin": "0.1", "I2C address": 0, "Max current": 2.0, "Factor": 113.33, "Current 0": 0.8, "Current 1": 0.8, "Current 2": 0.8, "Current 3": 0.8 }, { "Thread": "On load", "Type": "MCP4451", "Comment": "Digipot for joints 4 - 7", "I2C SDA pin": "0.0", "I2C SCL pin": "0.1", "I2C address": 2, "Max current": 2.0, "Factor": 113.33, "Current 0": 0.8, "Current 1": 0.8, "Current 2": 0.8, "Current 3": 0.8 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "2.0", "Direction Pin": "0.5", "Enable Pin": "0.4" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "2.1", "Direction Pin": "0.11", "Enable Pin": "0.10" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "2.2", "Direction Pin": "0.20", "Enable Pin": "0.19" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "2.3", "Direction Pin": "0.22", "Enable Pin": "0.21" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E1 - Joint 4 step generator", "Joint Number": 4, "Step Pin": "2.8", "Direction Pin": "2.13", "Enable Pin": "4.29" }, { "Thread": "Servo", "Type": "Blink", "Pin": "1.18", "Frequency": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "1.24", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max", "Pin": "1.25", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "1.26", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max", "Pin": "1.27", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "1.28", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max", "Pin": "1.29", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Heated Bed tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.23", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Bed heater PWM", "SP[i]": 0, "PWM Pin": "2.5" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Ext 0 temperature sensor", "PV[i]": 1, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.24", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Ext0 heater PWM", "SP[i]": 1, "PWM Pin": "2.7" }, { "Thread": "Servo", "Type": "PWM", "Comment": "Ext0 part cooling fan PWM on FAN", "SP[i]": 2, "PWM Max": 128, "PWM Pin": "2.4" }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe", "SP[i]": 3, "Servo Pin": "1.23" }, { "Thread": "Servo", "Type": "Switch", "Comment": "Extruder fan switch on E2", "Pin": "2.6", "Mode": "On", "PV[i]": 1, "SP": 35.0 } ] } ================================================ FILE: Firmware/ConfigSamples/TMC2209 Example/SKRv14_TMC2209/config.txt ================================================ { "Board": "BIGTREETECH SKR v1.4", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "1.31" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "2.2", "Direction Pin": "2.6", "Enable Pin": "2.1" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "X - Joint 0 TMC driver", "RX pin": "1.10", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "0.19", "Direction Pin": "0.20", "Enable Pin": "2.08" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "Y - Joint 1 TMC driver", "RX pin": "1.9", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "0.22", "Direction Pin": "2.11", "Enable Pin": "0.21" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "Z - Joint 2 TMC driver", "RX pin": "1.8", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "2.13", "Direction Pin": "0.11", "Enable Pin": "2.12" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "E0 - Joint 3 TMC driver", "RX pin": "1.4", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E1 - Joint 4 step generator", "Joint Number": 4, "Step Pin": "1.15", "Direction Pin": "1.14", "Enable Pin": "1.16" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "E1 - Joint 4 TMC driver", "RX pin": "1.1", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Servo", "Type": "PWM", "Comment": "Bed heater PWM", "SP[i]": 0, "PWM Pin": "2.5" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Bed tenperature sensor", "PV[i]": 0, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.25", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Hotend 0 heater PWM", "SP[i]": 1, "PWM Pin": "2.7" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Hotend 0 tenperature sensor", "PV[i]": 1, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.24", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "PWM", "Comment": "Hotend 1 heater PWM", "SP[i]": 2, "PWM Pin": "2.4" }, { "Thread": "Servo", "Type": "Temperature", "Comment": "Hotend 1 tenperature sensor", "PV[i]": 2, "Sensor": "Thermistor", "Thermistor": { "Pin": "0.23", "beta": 3990, "r0": 100000, "t0": 25 } }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "1.29", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "1.28", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "1.27", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "E0DET", "Pin": "1.26", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "E1DET", "Pin": "1.25", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "PWRDET", "Pin": "1.0", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Probe", "Pin": "0.10", "Mode": "Input", "Data Bit": 6 }, { "Thread": "Base", "Type": "RCServo", "Comment": "RC servo for probe", "SP[i]": 3, "Servo Pin": "2.0" }, { "Thread": "Servo", "Type": "Switch", "Comment": "Extruder fan switch", "Pin": "0.0", "Mode": "On", "PV[i]": 1, "SP": 25.5 } ] } ================================================ FILE: Firmware/ConfigSamples/TMC2209 Example/SKRv2_TMC2209/config.txt ================================================ { "Board": "BIGTREETECH SKR v2", "Modules":[ { "Thread": "Servo", "Type": "Reset Pin", "Comment": "Reset pin", "Pin": "PC_4" }, { "Thread": "On load", "Type": "Motor Power", "Comment": "Enable motor power SKR2", "Pin": "PC_13" }, { "Thread": "Base", "Type": "Stepgen", "Comment": "X - Joint 0 step generator", "Joint Number": 0, "Step Pin": "PE_2", "Direction Pin": "PE_1", "Enable Pin": "PE_3" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "X - Joint 0 TMC driver", "RX pin": "PE_0", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Y - Joint 1 step generator", "Joint Number": 1, "Step Pin": "PD_5", "Direction Pin": "PD_4", "Enable Pin": "PD_6" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "Y - Joint 1 TMC driver", "RX pin": "PD_3", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "Z - Joint 2 step generator", "Joint Number": 2, "Step Pin": "PA_15", "Direction Pin": "PA_8", "Enable Pin": "PD_1" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "Z - Joint 2 TMC driver", "RX pin": "PD_0", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E0 - Joint 3 step generator", "Joint Number": 3, "Step Pin": "PD_15", "Direction Pin": "PD_14", "Enable Pin": "PC_7" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "E0 - Joint 3 TMC driver", "RX pin": "PC_6", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Base", "Type": "Stepgen", "Comment": "E1 - Joint 4 step generator", "Joint Number": 4, "Step Pin": "PD_11", "Direction Pin": "PD_10", "Enable Pin": "PD_13" }, { "Thread": "On load", "Type": "TMC2209", "Comment": "E1 - Joint 4 TMC driver", "RX pin": "PD_12", "RSense": 0.11, "Current": 800, "Microsteps": 16, "Stealth chop": "on", "Stall sensitivity":0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X min", "Pin": "PC_1", "Mode": "Input", "Data Bit": 0 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "X max", "Pin": "PC_2", "Mode": "Input", "Data Bit": 1 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y min", "Pin": "PC_3", "Mode": "Input", "Data Bit": 2 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Y max", "Pin": "PA_0", "Mode": "Input", "Data Bit": 3 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z min", "Pin": "PC_0", "Mode": "Input", "Data Bit": 4 }, { "Thread": "Servo", "Type": "Digital Pin", "Comment": "Z max", "Pin": "PC_15", "Mode": "Input", "Data Bit": 5 }, { "Thread": "Servo", "Type": "Switch", "Comment": "Extruder fan switch", "Pin": "PB_7", "Mode": "On", "PV[i]": 0, "SP": 25.5 } ] } ================================================ FILE: Firmware/FirmwareSource/.gitignore ================================================ /Remora-OS5/mbed-os /Remora-OS5/BUILD /Remora-OS6/mbed-os /Remora-OS6/BUILD ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/.gitignore ================================================ /BUILD /mbed-os ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/.mbed ================================================ ROOT=. <<<<<<< refs/remotes/origin/main=undefined <<<<<<< Updated upstream=undefined = >>>>>>> Stashed changes=undefined >>>>>>> update=undefined ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/MODDMA.lib ================================================ https://os.mbed.com/users/AjK/code/MODDMA/#97a16bf2ff439853ed01edd65a382207e203c733 ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/README.md ================================================ Remora OS5 firmware ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/SoftwareSerial/SoftwareSerial.cpp ================================================ #include "SoftwareSerial.h" #include SoftwareSerial::SoftwareSerial(std::string tx, std::string rx) { if (!tx.empty()) TXportAndPin = tx; if (!rx.empty()) RXportAndPin = rx; halfDuplex = !TXportAndPin.compare(RXportAndPin); if(halfDuplex) { this->rxpin = new Pin(RXportAndPin,1); this->txpin = this->rxpin; setTX(); } else { this->txpin = new Pin(TXportAndPin,0); setTX(); this->rxpin = new Pin(RXportAndPin,1); setRX(); } qin = 0; qout = 0; activeTx = false; activeRx = false; } void SoftwareSerial::begin(int baudrate) { #ifdef FORCE_BAUD_RATE baudrate = FORCE_BAUD_RATE; // 19200 fastest stable baud rate #endif baudRate = baudrate; //ticker.attach_us(callback(this, &SoftwareSerial::tickerHandler), 1000000.0 / (baudRate * 3.0)); } void SoftwareSerial::setSpeed(int baudrate) { //ticker.detach(); //ticker.attach_us(callback(this, &SoftwareSerial::tickerHandler), 1000000.0 / (baudrate * 3.0)); this->baudRate = baudrate; } void SoftwareSerial::setTX(void) { // First write, then set output. If we do this the other way around, // the pin would be output low for a short while before switching to // output hihg. Now, it is input with pullup for a short while, which // is fine. With inverse logic, either order is fine. //this->txpin->set(1); // works for LPC1768 but not STM32 this->txpin->setAsOutput(); this->txpin->set(1); } void SoftwareSerial::setRX(void) { this->rxpin->setAsInput(); this->rxpin->pull_up(); } void SoftwareSerial::setRXTX(bool input) { if (halfDuplex) { if (input) { setRX(); rxBitCnt = -1; rxTickCnt = 2; activeRx = true; } else { if (activeRx) { setTX(); activeRx = false; } } } } bool SoftwareSerial::listen() { if (rxpin != nullptr) { setRXTX(true); return true; } return false; } void SoftwareSerial::end(void) { } void SoftwareSerial::tickerHandler(void) { if (activeTx) this->send(); if (activeRx) this->receive(); } void SoftwareSerial::send(void) { if (--txTickCnt <= 0) { if (txBitCnt++ < TX_BITS) // count out the bits in the txBuffer { this->txpin->set(txBuffer & 0x01); // set output equal to the LSB in txBuffer txBuffer >>= 1; // shift txBuffer to right txTickCnt = OVERSAMPLE; // reset the tick counter } else // transmit finished, stay active or wait for a period before swapping to Rx mode if half duplex mode { txTickCnt = 1; if (outputPending) { activeTx = false; // output pending allow new byte to be written to txBuffer from write() } else if (txBitCnt > 10 + OVERSAMPLE*5) { if (halfDuplex) { setRXTX(true); // switch to receive mode } activeTx = false; } } } } void SoftwareSerial::receive() { if (--rxTickCnt <= 0) { uint8_t inbit = this->rxpin->get(); // read the rx line if (rxBitCnt == -1) // waiting for start bit { if (!inbit) { // got a start bit rxBitCnt = 0; rxTickCnt = OVERSAMPLE + 1; rxBuffer = 0; } else { rxTickCnt = 1; } } else if (rxBitCnt >= RX_BITS) // full byte has been read { // add stop bit to buffer inbuf[qin] = rxBuffer; if ( ++qin >= IN_BUF_SIZE ) { // overflow - reset inbuf-index qin = 0; } rxTickCnt = 1; rxBitCnt = -1; // flag waiting for start bit } else // read data bits { rxBuffer >>= 1; if (inbit) rxBuffer |= 0x80; rxBitCnt++; rxTickCnt = OVERSAMPLE; } } } int SoftwareSerial::available() { return (qout - qin); } void SoftwareSerial::printStr(char* str) { int i = 0; int len = strlen(str); for(i = 0; i= IN_BUF_SIZE ) {qout = 0;} return d; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/SoftwareSerial/SoftwareSerial.h ================================================ #ifndef SOFTWARESERIAL_H #define SOFTWARESERIAL_H //#include "LPC17xx.h" #include "mbed.h" #include #include #include "configuration.h" #include "pin.h" #define FORCE_BAUD_RATE 19600 //9600 #define IN_BUF_SIZE 64 #define TX_BITS 10 // 1 Startbit, 8 Databits, 1 Stopbit = 10 Bits/Frame #define RX_BITS 8 // startbit and stopbit parsed internally (see ISR) //#define OVERSAMPLE 3 class SoftwareSerial { private: //static SoftwareSerial* instance; // there can only be one //void (*_rit_isr)(void); // storage for an appended isr function //void ritisr(void); // the default (instance) isr //static void _ritisr(void); // the actual static isr std::string TXportAndPin; std::string RXportAndPin; Pin* txpin; Pin* rxpin; //Ticker ticker; unsigned char inbuf[IN_BUF_SIZE]; unsigned char qin; unsigned char qout; int32_t baudRate; bool activeTx; bool activeRx; bool halfDuplex; bool outputPending; int32_t rxTickCnt; int32_t txTickCnt; int32_t txBitCnt; int32_t rxBitCnt; int32_t txBuffer; int32_t rxBuffer; public: SoftwareSerial(std::string, std::string); void begin(int); void setSpeed(int); void end(void); void setTX(void); void setRX(void); void setRXTX(bool); void send(void); void receive(void); void write(int); int16_t read(void); bool listen(void); void tickerHandler(void); void enableTx(void); void enableRx(void); void idle() {__NOP();} int available(); void flush_input_buffer(); void printStr(char*); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_OCTOPUS_429/PeripheralNames.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2015, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_PERIPHERALNAMES_H #define MBED_PERIPHERALNAMES_H #include "cmsis.h" #ifdef __cplusplus extern "C" { #endif typedef enum { ADC_1 = (int)ADC1_BASE, ADC_2 = (int)ADC2_BASE, ADC_3 = (int)ADC3_BASE } ADCName; typedef enum { DAC_1 = (int)DAC_BASE } DACName; typedef enum { UART_1 = (int)USART1_BASE, UART_2 = (int)USART2_BASE, UART_3 = (int)USART3_BASE, UART_4 = (int)UART4_BASE, UART_5 = (int)UART5_BASE, UART_6 = (int)USART6_BASE, UART_7 = (int)UART7_BASE, UART_8 = (int)UART8_BASE } UARTName; #define DEVICE_SPI_COUNT 6 typedef enum { SPI_1 = (int)SPI1_BASE, SPI_2 = (int)SPI2_BASE, SPI_3 = (int)SPI3_BASE, SPI_4 = (int)SPI4_BASE, SPI_5 = (int)SPI5_BASE, SPI_6 = (int)SPI6_BASE } SPIName; typedef enum { I2C_1 = (int)I2C1_BASE, I2C_2 = (int)I2C2_BASE, I2C_3 = (int)I2C3_BASE } I2CName; typedef enum { PWM_1 = (int)TIM1_BASE, PWM_2 = (int)TIM2_BASE, PWM_3 = (int)TIM3_BASE, PWM_4 = (int)TIM4_BASE, PWM_5 = (int)TIM5_BASE, PWM_8 = (int)TIM8_BASE, PWM_9 = (int)TIM9_BASE, PWM_10 = (int)TIM10_BASE, PWM_11 = (int)TIM11_BASE, PWM_12 = (int)TIM12_BASE, PWM_13 = (int)TIM13_BASE, PWM_14 = (int)TIM14_BASE } PWMName; typedef enum { CAN_1 = (int)CAN1_BASE, CAN_2 = (int)CAN2_BASE } CANName; typedef enum { USB_FS = (int)USB_OTG_FS_PERIPH_BASE, USB_HS = (int)USB_OTG_HS_PERIPH_BASE } USBName; #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_OCTOPUS_429/PeripheralPins.c ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #include "PeripheralPins.h" #include "mbed_toolchain.h" //============================================================================== // Notes // // - The pins mentioned Px_y_ALTz are alternative possibilities which use other // HW peripheral instances. You can use them the same way as any other "normal" // pin (i.e. PwmOut pwm(PA_7_ALT0);). These pins are not displayed on the board // pinout image on mbed.org. // // - The pins which are connected to other components present on the board have // the comment "Connected to xxx". The pin function may not work properly in this // case. These pins may not be displayed on the board pinout image on mbed.org. // Please read the board reference manual and schematic for more information. // // - Warning: pins connected to the default STDIO_UART_TX and STDIO_UART_RX pins are commented // See https://os.mbed.com/teams/ST/wiki/STDIO for more information. // //============================================================================== //*** ADC *** MBED_WEAK const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 // Connected to B1 [Blue PushButton] {PA_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 // Connected to B1 [Blue PushButton] {PA_0_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 // Connected to B1 [Blue PushButton] {PA_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 // Connected to MEMS_INT1 [L3GD20_INT1] {PA_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 // Connected to MEMS_INT1 [L3GD20_INT1] {PA_1_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 // Connected to MEMS_INT1 [L3GD20_INT1] {PA_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 // Connected to MEMS_INT2 [L3GD20_INT2] {PA_2_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 // Connected to MEMS_INT2 [L3GD20_INT2] {PA_2_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 // Connected to MEMS_INT2 [L3GD20_INT2] {PA_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 // Connected to B5 {PA_3_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 // Connected to B5 {PA_3_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 // Connected to B5 {PA_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 // Connected to VSYNC {PA_4_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 // Connected to VSYNC {PA_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 {PA_5_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 {PA_6, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 // Connected to G2 {PA_6_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 // Connected to G2 {PA_7, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 // Connected to ACP_RST {PA_7_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 // Connected to ACP_RST {PB_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 // Connected to R3 {PB_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 // Connected to R3 {PB_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 // Connected to R6 {PB_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 // Connected to R6 {PC_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 // Connected to SDNWE {PC_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 // Connected to SDNWE {PC_0_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 // Connected to SDNWE {PC_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 // Connected to NCS_MEMS_SPI [L3GD20_CS_I2C/SPI] {PC_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 // Connected to NCS_MEMS_SPI [L3GD20_CS_I2C/SPI] {PC_1_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 // Connected to NCS_MEMS_SPI [L3GD20_CS_I2C/SPI] {PC_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 // Connected to CSX [LCD-RGB_CSX] {PC_2_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 // Connected to CSX [LCD-RGB_CSX] {PC_2_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 // Connected to CSX [LCD-RGB_CSX] {PC_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 {PC_3_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 {PC_3_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 {PC_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 // Connected to OTG_FS_PSO [OTG_FS_PowerSwitchOn] {PC_4_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 // Connected to OTG_FS_PSO [OTG_FS_PowerSwitchOn] {PC_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 // Connected to OTG_FS_OC [OTG_FS_OverCurrent] {PC_5_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 // Connected to OTG_FS_OC [OTG_FS_OverCurrent] {PF_3, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9 // Connected to A3 {PF_4, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC3_IN14 // Connected to A4 {PF_5, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_IN15 // Connected to A5 {PF_6, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 {PF_7, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 // Connected to SPI5_SCK [L3GD20_SCL/SPC] {PF_8, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 // Connected to SPI5_MISO [L3GD20_SDO] {PF_9, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC3_IN7 // Connected to SPI5_MOSI [L3GD20_SDA/SDI/SDO] {PF_10, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC3_IN8 // Connected to ENABLE [LCD-RGB_ENABLE] {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_ADC_Internal[] = { {ADC_TEMP, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, {ADC_VREF, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, {ADC_VBAT, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, {NC, NC, 0} }; //*** DAC *** MBED_WEAK const PinMap PinMap_DAC[] = { {PA_4, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 // Connected to VSYNC {PA_5, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 {NC, NC, 0} }; //*** I2C *** MBED_WEAK const PinMap PinMap_I2C_SDA[] = { {PB_7, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // Connected to B7 {PB_11, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // Connected to G5 {PC_9, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // Connected to I2C3_SDA [ACP/RF_SDA] {PF_0, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // Connected to A0 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_I2C_SCL[] = { {PA_8, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // Connected to I2C3_SCL [ACP/RF_SCL] {PB_6, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // Connected to SDNE1 [SDRAM_CS] {PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // Connected to B6 {PB_10, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // Connected to G4 {PF_1, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // Connected to A1 {NC, NC, 0} }; //*** PWM *** // TIM5 cannot be used because already used by the us_ticker MBED_WEAK const PinMap PinMap_PWM[] = { {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // Connected to B1 [Blue PushButton] // {PA_0, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 // Connected to B1 [Blue PushButton] {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // Connected to MEMS_INT1 [L3GD20_INT1] // {PA_1, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 // Connected to MEMS_INT1 [L3GD20_INT1] {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // Connected to MEMS_INT2 [L3GD20_INT2] // {PA_2, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 // Connected to MEMS_INT2 [L3GD20_INT2] {PA_2_ALT0, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 // Connected to MEMS_INT2 [L3GD20_INT2] {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 // Connected to B5 // {PA_3, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 // Connected to B5 {PA_3_ALT0, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 // Connected to B5 {PA_5, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PA_5_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N {PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 // Connected to G2 {PA_6_ALT0, PWM_13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 // Connected to G2 {PA_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // Connected to ACP_RST {PA_7_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // Connected to ACP_RST {PA_7_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N // Connected to ACP_RST {PA_7_ALT2, PWM_14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 // Connected to ACP_RST {PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 // Connected to I2C3_SCL [ACP/RF_SCL] // {PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 // Connected to STDIO_UART_TX // {PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 // Connected to STDIO_UART_RX {PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 // Connected to R4 {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // Connected to TP_INT1 [Touch Panel] {PB_0, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N // Connected to R3 {PB_0_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 // Connected to R3 {PB_0_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N // Connected to R3 {PB_1, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N // Connected to R6 {PB_1_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 // Connected to R6 {PB_1_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N // Connected to R6 {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 {PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // Connected to SDCKE1 {PB_6, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 // Connected to SDNE1 [SDRAM_CS] {PB_7, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 {PB_8, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 // Connected to B6 {PB_8_ALT0, PWM_10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 // Connected to B6 {PB_9, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 // Connected to B7 {PB_9_ALT0, PWM_11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 // Connected to B7 {PB_10, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // Connected to G4 {PB_11, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 // Connected to G5 {PB_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // Connected to VBUS_HS {PB_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N // Connected to OTG_HS_DM {PB_14_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N // Connected to OTG_HS_DM {PB_14_ALT1, PWM_12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 // Connected to OTG_HS_DM {PB_15, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N // Connected to OTG_HS_DP {PB_15_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N // Connected to OTG_HS_DP {PB_15_ALT1, PWM_12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 // Connected to OTG_HS_DP {PC_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 // Connected to HSYNC {PC_6_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 // Connected to HSYNC {PC_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // Connected to G6 {PC_7_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 // Connected to G6 {PC_8, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 {PC_8_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 {PC_9, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 // Connected to I2C3_SDA [ACP/RF_SDA] {PC_9_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 // Connected to I2C3_SDA [ACP/RF_SDA] {PD_12, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 // Connected to RDX [LDC-RGB_RDX] {PD_13, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 // Connected to WRX_DCX [LCD-RGB_WRX_DCX] {PD_14, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 // Connected to D0 {PD_15, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 // Connected to D1 {PE_5, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 {PE_6, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 {PE_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // Connected to D5 {PE_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 // Connected to D6 {PE_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N // Connected to D7 {PE_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 // Connected to D8 {PE_12, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N // Connected to D9 {PE_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 // Connected to D10 {PE_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 // Connected to D11 {PF_6, PWM_10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 {PF_7, PWM_11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 // Connected to SPI5_SCK [L3GD20_SCL/SPC] {PF_8, PWM_13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 // Connected to SPI5_MISO [L3GD20_SDO] {PF_9, PWM_14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 // Connected to SPI5_MOSI [L3GD20_SDA/SDI/SDO] {NC, NC, 0} }; //*** SERIAL *** MBED_WEAK const PinMap PinMap_UART_TX[] = { {PA_0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // Connected to B1 [Blue PushButton] {PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to MEMS_INT2 [L3GD20_INT2] {PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to STDIO_UART_TX {PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to SDNE1 [SDRAM_CS] {PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to G4 {PC_6, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, // Connected to HSYNC {PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to R2 {PC_10_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // Connected to R2 {PC_12, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_5, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_8, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to D13 {PE_1, UART_8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, // Connected to NBL1 [SDRAM_UDQM] {PE_8, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART7)}, // Connected to D5 {PF_7, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART7)}, // Connected to SPI5_SCK [L3GD20_SCL/SPC] {PG_14, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, // Connected to LD4 [Red Led] {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_RX[] = { {PA_1, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // Connected to MEMS_INT1 [L3GD20_INT1] {PA_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to B5 {PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to STDIO_UART_RX {PB_7, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PB_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to G5 {PC_7, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, // Connected to G6 {PC_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PC_11_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PD_2, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_6, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to B2 {PD_9, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to D14 {PE_0, UART_8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, // Connected to NBL0 [SDRAM_LDQM] {PE_7, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART7)}, // Connected to D4 {PF_6, UART_7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART7)}, {PG_9, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_RTS[] = { {PA_1, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to MEMS_INT1 [L3GD20_INT1] {PA_12, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to R5 {PB_14, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to OTG_HS_DM {PD_4, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_12, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to RDX [LDC-RGB_RDX] {PG_8, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, // Connected to SDCLK {PG_12, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, // Connected to B4 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to B1 [Blue PushButton] {PA_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to R4 {PB_13, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to VBUS_HS {PD_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to G7 {PD_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to TE [LCD-RGB_TE] {PG_13, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, // Connected to LD3 [Green Led] {PG_15, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, // Connected to SDNCAS {NC, NC, 0} }; //*** SPI *** MBED_WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to ACP_RST {PB_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to SDCKE1 {PB_5_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // Connected to SDCKE1 {PB_15, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to OTG_HS_DP {PC_3, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PC_12, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PD_6, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to B2 {PE_6, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PE_14, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, // Connected to D11 {PF_9, SPI_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI5)}, // Connected to SPI5_MOSI [L3GD20_SDA/SDI/SDO] {PF_11, SPI_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI5)}, // Connected to SDNRAS {PG_14, SPI_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI6)}, // Connected to LD4 [Red Led] {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to G2 {PB_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PB_4_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PB_14, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to OTG_HS_DM {PC_2, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to CSX [LCD-RGB_CSX] {PC_11, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PE_5, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PE_13, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, // Connected to D10 {PF_8, SPI_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI5)}, // Connected to SPI5_MISO [L3GD20_SDO] {PG_12, SPI_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI6)}, // Connected to B4 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PB_3_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PB_10, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to G4 {PB_13, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to VBUS_HS {PC_10, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // Connected to R2 {PD_3, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to G7 {PE_2, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PE_12, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, // Connected to D9 {PF_7, SPI_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI5)}, // Connected to SPI5_SCK [L3GD20_SCL/SPC] {PG_13, SPI_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI6)}, // Connected to LD3 [Green Led] {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to VSYNC {PA_4_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // Connected to VSYNC {PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to TP_INT1 [Touch Panel] {PA_15_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // Connected to TP_INT1 [Touch Panel] {PB_9, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to B7 {PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to OTG_HS_ID {PE_4, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PE_11, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, // Connected to D8 {PF_6, SPI_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI5)}, {PG_8, SPI_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI6)}, // Connected to SDCLK {NC, NC, 0} }; //*** CAN *** MBED_WEAK const PinMap PinMap_CAN_RD[] = { {PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to R4 {PB_5, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, // Connected to SDCKE1 {PB_8, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to B6 {PB_12, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, // Connected to OTG_HS_ID {PD_0, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to D2 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_CAN_TD[] = { {PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to R5 {PB_6, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, // Connected to SDNE1 [SDRAM_CS] {PB_9, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to B7 {PB_13, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, // Connected to VBUS_HS {PD_1, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to D3 {NC, NC, 0} }; //*** USBDEVICE *** MBED_WEAK const PinMap PinMap_USB_FS[] = { // {PA_8, USB_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF // Connected to I2C3_SCL [ACP/RF_SCL] // {PA_9, USB_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS // Connected to STDIO_UART_TX // {PA_10, USB_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID // Connected to STDIO_UART_RX {PA_11, USB_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM // Connected to R4 {PA_12, USB_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP // Connected to R5 {NC, NC, 0} }; //*** USBDEVICE *** MBED_WEAK const PinMap PinMap_USB_HS[] = { #if (MBED_CONF_TARGET_USB_SPEED == USE_USB_HS_IN_FS) // {PA_4, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF // Connected to VSYNC {PB_12, USB_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID // Connected to OTG_HS_ID {PB_13, USB_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS // Connected to VBUS_HS {PB_14, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM // Connected to OTG_HS_DM {PB_15, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP // Connected to OTG_HS_DP #else /* MBED_CONF_TARGET_USB_SPEED */ {PA_3, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 // Connected to B5 {PA_5, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_CK {PB_0, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 // Connected to R3 {PB_1, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 // Connected to R6 {PB_5, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 // Connected to SDCKE1 {PB_10, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 // Connected to G4 {PB_11, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D4 // Connected to G5 {PB_12, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 // Connected to OTG_HS_ID {PB_13, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 // Connected to VBUS_HS {PC_0, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP // Connected to SDNWE {PC_2, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR // Connected to CSX [LCD-RGB_CSX] {PC_3, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT #endif /* MBED_CONF_TARGET_USB_SPEED */ {NC, NC, 0} }; ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_OCTOPUS_429/PinNames.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_PINNAMES_H #define MBED_PINNAMES_H #include "cmsis.h" #include "PinNamesTypes.h" #ifdef __cplusplus extern "C" { #endif typedef enum { ALT0 = 0x100, ALT1 = 0x200, ALT2 = 0x300, ALT3 = 0x400 } ALTx; typedef enum { PA_0 = 0x00, PA_0_ALT0 = PA_0 | ALT0, PA_0_ALT1 = PA_0 | ALT1, PA_1 = 0x01, PA_1_ALT0 = PA_1 | ALT0, PA_1_ALT1 = PA_1 | ALT1, PA_2 = 0x02, PA_2_ALT0 = PA_2 | ALT0, PA_2_ALT1 = PA_2 | ALT1, PA_3 = 0x03, PA_3_ALT0 = PA_3 | ALT0, PA_3_ALT1 = PA_3 | ALT1, PA_4 = 0x04, PA_4_ALT0 = PA_4 | ALT0, PA_5 = 0x05, PA_5_ALT0 = PA_5 | ALT0, PA_5_ALT1 = PA_5 | ALT1, PA_6 = 0x06, PA_6_ALT0 = PA_6 | ALT0, PA_7 = 0x07, PA_7_ALT0 = PA_7 | ALT0, PA_7_ALT1 = PA_7 | ALT1, PA_7_ALT2 = PA_7 | ALT2, PA_8 = 0x08, PA_9 = 0x09, PA_10 = 0x0A, PA_11 = 0x0B, PA_12 = 0x0C, PA_13 = 0x0D, PA_14 = 0x0E, PA_15 = 0x0F, PA_15_ALT0 = PA_15 | ALT0, PB_0 = 0x10, PB_0_ALT0 = PB_0 | ALT0, PB_0_ALT1 = PB_0 | ALT1, PB_1 = 0x11, PB_1_ALT0 = PB_1 | ALT0, PB_1_ALT1 = PB_1 | ALT1, PB_2 = 0x12, PB_3 = 0x13, PB_3_ALT0 = PB_3 | ALT0, PB_4 = 0x14, PB_4_ALT0 = PB_4 | ALT0, PB_5 = 0x15, PB_5_ALT0 = PB_5 | ALT0, PB_6 = 0x16, PB_7 = 0x17, PB_8 = 0x18, PB_8_ALT0 = PB_8 | ALT0, PB_9 = 0x19, PB_9_ALT0 = PB_9 | ALT0, PB_10 = 0x1A, PB_11 = 0x1B, PB_12 = 0x1C, PB_13 = 0x1D, PB_14 = 0x1E, PB_14_ALT0 = PB_14 | ALT0, PB_14_ALT1 = PB_14 | ALT1, PB_15 = 0x1F, PB_15_ALT0 = PB_15 | ALT0, PB_15_ALT1 = PB_15 | ALT1, PC_0 = 0x20, PC_0_ALT0 = PC_0 | ALT0, PC_0_ALT1 = PC_0 | ALT1, PC_1 = 0x21, PC_1_ALT0 = PC_1 | ALT0, PC_1_ALT1 = PC_1 | ALT1, PC_2 = 0x22, PC_2_ALT0 = PC_2 | ALT0, PC_2_ALT1 = PC_2 | ALT1, PC_3 = 0x23, PC_3_ALT0 = PC_3 | ALT0, PC_3_ALT1 = PC_3 | ALT1, PC_4 = 0x24, PC_4_ALT0 = PC_4 | ALT0, PC_5 = 0x25, PC_5_ALT0 = PC_5 | ALT0, PC_6 = 0x26, PC_6_ALT0 = PC_6 | ALT0, PC_7 = 0x27, PC_7_ALT0 = PC_7 | ALT0, PC_8 = 0x28, PC_8_ALT0 = PC_8 | ALT0, PC_9 = 0x29, PC_9_ALT0 = PC_9 | ALT0, PC_10 = 0x2A, PC_10_ALT0 = PC_10 | ALT0, PC_11 = 0x2B, PC_11_ALT0 = PC_11 | ALT0, PC_12 = 0x2C, PC_13 = 0x2D, PC_14 = 0x2E, PC_15 = 0x2F, PD_0 = 0x30, PD_1 = 0x31, PD_2 = 0x32, PD_3 = 0x33, PD_4 = 0x34, PD_5 = 0x35, PD_6 = 0x36, PD_7 = 0x37, PD_8 = 0x38, PD_9 = 0x39, PD_10 = 0x3A, PD_11 = 0x3B, PD_12 = 0x3C, PD_13 = 0x3D, PD_14 = 0x3E, PD_15 = 0x3F, PE_0 = 0x40, PE_1 = 0x41, PE_2 = 0x42, PE_3 = 0x43, PE_4 = 0x44, PE_5 = 0x45, PE_6 = 0x46, PE_7 = 0x47, PE_8 = 0x48, PE_9 = 0x49, PE_10 = 0x4A, PE_11 = 0x4B, PE_12 = 0x4C, PE_13 = 0x4D, PE_14 = 0x4E, PE_15 = 0x4F, PF_0 = 0x50, PF_1 = 0x51, PF_2 = 0x52, PF_3 = 0x53, PF_4 = 0x54, PF_5 = 0x55, PF_6 = 0x56, PF_7 = 0x57, PF_8 = 0x58, PF_9 = 0x59, PF_10 = 0x5A, PF_11 = 0x5B, PF_12 = 0x5C, PF_13 = 0x5D, PF_14 = 0x5E, PF_15 = 0x5F, PG_0 = 0x60, PG_1 = 0x61, PG_2 = 0x62, PG_3 = 0x63, PG_4 = 0x64, PG_5 = 0x65, PG_6 = 0x66, PG_7 = 0x67, PG_8 = 0x68, PG_9 = 0x69, PG_10 = 0x6A, PG_11 = 0x6B, PG_12 = 0x6C, PG_13 = 0x6D, PG_14 = 0x6E, PG_15 = 0x6F, PH_0 = 0x70, PH_1 = 0x71, // ADC internal channels ADC_TEMP = 0xF0, ADC_VREF = 0xF1, ADC_VBAT = 0xF2, // STDIO for console print #ifdef MBED_CONF_TARGET_STDIO_UART_TX STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX, #else STDIO_UART_TX = PA_9, #endif #ifdef MBED_CONF_TARGET_STDIO_UART_RX STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX, #else STDIO_UART_RX = PA_10, #endif // Generic signals namings LED1 = PG_13, // Corresponds to LD3 on MB1075B LED2 = PG_14, // Corresponds to LD4 on MB1075B LED3 = PG_13, LED4 = PG_14, LED_RED = LED2, USER_BUTTON = PA_0, // Standardized button names BUTTON1 = USER_BUTTON, SERIAL_TX = STDIO_UART_TX, SERIAL_RX = STDIO_UART_RX, USBTX = STDIO_UART_TX, USBRX = STDIO_UART_RX, SPI_MOSI = PA_7, SPI_MISO = PA_6, SPI_SCK = PA_5, SPI_CS = PB_6, /**** USB FS pins ****/ USB_OTG_FS_DM = PA_11, USB_OTG_FS_DP = PA_12, USB_OTG_FS_ID = PA_10, USB_OTG_FS_SOF = PA_8, USB_OTG_FS_VBUS = PA_9, /**** USB HS pins ****/ USB_OTG_HS_DM = PB_14, USB_OTG_HS_DP = PB_15, USB_OTG_HS_ID = PB_12, USB_OTG_HS_SOF = PA_4, USB_OTG_HS_ULPI_CK = PA_5, USB_OTG_HS_ULPI_D0 = PA_3, USB_OTG_HS_ULPI_D1 = PB_0, USB_OTG_HS_ULPI_D2 = PB_1, USB_OTG_HS_ULPI_D3 = PB_10, USB_OTG_HS_ULPI_D4 = PB_11, USB_OTG_HS_ULPI_D5 = PB_12, USB_OTG_HS_ULPI_D6 = PB_13, USB_OTG_HS_ULPI_D7 = PB_5, USB_OTG_HS_ULPI_DIR = PC_2, USB_OTG_HS_ULPI_NXT = PC_3, USB_OTG_HS_ULPI_STP = PC_0, USB_OTG_HS_VBUS = PB_13, /**** ETHERNET pins ****/ ETH_COL = PA_3, ETH_CRS = PA_0, ETH_CRS_DV = PA_7, ETH_MDC = PC_1, ETH_MDIO = PA_2, ETH_PPS_OUT = PG_8, ETH_PPS_OUT_ALT0 = PB_5, ETH_REF_CLK = PA_1, ETH_RXD0 = PC_4, ETH_RXD1 = PC_5, ETH_RXD2 = PB_0, ETH_RXD3 = PB_1, ETH_RX_CLK = PA_1, ETH_RX_DV = PA_7, ETH_RX_ER = PB_10, ETH_TXD0 = PB_12, ETH_TXD0_ALT0 = PG_13, ETH_TXD1 = PB_13, ETH_TXD1_ALT0 = PG_14, ETH_TXD2 = PC_2, ETH_TXD3 = PE_2, ETH_TXD3_ALT0 = PB_8, ETH_TX_CLK = PC_3, ETH_TX_EN = PB_11, ETH_TX_EN_ALT0 = PG_11, /**** OSCILLATOR pins ****/ RCC_OSC32_IN = PC_14, RCC_OSC32_OUT = PC_15, RCC_OSC_IN = PH_0, RCC_OSC_OUT = PH_1, /**** DEBUG pins ****/ SYS_JTCK_SWCLK = PA_14, SYS_JTDI = PA_15, SYS_JTDO_SWO = PB_3, SYS_JTMS_SWDIO = PA_13, SYS_JTRST = PB_4, SYS_TRACECLK = PE_2, SYS_TRACED0 = PE_3, SYS_TRACED1 = PE_4, SYS_TRACED2 = PE_5, SYS_TRACED3 = PE_6, SYS_WKUP = PA_0, // Not connected NC = (int)0xFFFFFFFF } PinName; #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_OCTOPUS_429/system_clock.c ================================================ /* mbed Microcontroller Library * Copyright (c) 2006-2017 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * This file configures the system clock as follows: *----------------------------------------------------------------------------------- * System clock source | 1- USE_PLL_HSE_EXTC (external 8 MHz clock) | * | 2- USE_PLL_HSE_XTAL (external 8 MHz xtal) | DEVICE_USBDEVICE=1 * | 3- USE_PLL_HSI (internal 16 MHz clock) | *----------------------------------------------------------------------------------- * SYSCLK(MHz) | 180 | 168 * AHBCLK (MHz) | 180 | 168 * APB1CLK (MHz) | 45 | 42 * APB2CLK (MHz) | 90 | 84 * USB capable (48 MHz) | NO | YES (HSI calibration needed) *----------------------------------------------------------------------------------- **/ #include "stm32f4xx.h" //#include "nvic_addr.h" original #include "mbed_error.h" /*!< COPIED FROM SKR2 Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x8000 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ // clock source is selected with CLOCK_SOURCE in json config #define USE_PLL_HSE_EXTC 0x8 // Use external clock (ST Link MCO) #define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default) #define USE_PLL_HSI 0x2 // Use HSI internal clock #if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) uint8_t SetSysClock_PLL_HSE(uint8_t bypass); #endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ #if ((CLOCK_SOURCE) & USE_PLL_HSI) uint8_t SetSysClock_PLL_HSI(void); #endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ /** * @brief Setup the microcontroller system * Initialize the FPU setting, vector table location and External memory * configuration. * @param None * @retval None */ void SystemInit(void) { /* FPU settings ------------------------------------------------------------*/ #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */ #endif /* Reset the RCC clock configuration to the default reset state ------------*/ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset CFGR register */ RCC->CFGR = 0x00000000; /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset PLLCFGR register */ RCC->PLLCFGR = 0x24003010; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Disable all interrupts */ RCC->CIR = 0x00000000; #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ /* Configure the Vector Table location add offset address ------------------*/ #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ #else // original line //SCB->VTOR = NVIC_FLASH_VECTOR_ADDRESS; /* Vector Table Relocation in Internal FLASH */ // copied from SKR2 SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ #endif } /** * @brief Configures the System clock source, PLL Multiplier and Divider factors, * AHB/APBx prescalers and Flash settings * @note This function should be called only once the RCC clock configuration * is reset to the default reset state (done in SystemInit() function). * @param None * @retval None */ void SetSysClock(void) { #if ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) /* 1- Try to start with HSE and external clock */ if (SetSysClock_PLL_HSE(1) == 0) #endif { #if ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) /* 2- If fail try to start with HSE and external xtal */ if (SetSysClock_PLL_HSE(0) == 0) #endif { #if ((CLOCK_SOURCE) & USE_PLL_HSI) /* 3- If fail start with HSI clock */ if (SetSysClock_PLL_HSI() == 0) #endif { { error("SetSysClock failed\n"); } } } } } #if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) /******************************************************************************/ /* PLL (clocked by HSE) used as System clock source */ /******************************************************************************/ uint8_t SetSysClock_PLL_HSE(uint8_t bypass) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; /* The voltage scaling allows optimizing the power consumption when the device is clocked below the maximum system frequency, to update the voltage scaling value regarding system frequency refer to product datasheet. */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); // Enable HSE oscillator and activate PLL with HSE as source RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; if (bypass == 0) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External 8 MHz xtal on OSC_IN/OSC_OUT } else { RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External 8 MHz clock on OSC_IN } RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 8; #if (DEVICE_USBDEVICE) RCC_OscInitStruct.PLL.PLLN = 336; #else RCC_OscInitStruct.PLL.PLLN = 360; #endif RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // 180 MHz or 168 MHz if DEVICE_USBDEVICE defined RCC_OscInitStruct.PLL.PLLQ = 7; // 48 MHz if DEVICE_USBDEVICE defined if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { return 0; // FAIL } // Activate the OverDrive to reach the 180 MHz Frequency if (HAL_PWREx_EnableOverDrive() != HAL_OK) { return 0; // FAIL } // Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 180 or 168 MHz RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 45 or 42 MHz RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 90 or 84 MHz if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { return 0; // FAIL } // HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_3); return 1; } #endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ #if ((CLOCK_SOURCE) & USE_PLL_HSI) /******************************************************************************/ /* PLL (clocked by HSI) used as System clock source */ /******************************************************************************/ uint8_t SetSysClock_PLL_HSI(void) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; /* The voltage scaling allows optimizing the power consumption when the device is clocked below the maximum system frequency, to update the voltage scaling value regarding system frequency refer to product datasheet. */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); // Enable HSI oscillator and activate PLL with HSI as source RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSEState = RCC_HSE_OFF; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = 8; #if (DEVICE_USBDEVICE) RCC_OscInitStruct.PLL.PLLN = 168; #else RCC_OscInitStruct.PLL.PLLN = 180; #endif RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // 180 MHz or 168 MHz if DEVICE_USBDEVICE defined RCC_OscInitStruct.PLL.PLLQ = 7; // 48 MHz if DEVICE_USBDEVICE defined if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { return 0; // FAIL } // Activate the OverDrive to reach the 180 MHz Frequency if (HAL_PWREx_EnableOverDrive() != HAL_OK) { return 0; // FAIL } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 180 or 168 MHz RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 45 or 42 MHz RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 90 or 84 MHz if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { return 0; // FAIL } // HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_3); return 1; } #endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_OCTOPUS_446/PeripheralNames.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2014, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_PERIPHERALNAMES_H #define MBED_PERIPHERALNAMES_H #include "cmsis.h" #ifdef __cplusplus extern "C" { #endif typedef enum { ADC_1 = (int)ADC1_BASE, ADC_2 = (int)ADC2_BASE, ADC_3 = (int)ADC3_BASE } ADCName; typedef enum { DAC_1 = (int)DAC_BASE } DACName; typedef enum { UART_1 = (int)USART1_BASE, UART_2 = (int)USART2_BASE, UART_3 = (int)USART3_BASE, UART_4 = (int)UART4_BASE, UART_5 = (int)UART5_BASE, UART_6 = (int)USART6_BASE } UARTName; #define DEVICE_SPI_COUNT 4 typedef enum { SPI_1 = (int)SPI1_BASE, SPI_2 = (int)SPI2_BASE, SPI_3 = (int)SPI3_BASE, SPI_4 = (int)SPI4_BASE } SPIName; typedef enum { I2C_1 = (int)I2C1_BASE, I2C_2 = (int)I2C2_BASE, I2C_3 = (int)I2C3_BASE, FMPI2C_1 = (int)FMPI2C1_BASE } I2CName; typedef enum { PWM_1 = (int)TIM1_BASE, PWM_2 = (int)TIM2_BASE, PWM_3 = (int)TIM3_BASE, PWM_4 = (int)TIM4_BASE, PWM_5 = (int)TIM5_BASE, PWM_8 = (int)TIM8_BASE, PWM_9 = (int)TIM9_BASE, PWM_10 = (int)TIM10_BASE, PWM_11 = (int)TIM11_BASE, PWM_12 = (int)TIM12_BASE, PWM_13 = (int)TIM13_BASE, PWM_14 = (int)TIM14_BASE } PWMName; typedef enum { CAN_1 = (int)CAN1_BASE, CAN_2 = (int)CAN2_BASE } CANName; typedef enum { QSPI_1 = (int)QSPI_R_BASE, } QSPIName; typedef enum { USB_FS = (int)USB_OTG_FS_PERIPH_BASE, USB_HS = (int)USB_OTG_HS_PERIPH_BASE } USBName; #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_OCTOPUS_446/PeripheralPins.c ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #include "PeripheralPins.h" #include "mbed_toolchain.h" //============================================================================== // Notes // // - The pins mentioned Px_y_ALTz are alternative possibilities which use other // HW peripheral instances. You can use them the same way as any other "normal" // pin (i.e. PwmOut pwm(PA_7_ALT0);). These pins are not displayed on the board // pinout image on mbed.org. // // - The pins which are connected to other components present on the board have // the comment "Connected to xxx". The pin function may not work properly in this // case. These pins may not be displayed on the board pinout image on mbed.org. // Please read the board reference manual and schematic for more information. // // - Warning: pins connected to the default STDIO_UART_TX and STDIO_UART_RX pins are commented // See https://os.mbed.com/teams/ST/wiki/STDIO for more information. // //============================================================================== //*** ADC *** MBED_WEAK const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 {PA_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 {PA_0_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 {PA_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 {PA_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 {PA_1_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 {PA_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 {PA_2_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 {PA_2_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 {PA_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 {PA_3_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 {PA_3_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 {PA_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 {PA_4_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 {PA_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 {PA_5_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 {PA_6, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 {PA_6_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 {PA_7, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 {PA_7_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 {PB_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 // Connected to LD1 {PB_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 // Connected to LD1 {PB_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 {PB_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 {PC_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 {PC_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 {PC_0_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 {PC_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 {PC_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 {PC_1_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 {PC_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 {PC_2_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 {PC_2_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 {PC_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 {PC_3_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 {PC_3_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 {PC_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 {PC_4_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 {PC_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 {PC_5_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 {PF_3, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9 {PF_4, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC3_IN14 {PF_5, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_IN15 {PF_6, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 {PF_7, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 {PF_8, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 {PF_9, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC3_IN7 {PF_10, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC3_IN8 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_ADC_Internal[] = { {ADC_TEMP, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, {ADC_VREF, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, {ADC_VBAT, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, {NC, NC, 0} }; //*** DAC *** MBED_WEAK const PinMap PinMap_DAC[] = { {PA_4, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 {PA_5, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 {NC, NC, 0} }; //*** I2C *** MBED_WEAK const PinMap PinMap_I2C_SDA[] = { {PB_3, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PB_4, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PB_7, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // Connected to LD2 [Blue] {PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_11, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PC_7, FMPI2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, {PC_9, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PC_12, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PD_13, FMPI2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, {PD_15, FMPI2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, {PF_0, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PF_15, FMPI2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_I2C_SCL[] = { {PA_8, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, // Connected to USB_SOF [TP1] {PB_6, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_10, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PC_6, FMPI2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, {PD_12, FMPI2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, {PD_14, FMPI2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, {PF_1, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PF_14, FMPI2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, {NC, NC, 0} }; //*** PWM *** // TIM5 cannot be used because already used by the us_ticker MBED_WEAK const PinMap PinMap_PWM[] = { {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // {PA_0, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // {PA_1, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // {PA_2, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 {PA_2_ALT0, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 // {PA_3, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 {PA_3_ALT0, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 {PA_5, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PA_5_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N {PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PA_6_ALT0, PWM_13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 {PA_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PA_7_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 {PA_7_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N {PA_7_ALT2, PWM_14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 {PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 // Connected to USB_SOF [TP1] {PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 // Connected to USB_VBUS {PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 // Connected to USB_ID {PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 // Connected to USB_DM {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PB_0, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N // Connected to LD1 {PB_0_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 // Connected to LD1 {PB_0_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N // Connected to LD1 {PB_1, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PB_1_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 {PB_1_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N {PB_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 {PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 {PB_6, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 {PB_7, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 // Connected to LD2 [Blue] {PB_8, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PB_8_ALT0, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 {PB_8_ALT1, PWM_10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 {PB_9, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 {PB_9_ALT0, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 {PB_9_ALT1, PWM_11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 {PB_10, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 {PB_11, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 {PB_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PB_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N // Connected to LD3 [Red] {PB_14_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N // Connected to LD3 [Red] {PB_14_ALT1, PWM_12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 // Connected to LD3 [Red] {PB_15, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PB_15_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N {PB_15_ALT1, PWM_12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 {PC_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PC_6_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 {PC_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 {PC_7_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 {PC_8, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 {PC_8_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 {PC_9, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 {PC_9_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 {PD_12, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 {PD_13, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 {PD_14, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 {PD_15, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 {PE_5, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 {PE_6, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 {PE_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PE_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 {PE_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N {PE_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 {PE_12, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PE_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 {PE_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 {PF_6, PWM_10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 {PF_7, PWM_11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 {PF_8, PWM_13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 {PF_9, PWM_14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 {NC, NC, 0} }; //*** SERIAL *** MBED_WEAK const PinMap PinMap_UART_TX[] = { {PA_0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to USB_VBUS {PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // {PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // STDIO UART {PC_6, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, // {PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // STDIO UART {PC_10, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PC_12, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_5, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_8, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to STDIO_UART_TX {PE_8, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PG_14, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_RX[] = { {PA_1, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PA_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to USB_ID {PB_7, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to LD2 [Blue] // {PB_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // STDIO UART {PC_5, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PC_7, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, // {PC_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // STDIO UART {PC_11, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PD_2, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_6, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_9, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to STDIO_UART_RX {PE_7, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PG_9, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_RTS[] = { {PA_1, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_12, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to USB_DP {PA_15, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PB_14, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to LD3 [Red] {PC_8, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, {PD_4, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_12, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PG_8, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {PG_12, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to USB_DM {PB_0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // Connected to LD1 {PB_13, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PC_9, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, {PD_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PG_13, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {PG_15, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {NC, NC, 0} }; //*** SPI *** MBED_WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PB_0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SPI3)}, // Connected to LD1 {PB_2, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SPI3)}, {PB_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PB_5_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PB_15, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PC_1, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SPI2)}, {PC_1_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI3)}, {PC_3, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PC_12, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PD_0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PD_6, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI3)}, {PE_6, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PE_14, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PG_13, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI4)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PB_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PB_4_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PB_14, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to LD3 [Red] {PC_2, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PC_11, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PD_0, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PE_5, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PE_13, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PG_12, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI4)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PA_9, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to USB_VBUS {PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PB_3_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PB_10, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PB_13, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PC_7, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PC_10, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PD_3, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PE_2, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PE_12, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PG_11, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI4)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PA_4_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PA_15_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PB_4, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SPI2)}, {PB_9, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PD_1, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SPI2)}, {PE_4, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PE_11, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI4)}, {PG_14, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI4)}, {NC, NC, 0} }; //*** CAN *** MBED_WEAK const PinMap PinMap_CAN_RD[] = { {PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to USB_DM {PB_5, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, {PB_8, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {PB_12, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, {PD_0, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_CAN_TD[] = { {PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to USB_DP {PB_6, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, {PB_9, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {PB_13, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, {PD_1, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {NC, NC, 0} }; //*** QUADSPI *** MBED_WEAK const PinMap PinMap_QSPI_DATA0[] = { {PC_9, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 {PD_11, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 {PF_8, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_IO0 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_QSPI_DATA1[] = { {PC_10, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 {PD_12, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 {PF_9, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_IO1 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_QSPI_DATA2[] = { {PE_2, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO2 {PF_7, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO2 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_QSPI_DATA3[] = { {PA_1, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 {PD_13, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 {PF_6, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_QSPI_SCLK[] = { {PB_2, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK {PD_3, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_QSPI_SSEL[] = { {PB_6, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS {PG_6, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS // Connected to USB_PowerSwitchOn [STMPS2151STR_EN] {NC, NC, 0} }; //*** USBDEVICE *** MBED_WEAK const PinMap PinMap_USB_FS[] = { // {PA_8, USB_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF // Connected to USB_SOF [TP1] {PA_9, USB_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS // Connected to USB_VBUS {PA_10, USB_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID // Connected to USB_ID {PA_11, USB_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM // Connected to USB_DM {PA_12, USB_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP // Connected to USB_DP {NC, NC, 0} }; //*** USBDEVICE *** MBED_WEAK const PinMap PinMap_USB_HS[] = { #if (MBED_CONF_TARGET_USB_SPEED == USE_USB_HS_IN_FS) // {PA_4, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF {PB_12, USB_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID {PB_13, USB_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS {PB_14, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM // Connected to LD3 [Red] {PB_15, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP #else /* MBED_CONF_TARGET_USB_SPEED */ {PA_3, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 {PA_5, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_CK {PB_0, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 {PB_1, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 {PB_2, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D4 {PB_5, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 {PB_10, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 {PB_12, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 {PB_13, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 {PC_0, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP {PC_2, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR {PC_3, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT #endif /* MBED_CONF_TARGET_USB_SPEED */ {NC, NC, 0} }; ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_OCTOPUS_446/PinNames.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_PINNAMES_H #define MBED_PINNAMES_H #include "cmsis.h" #include "PinNamesTypes.h" #ifdef __cplusplus extern "C" { #endif typedef enum { ALT0 = 0x100, ALT1 = 0x200, ALT2 = 0x300, ALT3 = 0x400 } ALTx; typedef enum { PA_0 = 0x00, PA_0_ALT0 = PA_0 | ALT0, PA_0_ALT1 = PA_0 | ALT1, PA_1 = 0x01, PA_1_ALT0 = PA_1 | ALT0, PA_1_ALT1 = PA_1 | ALT1, PA_2 = 0x02, PA_2_ALT0 = PA_2 | ALT0, PA_2_ALT1 = PA_2 | ALT1, PA_3 = 0x03, PA_3_ALT0 = PA_3 | ALT0, PA_3_ALT1 = PA_3 | ALT1, PA_4 = 0x04, PA_4_ALT0 = PA_4 | ALT0, PA_5 = 0x05, PA_5_ALT0 = PA_5 | ALT0, PA_6 = 0x06, PA_6_ALT0 = PA_6 | ALT0, PA_7 = 0x07, PA_7_ALT0 = PA_7 | ALT0, PA_7_ALT1 = PA_7 | ALT1, PA_7_ALT2 = PA_7 | ALT2, PA_8 = 0x08, PA_9 = 0x09, PA_10 = 0x0A, PA_11 = 0x0B, PA_12 = 0x0C, PA_13 = 0x0D, PA_14 = 0x0E, PA_15 = 0x0F, PA_15_ALT0 = PA_15 | ALT0, PB_0 = 0x10, PB_0_ALT0 = PB_0 | ALT0, PB_0_ALT1 = PB_0 | ALT1, PB_1 = 0x11, PB_1_ALT0 = PB_1 | ALT0, PB_1_ALT1 = PB_1 | ALT1, PB_2 = 0x12, PB_3 = 0x13, PB_3_ALT0 = PB_3 | ALT0, PB_4 = 0x14, PB_4_ALT0 = PB_4 | ALT0, PB_4_ALT1 = PB_4 | ALT1, PB_5 = 0x15, PB_5_ALT0 = PB_5 | ALT0, PB_5_ALT1 = PB_5 | ALT1, PB_6 = 0x16, PB_7 = 0x17, PB_8 = 0x18, PB_8_ALT0 = PB_8 | ALT0, PB_8_ALT1 = PB_8 | ALT1, PB_9 = 0x19, PB_9_ALT0 = PB_9 | ALT0, PB_9_ALT1 = PB_9 | ALT1, PB_10 = 0x1A, PB_11 = 0x1B, PB_12 = 0x1C, PB_13 = 0x1D, PB_14 = 0x1E, PB_14_ALT0 = PB_14 | ALT0, PB_14_ALT1 = PB_14 | ALT1, PB_15 = 0x1F, PB_15_ALT0 = PB_15 | ALT0, PB_15_ALT1 = PB_15 | ALT1, PC_0 = 0x20, PC_0_ALT0 = PC_0 | ALT0, PC_0_ALT1 = PC_0 | ALT1, PC_1 = 0x21, PC_1_ALT0 = PC_1 | ALT0, PC_1_ALT1 = PC_1 | ALT1, PC_2 = 0x22, PC_2_ALT0 = PC_2 | ALT0, PC_2_ALT1 = PC_2 | ALT1, PC_3 = 0x23, PC_3_ALT0 = PC_3 | ALT0, PC_3_ALT1 = PC_3 | ALT1, PC_4 = 0x24, PC_4_ALT0 = PC_4 | ALT0, PC_5 = 0x25, PC_5_ALT0 = PC_5 | ALT0, PC_6 = 0x26, PC_6_ALT0 = PC_6 | ALT0, PC_7 = 0x27, PC_7_ALT0 = PC_7 | ALT0, PC_8 = 0x28, PC_8_ALT0 = PC_8 | ALT0, PC_9 = 0x29, PC_9_ALT0 = PC_9 | ALT0, PC_10 = 0x2A, PC_11 = 0x2B, PC_12 = 0x2C, PC_13 = 0x2D, PC_14 = 0x2E, PC_15 = 0x2F, PD_0 = 0x30, PD_1 = 0x31, PD_2 = 0x32, PD_3 = 0x33, PD_4 = 0x34, PD_5 = 0x35, PD_6 = 0x36, PD_7 = 0x37, PD_8 = 0x38, PD_9 = 0x39, PD_10 = 0x3A, PD_11 = 0x3B, PD_12 = 0x3C, PD_13 = 0x3D, PD_14 = 0x3E, PD_15 = 0x3F, PE_0 = 0x40, PE_1 = 0x41, PE_2 = 0x42, PE_3 = 0x43, PE_4 = 0x44, PE_5 = 0x45, PE_6 = 0x46, PE_7 = 0x47, PE_8 = 0x48, PE_9 = 0x49, PE_10 = 0x4A, PE_11 = 0x4B, PE_12 = 0x4C, PE_13 = 0x4D, PE_14 = 0x4E, PE_15 = 0x4F, PF_0 = 0x50, PF_1 = 0x51, PF_2 = 0x52, PF_3 = 0x53, PF_4 = 0x54, PF_5 = 0x55, PF_6 = 0x56, PF_7 = 0x57, PF_8 = 0x58, PF_9 = 0x59, PF_10 = 0x5A, PF_11 = 0x5B, PF_12 = 0x5C, PF_13 = 0x5D, PF_14 = 0x5E, PF_15 = 0x5F, PG_0 = 0x60, PG_1 = 0x61, PG_2 = 0x62, PG_3 = 0x63, PG_4 = 0x64, PG_5 = 0x65, PG_6 = 0x66, PG_7 = 0x67, PG_8 = 0x68, PG_9 = 0x69, PG_10 = 0x6A, PG_11 = 0x6B, PG_12 = 0x6C, PG_13 = 0x6D, PG_14 = 0x6E, PG_15 = 0x6F, PH_0 = 0x70, PH_1 = 0x71, PH_2 = 0x72, // ADC internal channels ADC_TEMP = 0xF0, ADC_VREF = 0xF1, ADC_VBAT = 0xF2, // Arduino connector namings A0 = PA_3, A1 = PC_0, A2 = PC_3, A3 = PF_3, A4 = PF_5, A5 = PF_10, D0 = PG_9, D1 = PG_14, D2 = PF_15, D3 = PE_13, D4 = PF_14, D5 = PE_11, D6 = PE_9, D7 = PF_13, D8 = PF_12, D9 = PD_15, D10 = PD_14, D11 = PA_7, D12 = PA_6, D13 = PA_5, D14 = PB_9, D15 = PB_8, // STDIO for console print #ifdef MBED_CONF_TARGET_STDIO_UART_TX STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX, #else STDIO_UART_TX = PD_8, #endif #ifdef MBED_CONF_TARGET_STDIO_UART_RX STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX, #else STDIO_UART_RX = PD_9, #endif // Generic signals namings LED1 = PB_0, LED2 = PB_7, LED3 = PB_14, LED4 = LED1, LED_RED = LED3, USER_BUTTON = PC_13, // Standardized button names BUTTON1 = USER_BUTTON, SERIAL_TX = STDIO_UART_TX, // Virtual Com Port SERIAL_RX = STDIO_UART_RX, // Virtual Com Port USBTX = STDIO_UART_TX, // Virtual Com Port USBRX = STDIO_UART_RX, // Virtual Com Port I2C_SCL = D15, I2C_SDA = D14, SPI_MOSI = D11, SPI_MISO = D12, SPI_SCK = D13, SPI_CS = D10, PWM_OUT = D9, /**** USB FS pins ****/ USB_OTG_FS_DM = PA_11, USB_OTG_FS_DP = PA_12, USB_OTG_FS_ID = PA_10, USB_OTG_FS_SOF = PA_8, USB_OTG_FS_VBUS = PA_9, /**** USB HS pins ****/ USB_OTG_HS_DM = PB_14, USB_OTG_HS_DP = PB_15, USB_OTG_HS_ID = PB_12, USB_OTG_HS_SOF = PA_4, USB_OTG_HS_ULPI_CK = PA_5, USB_OTG_HS_ULPI_D0 = PA_3, USB_OTG_HS_ULPI_D1 = PB_0, USB_OTG_HS_ULPI_D2 = PB_1, USB_OTG_HS_ULPI_D3 = PB_10, USB_OTG_HS_ULPI_D4 = PB_2, USB_OTG_HS_ULPI_D5 = PB_12, USB_OTG_HS_ULPI_D6 = PB_13, USB_OTG_HS_ULPI_D7 = PB_5, USB_OTG_HS_ULPI_DIR = PC_2, USB_OTG_HS_ULPI_NXT = PC_3, USB_OTG_HS_ULPI_STP = PC_0, USB_OTG_HS_VBUS = PB_13, /**** OSCILLATOR pins ****/ RCC_OSC32_IN = PC_14, RCC_OSC32_OUT = PC_15, RCC_OSC_IN = PH_0, RCC_OSC_OUT = PH_1, /**** DEBUG pins ****/ SYS_JTCK_SWCLK = PA_14, SYS_JTDI = PA_15, SYS_JTDO_SWO = PB_3, SYS_JTMS_SWDIO = PA_13, SYS_JTRST = PB_4, SYS_TRACECLK = PE_2, SYS_TRACED0 = PE_3, SYS_TRACED0_ALT0 = PC_8, SYS_TRACED1 = PE_4, SYS_TRACED1_ALT0 = PD_3, SYS_TRACED2 = PE_5, SYS_TRACED2_ALT0 = PG_13, SYS_TRACED3 = PE_6, SYS_TRACED3_ALT0 = PG_14, SYS_WKUP0 = PA_0, SYS_WKUP1 = PC_13, // Not connected NC = (int)0xFFFFFFFF } PinName; #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_OCTOPUS_446/system_clock.c ================================================ /* mbed Microcontroller Library * Copyright (c) 2006-2017 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * This file configures the system clock as follows: *----------------------------------------------------------------------------- * System clock source | 1- USE_PLL_HSE_EXTC (external 12 MHz clock) * | 2- USE_PLL_HSE_XTAL (external 12 MHz xtal) * | 3- USE_PLL_HSI (internal 16 MHz) *----------------------------------------------------------------------------- * SYSCLK(MHz) | 180 * AHBCLK (MHz) | 180 * APB1CLK (MHz) | 45 * APB2CLK (MHz) | 90 * USB capable | YES *----------------------------------------------------------------------------- **/ #include "stm32f4xx.h" #include "mbed_error.h" /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0000 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ // clock source is selected with CLOCK_SOURCE in json config #define USE_PLL_HSE_EXTC 0x8 // Use external clock (ST Link MCO) #define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default) #define USE_PLL_HSI 0x2 // Use HSI internal clock //#define DEBUG_MCO (1) // Output the MCO1/MCO2 on PA8/PC9 for debugging (0=OFF, 1=ON) #if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) uint8_t SetSysClock_PLL_HSE(uint8_t bypass); #endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ #if ((CLOCK_SOURCE) & USE_PLL_HSI) uint8_t SetSysClock_PLL_HSI(void); #endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ /** * @brief Setup the microcontroller system * Initialize the FPU setting, vector table location and External memory * configuration. * @param None * @retval None */ void SystemInit(void) { /* FPU settings ------------------------------------------------------------*/ #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */ #endif /* Reset the RCC clock configuration to the default reset state ------------*/ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset CFGR register */ RCC->CFGR = 0x00000000; /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset PLLCFGR register */ RCC->PLLCFGR = 0x24003010; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Disable all interrupts */ RCC->CIR = 0x00000000; #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ /* Configure the Vector Table location add offset address ------------------*/ #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ #endif } /** * @brief Configures the System clock source, PLL Multiplier and Divider factors, * AHB/APBx prescalers and Flash settings * @note This function should be called only once the RCC clock configuration * is reset to the default reset state (done in SystemInit() function). * @param None * @retval None */ void SetSysClock(void) { #if ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) /* 1- Try to start with HSE and external clock */ if (SetSysClock_PLL_HSE(1) == 0) #endif { #if ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) /* 2- If fail try to start with HSE and external xtal */ if (SetSysClock_PLL_HSE(0) == 0) #endif { #if ((CLOCK_SOURCE) & USE_PLL_HSI) /* 3- If fail start with HSI clock */ if (SetSysClock_PLL_HSI() == 0) #endif { { error("SetSysClock failed\n"); } } } } // Output clock on MCO2 pin(PC9) for debugging purpose #if DEBUG_MCO == 1 HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4); #endif } #if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) /******************************************************************************/ /* PLL (clocked by HSE) used as System clock source */ /******************************************************************************/ uint8_t SetSysClock_PLL_HSE(uint8_t bypass) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; /* Enable Power Control clock */ __HAL_RCC_PWR_CLK_ENABLE(); /* The voltage scaling allows optimizing the power consumption when the device is clocked below the maximum system frequency, to update the voltage scaling value regarding system frequency refer to product datasheet. */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /* Enable HSE oscillator and activate PLL with HSE as source */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; if (bypass == 0) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */ } else { RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; /* External 8 MHz clock on OSC_IN */ } RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 6; RCC_OscInitStruct.PLL.PLLN = 180; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 7; RCC_OscInitStruct.PLL.PLLR = 2; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { return 0; // FAIL } // Activate the OverDrive to reach the 180 MHz Frequency if (HAL_PWREx_EnableOverDrive() != HAL_OK) { return 0; // FAIL } #if DEVICE_USBDEVICE // Select PLLSAI output as USB clock source PeriphClkInitStruct.PLLSAI.PLLSAIM = 6; PeriphClkInitStruct.PLLSAI.PLLSAIN = 96; PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV4; PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CLK48; PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48CLKSOURCE_PLLSAIP; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); #endif /* DEVICE_USBDEVICE */ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 180 MHz RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 45 MHz RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 90 MHz if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { return 0; // FAIL } // Output clock on MCO1 pin(PA8) for debugging purpose #if DEBUG_MCO == 1 if (bypass == 0) { HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz with xtal } else { HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz with external clock (MCO) } #endif return 1; // OK } #endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ #if ((CLOCK_SOURCE) & USE_PLL_HSI) /******************************************************************************/ /* PLL (clocked by HSI) used as System clock source */ /******************************************************************************/ uint8_t SetSysClock_PLL_HSI(void) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; /* Enable Power Control clock */ __HAL_RCC_PWR_CLK_ENABLE(); /* The voltage scaling allows optimizing the power consumption when the device is clocked below the maximum system frequency, to update the voltage scaling value regarding system frequency refer to product datasheet. */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /* Enable HSI oscillator and activate PLL with HSI as source */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSEState = RCC_HSE_OFF; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = 16; // VCO input clock = 1 MHz (16 MHz / 16) RCC_OscInitStruct.PLL.PLLN = 360; // VCO output clock = 360 MHz (1 MHz * 360) RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // PLLCLK = 180 MHz (360 MHz / 2) RCC_OscInitStruct.PLL.PLLQ = 7; // RCC_OscInitStruct.PLL.PLLR = 6; // if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { return 0; // FAIL } #if DEVICE_USBDEVICE /* Select PLLSAI output as USB clock source */ PeriphClkInitStruct.PLLSAI.PLLSAIM = 8; PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV8; PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CLK48; PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48CLKSOURCE_PLLSAIP; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); #endif /* DEVICE_USBDEVICE */ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 180 MHz RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 180 MHz RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 45 MHz RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 90 MHz if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { return 0; // FAIL } // Output clock on MCO1 pin(PA8) for debugging purpose #if DEBUG_MCO == 1 HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz #endif return 1; // OK } #endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_ROBIN_E3/PeripheralNames.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2014, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_PERIPHERALNAMES_H #define MBED_PERIPHERALNAMES_H #include "cmsis.h" #ifdef __cplusplus extern "C" { #endif typedef enum { ADC_1 = (int)ADC1_BASE, ADC_2 = (int)ADC2_BASE, ADC_3 = (int)ADC3_BASE } ADCName; typedef enum { DAC_1 = (int)DAC_BASE } DACName; typedef enum { UART_1 = (int)USART1_BASE, UART_2 = (int)USART2_BASE, UART_3 = (int)USART3_BASE, UART_4 = (int)UART4_BASE, UART_5 = (int)UART5_BASE } UARTName; #define DEVICE_SPI_COUNT 3 typedef enum { SPI_1 = (int)SPI1_BASE, SPI_2 = (int)SPI2_BASE, SPI_3 = (int)SPI3_BASE } SPIName; typedef enum { I2C_1 = (int)I2C1_BASE, I2C_2 = (int)I2C2_BASE } I2CName; typedef enum { PWM_1 = (int)TIM1_BASE, PWM_2 = (int)TIM2_BASE, PWM_3 = (int)TIM3_BASE, PWM_4 = (int)TIM4_BASE, PWM_5 = (int)TIM5_BASE, PWM_8 = (int)TIM8_BASE } PWMName; typedef enum { CAN_1 = (int)CAN1_BASE } CANName; typedef enum { USB_FS = (int)USB_BASE } USBName; #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_ROBIN_E3/PeripheralPins.c ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #include "PeripheralPins.h" #include "mbed_toolchain.h" //============================================================================== // Notes // // - The pins mentioned Px_y_ALTz are alternative possibilities which use other // HW peripheral instances. You can use them the same way as any other "normal" // pin (i.e. PwmOut pwm(PA_7_ALT0);). These pins are not displayed on the board // pinout image on mbed.org. // // - The pins which are connected to other components present on the board have // the comment "Connected to xxx". The pin function may not work properly in this // case. These pins may not be displayed on the board pinout image on mbed.org. // Please read the board reference manual and schematic for more information. // // - Warning: pins connected to the default STDIO_UART_TX and STDIO_UART_RX pins are commented // See https://os.mbed.com/teams/ST/wiki/STDIO for more information. // //============================================================================== //*** ADC *** MBED_WEAK const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 {PA_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 // {PA_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 // Connected to STDIO_UART_TX // {PA_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 // Connected to STDIO_UART_RX {PA_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 {PA_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 // Connected to LD2 [Green Led] {PA_6, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 {PA_7, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 {PB_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 {PB_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 {PC_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 {PC_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 {PC_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 {PC_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 {PC_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 {PC_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_ADC_Internal[] = { {ADC_TEMP, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, {ADC_VREF, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, {NC, NC, 0} }; //*** I2C *** MBED_WEAK const PinMap PinMap_I2C_SDA[] = { {PB_7, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 0)}, {PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 2)}, // GPIO_Remap_I2C1 {PB_11, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 0)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_I2C_SCL[] = { {PB_6, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 0)}, {PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 2)}, // GPIO_Remap_I2C1 {PB_10, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 0)}, {NC, NC, 0} }; //*** PWM *** // TIM4 cannot be used because already used by the us_ticker MBED_WEAK const PinMap PinMap_PWM[] = { {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 1, 0)}, // TIM2_CH1 {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 2, 0)}, // TIM2_CH2 // {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 3, 0)}, // TIM2_CH3 // Connected to STDIO_UART_TX // {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 4, 0)}, // TIM2_CH4 // Connected to STDIO_UART_RX {PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 1, 0)}, // TIM3_CH1 {PA_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 2, 0)}, // TIM3_CH2 {PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 1, 0)}, // TIM1_CH1 {PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 2, 0)}, // TIM1_CH2 {PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 3, 0)}, // TIM1_CH3 {PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 4, 0)}, // TIM1_CH4 {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 8, 1, 0)}, // TIM2_CH1 {PB_0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 3, 0)}, // TIM3_CH3 {PB_1, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 4, 0)}, // TIM3_CH4 {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 8, 2, 0)}, // TIM2_CH2 // Connected to SWO {PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 7, 1, 0)}, // TIM3_CH1 {PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 7, 2, 0)}, // TIM3_CH2 // {PB_6, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 1, 0)}, // TIM4_CH1 // {PB_7, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 2, 0)}, // TIM4_CH2 // {PB_8, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 3, 0)}, // TIM4_CH3 // {PB_9, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 4, 0)}, // TIM4_CH4 {PB_10, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 8, 3, 0)}, // TIM2_CH3 {PB_11, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 8, 4, 0)}, // TIM2_CH4 {PB_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 1, 1)}, // TIM1_CH1N {PB_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 2, 1)}, // TIM1_CH2N {PB_15, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 3, 1)}, // TIM1_CH3N {PC_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 9, 1, 0)}, // TIM3_CH1 {PC_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 9, 2, 0)}, // TIM3_CH2 {PC_8, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 9, 3, 0)}, // TIM3_CH3 {PC_9, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 9, 4, 0)}, // TIM3_CH4 {NC, NC, 0} }; //*** SERIAL *** MBED_WEAK const PinMap PinMap_UART_TX[] = { {PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, // Connected to STDIO_UART_TX {PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 3)}, // GPIO_Remap_USART1 {PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 5)}, // GPIO_PartialRemap_USART3 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_RX[] = { {PA_3, UART_2, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 0)}, // Connected to STDIO_UART_RX {PA_10, UART_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 0)}, {PB_7, UART_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 3)}, // GPIO_Remap_USART1 {PB_11, UART_3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 0)}, {PC_11, UART_3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 5)}, // GPIO_PartialRemap_USART3 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_RTS[] = { {PA_1, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PA_12, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PB_14, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PA_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PB_13, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {NC, NC, 0} }; //*** SPI *** MBED_WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {PB_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)}, // GPIO_Remap_SPI1 {PB_15, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {PB_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)}, // GPIO_Remap_SPI1 {PB_14, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, // Connected to LD2 [Green Led] {PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)}, // GPIO_Remap_SPI1 // Connected to SWO {PB_13, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)}, // GPIO_Remap_SPI1 {PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {NC, NC, 0} }; //*** CAN *** MBED_WEAK const PinMap PinMap_CAN_RD[] = { {PA_11, CAN_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, {PB_8, CAN_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 10)}, // Remap CAN_RX to PB_8 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_CAN_TD[] = { {PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {PB_9, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 10)}, // Remap CAN_TX to PB_9 {NC, NC, 0} }; //*** USBDEVICE *** MBED_WEAK const PinMap PinMap_USB_FS[] = { {PA_11, USB_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // USB_DM {PA_12, USB_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // USB_DP {NC, NC, 0} }; ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_ROBIN_E3/PinNames.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_PINNAMES_H #define MBED_PINNAMES_H #include "cmsis.h" #include "PinNamesTypes.h" #ifdef __cplusplus extern "C" { #endif typedef enum { PA_0 = 0x00, PA_1 = 0x01, PA_2 = 0x02, PA_3 = 0x03, PA_4 = 0x04, PA_5 = 0x05, PA_6 = 0x06, PA_7 = 0x07, PA_8 = 0x08, PA_9 = 0x09, PA_10 = 0x0A, PA_11 = 0x0B, PA_12 = 0x0C, PA_13 = 0x0D, PA_14 = 0x0E, PA_15 = 0x0F, PB_0 = 0x10, PB_1 = 0x11, PB_2 = 0x12, PB_3 = 0x13, PB_4 = 0x14, PB_5 = 0x15, PB_6 = 0x16, PB_7 = 0x17, PB_8 = 0x18, PB_9 = 0x19, PB_10 = 0x1A, PB_11 = 0x1B, PB_12 = 0x1C, PB_13 = 0x1D, PB_14 = 0x1E, PB_15 = 0x1F, PC_0 = 0x20, PC_1 = 0x21, PC_2 = 0x22, PC_3 = 0x23, PC_4 = 0x24, PC_5 = 0x25, PC_6 = 0x26, PC_7 = 0x27, PC_8 = 0x28, PC_9 = 0x29, PC_10 = 0x2A, PC_11 = 0x2B, PC_12 = 0x2C, PC_13 = 0x2D, PC_14 = 0x2E, PC_15 = 0x2F, PD_0 = 0x30, PD_1 = 0x31, PD_2 = 0x32, // ADC internal channels ADC_TEMP = 0xF0, ADC_VREF = 0xF1, // Arduino connector namings A0 = PA_0, A1 = PA_1, A2 = PA_4, A3 = PB_0, A4 = PC_1, A5 = PC_0, D0 = PA_3, D1 = PA_2, D2 = PA_10, D3 = PB_3, D4 = PB_5, D5 = PB_4, D6 = PB_10, D7 = PA_8, D8 = PA_9, D9 = PC_7, D10 = PB_6, D11 = PA_7, D12 = PA_6, D13 = PA_5, D14 = PB_9, D15 = PB_8, // STDIO for console print #ifdef MBED_CONF_TARGET_STDIO_UART_TX STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX, #else STDIO_UART_TX = PA_2, #endif #ifdef MBED_CONF_TARGET_STDIO_UART_RX STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX, #else STDIO_UART_RX = PA_3, #endif // Generic signals namings LED1 = PA_5, LED2 = PA_5, LED3 = PA_5, LED4 = PA_5, USER_BUTTON = PC_13, // Standardized button names BUTTON1 = USER_BUTTON, SERIAL_TX = STDIO_UART_TX, SERIAL_RX = STDIO_UART_RX, USBTX = STDIO_UART_TX, USBRX = STDIO_UART_RX, I2C_SCL = PB_8, I2C_SDA = PB_9, SPI_MOSI = PA_7, SPI_MISO = PA_6, SPI_SCK = PA_5, SPI_CS = PB_6, PWM_OUT = PB_3, /**** USB pins ****/ USB_DM = PA_11, USB_DP = PA_12, /**** OSCILLATOR pins ****/ RCC_OSC32_IN = PC_14, RCC_OSC32_OUT = PC_15, RCC_OSC_IN = PD_0, RCC_OSC_OUT = PD_1, /**** DEBUG pins ****/ SYS_JTCK_SWCLK = PA_14, SYS_JTDI = PA_15, SYS_JTDO_TRACESWO = PB_3, SYS_JTMS_SWDIO = PA_13, SYS_NJTRST = PB_4, SYS_WKUP = PA_0, // Not connected NC = (int)0xFFFFFFFF } PinName; #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_ROBIN_E3/system_clock.c ================================================ /* mbed Microcontroller Library * Copyright (c) 2006-2017 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * This file configures the system clock as follows: *------------------------------------------------------------------------------------------- * System clock source | 1- PLL_HSE_EXTC / DEVICE_USBDEVICE | 3- PLL_HSI / DEVICE_USBDEVICE * | (external 8 MHz clock) | (internal 8 MHz) * | 2- PLL_HSE_XTAL / DEVICE_USBDEVICE | * | (external 8 MHz xtal) | *------------------------------------------------------------------------------------------- * SYSCLK(MHz) | 72 / 72 | 64 / 48 *------------------------------------------------------------------------------------------- * AHBCLK (MHz) | 72 / 72 | 64 / 48 *------------------------------------------------------------------------------------------- * APB1CLK (MHz) | 36 / 36 | 32 / 24 *------------------------------------------------------------------------------------------- * APB2CLK (MHz) | 72 / 72 | 64 / 48 *------------------------------------------------------------------------------------------- */ #include "stm32f1xx.h" #include "mbed_error.h" /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ #define USE_PLL_HSE_EXTC 0x8 // Use external clock (ST Link MCO) #define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default) #define USE_PLL_HSI 0x2 // Use HSI internal clock #if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) uint8_t SetSysClock_PLL_HSE(uint8_t bypass); #endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ #if ((CLOCK_SOURCE) & USE_PLL_HSI) uint8_t SetSysClock_PLL_HSI(void); #endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= 0x00000001U; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= 0xF8FF0000U; #else RCC->CFGR &= 0xF0FF0000U; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= 0xFEF6FFFFU; /* Reset HSEBYP bit */ RCC->CR &= 0xFFFBFFFFU; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= 0xFF80FFFFU; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= 0xEBFFFFFFU; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000U; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000U; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000U; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000U; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000U; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Configures the System clock source, PLL Multiplier and Divider factors, * AHB/APBx prescalers and Flash settings * @note This function should be called only once the RCC clock configuration * is reset to the default reset state (done in SystemInit() function). * @param None * @retval None */ void SetSysClock(void) { #if ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) /* 1- Try to start with HSE and external clock */ if (SetSysClock_PLL_HSE(1) == 0) #endif { #if ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) /* 2- If fail try to start with HSE and external xtal */ if (SetSysClock_PLL_HSE(0) == 0) #endif { #if ((CLOCK_SOURCE) & USE_PLL_HSI) /* 3- If fail start with HSI clock */ if (SetSysClock_PLL_HSI() == 0) #endif { { error("SetSysClock failed\n"); } } } } /* Output clock on MCO1 pin(PA8) for debugging purpose */ //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_SYSCLK, RCC_MCODIV_1); // 72 MHz or 64 MHz } #if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) /******************************************************************************/ /* PLL (clocked by HSE) used as System clock source */ /******************************************************************************/ uint8_t SetSysClock_PLL_HSE(uint8_t bypass) { RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; #if (DEVICE_USBDEVICE) RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInit; #endif /* DEVICE_USBDEVICE */ /* Enable HSE oscillator and activate PLL with HSE as source */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; if (bypass == 0) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */ } else { RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; /* External 8 MHz clock on OSC_IN */ } RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; // 72 MHz (8 MHz * 9) if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { return 0; // FAIL } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 72 MHz RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 72 MHz RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 36 MHz RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 72 MHz if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { return 0; // FAIL } #if (DEVICE_USBDEVICE) /* USB clock selection */ RCC_PeriphCLKInit.PeriphClockSelection = RCC_PERIPHCLK_USB; RCC_PeriphCLKInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInit); #endif /* DEVICE_USBDEVICE */ /* Output clock on MCO1 pin(PA8) for debugging purpose */ //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz return 1; // OK } #endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ #if ((CLOCK_SOURCE) & USE_PLL_HSI) /******************************************************************************/ /* PLL (clocked by HSI) used as System clock source */ /******************************************************************************/ uint8_t SetSysClock_PLL_HSI(void) { RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; #if (DEVICE_USBDEVICE) RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInit; #endif /* DEVICE_USBDEVICE */ /* Enable HSI oscillator and activate PLL with HSI as source */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSEState = RCC_HSE_OFF; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2; #if (DEVICE_USBDEVICE) RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; // 48 MHz (8 MHz/2 * 12) #else /* DEVICE_USBDEVICE */ RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16; // 64 MHz (8 MHz/2 * 16) #endif /* DEVICE_USBDEVICE */ if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { return 0; // FAIL } #if (DEVICE_USBDEVICE) /* USB clock selection */ RCC_PeriphCLKInit.PeriphClockSelection = RCC_PERIPHCLK_USB; RCC_PeriphCLKInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL; HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInit); #endif /* DEVICE_USBDEVICE */ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 64 MHz RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 64 MHz RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 32 MHz RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 64 MHz if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { return 0; // FAIL } /* Output clock on MCO1 pin(PA8) for debugging purpose */ //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 8 MHz return 1; // OK } #endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/.hg/branch ================================================ default ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/.hg/cache/branch2-base ================================================ 97a16bf2ff439853ed01edd65a382207e203c733 17 97a16bf2ff439853ed01edd65a382207e203c733 o default ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/.hg/cache/rbc-names-v1 ================================================ default ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/.hg/cache/tags2-visible ================================================ 17 97a16bf2ff439853ed01edd65a382207e203c733 ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/.hg/hgrc ================================================ # example repository config (see 'hg help config' for more info) [paths] mbed-studio-cache = c:\Users\tanya\AppData\Local\Mbed Studio\library-cache\os.mbed.com\users\AjK\code\MODDMA default = https://os.mbed.com/users/AjK/code/MODDMA/ # path aliases to other clones of this repo in URLs or filesystem paths # (see 'hg help config.paths' for more info) # # default:pushurl = ssh://jdoe@example.net/hg/jdoes-fork # my-fork = ssh://jdoe@example.net/hg/jdoes-fork # my-clone = /home/jdoe/jdoes-clone [ui] # name and email (local to this repository, optional), e.g. # username = Jane Doe ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/.hg/requires ================================================ dotencode fncache generaldelta revlogv1 sparserevlog store ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/.hg/store/fncache ================================================ data/example4.h.i data/example2.h.i data/ChangeLog.c.i data/example2.cpp.i data/CONFIG.h.i data/example1.h.i data/MODDMA.h.i data/example1.cpp.i data/SETUP.cpp.i data/example3.h.i data/DATALUTS.cpp.i data/INIT.cpp.i data/iomacros.h.i data/MODDMA.cpp.i ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/.hg/thgstatus ================================================ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/CONFIG.h ================================================ /* Copyright (c) 2010 Andy Kirkham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifdef NOCOMPILE #ifndef MODDMA_CONFIG_H #define MODDMA_CONFIG_H #include "mbed.h" namespace AjK { // Forward reference. class MODDMA; class MODDMA_Channel_CFG_t { public: // ***************************************** // From GPDMA by NXP MCU SW Application Team // ***************************************** uint32_t ChannelNum; //!< DMA channel number, should be in range from 0 to 7. uint32_t TransferSize; //!< Length/Size of transfer uint32_t TransferWidth; //!< Transfer width - used for TransferType is GPDMA_TRANSFERTYPE_m2m only uint32_t SrcMemAddr; //!< Physical Src Addr, used in case TransferType is chosen as MODDMA::GPDMA_TRANSFERTYPE::m2m or MODDMA::GPDMA_TRANSFERTYPE::m2p uint32_t DstMemAddr; //!< Physical Destination Address, used in case TransferType is chosen as MODDMA::GPDMA_TRANSFERTYPE::m2m or MODDMA::GPDMA_TRANSFERTYPE::p2m uint32_t TransferType; //!< Transfer Type uint32_t SrcConn; ///!< Peripheral Source Connection type, used in case TransferType is chosen as uint32_t DstConn; //!< Peripheral Destination Connection type, used in case TransferType is chosen as uint32_t DMALLI; //!< Linker List Item structure data address if there's no Linker List, set as '0' // Mbed specifics. MODDMA_Channel_CFG_t() { isrIntTCStat = new FunctionPointer; isrIntErrStat = new FunctionPointer; } ~MODDMA_Channel_CFG_t() { delete(isrIntTCStat); delete(isrIntErrStat); } class MODDMA_Channel_CFG_t * channelNum(uint32_t n) { ChannelNum = n; return this; } class MODDMA_Channel_CFG_t * transferSize(uint32_t n) { TransferSize = n; return this; } class MODDMA_Channel_CFG_t * transferWidth(uint32_t n) { TransferWidth = n; return this; } class MODDMA_Channel_CFG_t * srcMemAddr(uint32_t n) { SrcMemAddr = n; return this; } class MODDMA_Channel_CFG_t * dstMemAddr(uint32_t n) { DstMemAddr = n; return this; } class MODDMA_Channel_CFG_t * transferType(uint32_t n) { TransferType = n; return this; } class MODDMA_Channel_CFG_t * srcConn(uint32_t n) { SrcConn = n; return this; } class MODDMA_Channel_CFG_t * dstConn(uint32_t n) { DstConn = n; return this; } class MODDMA_Channel_CFG_t * dmaLLI(uint32_t n) { DMALLI = n; return this; } uint32_t channelNum(void) { return ChannelNum; } FunctionPointer *isrIntTCStat; FunctionPointer *isrIntErrStat; }; /** * @brief GPDMA Linker List Item structure type definition */ class GPDMA_LLI_t { public: uint32_t SrcAddr; //!< Source Address uint32_t DstAddr; //!< Destination address uint32_t NextLLI; //!< Next LLI address, otherwise set to '0' uint32_t Control; //!< GPDMA Control of this LLI }; }; // namespace AjK ends. #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/ChangeLog.c ================================================ /* $Id:$ 1.13- 2 Mar 2013 * Update RESERVED9 to DMAREQSEL in SETUP.cpp Thanks Bryce Chee for pointing it out. 1.12- 14 Mar 2011 * Added example4.h that demonstrates alternately sending two buffers (double buffering) to the DAC. All those people building MP3 players may find this of interest. 1.11- 13 Mar 2011 * Fixed a silly typo in the documentation of example3.h 1.10- 13 Mar 2011 * The rescheduling showed the timer being stopped and restarted to perform a new scheduled grab. This was changed to show the timer free running and the reschedules being setup. 1.9 - 13 Mar 2011 * Improved example3.h to add rescheduling additional grabs based on the timer setup. 1.8 - 13 Mar 2011 * Renamed example files to .h * Added pseudo g2m and m2g transferTypes to support GPIO "memory moves" but triggered by peripheral timer. To support this new operating mode added example3.h 1.7 - 13 Mar 2011 * Remove the test at the beginning of the channel setup. 1.6 - 8 Mar 2011 * Fixed a typo bug. Reported by Wim van der Vegt http://mbed.org/forum/mbed/topic/1798/?page=1#comment-9845 1.5 - 5 Feb 2011 * Found a bug in the NXP library that I had copied over. http://mbed.org/forum/mbed/topic/1798 * Added example2.cpp to support that forum thread. 1.4 - 23/11/2010 * Added some extra overloaded methods to make calling certain userland API methods simpler. 1.3 - 23/10/2010 * Added the LLI class wrapper. * Added checking channel's LLI for non-null before auto-disable of a channel with the ISR. * Tested with MODSERIAL which is now natively MODDMA "aware". MODSERIAL can now, using MODDMA, send blocks of bytes out of it's TX port under DMA control. 1.2 - 23/10/2010 * Improved the IRQ callback attachment API to make easier attachments when creating configurations. 1.1 - 23/10/2010 * Tidied up example1.cpp * Removed some unneeded methoids that cause compiler errs. 1.0 - 23/11/2010 * First release */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/DATALUTS.cpp ================================================ /* Copyright (c) 2010 Andy Kirkham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "MODDMA.h" #ifndef MBED_H #include "mbed.h" #endif #ifndef MODDMA_CONFIG_H #include "CONFIG.h" #endif namespace AjK { uint32_t MODDMA::LUTPerAddr(int n) { const uint32_t lut[] = { (uint32_t)&LPC_SSP0->DR // SSP0 Tx , (uint32_t)&LPC_SSP0->DR // SSP0 Rx , (uint32_t)&LPC_SSP1->DR // SSP1 Tx , (uint32_t)&LPC_SSP1->DR // SSP1 Rx , (uint32_t)&LPC_ADC->ADGDR // ADC , (uint32_t)&LPC_I2S->I2STXFIFO // I2S Tx , (uint32_t)&LPC_I2S->I2SRXFIFO // I2S Rx , (uint32_t)&LPC_DAC->DACR // DAC , (uint32_t)&LPC_UART0->THR // UART0 Tx , (uint32_t)&LPC_UART0->RBR // UART0 Rx , (uint32_t)&LPC_UART1->THR // UART1 Tx , (uint32_t)&LPC_UART1->RBR // UART1 Rx , (uint32_t)&LPC_UART2->THR // UART2 Tx , (uint32_t)&LPC_UART2->RBR // UART2 Rx , (uint32_t)&LPC_UART3->THR // UART3 Tx , (uint32_t)&LPC_UART3->RBR // UART3 Rx , (uint32_t)&LPC_TIM0->MR0 // MAT0.0 , (uint32_t)&LPC_TIM0->MR1 // MAT0.1 , (uint32_t)&LPC_TIM1->MR0 // MAT1.0 , (uint32_t)&LPC_TIM1->MR1 // MAT1.1 , (uint32_t)&LPC_TIM2->MR0 // MAT2.0 , (uint32_t)&LPC_TIM2->MR1 // MAT2.1 , (uint32_t)&LPC_TIM3->MR0 // MAT3.0 , (uint32_t)&LPC_TIM3->MR1 // MAT3.1 }; return lut[n & 0xFF]; } uint32_t MODDMA::Channel_p(int channel) { const uint32_t lut[] = { (uint32_t)LPC_GPDMACH0 , (uint32_t)LPC_GPDMACH1 , (uint32_t)LPC_GPDMACH2 , (uint32_t)LPC_GPDMACH3 , (uint32_t)LPC_GPDMACH4 , (uint32_t)LPC_GPDMACH5 , (uint32_t)LPC_GPDMACH6 , (uint32_t)LPC_GPDMACH7 }; return lut[channel & 0xFF]; } uint8_t MODDMA::LUTPerBurst(int n) { const uint8_t lut[] = { (uint8_t)_4 // SSP0 Tx , (uint8_t)_4 // SSP0 Rx , (uint8_t)_4 // SSP1 Tx , (uint8_t)_4 // SSP1 Rx , (uint8_t)_1 // ADC , (uint8_t)_32 // I2S channel 0 , (uint8_t)_32 // I2S channel 1 , (uint8_t)_1 // DAC , (uint8_t)_1 // UART0 Tx , (uint8_t)_1 // UART0 Rx , (uint8_t)_1 // UART1 Tx , (uint8_t)_1 // UART1 Rx , (uint8_t)_1 // UART2 Tx , (uint8_t)_1 // UART2 Rx , (uint8_t)_1 // UART3 Tx , (uint8_t)_1 // UART3 Rx , (uint8_t)_1 // MAT0.0 , (uint8_t)_1 // MAT0.1 , (uint8_t)_1 // MAT1.0 , (uint8_t)_1 // MAT1.1 , (uint8_t)_1 // MAT2.0 , (uint8_t)_1 // MAT2.1 , (uint8_t)_1 // MAT3.0 , (uint8_t)_1 // MAT3.1 }; return lut[n & 0xFFF]; } uint8_t MODDMA::LUTPerWid(int n) { const uint8_t lut[] = { (uint8_t)byte // SSP0 Tx , (uint8_t)byte // SSP0 Rx , (uint8_t)byte // SSP1 Tx , (uint8_t)byte // SSP1 Rx , (uint8_t)word // ADC , (uint8_t)word // I2S channel 0 , (uint8_t)word // I2S channel 1 , (uint8_t)word // DAC , (uint8_t)byte // UART0 Tx , (uint8_t)byte // UART0 Rx , (uint8_t)byte // UART1 Tx , (uint8_t)byte // UART1 Rx , (uint8_t)byte // UART2 Tx , (uint8_t)byte // UART2 Rx , (uint8_t)byte // UART3 Tx , (uint8_t)byte // UART3 Rx , (uint8_t)word // MAT0.0 , (uint8_t)word // MAT0.1 , (uint8_t)word // MAT1.0 , (uint8_t)word // MAT1.1 , (uint8_t)word // MAT2.0 , (uint8_t)word // MAT2.1 , (uint8_t)word // MAT3.0 , (uint8_t)word // MAT3.1 }; return lut[n & 0xFFF]; } }; // namespace AjK ends ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/INIT.cpp ================================================ /* Copyright (c) 2010 Andy Kirkham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "MODDMA.h" namespace AjK { extern uint32_t oldDMAHandler; extern "C" void MODDMA_IRQHandler(void); extern class MODDMA *moddma_p; void MODDMA::init(bool isConstructorCalling, int Channels, int Tc, int Err) { if (isConstructorCalling) { if (LPC_SC->PCONP & (1UL << 29)) { if (LPC_GPDMA->DMACConfig & 1) { error("Only one instance of MODDMA can exist."); } } LPC_SC->PCONP |= (1UL << 29); LPC_GPDMA->DMACConfig = 1; moddma_p = this; for (int i = 0; i < 8; i++) { setups[i] = (MODDMA_Config *)NULL; } } // Reset channel configuration register(s) if (Channels & 0x01) LPC_GPDMACH0->DMACCConfig = 0; if (Channels & 0x02) LPC_GPDMACH1->DMACCConfig = 0; if (Channels & 0x04) LPC_GPDMACH2->DMACCConfig = 0; if (Channels & 0x08) LPC_GPDMACH3->DMACCConfig = 0; if (Channels & 0x10) LPC_GPDMACH4->DMACCConfig = 0; if (Channels & 0x20) LPC_GPDMACH5->DMACCConfig = 0; if (Channels & 0x40) LPC_GPDMACH6->DMACCConfig = 0; if (Channels & 0x80) LPC_GPDMACH7->DMACCConfig = 0; /* Clear DMA interrupt and error flag */ LPC_GPDMA->DMACIntTCClear = Tc; LPC_GPDMA->DMACIntErrClr = Err; if (isConstructorCalling) { oldDMAHandler = NVIC_GetVector(DMA_IRQn); NVIC_SetVector(DMA_IRQn, (uint32_t)MODDMA_IRQHandler); NVIC_EnableIRQ(DMA_IRQn); } } }; // namespace AjK ends ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/MODDMA.cpp ================================================ /* Copyright (c) 2010 Andy Kirkham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "iomacros.h" #include "MODDMA.h" namespace AjK { // Create a "hook" for our ISR to make callbacks. Set by init() class MODDMA *moddma_p = (class MODDMA *)NULL; void MODDMA::Enable(CHANNELS ChannelNumber) { LPC_GPDMACH_TypeDef *pChannel = (LPC_GPDMACH_TypeDef *)Channel_p( ChannelNumber ); pChannel->DMACCConfig |= _E; } bool MODDMA::Enabled(CHANNELS ChannelNumber) { LPC_GPDMACH_TypeDef *pChannel = (LPC_GPDMACH_TypeDef *)Channel_p( ChannelNumber ); return (bool)(pChannel->DMACCConfig & _E); } void MODDMA::Disable(CHANNELS ChannelNumber) { LPC_GPDMACH_TypeDef *pChannel = (LPC_GPDMACH_TypeDef *)Channel_p( ChannelNumber ); pChannel->DMACCConfig &= ~(_E); } bool MODDMA::isActive(CHANNELS ChannelNumber) { LPC_GPDMACH_TypeDef *pChannel = (LPC_GPDMACH_TypeDef *)Channel_p( ChannelNumber ); return (bool)( pChannel->DMACCConfig & CxConfig_A() ) ; } void MODDMA::haltChannel(CHANNELS ChannelNumber) { LPC_GPDMACH_TypeDef *pChannel = (LPC_GPDMACH_TypeDef *)Channel_p( ChannelNumber ); pChannel->DMACCConfig |= CxConfig_H(); } uint32_t MODDMA::getControl(CHANNELS ChannelNumber) { LPC_GPDMACH_TypeDef *pChannel = (LPC_GPDMACH_TypeDef *)Channel_p( ChannelNumber ); return pChannel->DMACCControl; } uint32_t oldDMAHandler = 0; typedef void (*MODDMA_FN)(void); extern "C" void MODDMA_IRQHandler(void) { uint32_t channel_mask; if (moddma_p == (class MODDMA *)NULL) { if (oldDMAHandler) { ((MODDMA_FN)oldDMAHandler)(); return; } else { error("Interrupt without instance"); } } for (int channel_number = 0; channel_number < 8; channel_number++) { channel_mask = (1UL << channel_number); if (LPC_GPDMA->DMACIntStat & channel_mask) { if (LPC_GPDMA->DMACIntTCStat & channel_mask) { if (moddma_p->setups[channel_number] != (MODDMA_Config *)NULL) { moddma_p->setIrqProcessingChannel((MODDMA::CHANNELS)channel_number); moddma_p->setIrqType(MODDMA::TcIrq); moddma_p->setups[channel_number]->isrIntTCStat->call(); moddma_p->isrIntTCStat.call(); // The user callback should clear the IRQ. But if they forget // then the Mbed will lockup. So, check to see if the IRQ has // been dismissed, if not, we will dismiss it here. if (LPC_GPDMA->DMACIntTCStat & channel_mask) { LPC_GPDMA->DMACIntTCClear = channel_mask; } // If the user has left the channel enabled, disable it. // Note, we don't check Active here as it may block inside // an ISR, we just shut it down immediately. If the user // must wait for completion they should implement their // own ISR. But only disable if the LLI linked list register // is null otherwise we can crap out a series of transfers. if (moddma_p->Enabled( (MODDMA::CHANNELS)channel_number )) { if (moddma_p->lli( (MODDMA::CHANNELS)channel_number ) == 0 ) { moddma_p->Disable( (MODDMA::CHANNELS)channel_number ); } } } } if (LPC_GPDMA->DMACIntErrStat & channel_mask) { if (moddma_p->setups[channel_number] != (MODDMA_Config *)NULL) { moddma_p->setIrqProcessingChannel((MODDMA::CHANNELS)channel_number); moddma_p->setIrqType(MODDMA::ErrIrq); moddma_p->setups[channel_number]->isrIntErrStat->call(); moddma_p->isrIntErrStat.call(); // The user callback should clear the IRQ. But if they forget // then the Mbed will lockup. So, check to see if the IRQ has // been dismissed, if not, we will dismiss it here. if (LPC_GPDMA->DMACIntErrStat & channel_mask) { LPC_GPDMA->DMACIntErrClr = channel_mask; } // If the user has left the channel enabled, disable it. // Not, we don't check Active here as it may block inside // an ISR, we just shut it down immediately. If the user // must wait for completion they should implement their // own ISR. But only disable if the LLI linked list register // is null otherwise we can crap out a series of transfers. if (moddma_p->Enabled( (MODDMA::CHANNELS)channel_number )) { if (moddma_p->lli( (MODDMA::CHANNELS)channel_number ) == 0 ) { moddma_p->Disable( (MODDMA::CHANNELS)channel_number ); } } } } } } /* IRQ should be handled by now, check to make sure. */ if (LPC_GPDMA->DMACIntStat) { ((MODDMA_FN)oldDMAHandler)(); LPC_GPDMA->DMACIntTCClear = (uint32_t)0xFF; /* If not, clear anyway! */ } if (LPC_GPDMA->DMACIntErrStat) { ((MODDMA_FN)oldDMAHandler)(); LPC_GPDMA->DMACIntErrClr = (uint32_t)0xFF; /* If not, clear anyway! */ } } }; // namespace AjK ends ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/MODDMA.h ================================================ /* Copyright (c) 2010 Andy Kirkham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @file MODDMA.h @purpose Adds DMA controller and multiple transfer configurations @version see ChangeLog.c @date Nov 2010 @author Andy Kirkham */ #ifndef MODDMA_H #define MODDMA_H /** @defgroup API The MODDMA API */ /** @defgroup MISC Misc MODSERIAL functions */ /** @defgroup INTERNALS MODSERIAL Internals */ #include "mbed.h" #include "iomacros.h" namespace AjK { /** * @brief The MODDMA configuration system * @author Andy Kirkham * @see http://mbed.org/cookbook/MODDMA_Config * @see MODDMA * @see API * * MODDMA_Config defines a configuration that can be passed to the MODDMA controller * instance to perform a GPDMA data transfer. */ class MODDMA_Config { protected: // ***************************************** // From GPDMA by NXP MCU SW Application Team // ***************************************** uint32_t ChannelNum; //!< DMA channel number, should be in range from 0 to 7. uint32_t TransferSize; //!< Length/Size of transfer uint32_t TransferWidth; //!< Transfer width - used for TransferType is GPDMA_TRANSFERTYPE_m2m only uint32_t SrcMemAddr; //!< Physical Src Addr, used in case TransferType is chosen as MODDMA::GPDMA_TRANSFERTYPE::m2m or MODDMA::GPDMA_TRANSFERTYPE::m2p uint32_t DstMemAddr; //!< Physical Destination Address, used in case TransferType is chosen as MODDMA::GPDMA_TRANSFERTYPE::m2m or MODDMA::GPDMA_TRANSFERTYPE::p2m uint32_t TransferType; //!< Transfer Type uint32_t SrcConn; //!< Peripheral Source Connection type, used in case TransferType is chosen as uint32_t DstConn; //!< Peripheral Destination Connection type, used in case TransferType is chosen as uint32_t DMALLI; //!< Linker List Item structure data address if there's no Linker List, set as '0' uint32_t DMACSync; //!< DMACSync if required. // Mbed specifics. public: MODDMA_Config() { isrIntTCStat = new FunctionPointer; isrIntErrStat = new FunctionPointer; ChannelNum = 0xFFFF; TransferSize = 0; TransferWidth = 0; SrcMemAddr = 0; DstMemAddr = 0; TransferType = 0; SrcConn = 0; DstConn = 0; DMALLI = 0; DMACSync = 0; } ~MODDMA_Config() { delete(isrIntTCStat); delete(isrIntErrStat); } class MODDMA_Config * channelNum(uint32_t n) { ChannelNum = n & 0x7; return this; } class MODDMA_Config * transferSize(uint32_t n) { TransferSize = n; return this; } class MODDMA_Config * transferWidth(uint32_t n) { TransferWidth = n; return this; } class MODDMA_Config * srcMemAddr(uint32_t n) { SrcMemAddr = n; return this; } class MODDMA_Config * dstMemAddr(uint32_t n) { DstMemAddr = n; return this; } class MODDMA_Config * transferType(uint32_t n) { TransferType = n; return this; } class MODDMA_Config * srcConn(uint32_t n) { SrcConn = n; return this; } class MODDMA_Config * dstConn(uint32_t n) { DstConn = n; return this; } class MODDMA_Config * dmaLLI(uint32_t n) { DMALLI = n; return this; } class MODDMA_Config * dmacSync(uint32_t n) { DMACSync = n; return this; } uint32_t channelNum(void) { return ChannelNum; } uint32_t transferSize(void) { return TransferSize; } uint32_t transferWidth(void) { return TransferWidth; } uint32_t srcMemAddr(void) { return SrcMemAddr; } uint32_t dstMemAddr(void) { return DstMemAddr; } uint32_t transferType(void) { return TransferType; } uint32_t srcConn(void) { return SrcConn; } uint32_t dstConn(void) { return DstConn; } uint32_t dmaLLI(void) { return DMALLI; } uint32_t dmacSync(void) { return DMACSync; } /** * Attach a callback to the TC IRQ configuration. * * @param fptr A function pointer to call * @return this */ class MODDMA_Config * attach_tc(void (*fptr)(void)) { isrIntTCStat->attach(fptr); return this; } /** * Attach a callback to the ERR IRQ configuration. * * @param fptr A function pointer to call * @return this */ class MODDMA_Config * attach_err(void (*fptr)(void)) { isrIntErrStat->attach(fptr); return this; } /** * Attach a callback to the TC IRQ configuration. * * @param tptr A template pointer to the calling object * @param mptr A method pointer within the object to call. * @return this */ template class MODDMA_Config * attach_tc(T* tptr, void (T::*mptr)(void)) { if((mptr != NULL) && (tptr != NULL)) { isrIntTCStat->attach(tptr, mptr); } return this; } /** * Attach a callback to the ERR IRQ configuration. * * @param tptr A template pointer to the calling object * @param mptr A method pointer within the object to call. * @return this */ template class MODDMA_Config * attach_err(T* tptr, void (T::*mptr)(void)) { if((mptr != NULL) && (tptr != NULL)) { isrIntErrStat->attach(tptr, mptr); } return this; } FunctionPointer *isrIntTCStat; FunctionPointer *isrIntErrStat; }; /** * @brief The MODDMA configuration system (linked list items) * @author Andy Kirkham * @see http://mbed.org/cookbook/MODDMA_Config * @see MODDMA * @see MODDMA_Config * @see API */ class MODDMA_LLI { public: class MODDMA_LLI *srcAddr(uint32_t n) { SrcAddr = n; return this; } class MODDMA_LLI *dstAddr(uint32_t n) { DstAddr = n; return this; } class MODDMA_LLI *nextLLI(uint32_t n) { NextLLI = n; return this; } class MODDMA_LLI *control(uint32_t n) { Control = n; return this; } uint32_t srcAddr(void) { return SrcAddr; } uint32_t dstAddr(void) { return DstAddr; } uint32_t nextLLI(void) { return NextLLI; } uint32_t control(void) { return Control; } uint32_t SrcAddr; //!< Source Address uint32_t DstAddr; //!< Destination address uint32_t NextLLI; //!< Next LLI address, otherwise set to '0' uint32_t Control; //!< GPDMA Control of this LLI }; /** * @brief MODDMA GPDMA Controller * @author Andy Kirkham * @see http://mbed.org/cookbook/MODDMA * @see example1.cpp * @see API * * MODDMA defines a GPDMA controller and multiple DMA configurations that allow for DMA * transfers from memory to memory, memory to peripheral or peripheral to memory. * * At the heart of the library is the MODDMA class that defines a single instance controller that * manages all the GPDMA hardware registers and interrupts. The controller can accept multiple * configurations that define the channel transfers. Each configuration specifies the source and * destination information and other associated parts to maintain the transfer process. * * Standard example: * @code * #include "mbed.h" * #include "MODDMA.h" * * DigitalOut led1(LED1); * Serial pc(USBTX, USBRX); // tx, rx * MODDMA dma; * * int main() { * * // Create a string buffer to send directly to a Uart/Serial * char s[] = "***DMA*** ABCDEFGHIJKLMNOPQRSTUVWXYZ ***DMA***"; * * // Create a transfer configuarion * MODDMA_Config *config = new MODDMA_Config; * * // Provide a "minimal" setup for demo purposes. * config * ->channelNum ( MODDMA::Channel_0 ) // The DMA channel to use. * ->srcMemAddr ( (uint32_t) &s ) // A pointer to the buffer to send. * ->transferSize ( sizeof(s) ) // The size of that buffer. * ->transferType ( MODDMA::m2p ) // Source is memory, destination is peripheral * ->dstConn ( MODDMA::UART0_Tx ) // Specifically, peripheral is Uart0 TX (USBTX, USBRX) * ; // config end. * * // Pass the configuration to the MODDMA controller. * dma.Setup( config ); * * // Enable the channel and begin transfer. * dma.Enable( config->channelNum() ); * * while(1) { * led1 = !led1; * wait(0.25); * } * } * @endcode */ class MODDMA { public: //! Channel definitions. enum CHANNELS { Channel_0 = 0 /*!< Channel 0 */ , Channel_1 /*!< Channel 1 */ , Channel_2 /*!< Channel 2 */ , Channel_3 /*!< Channel 3 */ , Channel_4 /*!< Channel 4 */ , Channel_5 /*!< Channel 5 */ , Channel_6 /*!< Channel 6 */ , Channel_7 /*!< Channel 7 */ }; //! Interrupt callback types. enum IrqType_t { TcIrq = 0 /*!< Terminal Count interrupt */ , ErrIrq /*!< Error interrupt */ }; //! Return status codes. enum Status { Ok = 0 /*!< Ok, suceeded */ , Error = -1 /*!< General error */ , ErrChInUse = -2 /*!< Specific error, channel in use */ }; //! DMA Connection number definitions enum GPDMA_CONNECTION { SSP0_Tx = 0UL /*!< SSP0 Tx */ , SSP0_Rx = 1UL /*!< SSP0 Rx */ , SSP1_Tx = 2UL /*!< SSP1 Tx */ , SSP1_Rx = 3UL /*!< SSP1 Rx */ , ADC = 4UL /*!< ADC */ , I2S_Channel_0 = 5UL /*!< I2S channel 0 */ , I2S_Channel_1 = 6UL /*!< I2S channel 1 */ , DAC = 7UL /*!< DAC */ , UART0_Tx = 8UL /*!< UART0 Tx */ , UART0_Rx = 9UL /*!< UART0 Rx */ , UART1_Tx = 10UL /*!< UART1 Tx */ , UART1_Rx = 11UL /*!< UART1 Rx */ , UART2_Tx = 12UL /*!< UART2 Tx */ , UART2_Rx = 13UL /*!< UART2 Rx */ , UART3_Tx = 14UL /*!< UART3 Tx */ , UART3_Rx = 15UL /*!< UART3 Rx */ , MAT0_0 = 16UL /*!< MAT0.0 */ , MAT0_1 = 17UL /*!< MAT0.1 */ , MAT1_0 = 18UL /*!< MAT1.0 */ , MAT1_1 = 19UL /*!< MAT1.1 */ , MAT2_0 = 20UL /**< MAT2.0 */ , MAT2_1 = 21UL /*!< MAT2.1 */ , MAT3_0 = 22UL /*!< MAT3.0 */ , MAT3_1 = 23UL /*!< MAT3.1 */ }; //! GPDMA Transfer type definitions enum GPDMA_TRANSFERTYPE { m2m = 0UL /*!< Memory to memory - DMA control */ , m2p = 1UL /*!< Memory to peripheral - DMA control */ , p2m = 2UL /*!< Peripheral to memory - DMA control */ , p2p = 3UL /*!< Src peripheral to dest peripheral - DMA control */ , g2m = 4UL /*!< Psuedo special case for reading "peripheral GPIO" that's memory mapped. */ , m2g = 5UL /*!< Psuedo Special case for writing "peripheral GPIO" that's memory mapped. */ }; //! Burst size in Source and Destination definitions */ enum GPDMA_BSIZE { _1 = 0UL /*!< Burst size = 1 */ , _4 = 1UL /*!< Burst size = 4 */ , _8 = 2UL /*!< Burst size = 8 */ , _16 = 3UL /*!< Burst size = 16 */ , _32 = 4UL /*!< Burst size = 32 */ , _64 = 5UL /*!< Burst size = 64 */ , _128 = 6UL /*!< Burst size = 128 */ , _256 = 7UL /*!< Burst size = 256 */ }; //! Width in Src transfer width and Dest transfer width definitions */ enum GPDMA_WIDTH { byte = 0UL /*!< Width = 1 byte */ , halfword = 1UL /*!< Width = 2 bytes */ , word = 2UL /*!< Width = 4 bytes */ }; //! DMA Request Select Mode definitions. */ enum GPDMA_REQSEL { uart = 0UL /*!< UART TX/RX is selected */ , timer = 1UL /*!< Timer match is selected */ }; //! GPDMA Control register bits. enum Config { _E = 1 /*!< DMA Controller enable */ , _M = 2 /*!< AHB Master endianness configuration */ }; //! GPDMA Channel config register bits. enum CConfig { _CE = (1UL << 0) /*!< Channel enable */ , _IE = (1UL << 14) /*!< Interrupt error mask */ , _ITC = (1UL << 15) /*!< Terminal count interrupt mask */ , _L = (1UL << 16) /*!< Lock */ , _A = (1UL << 17) /*!< Active */ , _H = (1UL << 18) /*!< Halt */ }; /** * The MODDMA constructor is used to initialise the DMA controller object. */ MODDMA() { init(true); } /** * The MODDMA destructor. */ ~MODDMA() {} /** * Used to setup the DMA controller to prepare for a data transfer. * * @ingroup API * @param isConstructorCalling Set true when called from teh constructor * @param */ void init(bool isConstructorCalling, int Channels = 0xFF, int Tc = 0xFF, int Err = 0xFF); /** * Used to setup and enable the DMA controller. * * @see Setup * @see Enable * @ingroup API * @param c A pointer to an instance of MODDMA_Config to setup. */ uint32_t Prepare(MODDMA_Config *c) { uint32_t u = Setup(c); if (u) Enable(c); return u; } /** * Used to setup the DMA controller to prepare for a data transfer. * * @ingroup API * @param c A pointer to an instance of MODDMA_Config to setup. */ uint32_t Setup(MODDMA_Config *c); /** * Enable and begin data transfer. * * @ingroup API * @param ChannelNumber Type CHANNELS, the channel number to enable */ void Enable(CHANNELS ChannelNumber); /** * Enable and begin data transfer (overloaded function) * * @ingroup API * @param ChannelNumber Type uin32_t, the channel number to enable */ void Enable(uint32_t ChannelNumber) { Enable((CHANNELS)(ChannelNumber & 0x7)); } /** * Enable and begin data transfer (overloaded function) * * @ingroup API * @param config A pointer to teh configuration */ void Enable(MODDMA_Config *config) { Enable( config->channelNum() ); } /** * Disable a channel and end data transfer. * * @ingroup API * @param ChannelNumber Type CHANNELS, the channel number to enable */ void Disable(CHANNELS ChannelNumber); /** * Disable a channel and end data transfer (overloaded function) * * @ingroup API * @param ChannelNumber Type uin32_t, the channel number to disable */ void Disable(uint32_t ChannelNumber) { Disable((CHANNELS)(ChannelNumber & 0x7)); } /** * Is the specified channel enabled? * * @ingroup API * @param ChannelNumber Type CHANNELS, the channel number to test * @return bool true if enabled, false otherwise. */ bool Enabled(CHANNELS ChannelNumber); /** * Is the specified channel enabled? (overloaded function) * * @ingroup API * @param ChannelNumber Type uin32_t, the channel number to test * @return bool true if enabled, false otherwise. */ bool Enabled(uint32_t ChannelNumber) { return Enabled((CHANNELS)(ChannelNumber & 0x7)); } __INLINE uint32_t IntStat(uint32_t n) { return (1UL << n) & 0xFF; } __INLINE uint32_t IntTCStat_Ch(uint32_t n) { return (1UL << n) & 0xFF; } __INLINE uint32_t IntTCClear_Ch(uint32_t n) { return (1UL << n) & 0xFF; } __INLINE uint32_t IntErrStat_Ch(uint32_t n) { return (1UL << n) & 0xFF; } __INLINE uint32_t IntErrClr_Ch(uint32_t n) { return (1UL << n) & 0xFF; } __INLINE uint32_t RawIntErrStat_Ch(uint32_t n) { return (1UL << n) & 0xFF; } __INLINE uint32_t EnbldChns_Ch(uint32_t n) { return (1UL << n) & 0xFF; } __INLINE uint32_t SoftBReq_Src(uint32_t n) { return (1UL << n) & 0xFFFF; } __INLINE uint32_t SoftSReq_Src(uint32_t n) { return (1UL << n) & 0xFFFF; } __INLINE uint32_t SoftLBReq_Src(uint32_t n) { return (1UL << n) & 0xFFFF; } __INLINE uint32_t SoftLSReq_Src(uint32_t n) { return (1UL << n) & 0xFFFF; } __INLINE uint32_t Sync_Src(uint32_t n) { return (1UL << n) & 0xFFFF; } __INLINE uint32_t ReqSel_Input(uint32_t n) { return (1UL << (n - 8)) & 0xFF; } __INLINE uint32_t CxControl_TransferSize(uint32_t n) { return (n & 0xFFF) << 0; } __INLINE uint32_t CxControl_SBSize(uint32_t n) { return (n & 0x7) << 12; } __INLINE uint32_t CxControl_DBSize(uint32_t n) { return (n & 0x7) << 15; } __INLINE uint32_t CxControl_SWidth(uint32_t n) { return (n & 0x7) << 18; } __INLINE uint32_t CxControl_DWidth(uint32_t n) { return (n & 0x7) << 21; } __INLINE uint32_t CxControl_SI() { return (1UL << 26); } __INLINE uint32_t CxControl_DI() { return (1UL << 27); } __INLINE uint32_t CxControl_Prot1() { return (1UL << 28); } __INLINE uint32_t CxControl_Prot2() { return (1UL << 29); } __INLINE uint32_t CxControl_Prot3() { return (1UL << 30); } __INLINE uint32_t CxControl_I() { return (1UL << 31); } __INLINE uint32_t CxControl_E() { return (1UL << 0); } __INLINE uint32_t CxConfig_SrcPeripheral(uint32_t n) { return (n & 0x1F) << 1; } __INLINE uint32_t CxConfig_DestPeripheral(uint32_t n) { return (n & 0x1F) << 6; } __INLINE uint32_t CxConfig_TransferType(uint32_t n) { return (n & 0x7) << 11; } __INLINE uint32_t CxConfig_IE() { return (1UL << 14); } __INLINE uint32_t CxConfig_ITC() { return (1UL << 15); } __INLINE uint32_t CxConfig_L() { return (1UL << 16); } __INLINE uint32_t CxConfig_A() { return (1UL << 17); } __INLINE uint32_t CxConfig_H() { return (1UL << 18); } /** * A store for up to 8 (8 channels) of configurations. * @see MODDMA_Config */ MODDMA_Config *setups[8]; /** * Get a pointer to the current configuration the ISR is servicing. * * @ingroup API * @return MODDMA_Config * A pointer to the setup the ISR is currently servicing. */ MODDMA_Config *getConfig(void) { return setups[IrqProcessingChannel]; } /** * Set which channel the ISR is currently servicing. * * *** USED INTERNALLY. DO NOT CALL FROM USER PROGRAMS *** * * Must be public so the extern "C" ISR can use it. */ void setIrqProcessingChannel(CHANNELS n) { IrqProcessingChannel = n; } /** * Gets which channel the ISR is currently servicing. * * @ingroup API * @return CHANNELS The current channel the ISR is servicing. */ CHANNELS irqProcessingChannel(void) { return IrqProcessingChannel; } /** * Sets which type of IRQ the ISR is making a callback for. * * *** USED INTERNALLY. DO NOT CALL FROM USER PROGRAMS *** * * Must be public so the extern "C" ISR can use it. */ void setIrqType(IrqType_t n) { IrqType = n; } /** * Get which type of IRQ the ISR is calling you about, * terminal count or error. */ IrqType_t irqType(void) { return IrqType; } /** * Clear the interrupt after handling. * * @param CHANNELS The channel the IQR occured on. */ void clearTcIrq(CHANNELS n) { LPC_GPDMA->DMACIntTCClear = (uint32_t)(1UL << n); } /** * Clear the interrupt the ISR is currently handing.. */ void clearTcIrq(void) { clearTcIrq( IrqProcessingChannel ); } /** * Clear the error interrupt after handling. * * @ingroup API * @param CHANNELS The channel the IQR occured on. */ void clearErrIrq(CHANNELS n) { LPC_GPDMA->DMACIntTCClear = (uint32_t)(1UL << n); } /** * Clear the error interrupt the ISR is currently handing. * @ingroup API */ void clearErrIrq(void) { clearErrIrq( IrqProcessingChannel ); } /** * Is the supplied channel currently active? * * @ingroup API * @param CHANNELS The channel to inquire about. * @return bool true if active, false otherwise. */ bool isActive(CHANNELS ChannelNumber); /** * Halt the supplied channel. * * @ingroup API * @param CHANNELS The channel to halt. */ void haltChannel(CHANNELS ChannelNumber); /** * get a channels control register. * * @ingroup API * @param CHANNELS The channel to get the control register for. */ uint32_t getControl(CHANNELS ChannelNumber); /** * Wait for channel transfer to complete and then halt. * * @ingroup API * @param CHANNELS The channel to wait for then halt. */ void haltAndWaitChannelComplete(CHANNELS n) { haltChannel(n); while (isActive(n)); } /** * Attach a callback to the TC IRQ controller. * * @ingroup API * @param fptr A function pointer to call * @return this */ void attach_tc(void (*fptr)(void)) { isrIntTCStat.attach(fptr); } /** * Attach a callback to the TC IRQ controller. * * @ingroup API * @param tptr A template pointer to the calling object * @param mptr A method pointer within the object to call. * @return this */ template void attach_tc(T* tptr, void (T::*mptr)(void)) { if((mptr != NULL) && (tptr != NULL)) { isrIntTCStat.attach(tptr, mptr); } } /** * The MODDMA controllers terminal count interrupt callback. */ FunctionPointer isrIntTCStat; /** * Attach a callback to the ERR IRQ controller. * * @ingroup API * @param fptr A function pointer to call * @return this */ void attach_err(void (*fptr)(void)) { isrIntErrStat.attach(fptr); } /** * Attach a callback to the ERR IRQ controller. * * @ingroup API * @param tptr A template pointer to the calling object * @param mptr A method pointer within the object to call. * @return this */ template void attach_err(T* tptr, void (T::*mptr)(void)) { if((mptr != NULL) && (tptr != NULL)) { isrIntErrStat.attach(tptr, mptr); } } /** * Get the Linked List index regsiter for the requested channel. * * @param channelNum The channel number. * @return uint32_t The value of the DMACCLLI register */ uint32_t lli(CHANNELS ChannelNumber, MODDMA_LLI *set = 0) { LPC_GPDMACH_TypeDef *pChannel = (LPC_GPDMACH_TypeDef *)Channel_p( ChannelNumber & 0x7 ); if (set) pChannel->DMACCLLI = (uint32_t)set; return pChannel->DMACCLLI; } /** * The MODDMA controllers error interrupt callback. */ FunctionPointer isrIntErrStat; uint32_t Channel_p(int channel); protected: // Data LUTs. uint32_t LUTPerAddr(int n); uint8_t LUTPerBurst(int n); uint8_t LUTPerWid(int n); //uint32_t Channel_p(int channel); CHANNELS IrqProcessingChannel; IrqType_t IrqType; }; }; // namespace AjK ends. using namespace AjK; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/SETUP.cpp ================================================ /* Copyright (c) 2010 Andy Kirkham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "MODDMA.h" namespace AjK { uint32_t MODDMA::Setup(MODDMA_Config *config) { LPC_GPDMACH_TypeDef *pChannel = (LPC_GPDMACH_TypeDef *)Channel_p( config->channelNum() ); setups[config->channelNum() & 0x7] = config; // Reset the Interrupt status LPC_GPDMA->DMACIntTCClear = IntTCClear_Ch( config->channelNum() ); LPC_GPDMA->DMACIntErrClr = IntErrClr_Ch ( config->channelNum() ); // Clear DMA configure pChannel->DMACCControl = 0x00; pChannel->DMACCConfig = 0x00; // Assign Linker List Item value pChannel->DMACCLLI = config->dmaLLI(); // Set value to Channel Control Registers switch (config->transferType()) { // Memory to memory case m2m: // Assign physical source and destination address pChannel->DMACCSrcAddr = config->srcMemAddr(); pChannel->DMACCDestAddr = config->dstMemAddr(); pChannel->DMACCControl = CxControl_TransferSize(config->transferSize()) | CxControl_SBSize(_32) | CxControl_DBSize(_32) | CxControl_SWidth(config->transferWidth()) | CxControl_DWidth(config->transferWidth()) | CxControl_SI() | CxControl_DI() | CxControl_I(); break; // Memory to peripheral case m2p: // Assign physical source pChannel->DMACCSrcAddr = config->srcMemAddr(); // Assign peripheral destination address pChannel->DMACCDestAddr = (uint32_t)LUTPerAddr(config->dstConn()); pChannel->DMACCControl = CxControl_TransferSize((uint32_t)config->transferSize()) | CxControl_SBSize((uint32_t)LUTPerBurst(config->dstConn())) | CxControl_DBSize((uint32_t)LUTPerBurst(config->dstConn())) | CxControl_SWidth((uint32_t)LUTPerWid(config->dstConn())) | CxControl_DWidth((uint32_t)LUTPerWid(config->dstConn())) | CxControl_SI() | CxControl_I(); break; // Peripheral to memory case p2m: // Assign peripheral source address pChannel->DMACCSrcAddr = (uint32_t)LUTPerAddr(config->srcConn()); // Assign memory destination address pChannel->DMACCDestAddr = config->dstMemAddr(); pChannel->DMACCControl = CxControl_TransferSize((uint32_t)config->transferSize()) | CxControl_SBSize((uint32_t)LUTPerBurst(config->srcConn())) | CxControl_DBSize((uint32_t)LUTPerBurst(config->srcConn())) | CxControl_SWidth((uint32_t)LUTPerWid(config->srcConn())) | CxControl_DWidth((uint32_t)LUTPerWid(config->srcConn())) | CxControl_DI() | CxControl_I(); break; // Peripheral to peripheral case p2p: // Assign peripheral source address pChannel->DMACCSrcAddr = (uint32_t)LUTPerAddr(config->srcConn()); // Assign peripheral destination address pChannel->DMACCDestAddr = (uint32_t)LUTPerAddr(config->dstConn()); pChannel->DMACCControl = CxControl_TransferSize((uint32_t)config->transferSize()) | CxControl_SBSize((uint32_t)LUTPerBurst(config->srcConn())) | CxControl_DBSize((uint32_t)LUTPerBurst(config->dstConn())) | CxControl_SWidth((uint32_t)LUTPerWid(config->srcConn())) | CxControl_DWidth((uint32_t)LUTPerWid(config->dstConn())) | CxControl_I(); break; // GPIO to memory case g2m: // Assign GPIO source address pChannel->DMACCSrcAddr = config->srcMemAddr(); // Assign memory destination address pChannel->DMACCDestAddr = config->dstMemAddr(); pChannel->DMACCControl = CxControl_TransferSize((uint32_t)config->transferSize()) | CxControl_SBSize((uint32_t)LUTPerBurst(config->srcConn())) | CxControl_DBSize((uint32_t)LUTPerBurst(config->srcConn())) | CxControl_SWidth((uint32_t)LUTPerWid(config->srcConn())) | CxControl_DWidth((uint32_t)LUTPerWid(config->srcConn())) | CxControl_DI() | CxControl_I(); break; // Memory to GPIO case m2g: // Assign physical source pChannel->DMACCSrcAddr = config->srcMemAddr(); // Assign peripheral destination address pChannel->DMACCDestAddr = config->dstMemAddr(); pChannel->DMACCControl = CxControl_TransferSize((uint32_t)config->transferSize()) | CxControl_SBSize((uint32_t)LUTPerBurst(config->dstConn())) | CxControl_DBSize((uint32_t)LUTPerBurst(config->dstConn())) | CxControl_SWidth((uint32_t)LUTPerWid(config->dstConn())) | CxControl_DWidth((uint32_t)LUTPerWid(config->dstConn())) | CxControl_SI() | CxControl_I(); break; // Do not support any more transfer type, return ERROR default: return 0; } // Re-Configure DMA Request Select for source peripheral if (config->srcConn() > 15) { LPC_SC->DMAREQSEL |= (1 << (config->srcConn() - 16)); } else { LPC_SC->DMAREQSEL &= ~(1 << (config->srcConn() - 8)); } // Re-Configure DMA Request Select for destination peripheral if (config->dstConn() > 15) { LPC_SC->DMAREQSEL |= (1 << (config->dstConn() - 16)); } else { LPC_SC->DMAREQSEL &= ~(1 << (config->dstConn() - 8)); } // Enable DMA channels, little endian LPC_GPDMA->DMACConfig = _E; while (!(LPC_GPDMA->DMACConfig & _E)); // Calculate absolute value for Connection number uint32_t tmp1 = config->srcConn(); tmp1 = ((tmp1 > 15) ? (tmp1 - 8) : tmp1); uint32_t tmp2 = config->dstConn(); tmp2 = ((tmp2 > 15) ? (tmp2 - 8) : tmp2); if (config->dmacSync()) { uint32_t tmp3 = config->dmacSync(); tmp3 = ((tmp3 > 15) ? (tmp3 - 8) : tmp3); LPC_GPDMA->DMACSync |= Sync_Src( tmp3 ); } uint32_t tfer_type = (uint32_t)config->transferType(); if (tfer_type == g2m || tfer_type == m2g) { tfer_type -= 2; // Adjust psuedo transferType to a real transferType. } // Configure DMA Channel, enable Error Counter and Terminate counter pChannel->DMACCConfig = CxConfig_IE() | CxConfig_ITC() | CxConfig_TransferType(tfer_type) | CxConfig_SrcPeripheral(tmp1) | CxConfig_DestPeripheral(tmp2); return pChannel->DMACCControl; } }; // namespace AjK ends ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/example1.h ================================================ #include "mbed.h" #include "MODDMA.h" #include "MODSERIAL.h" DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); MODDMA dma; MODSERIAL pc(USBTX, USBRX); // Function prototypes for IRQ callbacks. // See definitions following main() below. void dmaTCCallback(void); void dmaERRCallback(void); void TC0_callback(void); void ERR0_callback(void); int main() { char s[] = "**DMA** ABCDEFGHIJKLMNOPQRSTUVWXYZ **DMA**"; pc.baud(PC_BAUD); dma.attach_tc( &dmaTCCallback ); dma.attach_err( &dmaERRCallback ); MODDMA_Config *config = new MODDMA_Config; config ->channelNum ( MODDMA::Channel_0 ) ->srcMemAddr ( (uint32_t) &s ) ->dstMemAddr ( 0 ) ->transferSize ( sizeof(s) ) ->transferType ( MODDMA::m2p ) ->transferWidth ( 0 ) ->srcConn ( 0 ) ->dstConn ( MODDMA::UART0_Tx ) ->dmaLLI ( 0 ) ->attach_tc ( &TC0_callback ) ->attach_err ( &ERR0_callback ) ; // config end // Setup the configuration. dma.Setup(config); //dma.Enable( MODDMA::Channel_0 ); //dma.Enable( config->channelNum() ); dma.Enable( config ); while (1) { led1 = !led1; wait(0.25); } } // Main controller TC IRQ callback void dmaTCCallback(void) { led2 = 1; } // Main controller ERR IRQ callback void dmaERRCallback(void) { error("Oh no! My Mbed exploded! :( Only kidding, find the problem"); } // Configuration callback on TC void TC0_callback(void) { MODDMA_Config *config = dma.getConfig(); dma.haltAndWaitChannelComplete( (MODDMA::CHANNELS)config->channelNum()); dma.Disable( (MODDMA::CHANNELS)config->channelNum() ); // Configurations have two IRQ callbacks for TC and Err so you // know which you are processing. However, if you want to use // a single callback function you can tell what type of IRQ // is being processed thus:- if (dma.irqType() == MODDMA::TcIrq) { led3 = 1; dma.clearTcIrq(); } if (dma.irqType() == MODDMA::ErrIrq) { led4 = 1; dma.clearErrIrq(); } } // Configuration cakllback on Error void ERR0_callback(void) { error("Oh no! My Mbed exploded! :( Only kidding, find the problem"); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/example2.h ================================================ /* * This example was provided to support Mbed forum thread:- * http://mbed.org/forum/mbed/topic/1798 */ #include "mbed.h" #include "MODDMA.h" #define SAMPLE_BUFFER_LENGTH 32 DigitalOut led1(LED1); DigitalOut led2(LED2); MODDMA dma; Serial pc(USBTX, USBRX); // ISR set's this when transfer complete. bool dmaTransferComplete = false; // Function prototypes for IRQ callbacks. // See definitions following main() below. void TC0_callback(void); void ERR0_callback(void); int main() { // Create a buffer to hold the ADC samples and clear it. // Note, we are going to sample two ADC inputs so they // end up in this buffer "interleaved". So you will want // a buffer twice this size to a real life given sample // frequency. See the printf() output for details. uint32_t adcInputBuffer[SAMPLE_BUFFER_LENGTH]; memset(adcInputBuffer, 0, sizeof(adcInputBuffer)); // We use the ADC irq to trigger DMA and the manual says // that in this case the NVIC for ADC must be disabled. NVIC_DisableIRQ(ADC_IRQn); // Power up the ADC and set PCLK LPC_SC->PCONP |= (1UL << 12); LPC_SC->PCLKSEL0 &= ~(3UL << 24); // PCLK = CCLK/4 96M/4 = 24MHz // Enable the ADC, 12MHz, ADC0.0 & .1 LPC_ADC->ADCR = (1UL << 21) | (1UL << 8) | (3UL << 0); // Set the pin functions to ADC LPC_PINCON->PINSEL1 &= ~(3UL << 14); /* P0.23, Mbed p15. */ LPC_PINCON->PINSEL1 |= (1UL << 14); LPC_PINCON->PINSEL1 &= ~(3UL << 16); /* P0.24, Mbed p16. */ LPC_PINCON->PINSEL1 |= (1UL << 16); // Setup the serial port to print out results. pc.baud(115200); pc.printf("ADC with DMA example\n"); pc.printf("====================\n"); // Prepare an ADC configuration. MODDMA_Config *conf = new MODDMA_Config; conf ->channelNum ( MODDMA::Channel_0 ) ->srcMemAddr ( 0 ) ->dstMemAddr ( (uint32_t)adcInputBuffer ) ->transferSize ( SAMPLE_BUFFER_LENGTH ) ->transferType ( MODDMA::p2m ) ->transferWidth ( MODDMA::word ) ->srcConn ( MODDMA::ADC ) ->dstConn ( 0 ) ->dmaLLI ( 0 ) ->attach_tc ( &TC0_callback ) ->attach_err ( &ERR0_callback ) ; // end conf. // Prepare configuration. dma.Setup( conf ); // Enable configuration. dma.Enable( conf ); // Enable ADC irq flag (to DMA). // Note, don't set the individual flags, // just set the global flag. LPC_ADC->ADINTEN = 0x100; // Enable burst mode on inputs 0 and 1. LPC_ADC->ADCR |= (1UL << 16); while (1) { // When transfer complete do this block. if (dmaTransferComplete) { delete conf; // No memory leaks, delete the configuration. dmaTransferComplete = false; for (int i = 0; i < SAMPLE_BUFFER_LENGTH; i++) { int channel = (adcInputBuffer[i] >> 24) & 0x7; int iVal = (adcInputBuffer[i] >> 4) & 0xFFF; double fVal = 3.3 * (double)((double)iVal) / ((double)0x1000); // scale to 0v to 3.3v pc.printf("Array index %02d : ADC input channel %d = 0x%03x %01.3f volts\n", i, channel, iVal, fVal); } } // Just flash LED1 for something to do. led1 = !led1; wait(0.25); } } // Configuration callback on TC void TC0_callback(void) { MODDMA_Config *config = dma.getConfig(); // Disbale burst mode and switch off the IRQ flag. LPC_ADC->ADCR &= ~(1UL << 16); LPC_ADC->ADINTEN = 0; // Finish the DMA cycle by shutting down the channel. dma.haltAndWaitChannelComplete( (MODDMA::CHANNELS)config->channelNum()); dma.Disable( (MODDMA::CHANNELS)config->channelNum() ); // Tell main() while(1) loop to print the results. dmaTransferComplete = true; // Switch on LED2 to show transfer complete. led2 = 1; // Clear DMA IRQ flags. if (dma.irqType() == MODDMA::TcIrq) dma.clearTcIrq(); if (dma.irqType() == MODDMA::ErrIrq) dma.clearErrIrq(); } // Configuration callback on Error void ERR0_callback(void) { // Switch off burst conversions. LPC_ADC->ADCR |= ~(1UL << 16); LPC_ADC->ADINTEN = 0; error("Oh no! My Mbed EXPLODED! :( Only kidding, go find the problem"); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/example3.h ================================================ /* * Demonstrates capturing the GPIO P0.4 to P0.7 "nibble" to memory * using GPDMA. The transfers from port pins to memory buffer are * triggered using Timer1 MAT1.0 match compare. * * In this example all inputs have pullups. So with nothing connected * the P0.4/7 reads as 0xF. Connecting a wire from one or more of the four * inputs to ground will show up in the captured buffer sequence. */ #include "mbed.h" #include "MODDMA.h" #include "iomacros.h" // within MODDMA library. // How long between grabbing GPIO FIO0PIN register. // Value is in microseconds. (500000 is half a second). #define SAMPLE_PERIOD 500000 #define NUM_OF_SAMPLES 5 Serial pc(USBTX, USBRX); DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); uint32_t buffer[NUM_OF_SAMPLES]; bool dmaTransferComplete; MODDMA dma; MODDMA_Config *conf; void TC0_callback(void); void ERR0_callback(void); int main() { volatile int life_counter = 0; // Macros defined in iomacros.h, saves messing with DigitalIn p30_AS_INPUT; p30_MODE( PIN_PULLUP ); // P0.4 p29_AS_INPUT; p29_MODE( PIN_PULLUP ); // P0.5 p8_AS_INPUT; p8_MODE( PIN_PULLUP ); // P0.6 p7_AS_INPUT; p7_MODE( PIN_PULLUP ); // P0.7 // Clear the buffer. memset(buffer, 0, sizeof(buffer)); // Setup the serial port to print out results. pc.baud(115200); pc.printf("Starting up...\n"); // Set-up timer1 as a periodic timer. LPC_SC->PCONP |= (1UL << 2); // TIM1 On LPC_SC->PCLKSEL0 |= (3UL << 4); // CCLK/8 = 12MHz LPC_TIM1->PR = 11; // TC clocks at 1MHz. LPC_TIM1->MCR = 2; // Reset TCR to zero on match. LPC_TIM1->MR0 = SAMPLE_PERIOD; // Prepare the GPDMA system. conf = new MODDMA_Config; conf ->channelNum ( MODDMA::Channel_0 ) ->srcMemAddr ( (uint32_t)&LPC_GPIO0->FIOPIN ) ->dstMemAddr ( (uint32_t)&buffer[0] ) ->transferSize ( NUM_OF_SAMPLES ) ->transferType ( MODDMA::g2m ) // pseudo transfer code MODDMA understands. ->transferWidth ( MODDMA::word ) ->srcConn ( MODDMA::MAT1_0 ) ->dmacSync ( MODDMA::MAT1_0 ) ->attach_tc ( TC0_callback ) ->attach_err ( ERR0_callback ) ; // end conf. // Prepare configuration. if (!dma.Setup( conf )) { error("Doh!"); } // Enable GPDMA to be ready for the TIM1 "ticks". dma.Enable( conf ); // Begin. LPC_TIM1->TCR = 1; while (1) { if (life_counter++ > 1000000) { led1 = !led1; // Show some sort of life. life_counter = 0; } if (dmaTransferComplete) { dmaTransferComplete = false; for (int i = 0; i < NUM_OF_SAMPLES; i++) { int val = (buffer[i] >> 4) & 0xF; pc.printf("Buffer index %d = 0x%x\n", i, val); } pc.printf("Done.\n"); // Schedule another grab. if (dma.Setup( conf )) { dma.Enable( conf ); } } } } // Configuration callback on TC void TC0_callback(void) { // Just show sample sequence grab complete. led3 = !led3; // Get configuration pointer. MODDMA_Config *config = dma.getConfig(); // Finish the DMA cycle by shutting down the channel. dma.Disable( (MODDMA::CHANNELS)config->channelNum() ); // Tell main() while(1) loop to print the results. dmaTransferComplete = true; // Clear DMA IRQ flags. if (dma.irqType() == MODDMA::TcIrq) dma.clearTcIrq(); if (dma.irqType() == MODDMA::ErrIrq) dma.clearErrIrq(); } // Configuration callback on Error void ERR0_callback(void) { error("Oh no! My Mbed EXPLODED! :( Only kidding, go find the problem"); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/example4.h ================================================ /* * Demonstrates sending a buffer repeatedly to the DAC using DMA. * Connect an oscilloscope to Mbed pin 18. This example doesn't * output anything else (nothing on any serial ports). */ #include "mbed.h" #include "MODDMA.h" // Make the buffer size match the number of degrees // in a circle since we are going to output a sinewave. #define BUFFER_SIZE 360 // Set DAC output power mode. #define DAC_POWER_MODE (1 << 16) DigitalOut led1(LED1); DigitalOut led3(LED3); DigitalOut led4(LED4); int buffer[2][BUFFER_SIZE]; AnalogOut signal(p18); MODDMA dma; MODDMA_Config *conf0, *conf1; void TC0_callback(void); void ERR0_callback(void); void TC1_callback(void); void ERR1_callback(void); int main() { volatile int life_counter = 0; // Create a sinewave buffer for testing. for (int i = 0; i <= 90; i++) buffer[0][i] = (512 * sin(3.14159/180.0 * i)) + 512; for (int i = 91; i <= 180; i++) buffer[0][i] = buffer[0][180 - i]; for (int i = 181; i <= 270; i++) buffer[0][i] = 512 - (buffer[0][i - 180] - 512); for (int i = 271; i < 360; i++) buffer[0][i] = 512 - (buffer[0][360 - i] - 512); // Adjust the sinewave buffer for use with DAC hardware. for (int i = 0; i < 360; i++) { buffer[0][i] = DAC_POWER_MODE | ((buffer[0][i] << 6) & 0xFFC0); buffer[1][i] = buffer[0][i]; // Just create a copy of buffer0 to continue sinewave. } // Prepare the GPDMA system for buffer0. conf0 = new MODDMA_Config; conf0 ->channelNum ( MODDMA::Channel_0 ) ->srcMemAddr ( (uint32_t) &buffer[0] ) ->dstMemAddr ( MODDMA::DAC ) ->transferSize ( 360 ) ->transferType ( MODDMA::m2p ) ->dstConn ( MODDMA::DAC ) ->attach_tc ( &TC0_callback ) ->attach_err ( &ERR0_callback ) ; // config end // Prepare the GPDMA system for buffer1. conf1 = new MODDMA_Config; conf1 ->channelNum ( MODDMA::Channel_1 ) ->srcMemAddr ( (uint32_t) &buffer[1] ) ->dstMemAddr ( MODDMA::DAC ) ->transferSize ( 360 ) ->transferType ( MODDMA::m2p ) ->dstConn ( MODDMA::DAC ) ->attach_tc ( &TC1_callback ) ->attach_err ( &ERR1_callback ) ; // config end // Calculating the transfer frequency: // By default, the Mbed library sets the PCLK_DAC clock value // to 24MHz. One complete sinewave cycle in each buffer is 360 // points long. So, for a 1Hz wave we would need to transfer 360 // values per second. That would be 24000000/360 which is approx // 66,666. But that's no good! The count val is only 16bits in size // so bare this in mind. If you need to go slower you will need to // alter PCLK_DAC from CCLK/4 to CCLK/8. // For our demo we are going to have the sinewave run at 1kHz. // That's 24000000/360000 which is approx 66. Experimentation // however showed 65 to get closer to 1kHz (on my Mbed and scope // at least). LPC_DAC->DACCNTVAL = 65; // 6500 for 10Hz // Prepare first configuration. if (!dma.Prepare( conf0 )) { error("Doh!"); } // Begin (enable DMA and counter). Note, don't enable // DBLBUF_ENA as we are using DMA double buffering. LPC_DAC->DACCTRL |= (3UL << 2); while (1) { // There's not a lot to do as DMA and interrupts are // now handling the buffer transfers. So we'll just // flash led1 to show the Mbed is alive and kicking. if (life_counter++ > 1000000) { led1 = !led1; // Show some sort of life. life_counter = 0; } } } // Configuration callback on TC void TC0_callback(void) { // Just show sending buffer0 complete. led3 = !led3; // Get configuration pointer. MODDMA_Config *config = dma.getConfig(); // Finish the DMA cycle by shutting down the channel. dma.Disable( (MODDMA::CHANNELS)config->channelNum() ); // Swap to buffer1 dma.Prepare( conf1 ); // Clear DMA IRQ flags. if (dma.irqType() == MODDMA::TcIrq) dma.clearTcIrq(); } // Configuration callback on Error void ERR0_callback(void) { error("Oh no! My Mbed EXPLODED! :( Only kidding, go find the problem"); } // Configuration callback on TC void TC1_callback(void) { // Just show sending buffer1 complete. led4 = !led4; // Get configuration pointer. MODDMA_Config *config = dma.getConfig(); // Finish the DMA cycle by shutting down the channel. dma.Disable( (MODDMA::CHANNELS)config->channelNum() ); // Swap to buffer0 dma.Prepare( conf0 ); // Clear DMA IRQ flags. if (dma.irqType() == MODDMA::TcIrq) dma.clearTcIrq(); } // Configuration callback on Error void ERR1_callback(void) { error("Oh no! My Mbed EXPLODED! :( Only kidding, go find the problem"); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA/iomacros.h ================================================ /* Copyright (c) 2011 Andy Kirkham Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef IOMACROS_H #define IOMACROS_H #ifndef __LPC17xx_H__ #include "LPC17xx.h" #endif #define PIN_PULLUP 0UL #define PIN_REPEAT 1UL #define PIN_NONE 2UL #define PIN_PULLDOWN 3UL /* p5 is P0.9 */ #define p5_SEL_MASK ~(3UL << 18) #define p5_SET_MASK (1UL << 9) #define p5_CLR_MASK ~(p5_SET_MASK) #define p5_AS_OUTPUT LPC_PINCON->PINSEL0&=p5_SEL_MASK;LPC_GPIO0->FIODIR|=p5_SET_MASK #define p5_AS_INPUT LPC_GPIO0->FIOMASK &= p5_CLR_MASK; #define p5_SET LPC_GPIO0->FIOSET = p5_SET_MASK #define p5_CLR LPC_GPIO0->FIOCLR = p5_SET_MASK #define p5_IS_SET (bool)(LPC_GPIO0->FIOPIN & p5_SET_MASK) #define p5_IS_CLR !(p5_IS_SET) #define p5_MODE(x) LPC_PINCON->PINMODE0&=p5_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<18) /* p6 is P0.8 */ #define p6_SEL_MASK ~(3UL << 16) #define p6_SET_MASK (1UL << 8) #define p6_CLR_MASK ~(p6_SET_MASK) #define p6_AS_OUTPUT LPC_PINCON->PINSEL0&=p6_SEL_MASK;LPC_GPIO0->FIODIR|=p6-SET_MASK #define p6_AS_INPUT LPC_GPIO0->FIOMASK &= p6_CLR_MASK; #define p6_SET LPC_GPIO0->FIOSET = p6_SET_MASK #define p6_CLR LPC_GPIO0->FIOCLR = p6_SET_MASK #define p6_IS_SET (bool)(LPC_GPIO0->FIOPIN & p6_SET_MASK) #define p6_IS_CLR !(p6_IS_SET) #define p6_MODE(x) LPC_PINCON->PINMODE0&=p6_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<16) /* p7 is P0.7 */ #define p7_SEL_MASK ~(3UL << 14) #define p7_SET_MASK (1UL << 7) #define p7_CLR_MASK ~(p7_SET_MASK) #define p7_AS_OUTPUT LPC_PINCON->PINSEL0&=p7_SEL_MASK;LPC_GPIO0->FIODIR|=p7_SET_MASK #define p7_AS_INPUT LPC_GPIO0->FIOMASK &= p7_CLR_MASK; #define p7_SET LPC_GPIO0->FIOSET = p7_SET_MASK #define p7_CLR LPC_GPIO0->FIOCLR = p7_SET_MASK #define p7_IS_SET (bool)(LPC_GPIO0->FIOPIN & p7_SET_MASK) #define p7_IS_CLR !(p7_IS_SET) #define p7_MODE(x) LPC_PINCON->PINMODE0&=p7_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<14) /* p8 is P0.6 */ #define p8_SEL_MASK ~(3UL << 12) #define p8_SET_MASK (1UL << 6) #define p8_CLR_MASK ~(p8_SET_MASK) #define p8_AS_OUTPUT LPC_PINCON->PINSEL0&=p8_SEL_MASK;LPC_GPIO0->FIODIR|=p8_SET_MASK #define p8_AS_INPUT LPC_GPIO0->FIOMASK &= p8_CLR_MASK; #define p8_SET LPC_GPIO0->FIOSET = p8_SET_MASK #define p8_CLR LPC_GPIO0->FIOCLR = p8_SET_MASK #define p8_IS_SET (bool)(LPC_GPIO0->FIOPIN & p8_SET_MASK) #define p8_IS_CLR !(p8_IS_SET) #define p8_MODE(x) LPC_PINCON->PINMODE0&=p8_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<12) /* p9 is P0.0 */ #define p9_SEL_MASK ~(3UL << 0) #define p9_SET_MASK (1UL << 0) #define p9_CLR_MASK ~(p9_SET_MASK) #define p9_AS_OUTPUT LPC_PINCON->PINSEL0&=p9_SEL_MASK;LPC_GPIO0->FIODIR|=p9_SET_MASK #define p9_AS_INPUT LPC_GPIO0->FIOMASK &= p9_CLR_MASK; #define p9_SET LPC_GPIO0->FIOSET = p9_SET_MASK #define p9_CLR LPC_GPIO0->FIOCLR = p9_SET_MASK #define p9_IS_SET (bool)(LPC_GPIO0->FIOPIN & p9_SET_MASK) #define p9_IS_CLR !(p9_IS_SET) #define p9_MODE(x) LPC_PINCON->PINMODE0&=p9_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<0) /* p10 is P0.1 */ #define p10_SEL_MASK ~(3UL << 2) #define p10_SET_MASK (1UL << 1) #define p10_CLR_MASK ~(p10_SET_MASK) #define p10_AS_OUTPUT LPC_PINCON->PINSEL0&=p10_SEL_MASK;LPC_GPIO0->FIODIR|=p10_SET_MASK #define p10_AS_INPUT LPC_GPIO0->FIOMASK &= p10_CLR_MASK; #define p10_SET LPC_GPIO0->FIOSET = p10_SET_MASK #define p10_CLR LPC_GPIO0->FIOCLR = p10_SET_MASK #define p10_IS_SET (bool)(LPC_GPIO0->FIOPIN & p10_SET_MASK) #define p10_IS_CLR !(p10_IS_SET) #define p10_MODE(x) LPC_PINCON->PINMODE0&=p10_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<2) /* p11 is P0.18 */ #define p11_SEL_MASK ~(3UL << 4) #define p11_SET_MASK (1UL << 18) #define p11_CLR_MASK ~(p11_SET_MASK) #define p11_AS_OUTPUT LPC_PINCON->PINSEL1&=p11_SEL_MASK;LPC_GPIO0->FIODIR|=p11_SET_MASK #define p11_AS_INPUT LPC_GPIO0->FIOMASK &= p11_CLR_MASK; #define p11_SET LPC_GPIO0->FIOSET = p11_SET_MASK #define p11_CLR LPC_GPIO0->FIOCLR = p11_SET_MASK #define p11_IS_SET (bool)(LPC_GPIO0->FIOPIN & p11_SET_MASK) #define p11_IS_CLR !(p11_IS_SET) #define p11_MODE(x) LPC_PINCON->PINMODE1&=p11_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<4) /* p12 is P0.17 */ #define p12_SEL_MASK ~(3UL << 2) #define p12_SET_MASK (1UL << 17) #define p12_CLR_MASK ~(p12_SET_MASK) #define p12_AS_OUTPUT LPC_PINCON->PINSEL1&=p12_SEL_MASK;LPC_GPIO0->FIODIR|=p12_SET_MASK #define p12_AS_INPUT LPC_GPIO0->FIOMASK &= p12_CLR_MASK; #define p12_SET LPC_GPIO0->FIOSET = p12_SET_MASK #define p12_CLR LPC_GPIO0->FIOCLR = p12_SET_MASK #define p12_IS_SET (bool)(LPC_GPIO0->FIOPIN & p12_SET_MASK) #define p12_IS_CLR !(p12_IS_SET) #define p12_MODE(x) LPC_PINCON->PINMODE1&=p12_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<2) /* p13 is P0.15 */ #define p13_SEL_MASK ~(3UL << 30) #define p13_SET_MASK (1UL << 15) #define p13_CLR_MASK ~(p13_SET_MASK) #define p13_AS_OUTPUT LPC_PINCON->PINSEL0&=p13_SEL_MASK;LPC_GPIO0->FIODIR|=p13_SET_MASK #define p13_AS_INPUT LPC_GPIO0->FIOMASK &= p13_CLR_MASK; #define p13_SET LPC_GPIO0->FIOSET = p13_SET_MASK #define p13_CLR LPC_GPIO0->FIOCLR = p13_SET_MASK #define p13_IS_SET (bool)(LPC_GPIO0->FIOPIN & p13_SET_MASK) #define p13_IS_CLR !(p13_IS_SET) #define p13_MODE(x) LPC_PINCON->PINMODE0&=p13_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<30) /* p14 is P0.16 */ #define p14_SEL_MASK ~(3UL << 0) #define p14_SET_MASK (1UL << 16) #define p14_CLR_MASK ~(p14_SET_MASK) #define p14_AS_OUTPUT LPC_PINCON->PINSEL1&=p14_SEL_MASK;LPC_GPIO0->FIODIR|=p14_SET_MASK #define p14_AS_INPUT LPC_GPIO0->FIOMASK &= p14_CLR_MASK; #define p14_SET LPC_GPIO0->FIOSET = p14_SET_MASK #define p14_CLR LPC_GPIO0->FIOCLR = p14_SET_MASK #define p14_IS_SET (bool)(LPC_GPIO0->FIOPIN & p14_SET_MASK) #define p14_IS_CLR !(p14_IS_SET) #define p14_MODE(x) LPC_PINCON->PINMODE1&=p14_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<0) /* p15 is P0.23 */ #define p15_SEL_MASK ~(3UL << 14) #define p15_SET_MASK (1UL << 23) #define p15_CLR_MASK ~(p15_SET_MASK) #define p15_AS_OUTPUT LPC_PINCON->PINSEL1&=p15_SEL_MASK;LPC_GPIO0->FIODIR|=p15_SET_MASK #define p15_AS_INPUT LPC_GPIO0->FIOMASK &= p15_CLR_MASK; #define p15_SET LPC_GPIO0->FIOSET = p15_SET_MASK #define p15_CLR LPC_GPIO0->FIOCLR = p15_SET_MASK #define p15_IS_SET (bool)(LPC_GPIO0->FIOPIN & p15_SET_MASK) #define p15_IS_CLR !(p15_IS_SET) #define p15_MODE(x) LPC_PINCON->PINMODE1&=p15_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<14) /* p16 is P0.24 */ #define p16_SEL_MASK ~(3UL << 16) #define p16_SET_MASK (1UL << 24) #define p16_CLR_MASK ~(p16_SET_MASK) #define p16_AS_OUTPUT LPC_PINCON->PINSEL1&=p16_SEL_MASK;LPC_GPIO0->FIODIR|=p16_SET_MASK #define p16_AS_INPUT LPC_GPIO0->FIOMASK &= p16_CLR_MASK; #define p16_SET LPC_GPIO0->FIOSET = p16_SET_MASK #define p16_CLR LPC_GPIO0->FIOCLR = p16_SET_MASK #define p16_IS_SET (bool)(LPC_GPIO0->FIOPIN & p16_SET_MASK) #define p16_IS_CLR !(p16_IS_SET) #define p16_MODE(x) LPC_PINCON->PINMODE1&=p16_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<16) /* p17 is P0.25 */ #define p17_SEL_MASK ~(3UL << 18) #define p17_SET_MASK (1UL << 25) #define p17_CLR_MASK ~(p17_SET_MASK) #define p17_AS_OUTPUT LPC_PINCON->PINSEL1&=p17_SEL_MASK;LPC_GPIO0->FIODIR|=p17_SET_MASK #define p17_AS_INPUT LPC_GPIO0->FIOMASK &= p17_CLR_MASK; #define p17_SET LPC_GPIO0->FIOSET = p17_SET_MASK #define p17_CLR LPC_GPIO0->FIOCLR = p17_SET_MASK #define p17_IS_SET (bool)(LPC_GPIO0->FIOPIN & p17_SET_MASK) #define p17_IS_CLR !(p17_IS_SET) #define p17_MODE(x) LPC_PINCON->PINMODE1&=p17_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<18) /* p18 is P0.26 */ #define p18_SEL_MASK ~(3UL << 20) #define p18_SET_MASK (1UL << 26) #define p18_CLR_MASK ~(p18_SET_MASK) #define p18_AS_OUTPUT LPC_PINCON->PINSEL1&=p18_SEL_MASK;LPC_GPIO0->FIODIR|=p18_SET_MASK #define p18_AS_INPUT LPC_GPIO0->FIOMASK &= p18_CLR_MASK; #define p18_SET LPC_GPIO0->FIOSET = p18_SET_MASK #define p18_CLR LPC_GPIO0->FIOCLR = p18_SET_MASK #define p18_IS_SET (bool)(LPC_GPIO0->FIOPIN & p18_SET_MASK) #define p18_IS_CLR !(p18_IS_SET) #define p18_MODE(x) LPC_PINCON->PINMODE1&=p18_SEL_MASK;LPC_PINCON->PINMODE1|=((x&0x3)<<20) /* p19 is P1.30 */ #define p19_SEL_MASK ~(3UL << 28) #define p19_SET_MASK (1UL << 30) #define p19_AS_OUTPUT LPC_PINCON->PINSEL3&=p19_SEL_MASK;LPC_GPIO1->FIODIR|=p19_SET_MASK #define p19_AS_INPUT LPC_GPIO1->FIOMASK &= p19_CLR_MASK; #define p19_SET LPC_GPIO1->FIOSET = p19_SET_MASK #define p19_CLR LPC_GPIO1->FIOCLR = p19_SET_MASK #define p19_IS_SET (bool)(LPC_GPIO1->FIOPIN & p19_SET_MASK) #define p19_IS_CLR !(p19_IS_SET) #define p19_MODE(x) LPC_PINCON->PINMODE3&=p19_SEL_MASK;LPC_PINCON->PINMODE3|=((x&0x3)<<28) /* p20 is P1.31 */ #define p20_SEL_MASK ~(3UL << 30) #define p20_SET_MASK (1UL << 31) #define p20_CLR_MASK ~(p20_SET_MASK) #define p20_AS_OUTPUT LPC_PINCON->PINSEL3&=p20_SEL_MASK;LPC_GPIO1->FIODIR|=p20_SET_MASK #define p20_AS_INPUT LPC_GPIO1->FIOMASK &= p20_CLR_MASK; #define p20_SET LPC_GPIO1->FIOSET = p20_SET_MASK #define p20_CLR LPC_GPIO1->FIOCLR = p20_SET_MASK #define p20_IS_SET (bool)(LPC_GPIO1->FIOPIN & p20_SET_MASK) #define p20_IS_CLR !(p20_IS_SET) #define p20_MODE(x) LPC_PINCON->PINMODE3&=p20_SEL_MASK;LPC_PINCON->PINMODE3|=((x&0x3)<<30) /* p21 is P2.5 */ #define p21_SEL_MASK ~(3UL << 10) #define p21_SET_MASK (1UL << 5) #define p21_CLR_MASK ~(p21_SET_MASK) #define p21_AS_OUTPUT LPC_PINCON->PINSEL4&=p21_SEL_MASK;LPC_GPIO2->FIODIR|=p21_SET_MASK #define p21_AS_INPUT LPC_GPIO2->FIOMASK &= p21_CLR_MASK; #define p21_SET LPC_GPIO2->FIOSET = p21_SET_MASK #define p21_CLR LPC_GPIO2->FIOCLR = p21_SET_MASK #define p21_IS_SET (bool)(LPC_GPIO2->FIOPIN & p21_SET_MASK) #define p21_IS_CLR !(p21_IS_SET) #define p21_TOGGLE p21_IS_SET?p21_CLR:p21_SET #define p21_MODE(x) LPC_PINCON->PINMODE4&=p21_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<10) /* p22 is P2.4 */ #define p22_SEL_MASK ~(3UL << 8) #define p22_SET_MASK (1UL << 4) #define p22_CLR_MASK ~(p22_SET_MASK) #define p22_AS_OUTPUT LPC_PINCON->PINSEL4&=p22_SEL_MASK;LPC_GPIO2->FIODIR|=p22_SET_MASK #define p22_AS_INPUT LPC_GPIO2->FIOMASK &= p22_CLR_MASK; #define p22_SET LPC_GPIO2->FIOSET = p22_SET_MASK #define p22_CLR LPC_GPIO2->FIOCLR = p22_SET_MASK #define p22_IS_SET (bool)(LPC_GPIO2->FIOPIN & p22_SET_MASK) #define p22_IS_CLR !(p22_IS_SET) #define p22_TOGGLE p22_IS_SET?p22_CLR:p22_SET #define p22_MODE(x) LPC_PINCON->PINMODE4&=p22_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<8) /* p23 is P2.3 */ #define p23_SEL_MASK ~(3UL << 6) #define p23_SET_MASK (1UL << 3) #define p23_CLR_MASK ~(p23_SET_MASK) #define p23_AS_OUTPUT LPC_PINCON->PINSEL4&=p23_SEL_MASK;LPC_GPIO2->FIODIR|=p23_SET_MASK #define p23_AS_INPUT LPC_GPIO2->FIOMASK &= p23_CLR_MASK; #define p23_SET LPC_GPIO2->FIOSET = p23_SET_MASK #define p23_CLR LPC_GPIO2->FIOCLR = p23_SET_MASK #define p23_IS_SET (bool)(LPC_GPIO2->FIOPIN & p23_SET_MASK) #define p23_IS_CLR !(p23_IS_SET) #define p23_TOGGLE p23_IS_SET?p23_CLR:p23_SET #define p23_MODE(x) LPC_PINCON->PINMODE4&=p23_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<6) /* p24 is P2.2 */ #define p24_SEL_MASK ~(3UL << 4) #define p24_SET_MASK (1UL << 2) #define p24_CLR_MASK ~(p24_SET_MASK) #define p24_AS_OUTPUT LPC_PINCON->PINSEL4&=p24_SEL_MASK;LPC_GPIO2->FIODIR|=p24_SET_MASK #define p24_AS_INPUT LPC_GPIO2->FIOMASK &= p24_CLR_MASK; #define p24_SET LPC_GPIO2->FIOSET = p24_SET_MASK #define p24_CLR LPC_GPIO2->FIOCLR = p24_SET_MASK #define p24_IS_SET (bool)(LPC_GPIO2->FIOPIN & p24_SET_MASK) #define p24_IS_CLR !(p24_IS_SET) #define p24_TOGGLE p24_IS_SET?p24_CLR:p24_SET #define p24_MODE(x) LPC_PINCON->PINMODE4&=p24_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<4) /* p25 is P2.1 */ #define p25_SEL_MASK ~(3UL << 2) #define p25_SET_MASK (1UL << 1) #define p25_CLR_MASK ~(p25_SET_MASK) #define p25_AS_OUTPUT LPC_PINCON->PINSEL4&=p25_SEL_MASK;LPC_GPIO2->FIODIR|=p25_SET_MASK #define p25_AS_INPUT LPC_GPIO2->FIOMASK &= p25_CLR_MASK; #define p25_SET LPC_GPIO2->FIOSET = p25_SET_MASK #define p25_CLR LPC_GPIO2->FIOCLR = p25_SET_MASK #define p25_IS_SET (bool)(LPC_GPIO2->FIOPIN & p25_SET_MASK) #define p25_IS_CLR !(p25_IS_SET) #define p25_MODE(x) LPC_PINCON->PINMODE4&=p25_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<2) /* p26 is P2.0 */ #define p26_SEL_MASK ~(3UL << 0) #define p26_SET_MASK (1UL << 0) #define p26_CLR_MASK ~(p26_SET_MASK) #define p26_AS_OUTPUT LPC_PINCON->PINSEL4&=p26_SEL_MASK;LPC_GPIO2->FIODIR|=p26_SET_MASK #define p26_AS_INPUT LPC_GPIO2->FIOMASK &= p26_CLR_MASK; #define p26_SET LPC_GPIO2->FIOSET = p26_SET_MASK #define p26_CLR LPC_GPIO2->FIOCLR = p26_SET_MASK #define p26_IS_SET (bool)(LPC_GPIO2->FIOPIN & p26_SET_MASK) #define p26_IS_CLR !(p26_IS_SET) #define p26_MODE(x) LPC_PINCON->PINMODE4&=p26_SEL_MASK;LPC_PINCON->PINMODE4|=((x&0x3)<<0) /* p27 is P0.11 */ #define p27_SEL_MASK ~(3UL << 22) #define p27_SET_MASK (1UL << 11) #define p27_CLR_MASK ~(p27_SET_MASK) #define p27_AS_OUTPUT LPC_PINCON->PINSEL0&=p27_SEL_MASK;LPC_GPIO0->FIODIR|=p27_SET_MASK #define p27_AS_INPUT LPC_GPIO0->FIOMASK &= p27_CLR_MASK; #define p27_SET LPC_GPIO0->FIOSET = p27_SET_MASK #define p27_CLR LPC_GPIO0->FIOCLR = p27_SET_MASK #define p27_IS_SET (bool)(LPC_GPIO0->FIOPIN & p27_SET_MASK) #define p27_IS_CLR !(p27_IS_SET) #define p27_MODE(x) LPC_PINCON->PINMODE0&=p27_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<22) /* p28 is P0.10 */ #define p28_SEL_MASK ~(3UL << 20) #define p28_SET_MASK (1UL << 10) #define p28_CLR_MASK ~(p28_SET_MASK) #define p28_AS_OUTPUT LPC_PINCON->PINSEL0&=p28_SEL_MASK;LPC_GPIO0->FIODIR|=p28_SET_MASK #define p28_AS_INPUT LPC_GPIO0->FIOMASK &= p28_CLR_MASK; #define p28_SET LPC_GPIO0->FIOSET = p28_SET_MASK #define p28_CLR LPC_GPIO0->FIOCLR = p28_SET_MASK #define p28_IS_SET (bool)(LPC_GPIO0->FIOPIN & p28_SET_MASK) #define p28_IS_CLR !(p28_IS_SET) #define p28_MODE(x) LPC_PINCON->PINMODE0&=p28_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<20) /* p29 is P0.5 */ #define p29_SEL_MASK ~(3UL << 10) #define p29_SET_MASK (1UL << 5) #define p29_CLR_MASK ~(p29_SET_MASK) #define p29_AS_OUTPUT LPC_PINCON->PINSEL0&=p29_SEL_MASK;LPC_GPIO0->FIODIR|=p29_SET_MASK #define p29_AS_INPUT LPC_GPIO0->FIOMASK &= p29_CLR_MASK; #define p29_SET LPC_GPIO0->FIOSET = p29_SET_MASK #define p29_CLR LPC_GPIO0->FIOCLR = p29_SET_MASK #define p29_IS_SET (bool)(LPC_GPIO0->FIOPIN & p29_SET_MASK) #define p29_IS_CLR !(p29_IS_SET) #define p29_TOGGLE p29_IS_SET?p29_CLR:p29_SET #define p29_MODE(x) LPC_PINCON->PINMODE0&=p29_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<10) /* p30 is P0.4 */ #define p30_SEL_MASK ~(3UL << 8) #define p30_SET_MASK (1UL << 4) #define p30_CLR_MASK ~(p30_SET_MASK) #define p30_AS_OUTPUT LPC_PINCON->PINSEL0&=p30_SEL_MASK;LPC_GPIO0->FIODIR|=p30_SET_MASK #define p30_AS_INPUT LPC_GPIO0->FIOMASK &= p30_CLR_MASK; #define p30_SET LPC_GPIO0->FIOSET = p30_SET_MASK #define p30_CLR LPC_GPIO0->FIOCLR = p30_SET_MASK #define p30_IS_SET (bool)(LPC_GPIO0->FIOPIN & p30_SET_MASK) #define p30_IS_CLR !(p30_IS_SET) #define p30_MODE(x) LPC_PINCON->PINMODE0&=p30_SEL_MASK;LPC_PINCON->PINMODE0|=((x&0x3)<<8) /* The following definitions are for the four Mbed LEDs. LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23 */ #define P1_18_SEL_MASK ~(3UL << 4) #define P1_18_SET_MASK (1UL << 18) #define P1_18_CLR_MASK ~(P1_18_SET_MASK) #define P1_18_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_18_SEL_MASK;LPC_GPIO1->FIODIR|=P1_18_SET_MASK #define P1_18_AS_INPUT LPC_GPIO1->FIOMASK &= P1_18_CLR_MASK; #define P1_18_SET LPC_GPIO1->FIOSET = P1_18_SET_MASK #define P1_18_CLR LPC_GPIO1->FIOCLR = P1_18_SET_MASK #define P1_18_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_18_SET_MASK) #define P1_18_IS_CLR !(P1_18_IS_SET) #define LED1_USE P1_18_AS_OUTPUT;P1_18_AS_INPUT #define LED1_ON P1_18_SET #define LED1_OFF P1_18_CLR #define LED1_IS_ON P1_18_IS_SET #define LED1_TOGGLE P1_18_IS_SET?LED1_OFF:LED1_ON #define P1_20_SEL_MASK ~(3UL << 8) #define P1_20_SET_MASK (1UL << 20) #define P1_20_CLR_MASK ~(P1_20_SET_MASK) #define P1_20_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_20_SEL_MASK;LPC_GPIO1->FIODIR|=P1_20_SET_MASK #define P1_20_AS_INPUT LPC_GPIO1->FIOMASK &= P1_20_CLR_MASK; #define P1_20_SET LPC_GPIO1->FIOSET = P1_20_SET_MASK #define P1_20_CLR LPC_GPIO1->FIOCLR = P1_20_SET_MASK #define P1_20_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_20_SET_MASK) #define P1_20_IS_CLR !(P1_20_IS_SET) #define LED2_USE P1_20_AS_OUTPUT;P1_20_AS_INPUT #define LED2_ON P1_20_SET #define LED2_OFF P1_20_CLR #define LED2_IS_ON P1_20_IS_SET #define LED2_TOGGLE P1_20_IS_SET?LED2_OFF:LED2_ON #define P1_21_SEL_MASK ~(3UL << 10) #define P1_21_SET_MASK (1UL << 21) #define P1_21_CLR_MASK ~(P1_21_SET_MASK) #define P1_21_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_21_SEL_MASK;LPC_GPIO1->FIODIR|=P1_21_SET_MASK #define P1_21_AS_INPUT LPC_GPIO1->FIOMASK &= P1_21_CLR_MASK; #define P1_21_SET LPC_GPIO1->FIOSET = P1_21_SET_MASK #define P1_21_CLR LPC_GPIO1->FIOCLR = P1_21_SET_MASK #define P1_21_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_21_SET_MASK) #define P1_21_IS_CLR !(P1_21_IS_SET) #define LED3_USE P1_21_AS_OUTPUT;P1_21_AS_INPUT #define LED3_ON P1_21_SET #define LED3_OFF P1_21_CLR #define LED3_IS_ON P1_21_IS_SET #define LED3_TOGGLE P1_21_IS_SET?LED3_OFF:LED3_ON #define P1_23_SEL_MASK ~(3UL << 14) #define P1_23_SET_MASK (1UL << 23) #define P1_23_CLR_MASK ~(P1_23_SET_MASK) #define P1_23_AS_OUTPUT LPC_PINCON->PINSEL3&=P1_23_SEL_MASK;LPC_GPIO1->FIODIR|=P1_23_SET_MASK #define P1_23_AS_INPUT LPC_GPIO1->FIOMASK &= P1_23_CLR_MASK; #define P1_23_SET LPC_GPIO1->FIOSET = P1_23_SET_MASK #define P1_23_CLR LPC_GPIO1->FIOCLR = P1_23_SET_MASK #define P1_23_IS_SET (bool)(LPC_GPIO1->FIOPIN & P1_23_SET_MASK) #define P1_23_IS_CLR !(P1_23_IS_SET) #define LED4_USE P1_23_AS_OUTPUT;P1_23_AS_INPUT #define LED4_ON P1_23_SET #define LED4_OFF P1_23_CLR #define LED4_IS_ON P1_23_IS_SET #define LED4_TOGGLE P1_23_IS_SET?LED4_OFF:LED4_ON #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/MODDMA.lib ================================================ https://os.mbed.com/users/AjK/code/MODDMA/#97a16bf2ff439853ed01edd65a382207e203c733 ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/RemoraComms.cpp ================================================ #include "mbed.h" #include "RemoraComms.h" RemoraComms::RemoraComms(volatile rxData_t* ptrRxData, volatile txData_t* ptrTxData) : ptrRxData(ptrRxData), ptrTxData(ptrTxData), spiSlave(MOSI0, MISO0, SCK0, SSEL0) { spiSlave.frequency(48000000); } void RemoraComms::init() { // Create MODDMA configuration objects for the SPI transfer and memory copy spiDMAmemcpy1 = new MODDMA_Config; spiDMAmemcpy2 = new MODDMA_Config; spiDMAtx1 = new MODDMA_Config; spiDMAtx2 = new MODDMA_Config; spiDMArx1 = new MODDMA_Config; spiDMArx2 = new MODDMA_Config; // Setup DMA configurations spiDMAtx1 ->channelNum ( MODDMA::Channel_0 ) ->srcMemAddr ( (uint32_t) ptrTxData ) ->dstMemAddr ( 0 ) ->transferSize ( SPI_BUFF_SIZE ) ->transferType ( MODDMA::m2p ) ->srcConn ( 0 ) ->dstConn ( MODDMA::SSP0_Tx ) ->attach_tc ( this, &RemoraComms::tc0_callback ) ->attach_err ( this, &RemoraComms::err_callback ) ; spiDMAtx2 ->channelNum ( MODDMA::Channel_1 ) ->srcMemAddr ( (uint32_t) ptrTxData ) ->dstMemAddr ( 0 ) ->transferSize ( SPI_BUFF_SIZE ) ->transferType ( MODDMA::m2p ) ->srcConn ( 0 ) ->dstConn ( MODDMA::SSP0_Tx ) ->attach_tc ( this, &RemoraComms::tc1_callback ) ->attach_err ( this, &RemoraComms::err_callback ) ; spiDMArx1 ->channelNum ( MODDMA::Channel_2 ) ->srcMemAddr ( 0 ) ->dstMemAddr ( (uint32_t) &spiRxBuffer1 ) ->transferSize ( SPI_BUFF_SIZE ) ->transferType ( MODDMA::p2m ) ->srcConn ( MODDMA::SSP0_Rx ) ->dstConn ( 0 ) ->attach_tc ( this, &RemoraComms::tc2_callback ) ->attach_err ( this, &RemoraComms::err_callback ) ; spiDMArx2 ->channelNum ( MODDMA::Channel_3 ) ->srcMemAddr ( 0 ) ->dstMemAddr ( (uint32_t) &spiRxBuffer2 ) ->transferSize ( SPI_BUFF_SIZE ) ->transferType ( MODDMA::p2m ) ->srcConn ( MODDMA::SSP0_Rx ) ->dstConn ( 0 ) ->attach_tc ( this, &RemoraComms::tc3_callback ) ->attach_err ( this, &RemoraComms::err_callback ) ; spiDMAmemcpy1 ->channelNum ( MODDMA::Channel_4 ) ->srcMemAddr ( (uint32_t) &spiRxBuffer1 ) ->dstMemAddr ( (uint32_t) &rxData ) ->transferSize ( SPI_BUFF_SIZE ) ->transferType ( MODDMA::m2m ) ; spiDMAmemcpy2 ->channelNum ( MODDMA::Channel_5 ) ->srcMemAddr ( (uint32_t) &spiRxBuffer2 ) ->dstMemAddr ( (uint32_t) &rxData ) ->transferSize ( SPI_BUFF_SIZE ) ->transferType ( MODDMA::m2m ) ; } void RemoraComms::start() { this->ptrTxData->header = PRU_DATA; // Pass the configurations to the controller dma.Prepare( spiDMArx1 ); dma.Prepare( spiDMAtx1 ); // Enable SSP0 for DMA LPC_SSP0->DMACR = 0; LPC_SSP0->DMACR = (1<<1)|(1<<0); // TX,RX DMA Enable } void RemoraComms::tc0_callback() { // SPI Tx MODDMA_Config *config = dma.getConfig(); dma.Disable( (MODDMA::CHANNELS)config->channelNum() ); // Clear DMA IRQ flags. if (dma.irqType() == MODDMA::TcIrq) dma.clearTcIrq(); if (dma.irqType() == MODDMA::ErrIrq) dma.clearErrIrq(); dma.Prepare( spiDMAtx2 ); } void RemoraComms::tc1_callback() { // SPI Tx MODDMA_Config *config = dma.getConfig(); dma.Disable( (MODDMA::CHANNELS)config->channelNum() ); // Clear DMA IRQ flags. if (dma.irqType() == MODDMA::TcIrq) dma.clearTcIrq(); if (dma.irqType() == MODDMA::ErrIrq) dma.clearErrIrq(); dma.Prepare( spiDMAtx1 ); } void RemoraComms::tc2_callback() { // SPI Rx MODDMA_Config *config = dma.getConfig(); dma.Disable( (MODDMA::CHANNELS)config->channelNum() ); SPIdata = false; SPIdataError = false; // Clear DMA IRQ flags. if (dma.irqType() == MODDMA::TcIrq) dma.clearTcIrq(); if (dma.irqType() == MODDMA::ErrIrq) dma.clearErrIrq(); // Check and move the recieved SPI data payload switch (spiRxBuffer1.header) { case PRU_READ: SPIdata = true; rejectCnt = 0; dma.Disable( spiDMAmemcpy2->channelNum() ); break; case PRU_WRITE: SPIdata = true; rejectCnt = 0; dma.Prepare( spiDMAmemcpy1 ); break; default: rejectCnt++; if (rejectCnt > 5) { SPIdataError = true; } dma.Disable( spiDMAmemcpy2->channelNum() ); } // swap Rx buffers dma.Prepare( spiDMArx2 ); } void RemoraComms::tc3_callback() { // SPI Rx MODDMA_Config *config = dma.getConfig(); dma.Disable( (MODDMA::CHANNELS)config->channelNum() ); SPIdata = false; SPIdataError = false; // Clear DMA IRQ flags. if (dma.irqType() == MODDMA::TcIrq) dma.clearTcIrq(); if (dma.irqType() == MODDMA::ErrIrq) dma.clearErrIrq(); // Check and move the recieved SPI data payload switch (spiRxBuffer2.header) { case PRU_READ: SPIdata = true; rejectCnt = 0; dma.Disable( spiDMAmemcpy1->channelNum() ); break; case PRU_WRITE: SPIdata = true; rejectCnt = 0; dma.Prepare( spiDMAmemcpy2 ); break; default: rejectCnt++; if (rejectCnt > 5) { SPIdataError = true; } dma.Disable( spiDMAmemcpy1->channelNum() ); } // swap Rx buffers dma.Prepare( spiDMArx1 ); } void RemoraComms::err_callback() { printf("err\r\n"); } bool RemoraComms::getStatus(void) { return this->SPIdata; } void RemoraComms::setStatus(bool status) { this->SPIdata = status; } bool RemoraComms::getError(void) { return this->SPIdataError; } void RemoraComms::setError(bool error) { this->SPIdataError = error; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/comms/RemoraComms.h ================================================ #ifndef REMORASPI_H #define REMORASPI_H #include "mbed.h" #include "configuration.h" #include "remora.h" #include "MODDMA.h" // RPi SPI #define MOSI0 P0_18 #define MISO0 P0_17 #define SCK0 P0_15 #define SSEL0 P0_16 class RemoraComms { private: SPISlave spiSlave; MODDMA dma; MODDMA_Config* spiDMArx1; MODDMA_Config* spiDMArx2; MODDMA_Config* spiDMAtx1; MODDMA_Config* spiDMAtx2; MODDMA_Config* spiDMAmemcpy1; MODDMA_Config* spiDMAmemcpy2; volatile rxData_t* ptrRxData; volatile txData_t* ptrTxData; rxData_t spiRxBuffer1; rxData_t spiRxBuffer2; uint8_t rejectCnt; bool SPIdata; bool SPIdataError; public: RemoraComms(volatile rxData_t*, volatile txData_t*); void tc0_callback(void); void tc1_callback(void); void tc2_callback(void); void tc3_callback(void); void err_callback(void); void init(void); void start(void); bool getStatus(void); void setStatus(bool); bool getError(void); void setError(bool); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/pin/pin.cpp ================================================ #include "mbed.h" #include "pin.h" #include #include #include #include "LPC17xx.h" Pin::Pin(std::string portAndPin, int dir) : portAndPin(portAndPin), dir(dir) { this->configPin(); } Pin::Pin(std::string portAndPin, int dir, int modifier) : portAndPin(portAndPin), dir(dir), modifier(modifier) { this->configPin(); if (this->dir == 0) //input { switch(this->modifier) { case OPENDRAIN: printf(" Setting pin as open drain\n"); this->as_open_drain(); break; case PULLUP: printf(" Setting pin as pull_up\n"); this->pull_up(); break; case PULLDOWN: printf(" Setting pin as pull_down\n"); this->pull_down(); break; case PULLNONE: printf(" Setting pin as pull_none\n"); this->pull_none(); break; } } } void Pin::configPin() { printf("Creating Pin @\n"); LPC_GPIO_TypeDef* gpios[5] ={LPC_GPIO0,LPC_GPIO1,LPC_GPIO2,LPC_GPIO3,LPC_GPIO4}; // The method below to determine the port and pin from the string is taken from Smoothieware, thanks! // cs is the current position in the string const char* cs = this->portAndPin.c_str(); // cn is the position of the next char after the number we just read char* cn = NULL; // grab first integer as port. pointer to first non-digit goes in cn this->portNumber = std::strtol(cs, &cn, 10); printf(" portNumber = %d\n", this->portNumber); // if cn > cs then strtol read at least one digit if ((cn > cs) && (this->portNumber <= 4)) { // translate port index into something useful this->port = gpios[this->portNumber]; // if the char after the first integer is a . then we should expect a pin index next if (*cn == '.') { // move pointer to first digit (hopefully) of pin index cs = ++cn; // grab pin index. this->pin = strtol(cs, &cn, 10); printf(" pin = %d\n", this->pin); // if strtol read some numbers, cn will point to the first non-digit if ((cn > cs) && (this->pin < 32) && (this->dir >= 0)) { // configure pin direction: FIODIR if (dir == INPUT) { this->port->FIODIR &= ~(1<pin); } else { this->port->FIODIR |= 1<pin; } // configure this->port->FIOMASK &= ~(1 << this->pin); } } } } void Pin::setAsOutput() { this->port->FIODIR |= 1<pin; } void Pin::setAsInput() { this->port->FIODIR &= ~(1<pin); } // Configure this pin as OD void Pin::as_open_drain(){ if( this->portNumber == 0 ){ LPC_PINCON->PINMODE_OD0 |= (1<pin); } if( this->portNumber == 1 ){ LPC_PINCON->PINMODE_OD1 |= (1<pin); } if( this->portNumber == 2 ){ LPC_PINCON->PINMODE_OD2 |= (1<pin); } if( this->portNumber == 3 ){ LPC_PINCON->PINMODE_OD3 |= (1<pin); } if( this->portNumber == 4 ){ LPC_PINCON->PINMODE_OD4 |= (1<pin); } pull_none(); // no pull up by default } // Configure this pin as no pullup or pulldown void Pin::pull_none() { // Set the two bits for this pin as 10 if( this->portNumber == 0 && this->pin < 16 ){ LPC_PINCON->PINMODE0 |= (2<<( this->pin*2)); LPC_PINCON->PINMODE0 &= ~(1<<( this->pin *2)); } if( this->portNumber == 0 && this->pin >= 16 ){ LPC_PINCON->PINMODE1 |= (2<<( this->pin*2)); LPC_PINCON->PINMODE1 &= ~(1<<((this->pin-16)*2)); } if( this->portNumber == 1 && this->pin < 16 ){ LPC_PINCON->PINMODE2 |= (2<<( this->pin*2)); LPC_PINCON->PINMODE2 &= ~(1<<( this->pin *2)); } if( this->portNumber == 1 && this->pin >= 16 ){ LPC_PINCON->PINMODE3 |= (2<<( this->pin*2)); LPC_PINCON->PINMODE3 &= ~(1<<((this->pin-16)*2)); } if( this->portNumber == 2 && this->pin < 16 ){ LPC_PINCON->PINMODE4 |= (2<<( this->pin*2)); LPC_PINCON->PINMODE4 &= ~(1<<( this->pin *2)); } if( this->portNumber == 3 && this->pin >= 16 ){ LPC_PINCON->PINMODE7 |= (2<<( this->pin*2)); LPC_PINCON->PINMODE7 &= ~(1<<((this->pin-16)*2)); } if( this->portNumber == 4 && this->pin >= 16 ){ LPC_PINCON->PINMODE9 |= (2<<( this->pin*2)); LPC_PINCON->PINMODE9 &= ~(1<<((this->pin-16)*2)); } } // Configure this pin as a pullup void Pin::pull_up() { // Set the two bits for this pin as 00 if( this->portNumber == 0 && this->pin < 16 ){ LPC_PINCON->PINMODE0 &= ~(3<<( this->pin *2)); } if( this->portNumber == 0 && this->pin >= 16 ){ LPC_PINCON->PINMODE1 &= ~(3<<((this->pin-16)*2)); } if( this->portNumber == 1 && this->pin < 16 ){ LPC_PINCON->PINMODE2 &= ~(3<<( this->pin *2)); } if( this->portNumber == 1 && this->pin >= 16 ){ LPC_PINCON->PINMODE3 &= ~(3<<((this->pin-16)*2)); } if( this->portNumber == 2 && this->pin < 16 ){ LPC_PINCON->PINMODE4 &= ~(3<<( this->pin *2)); } if( this->portNumber == 3 && this->pin >= 16 ){ LPC_PINCON->PINMODE7 &= ~(3<<((this->pin-16)*2)); } if( this->portNumber == 4 && this->pin >= 16 ){ LPC_PINCON->PINMODE9 &= ~(3<<((this->pin-16)*2)); } } // Configure this pin as a pulldown void Pin::pull_down() { // Set the two bits for this pin as 11 if( this->portNumber == 0 && this->pin < 16 ){ LPC_PINCON->PINMODE0 |= (3<<( this->pin *2)); } if( this->portNumber == 0 && this->pin >= 16 ){ LPC_PINCON->PINMODE1 |= (3<<((this->pin-16)*2)); } if( this->portNumber == 1 && this->pin < 16 ){ LPC_PINCON->PINMODE2 |= (3<<( this->pin *2)); } if( this->portNumber == 1 && this->pin >= 16 ){ LPC_PINCON->PINMODE3 |= (3<<((this->pin-16)*2)); } if( this->portNumber == 2 && this->pin < 16 ){ LPC_PINCON->PINMODE4 |= (3<<( this->pin *2)); } if( this->portNumber == 3 && this->pin >= 16 ){ LPC_PINCON->PINMODE7 |= (3<<((this->pin-16)*2)); } if( this->portNumber == 4 && this->pin >= 16 ){ LPC_PINCON->PINMODE9 |= (3<<((this->pin-16)*2)); } } // Convert a PortAndPin into a mBed Pin // allows use of standard mbed libraries, eg FastAnalogIn PinName Pin::pinToPinName() { if( this->port == LPC_GPIO0 && this->pin == 0 ) { return p9; } else if( this->port == LPC_GPIO0 && this->pin == 1 ) { return p10; } else if( this->port == LPC_GPIO0 && this->pin == 23 ) { return p15; } else if( this->port == LPC_GPIO0 && this->pin == 24 ) { return p16; } else if( this->port == LPC_GPIO0 && this->pin == 25 ) { return p17; } else if( this->port == LPC_GPIO0 && this->pin == 26 ) { return p18; } else if( this->port == LPC_GPIO1 && this->pin == 30 ) { return p19; } else if( this->port == LPC_GPIO1 && this->pin == 31 ) { return p20; } else { //TODO: Error return NC; } } // If available on this pin, return mbed hardware pwm class for this pin PwmOut* Pin::hardware_pwm() { if (this->portNumber == 1) { if (this->pin == 18) { return new mbed::PwmOut(P1_18); } if (this->pin == 20) { return new mbed::PwmOut(P1_20); } if (this->pin == 21) { return new mbed::PwmOut(P1_21); } if (this->pin == 23) { return new mbed::PwmOut(P1_23); } if (this->pin == 24) { return new mbed::PwmOut(P1_24); } if (this->pin == 26) { return new mbed::PwmOut(P1_26); } } else if (this->portNumber == 2) { if (this->pin == 0) { return new mbed::PwmOut(P2_0); } if (this->pin == 1) { return new mbed::PwmOut(P2_1); } if (this->pin == 2) { return new mbed::PwmOut(P2_2); } if (this->pin == 3) { return new mbed::PwmOut(P2_3); } if (this->pin == 4) { return new mbed::PwmOut(P2_4); } if (this->pin == 5) { return new mbed::PwmOut(P2_5); } } else if (this->portNumber == 3) { if (this->pin == 25) { return new mbed::PwmOut(P3_25); } if (this->pin == 26) { return new mbed::PwmOut(P3_26); } } return nullptr; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/pin/pin.h ================================================ #ifndef PIN_H #define PIN_H #include "mbed.h" #include #include #include #include #include "LPC17xx.h" #define INPUT 0x0 #define OUTPUT 0x1 #define NONE 0b000 #define OPENDRAIN 0b001 #define PULLUP 0b010 #define PULLDOWN 0b011 #define PULLNONE 0b100 class Pin { private: std::string portAndPin; uint8_t dir; uint8_t modifier; uint8_t portNumber; uint8_t pin; LPC_GPIO_TypeDef* port; public: Pin(std::string, int); Pin(std::string, int, int); PwmOut* hardware_pwm(); void configPin(); void setAsOutput(); void setAsInput(); void as_open_drain(); void pull_none(); void pull_up(); void pull_down(); PinName pinToPinName(); inline bool get() { return ((this->port->FIOPIN >> this->pin ) & 1); } inline void set(bool value) { if (value) this->port->FIOSET = 1 << this->pin; else this->port->FIOCLR = 1 << this->pin; } }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/qei/qeiDriver.cpp ================================================ #include "mbed.h" #include "qeiDriver.h" #include "interrupt.h" #include "qeiInterrupt.h" QEIdriver::QEIdriver() { this->hasIndex = false; this->dirinv = 0; this->sigmode = 0; // quadrature inputs this->capmode = 1; // count channels A and B (4x mode) this->invinx = 0; this->init(); } QEIdriver::QEIdriver(bool hasIndex) : hasIndex(hasIndex) { this->hasIndex = true; this->dirinv = 0; this->sigmode = 0; // quadrature inputs this->capmode = 1; // count channels A and B (4x mode) this->invinx = 0; this->irq = QEI_IRQn; this->init(); interruptPtr = new qeiInterrupt(this->irq, this); // Instantiate a new Timer Interrupt object and pass "this" pointer NVIC_EnableIRQ(this->irq); } void QEIdriver::interruptHandler() { this->indexDetected = true; this->indexCount = this->get(); } uint32_t QEIdriver::get() { return (LPC_QEI->QEIPOS); } void QEIdriver::init() { printf(" Initialising hardware QEI module\n"); /* Set up clock and power for QEI module */ LPC_SC->PCONP |= PCONP_QEI_ENABLE; /* The clock for theQEI module is set to FCCLK */ LPC_SC->PCLKSEL1 = LPC_SC->PCLKSEL1 & ~(3UL<<0) | ((PCLKSEL_CCLK_DIV_1 & 3)<<0); /* Assign the pins. They are hard-coded, not user-selected. */ // MCI0 (PhA) LPC_PINCON->PINSEL3 = (LPC_PINCON->PINSEL3 & PINSEL3_MCI0_MASK) | PINSEL3_MCI0 ; LPC_PINCON->PINMODE3 = (LPC_PINCON->PINMODE3 & PINMODE3_MCI0_MASK) | PINMODE3_MCI0; // MCI1 (PhB) LPC_PINCON->PINSEL3 = (LPC_PINCON->PINSEL3 & PINSEL3_MCI1_MASK) | PINSEL3_MCI1 ; LPC_PINCON->PINMODE3 = (LPC_PINCON->PINMODE3 & PINMODE3_MCI1_MASK) | PINMODE3_MCI1; // MCI2 (Index) if (hasIndex) { LPC_PINCON->PINSEL3 = (LPC_PINCON->PINSEL3 & PINSEL3_MCI2_MASK) | PINSEL3_MCI2 ; LPC_PINCON->PINMODE3 = (LPC_PINCON->PINMODE3 & PINMODE3_MCI2_MASK) | PINMODE3_MCI2; } // Initialize all remaining values in QEI peripheral LPC_QEI->QEICON = QEI_CON_RESP | QEI_CON_RESV | QEI_CON_RESI; LPC_QEI->QEIMAXPOS = 0xFFFFFFFF; // Default value LPC_QEI->CMPOS0 = 0x00; LPC_QEI->CMPOS1 = 0x00; LPC_QEI->CMPOS2 = 0x00; LPC_QEI->INXCMP = 0x00; LPC_QEI->QEILOAD = 0x00; LPC_QEI->VELCOMP = 0x00; LPC_QEI->FILTER = 200000; // Default for mechanical switches. // Set QEI configuration value corresponding to the call parameters LPC_QEI->QEICONF = ( ((dirinv << 0) & 1) | \ ((sigmode << 1) & 2) | \ ((capmode << 2) & 4) | \ ((invinx <<3) & 8) ); // Mask all int sources LPC_QEI->QEIIEC = QEI_IECLR_BITMASK; // Set the "clear" bits for all sources in the IE clear register // Clear any pending ints LPC_QEI->QEICLR = QEI_INTCLR_BITMASK; // Set the "clear" bits for for all sources in the Interrupt clear register // Enable specified interrupt on QEI peropheral LPC_QEI->QEIIES = QEI_INTSTAT_INX_Int; // set digital filter LPC_QEI->FILTER = 480UL; // set max position LPC_QEI->QEIMAXPOS = 0xFFFFFFFF; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/drivers/qei/qeiDriver.h ================================================ #ifndef QEIDRIVER_H #define QEIDRIVER_H #include "mbed.h" #include #include #include #include class qeiInterrupt; // forward declatation class QEIdriver { friend class qeiInterrupt; private: qeiInterrupt* interruptPtr; IRQn_Type irq; int dirinv; // Direction invert. When = 1, complements the QEICONF register DIR bit int sigmode; // Signal mode. When = 0, PhA and PhB are quadrature inputs. When = 1, PhA is direction and PhB is clock int capmode; // Capture mode. When = 0, count PhA edges only (2X mode). Whe = 1, count PhB edges also (4X mode) int invinx; // Invert index. When = 1, inverts the sense of the index signal void interruptHandler(); public: bool hasIndex; bool indexDetected; int32_t indexCount; QEIdriver(); // for channel A & B QEIdriver(bool); // For channels A & B, and index void init(void); uint32_t get(void); /* Private Macros ------------------------------------------------------------- */ /* --------------------- BIT DEFINITIONS -------------------------------------- */ /* Quadrature Encoder Interface Control Register Definition --------------------- */ /*********************************************************************//** * Macro defines for QEI Control register **********************************************************************/ #define QEI_CON_RESP ((uint32_t)(1<<0)) /**< Reset position counter */ #define QEI_CON_RESPI ((uint32_t)(1<<1)) /**< Reset Posistion Counter on Index */ #define QEI_CON_RESV ((uint32_t)(1<<2)) /**< Reset Velocity */ #define QEI_CON_RESI ((uint32_t)(1<<3)) /**< Reset Index Counter */ #define QEI_CON_BITMASK ((uint32_t)(0x0F)) /**< QEI Control register bit-mask */ /*********************************************************************//** * Macro defines for QEI Configuration register **********************************************************************/ #define QEI_CONF_DIRINV ((uint32_t)(1<<0)) /**< Direction Invert */ #define QEI_CONF_SIGMODE ((uint32_t)(1<<1)) /**< Signal mode */ #define QEI_CONF_CAPMODE ((uint32_t)(1<<2)) /**< Capture mode */ #define QEI_CONF_INVINX ((uint32_t)(1<<3)) /**< Invert index */ #define QEI_CONF_BITMASK ((uint32_t)(0x0F)) /**< QEI Configuration register bit-mask */ /*********************************************************************//** * Macro defines for QEI Status register **********************************************************************/ #define QEI_STAT_DIR ((uint32_t)(1<<0)) /**< Direction bit */ #define QEI_STAT_BITMASK ((uint32_t)(1<<0)) /**< QEI status register bit-mask */ /* Quadrature Encoder Interface Interrupt registers definitions --------------------- */ /*********************************************************************//** * Macro defines for QEI Interrupt Status register **********************************************************************/ #define QEI_INTSTAT_INX_Int ((uint32_t)(1<<0)) /**< Indicates that an index pulse was detected */ #define QEI_INTSTAT_TIM_Int ((uint32_t)(1<<1)) /**< Indicates that a velocity timer overflow occurred */ #define QEI_INTSTAT_VELC_Int ((uint32_t)(1<<2)) /**< Indicates that capture velocity is less than compare velocity */ #define QEI_INTSTAT_DIR_Int ((uint32_t)(1<<3)) /**< Indicates that a change of direction was detected */ #define QEI_INTSTAT_ERR_Int ((uint32_t)(1<<4)) /**< Indicates that an encoder phase error was detected */ #define QEI_INTSTAT_ENCLK_Int ((uint32_t)(1<<5)) /**< Indicates that and encoder clock pulse was detected */ #define QEI_INTSTAT_POS0_Int ((uint32_t)(1<<6)) /**< Indicates that the position 0 compare value is equal to the current position */ #define QEI_INTSTAT_POS1_Int ((uint32_t)(1<<7)) /**< Indicates that the position 1compare value is equal to the current position */ #define QEI_INTSTAT_POS2_Int ((uint32_t)(1<<8)) /**< Indicates that the position 2 compare value is equal to the current position */ #define QEI_INTSTAT_REV_Int ((uint32_t)(1<<9)) /**< Indicates that the index compare value is equal to the current index count */ #define QEI_INTSTAT_POS0REV_Int ((uint32_t)(1<<10)) /**< Combined position 0 and revolution count interrupt. Set when both the POS0_Int bit is set and the REV_Int is set */ #define QEI_INTSTAT_POS1REV_Int ((uint32_t)(1<<11)) /**< Combined position 1 and revolution count interrupt. Set when both the POS1_Int bit is set and the REV_Int is set */ #define QEI_INTSTAT_POS2REV_Int ((uint32_t)(1<<12)) /**< Combined position 2 and revolution count interrupt. Set when both the POS2_Int bit is set and the REV_Int is set */ #define QEI_INTSTAT_BITMASK ((uint32_t)(0x1FFF)) /**< QEI Interrupt Status register bit-mask */ /*********************************************************************//** * Macro defines for QEI Interrupt Set register **********************************************************************/ #define QEI_INTSET_INX_Int ((uint32_t)(1<<0)) /**< Set Bit Indicates that an index pulse was detected */ #define QEI_INTSET_TIM_Int ((uint32_t)(1<<1)) /**< Set Bit Indicates that a velocity timer overflow occurred */ #define QEI_INTSET_VELC_Int ((uint32_t)(1<<2)) /**< Set Bit Indicates that capture velocity is less than compare velocity */ #define QEI_INTSET_DIR_Int ((uint32_t)(1<<3)) /**< Set Bit Indicates that a change of direction was detected */ #define QEI_INTSET_ERR_Int ((uint32_t)(1<<4)) /**< Set Bit Indicates that an encoder phase error was detected */ #define QEI_INTSET_ENCLK_Int ((uint32_t)(1<<5)) /**< Set Bit Indicates that and encoder clock pulse was detected */ #define QEI_INTSET_POS0_Int ((uint32_t)(1<<6)) /**< Set Bit Indicates that the position 0 compare value is equal to the current position */ #define QEI_INTSET_POS1_Int ((uint32_t)(1<<7)) /**< Set Bit Indicates that the position 1compare value is equal to the current position */ #define QEI_INTSET_POS2_Int ((uint32_t)(1<<8)) /**< Set Bit Indicates that the position 2 compare value is equal to the current position */ #define QEI_INTSET_REV_Int ((uint32_t)(1<<9)) /**< Set Bit Indicates that the index compare value is equal to the current index count */ #define QEI_INTSET_POS0REV_Int ((uint32_t)(1<<10)) /**< Set Bit that combined position 0 and revolution count interrupt */ #define QEI_INTSET_POS1REV_Int ((uint32_t)(1<<11)) /**< Set Bit that Combined position 1 and revolution count interrupt */ #define QEI_INTSET_POS2REV_Int ((uint32_t)(1<<12)) /**< Set Bit that Combined position 2 and revolution count interrupt */ #define QEI_INTSET_BITMASK ((uint32_t)(0x1FFF)) /**< QEI Interrupt Set register bit-mask */ /*********************************************************************//** * Macro defines for QEI Interrupt Clear register **********************************************************************/ #define QEI_INTCLR_INX_Int ((uint32_t)(1<<0)) /**< Clear Bit Indicates that an index pulse was detected */ #define QEI_INTCLR_TIM_Int ((uint32_t)(1<<1)) /**< Clear Bit Indicates that a velocity timer overflow occurred */ #define QEI_INTCLR_VELC_Int ((uint32_t)(1<<2)) /**< Clear Bit Indicates that capture velocity is less than compare velocity */ #define QEI_INTCLR_DIR_Int ((uint32_t)(1<<3)) /**< Clear Bit Indicates that a change of direction was detected */ #define QEI_INTCLR_ERR_Int ((uint32_t)(1<<4)) /**< Clear Bit Indicates that an encoder phase error was detected */ #define QEI_INTCLR_ENCLK_Int ((uint32_t)(1<<5)) /**< Clear Bit Indicates that and encoder clock pulse was detected */ #define QEI_INTCLR_POS0_Int ((uint32_t)(1<<6)) /**< Clear Bit Indicates that the position 0 compare value is equal to the current position */ #define QEI_INTCLR_POS1_Int ((uint32_t)(1<<7)) /**< Clear Bit Indicates that the position 1compare value is equal to the current position */ #define QEI_INTCLR_POS2_Int ((uint32_t)(1<<8)) /**< Clear Bit Indicates that the position 2 compare value is equal to the current position */ #define QEI_INTCLR_REV_Int ((uint32_t)(1<<9)) /**< Clear Bit Indicates that the index compare value is equal to the current index count */ #define QEI_INTCLR_POS0REV_Int ((uint32_t)(1<<10)) /**< Clear Bit that combined position 0 and revolution count interrupt */ #define QEI_INTCLR_POS1REV_Int ((uint32_t)(1<<11)) /**< Clear Bit that Combined position 1 and revolution count interrupt */ #define QEI_INTCLR_POS2REV_Int ((uint32_t)(1<<12)) /**< Clear Bit that Combined position 2 and revolution count interrupt */ #define QEI_INTCLR_BITMASK ((uint32_t)(0x1FFF)) /**< QEI Interrupt Clear register bit-mask */ /*********************************************************************//** * Macro defines for QEI Interrupt Enable register **********************************************************************/ #define QEI_INTEN_INX_Int ((uint32_t)(1<<0)) /**< Enabled Interrupt Bit Indicates that an index pulse was detected */ #define QEI_INTEN_TIM_Int ((uint32_t)(1<<1)) /**< Enabled Interrupt Bit Indicates that a velocity timer overflow occurred */ #define QEI_INTEN_VELC_Int ((uint32_t)(1<<2)) /**< Enabled Interrupt Bit Indicates that capture velocity is less than compare velocity */ #define QEI_INTEN_DIR_Int ((uint32_t)(1<<3)) /**< Enabled Interrupt Bit Indicates that a change of direction was detected */ #define QEI_INTEN_ERR_Int ((uint32_t)(1<<4)) /**< Enabled Interrupt Bit Indicates that an encoder phase error was detected */ #define QEI_INTEN_ENCLK_Int ((uint32_t)(1<<5)) /**< Enabled Interrupt Bit Indicates that and encoder clock pulse was detected */ #define QEI_INTEN_POS0_Int ((uint32_t)(1<<6)) /**< Enabled Interrupt Bit Indicates that the position 0 compare value is equal to the current position */ #define QEI_INTEN_POS1_Int ((uint32_t)(1<<7)) /**< Enabled Interrupt Bit Indicates that the position 1compare value is equal to the current position */ #define QEI_INTEN_POS2_Int ((uint32_t)(1<<8)) /**< Enabled Interrupt Bit Indicates that the position 2 compare value is equal to the current position */ #define QEI_INTEN_REV_Int ((uint32_t)(1<<9)) /**< Enabled Interrupt Bit Indicates that the index compare value is equal to the current index count */ #define QEI_INTEN_POS0REV_Int ((uint32_t)(1<<10)) /**< Enabled Interrupt Bit that combined position 0 and revolution count interrupt */ #define QEI_INTEN_POS1REV_Int ((uint32_t)(1<<11)) /**< Enabled Interrupt Bit that Combined position 1 and revolution count interrupt */ #define QEI_INTEN_POS2REV_Int ((uint32_t)(1<<12)) /**< Enabled Interrupt Bit that Combined position 2 and revolution count interrupt */ #define QEI_INTEN_BITMASK ((uint32_t)(0x1FFF)) /**< QEI Interrupt Enable register bit-mask */ /*********************************************************************//** * Macro defines for QEI Interrupt Enable Set register **********************************************************************/ #define QEI_IESET_INX_Int ((uint32_t)(1<<0)) /**< Set Enable Interrupt Bit Indicates that an index pulse was detected */ #define QEI_IESET_TIM_Int ((uint32_t)(1<<1)) /**< Set Enable Interrupt Bit Indicates that a velocity timer overflow occurred */ #define QEI_IESET_VELC_Int ((uint32_t)(1<<2)) /**< Set Enable Interrupt Bit Indicates that capture velocity is less than compare velocity */ #define QEI_IESET_DIR_Int ((uint32_t)(1<<3)) /**< Set Enable Interrupt Bit Indicates that a change of direction was detected */ #define QEI_IESET_ERR_Int ((uint32_t)(1<<4)) /**< Set Enable Interrupt Bit Indicates that an encoder phase error was detected */ #define QEI_IESET_ENCLK_Int ((uint32_t)(1<<5)) /**< Set Enable Interrupt Bit Indicates that and encoder clock pulse was detected */ #define QEI_IESET_POS0_Int ((uint32_t)(1<<6)) /**< Set Enable Interrupt Bit Indicates that the position 0 compare value is equal to the current position */ #define QEI_IESET_POS1_Int ((uint32_t)(1<<7)) /**< Set Enable Interrupt Bit Indicates that the position 1compare value is equal to the current position */ #define QEI_IESET_POS2_Int ((uint32_t)(1<<8)) /**< Set Enable Interrupt Bit Indicates that the position 2 compare value is equal to the current position */ #define QEI_IESET_REV_Int ((uint32_t)(1<<9)) /**< Set Enable Interrupt Bit Indicates that the index compare value is equal to the current index count */ #define QEI_IESET_POS0REV_Int ((uint32_t)(1<<10)) /**< Set Enable Interrupt Bit that combined position 0 and revolution count interrupt */ #define QEI_IESET_POS1REV_Int ((uint32_t)(1<<11)) /**< Set Enable Interrupt Bit that Combined position 1 and revolution count interrupt */ #define QEI_IESET_POS2REV_Int ((uint32_t)(1<<12)) /**< Set Enable Interrupt Bit that Combined position 2 and revolution count interrupt */ #define QEI_IESET_BITMASK ((uint32_t)(0x1FFF)) /**< QEI Interrupt Enable Set register bit-mask */ /*********************************************************************//** * Macro defines for QEI Interrupt Enable Clear register **********************************************************************/ #define QEI_IECLR_INX_Int ((uint32_t)(1<<0)) /**< Clear Enabled Interrupt Bit Indicates that an index pulse was detected */ #define QEI_IECLR_TIM_Int ((uint32_t)(1<<1)) /**< Clear Enabled Interrupt Bit Indicates that a velocity timer overflow occurred */ #define QEI_IECLR_VELC_Int ((uint32_t)(1<<2)) /**< Clear Enabled Interrupt Bit Indicates that capture velocity is less than compare velocity */ #define QEI_IECLR_DIR_Int ((uint32_t)(1<<3)) /**< Clear Enabled Interrupt Bit Indicates that a change of direction was detected */ #define QEI_IECLR_ERR_Int ((uint32_t)(1<<4)) /**< Clear Enabled Interrupt Bit Indicates that an encoder phase error was detected */ #define QEI_IECLR_ENCLK_Int ((uint32_t)(1<<5)) /**< Clear Enabled Interrupt Bit Indicates that and encoder clock pulse was detected */ #define QEI_IECLR_POS0_Int ((uint32_t)(1<<6)) /**< Clear Enabled Interrupt Bit Indicates that the position 0 compare value is equal to the current position */ #define QEI_IECLR_POS1_Int ((uint32_t)(1<<7)) /**< Clear Enabled Interrupt Bit Indicates that the position 1compare value is equal to the current position */ #define QEI_IECLR_POS2_Int ((uint32_t)(1<<8)) /**< Clear Enabled Interrupt Bit Indicates that the position 2 compare value is equal to the current position */ #define QEI_IECLR_REV_Int ((uint32_t)(1<<9)) /**< Clear Enabled Interrupt Bit Indicates that the index compare value is equal to the current index count */ #define QEI_IECLR_POS0REV_Int ((uint32_t)(1<<10)) /**< Clear Enabled Interrupt Bit that combined position 0 and revolution count interrupt */ #define QEI_IECLR_POS1REV_Int ((uint32_t)(1<<11)) /**< Clear Enabled Interrupt Bit that Combined position 1 and revolution count interrupt */ #define QEI_IECLR_POS2REV_Int ((uint32_t)(1<<12)) /**< Clear Enabled Interrupt Bit that Combined position 2 and revolution count interrupt */ #define QEI_IECLR_BITMASK ((uint32_t)(0x1FFF)) /**< QEI Interrupt Enable Clear register bit-mask */ /*********************************************************************//** * Macro defines for PCONP register QEI-related bits **********************************************************************/ #define PCONP_QEI_ENABLE ((uint32_t)(1<<18)) /**< QEI peripheral power enable bit */ #define PCONP_QEI_DISABLE ~((uint32_t)(1<<18)) /**< QEI peripheral power disable bit-mask */ /*********************************************************************//** * Macro defines for PCLKSELx register QEI-related bits **********************************************************************/ #define PCLKSEL_CCLK_DIV_1 1UL /**< Set PCLK to CCLK/1 */ #define PCLKSEL_CCLK_DIV_2 2UL /**< Set PCLK to CCLK/2 */ #define PCLKSEL_CCLK_DIV_4 0UL /**< Set PCLK to CCLK/4 */ #define PCLKSEL_CCLK_DIV_8 3UL /**< Set PCLK to CCLK/8 */ #define PCLKSEL1_PCLK_QEI_MASK ((uint32_t)(3<<0)) /**< PCLK_QEI PCLK_QEI bit field mask */ /*********************************************************************//** * Macro defines for PINSEL3 register QEI-related bits **********************************************************************/ #define PINSEL3_MCI0 ((uint32_t)(1<<8)) /**< MCIO (PhA) pin select */ #define PINSEL3_MCI0_MASK ~((uint32_t)(3<<8)) /**< MCIO (PhA) pin mask */ #define PINSEL3_MCI1 ((uint32_t)(1<<14)) /**< MCI1 (PhB) pin select */ #define PINSEL3_MCI1_MASK ~((uint32_t)(3<<14)) /**< MCI2 (PhB) pin mask */ #define PINSEL3_MCI2 ((uint32_t)(1<<16)) /**< MCI2 (Index) pin select */ #define PINSEL3_MCI2_MASK ~((uint32_t)(3<<16)) /**< MCI2 (Index) pin mask */ /*********************************************************************//** * Macro defines for PINMODE3 register QEI-related bits **********************************************************************/ #define PIN_PULL_UP 0UL #define PIN_REPEATER 1UL #define PIN_NORESISTOR 2UL #define PIN_PULL_DOWN 3UL #define PINMODE3_MCI0 ((uint32_t)(PIN_NORESISTOR<<8)) /**< MCIO (PhA) resistor selection */ #define PINMODE3_GPIO1p20 ((uint32_t)(PIN_PULL_DOWN<<8)) /**< GPIO 1.20) resistor selection */ #define PINMODE3_MCI0_MASK ~((uint32_t)(3<<8)) /**< MCIO (PhA) resistor mask */ #define PINMODE3_MCI1 ((uint32_t)(PIN_NORESISTOR<<14)) /**< MCI1 (PhB) resistor selection */ #define PINMODE3_GPIO1p23 ((uint32_t)(PIN_PULL_DOWN<<14)) /**< GPIO 1.23) resistor selection */ #define PINMODE3_MCI1_MASK ~((uint32_t)(3<<14)) /**< MCI1 (PhB) resistor mask */ #define PINMODE3_MCI2 ((uint32_t)(PIN_PULL_UP<<16)) /**< MCI2 (Index) resistor selection */ #define PINMODE3_GPIO1p24 ((uint32_t)(PIN_PULL_DOWN<<16)) /**< GPIO 1.24) resistor selection */ #define PINMODE3_MCI2_MASK ~((uint32_t)(3<<16)) /**< MCI2 (Index) resistor mask */ }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/thread/createThreads.h ================================================ #include "extern.h" void createThreads(void) { // Create the thread objects and set the interrupt vectors to RAM. This is needed // as we are using the USB bootloader that requires a different code starting // address. Also set interrupt priority with NVIC_SetPriority. // // Note: DMAC has highest priority, then Base thread and then Servo thread // to ensure SPI data transfer is reliable NVIC_SetPriority(DMA_IRQn, 1); baseThread = new pruThread(LPC_TIM0, TIMER0_IRQn, base_freq); NVIC_SetVector(TIMER0_IRQn, (uint32_t)TIMER0_IRQHandler); NVIC_SetPriority(TIMER0_IRQn, 2); servoThread = new pruThread(LPC_TIM1, TIMER1_IRQn, servo_freq); NVIC_SetVector(TIMER1_IRQn, (uint32_t)TIMER1_IRQHandler); NVIC_SetPriority(TIMER1_IRQn, 3); commsThread = new pruThread(LPC_TIM2, TIMER2_IRQn, PRU_COMMSFREQ); NVIC_SetVector(TIMER2_IRQn, (uint32_t)TIMER2_IRQHandler); NVIC_SetPriority(TIMER2_IRQn, 4); // for QEI modudule NVIC_SetVector(QEI_IRQn, (uint32_t)QEI_IRQHandler); NVIC_SetPriority(QEI_IRQn, 5); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/thread/interrupt.cpp ================================================ #include "interrupt.h" #include "LPC17xx.h" #include // Define the vector table, it is only declared in the class declaration Interrupt* Interrupt::ISRVectorTable[] = {0}; // Constructor Interrupt::Interrupt(void){} // Methods void Interrupt::Register(int interruptNumber, Interrupt* intThisPtr) { printf("Registering interrupt for interrupt number = %d\n", interruptNumber); ISRVectorTable[interruptNumber] = intThisPtr; } void Interrupt::TIMER0_Wrapper(void) { ISRVectorTable[TIMER0_IRQn]->ISR_Handler(); } void Interrupt::TIMER1_Wrapper(void) { ISRVectorTable[TIMER1_IRQn]->ISR_Handler(); } void Interrupt::TIMER2_Wrapper(void) { ISRVectorTable[TIMER2_IRQn]->ISR_Handler(); } void Interrupt::QEI_Wrapper(void) { ISRVectorTable[QEI_IRQn]->ISR_Handler(); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/thread/interrupt.h ================================================ #ifndef INTERRUPT_H #define INTERRUPT_H // Base class for all interrupt derived classes #define PERIPH_COUNT_IRQn 32 // Total number of device interrupt sources class Interrupt { protected: static Interrupt* ISRVectorTable[PERIPH_COUNT_IRQn]; public: Interrupt(void); //static Interrupt* ISRVectorTable[PERIPH_COUNT_IRQn]; static void Register(int interruptNumber, Interrupt* intThisPtr); // wrapper functions to ISR_Handler() static void TIMER0_Wrapper(); static void TIMER1_Wrapper(); static void TIMER2_Wrapper(); static void QEI_Wrapper(); virtual void ISR_Handler(void) = 0; }; #endif /****** LPC17xx Specific Interrupt Numbers ****************************************************** WDT_IRQn = 0, Watchdog Timer Interrupt TIMER0_IRQn = 1, Timer0 Interrupt TIMER1_IRQn = 2, Timer1 Interrupt TIMER2_IRQn = 3, Timer2 Interrupt TIMER3_IRQn = 4, Timer3 Interrupt UART0_IRQn = 5, UART0 Interrupt UART1_IRQn = 6, UART1 Interrupt UART2_IRQn = 7, UART2 Interrupt UART3_IRQn = 8, UART3 Interrupt PWM1_IRQn = 9, PWM1 Interrupt I2C0_IRQn = 10, I2C0 Interrupt I2C1_IRQn = 11, I2C1 Interrupt I2C2_IRQn = 12, I2C2 Interrupt SPI_IRQn = 13, SPI Interrupt SSP0_IRQn = 14, SSP0 Interrupt SSP1_IRQn = 15, SSP1 Interrupt PLL0_IRQn = 16, PLL0 Lock (Main PLL) Interrupt RTC_IRQn = 17, Real Time Clock Interrupt EINT0_IRQn = 18, External Interrupt 0 Interrupt EINT1_IRQn = 19, External Interrupt 1 Interrupt EINT2_IRQn = 20, External Interrupt 2 Interrupt EINT3_IRQn = 21, External Interrupt 3 Interrupt ADC_IRQn = 22, A/D Converter Interrupt BOD_IRQn = 23, Brown-Out Detect Interrupt USB_IRQn = 24, USB Interrupt CAN_IRQn = 25, CAN Interrupt DMA_IRQn = 26, General Purpose DMA Interrupt I2S_IRQn = 27, I2S Interrupt ENET_IRQn = 28, Ethernet Interrupt RIT_IRQn = 29, Repetitive Interrupt Timer Interrupt MCPWM_IRQn = 30, Motor Control PWM Interrupt QEI_IRQn = 31, Quadrature Encoder Interface Interrupt PLL1_IRQn = 32, PLL1 Lock (USB PLL) Interrupt PERIPH_COUNT_IRQn = 32 < Number of peripheral IDs */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/thread/irqHandlers.h ================================================ #include "interrupt.h" void TIMER0_IRQHandler() { // Base thread interrupt handler unsigned int isrMask = LPC_TIM0->IR; LPC_TIM0->IR = isrMask; /* Clear the Interrupt Bit */ Interrupt::TIMER0_Wrapper(); } void TIMER1_IRQHandler(void) { // Servo thread interrupt handler unsigned int isrMask = LPC_TIM1->IR; LPC_TIM1->IR = isrMask; /* Clear the Interrupt Bit */ Interrupt::TIMER1_Wrapper(); } void TIMER2_IRQHandler(void) { // Servo thread interrupt handler unsigned int isrMask = LPC_TIM2->IR; LPC_TIM2->IR = isrMask; /* Clear the Interrupt Bit */ Interrupt::TIMER2_Wrapper(); } void QEI_IRQHandler(void) { // QEI (quatrature encoder interface) index interrupt handler LPC_QEI->QEICLR = ((uint32_t)(1<<0)); Interrupt:: QEI_Wrapper(); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/thread/pruThread.cpp ================================================ #include "pruThread.h" #include "modules/module.h" using namespace std; // Thread constructor pruThread::pruThread(LPC_TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency) : timer(timer), irq(irq), frequency(frequency) { printf("Creating thread %d\n", this->frequency); } void pruThread::startThread(void) { TimerPtr = new pruTimer(this->timer, this->irq, this->frequency, this); } void pruThread::stopThread(void) { this->TimerPtr->stopTimer(); } void pruThread::registerModule(Module* module) { this->vThread.push_back(module); } void pruThread::unregisterModule(Module* module) { iter = std::remove(vThread.begin(),vThread.end(), module); vThread.erase(iter, vThread.end()); } void pruThread::run(void) { // iterate over the Thread pointer vector to run all instances of Module::runModule() for (iter = vThread.begin(); iter != vThread.end(); ++iter) (*iter)->runModule(); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/thread/pruThread.h ================================================ #ifndef PRUTHREAD_H #define PRUTHREAD_H #include "LPC17xx.h" #include "timer.h" // Standard Template Library (STL) includes #include #include using namespace std; class Module; class pruThread { private: pruTimer* TimerPtr; LPC_TIM_TypeDef* timer; IRQn_Type irq; uint32_t frequency; vector vThread; // vector containing pointers to Thread modules vector::iterator iter; public: pruThread(LPC_TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency); void registerModule(Module *module); void unregisterModule(Module *module); void startThread(void); void stopThread(void); void run(void); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/thread/qeiInterrupt.cpp ================================================ #include "interrupt.h" #include "qeiInterrupt.h" #include "qei.h" qeiInterrupt::qeiInterrupt(int interruptNumber, QEIdriver* owner) { // Allows interrupt to access owner's data InterruptOwnerPtr = owner; // When a device interrupt object is instantiated, the Register function must be called to let the // Interrupt base class know that there is an appropriate ISR function for the given interrupt. Interrupt::Register(interruptNumber, this); } void qeiInterrupt::ISR_Handler(void) { this->InterruptOwnerPtr->interruptHandler(); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/thread/qeiInterrupt.h ================================================ #ifndef QEIINTERRUPT_H #define QEIINTERRUPT_H // Derived class for timer interrupts class QEIdriver; // forward declatation class qeiInterrupt : public Interrupt { private: QEIdriver* InterruptOwnerPtr; public: qeiInterrupt(int interruptNumber, QEIdriver* ownerptr); void ISR_Handler(void); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV1_4/thread/timer.cpp ================================================ #include "mbed.h" #include "LPC17xx.h" #include #include #include "interrupt.h" #include "timerInterrupt.h" #include "timer.h" #include "pruThread.h" #define SBIT_TIMER0 1 #define SBIT_TIMER1 2 #define SBIT_TIMER2 22 #define SBIT_TIMER3 23 #define SBIT_MR0I 0 #define SBIT_MR0R 1 #define SBIT_CNTEN 0 // Timer constructor pruTimer::pruTimer(LPC_TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency, pruThread* ownerPtr): timer(timer), irq(irq), frequency(frequency), timerOwnerPtr(ownerPtr) { interruptPtr = new TimerInterrupt(this->irq, this); // Instantiate a new Timer Interrupt object and pass "this" pointer this->startTimer(); } void pruTimer::timerTick(void) { //Do something here this->timerOwnerPtr->run(); } void pruTimer::startTimer(void) { if (this->timer == LPC_TIM0) { printf(" power on Timer 0\n"); LPC_SC->PCONP |= (1<timer == LPC_TIM1) { printf(" power on Timer 1\n"); LPC_SC->PCONP |= (1<timer == LPC_TIM2) { printf(" power on Timer 2\n"); LPC_SC->PCONP |= (1<timer->MCR = (1<timer->PR = 0x00; printf(" timer set PRO\n"); this->timer->MR0 = SystemCoreClock/4/this->frequency; printf(" timer start\n"); this->timer->TCR = (1<irq); } void pruTimer::stopTimer() { NVIC_DisableIRQ(this->irq); printf(" timer stop\n"); this->timer->TCR = (0< class TimerInterrupt; // forward declatation class pruThread; // forward declatation class pruTimer { friend class TimerInterrupt; private: TimerInterrupt* interruptPtr; LPC_TIM_TypeDef* timer; IRQn_Type irq; uint32_t frequency; pruThread* timerOwnerPtr; void startTimer(void); void timerTick(); // Private timer tiggered method public: pruTimer(LPC_TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency, pruThread* ownerPtr); void stopTimer(void); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV2/PeripheralNames.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2014, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_PERIPHERALNAMES_H #define MBED_PERIPHERALNAMES_H #include "cmsis.h" #ifdef __cplusplus extern "C" { #endif typedef enum { ADC_1 = (int)ADC1_BASE, ADC_2 = (int)ADC2_BASE, ADC_3 = (int)ADC3_BASE } ADCName; typedef enum { DAC_0 = 0, DAC_1 } DACName; typedef enum { UART_1 = (int)USART1_BASE, UART_2 = (int)USART2_BASE, UART_3 = (int)USART3_BASE, UART_4 = (int)UART4_BASE, UART_5 = (int)UART5_BASE, UART_6 = (int)USART6_BASE, } UARTName; #define DEVICE_SPI_COUNT 3 typedef enum { SPI_1 = (int)SPI1_BASE, SPI_2 = (int)SPI2_BASE, SPI_3 = (int)SPI3_BASE } SPIName; typedef enum { I2C_1 = (int)I2C1_BASE, I2C_2 = (int)I2C2_BASE, I2C_3 = (int)I2C3_BASE } I2CName; typedef enum { PWM_1 = (int)TIM1_BASE, PWM_2 = (int)TIM2_BASE, PWM_3 = (int)TIM3_BASE, PWM_4 = (int)TIM4_BASE, PWM_5 = (int)TIM5_BASE, PWM_8 = (int)TIM8_BASE, PWM_9 = (int)TIM9_BASE, PWM_10 = (int)TIM10_BASE, PWM_11 = (int)TIM11_BASE, PWM_12 = (int)TIM12_BASE, PWM_13 = (int)TIM13_BASE, PWM_14 = (int)TIM14_BASE } PWMName; typedef enum { CAN_1 = (int)CAN1_BASE, CAN_2 = (int)CAN2_BASE } CANName; typedef enum { USB_FS = (int)USB_OTG_FS_PERIPH_BASE, USB_HS = (int)USB_OTG_HS_PERIPH_BASE } USBName; #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV2/PeripheralPins.c ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #include "PeripheralPins.h" #include "mbed_toolchain.h" //============================================================================== // Notes // // - The pins mentioned Px_y_ALTz are alternative possibilities which use other // HW peripheral instances. You can use them the same way as any other "normal" // pin (i.e. PwmOut pwm(PA_7_ALT0);). These pins are not displayed on the board // pinout image on mbed.org. // // - The pins which are connected to other components present on the board have // the comment "Connected to xxx". The pin function may not work properly in this // case. These pins may not be displayed on the board pinout image on mbed.org. // Please read the board reference manual and schematic for more information. // // - Warning: pins connected to the default STDIO_UART_TX and STDIO_UART_RX pins are commented // See https://os.mbed.com/teams/ST/wiki/STDIO for more information. // //============================================================================== //*** ADC *** MBED_WEAK const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 // Connected to B1 [Blue PushButton] {PA_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 // Connected to B1 [Blue PushButton] {PA_0_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 // Connected to B1 [Blue PushButton] {PA_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 {PA_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 {PA_1_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 {PA_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 {PA_2_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 {PA_2_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 {PA_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 {PA_3_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 {PA_3_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 {PA_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 // Connected to I2S3_WS [CS43L22_LRCK] {PA_4_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 // Connected to I2S3_WS [CS43L22_LRCK] {PA_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 // Connected to SPI1_SCK [LIS302DL_SCL/SPC] {PA_5_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 // Connected to SPI1_SCK [LIS302DL_SCL/SPC] {PA_6, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 // Connected to SPI1_MISO [LIS302DL_SDO] {PA_6_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 // Connected to SPI1_MISO [LIS302DL_SDO] {PA_7, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 // Connected to SPI1_MOSI [LIS302DL_SDA/SDI/SDO] {PA_7_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 // Connected to SPI1_MOSI [LIS302DL_SDA/SDI/SDO] {PB_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 {PB_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 {PB_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 {PB_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 {PC_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 // Connected to OTG_FS_PowerSwitchOn {PC_0_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 // Connected to OTG_FS_PowerSwitchOn {PC_0_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 // Connected to OTG_FS_PowerSwitchOn {PC_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 {PC_1_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 {PC_1_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 {PC_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 {PC_2_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 {PC_2_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 {PC_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 // Connected to PDM_OUT [MP45DT02_DOUT] {PC_3_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 // Connected to PDM_OUT [MP45DT02_DOUT] {PC_3_ALT1, ADC_3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 // Connected to PDM_OUT [MP45DT02_DOUT] {PC_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 {PC_4_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 {PC_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 {PC_5_ALT0, ADC_2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_ADC_Internal[] = { {ADC_TEMP, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, {ADC_VREF, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, {ADC_VBAT, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, {NC, NC, 0} }; //*** DAC *** MBED_WEAK const PinMap PinMap_DAC[] = { {PA_4, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 // Connected to I2S3_WS [CS43L22_LRCK] {PA_5, DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 // Connected to SPI1_SCK [LIS302DL_SCL/SPC] {NC, NC, 0} }; //*** I2C *** MBED_WEAK const PinMap PinMap_I2C_SDA[] = { {PB_7, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // Connected to Audio_SDA [CS43L22_SDA] {PB_11, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, {PC_9, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_I2C_SCL[] = { {PA_8, I2C_3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, {PB_6, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, // Connected to Audio_SCL [CS43L22_SCL] {PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {PB_10, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, // Connected to CLK_IN [MP45DT02_CLK] {NC, NC, 0} }; //*** PWM *** // TIM5 cannot be used because already used by the us_ticker MBED_WEAK const PinMap PinMap_PWM[] = { {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // Connected to B1 [Blue PushButton] // {PA_0, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 // Connected to B1 [Blue PushButton] {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // {PA_1, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // {PA_2, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 {PA_2_ALT0, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 // {PA_3, PWM_5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 {PA_3_ALT0, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 {PA_5, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 // Connected to SPI1_SCK [LIS302DL_SCL/SPC] {PA_5_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N // Connected to SPI1_SCK [LIS302DL_SCL/SPC] {PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 // Connected to SPI1_MISO [LIS302DL_SDO] {PA_6_ALT0, PWM_13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 // Connected to SPI1_MISO [LIS302DL_SDO] {PA_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N // Connected to SPI1_MOSI [LIS302DL_SDA/SDI/SDO] {PA_7_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // Connected to SPI1_MOSI [LIS302DL_SDA/SDI/SDO] {PA_7_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N // Connected to SPI1_MOSI [LIS302DL_SDA/SDI/SDO] {PA_7_ALT2, PWM_14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 // Connected to SPI1_MOSI [LIS302DL_SDA/SDI/SDO] {PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 {PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 // Connected to VBUS_FS {PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 // Connected to OTG_FS_ID {PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 // Connected to OTG_FS_DM {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 {PB_0, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N {PB_0_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 {PB_0_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N {PB_1, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PB_1_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 {PB_1_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 // Connected to SWO {PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 {PB_6, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 // Connected to Audio_SCL [CS43L22_SCL] {PB_7, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 {PB_8, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 {PB_8_ALT0, PWM_10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 {PB_9, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 // Connected to Audio_SDA [CS43L22_SDA] {PB_9_ALT0, PWM_11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 // Connected to Audio_SDA [CS43L22_SDA] {PB_10, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 // Connected to CLK_IN [MP45DT02_CLK] {PB_11, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 {PB_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PB_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N {PB_14_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N {PB_14_ALT1, PWM_12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 {PB_15, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PB_15_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N {PB_15_ALT1, PWM_12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 {PC_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 {PC_6_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 {PC_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 // Connected to I2S3_MCK [CS43L22_MCLK] {PC_7_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 // Connected to I2S3_MCK [CS43L22_MCLK] {PC_8, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 {PC_8_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 {PC_9, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 {PC_9_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 {PD_12, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 // Connected to LD4 [Green Led] {PD_13, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 // Connected to LD3 [Orange Led] {PD_14, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 // Connected to LD5 [Red Led] {PD_15, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 // Connected to LD6 [Blue Led] {PE_5, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 {PE_6, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 {PE_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N {PE_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 {PE_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N {PE_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 {PE_12, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N {PE_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 {PE_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 {NC, NC, 0} }; //*** SERIAL *** MBED_WEAK const PinMap PinMap_UART_TX[] = { {PA_0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // Connected to B1 [Blue PushButton] {PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to VBUS_FS {PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to Audio_SCL [CS43L22_SCL] {PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to CLK_IN [MP45DT02_CLK] {PC_6, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, {PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to I2S3_SCK [CS43L22_SCLK] {PC_10_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, // Connected to I2S3_SCK [CS43L22_SCLK] {PC_12, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, // Connected to I2S3_SD [CS43L22_SDIN] {PD_5, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to OTG_FS_OverCurrent {PD_8, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_RX[] = { {PA_1, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PA_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to OTG_FS_ID {PB_7, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, {PB_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PC_7, UART_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, // Connected to I2S3_MCK [CS43L22_MCLK] {PC_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PC_11_ALT0, UART_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, {PD_2, UART_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, {PD_6, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_9, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_RTS[] = { {PA_1, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PA_12, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to OTG_FS_DP {PB_14, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PD_4, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to Audio_RST [CS43L22_RESET] {PD_12, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, // Connected to LD4 [Green Led] {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to B1 [Blue PushButton] {PA_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, // Connected to OTG_FS_DM {PB_13, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {PD_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, {PD_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, {NC, NC, 0} }; //*** SPI *** MBED_WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to SPI1_MOSI [LIS302DL_SDA/SDI/SDO] {PB_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PB_5_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PB_15, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PC_3, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to PDM_OUT [MP45DT02_DOUT] {PC_12, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // Connected to I2S3_SD [CS43L22_SDIN] {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to SPI1_MISO [LIS302DL_SDO] {PB_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PB_4_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PB_14, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PC_2, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PC_11, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to SPI1_SCK [LIS302DL_SCL/SPC] {PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to SWO {PB_3_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // Connected to SWO {PB_10, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to CLK_IN [MP45DT02_CLK] {PB_13, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {PC_10, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // Connected to I2S3_SCK [CS43L22_SCLK] {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, // Connected to I2S3_WS [CS43L22_LRCK] {PA_4_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, // Connected to I2S3_WS [CS43L22_LRCK] {PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI1)}, {PA_15_ALT0, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF6_SPI3)}, {PB_9, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, // Connected to Audio_SDA [CS43L22_SDA] {PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)}, {NC, NC, 0} }; //*** CAN *** MBED_WEAK const PinMap PinMap_CAN_RD[] = { {PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to OTG_FS_DM {PB_5, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, {PB_8, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {PB_12, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, {PD_0, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_CAN_TD[] = { {PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to OTG_FS_DP {PB_6, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, // Connected to Audio_SCL [CS43L22_SCL] {PB_9, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to Audio_SDA [CS43L22_SDA] {PB_13, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, {PD_1, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, {NC, NC, 0} }; //*** USBDEVICE *** MBED_WEAK const PinMap PinMap_USB_FS[] = { // {PA_8, USB_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF {PA_9, USB_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS // Connected to VBUS_FS {PA_10, USB_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID // Connected to OTG_FS_ID {PA_11, USB_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM // Connected to OTG_FS_DM {PA_12, USB_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP // Connected to OTG_FS_DP {NC, NC, 0} }; //*** USBDEVICE *** MBED_WEAK const PinMap PinMap_USB_HS[] = { #if (MBED_CONF_TARGET_USB_SPEED == USE_USB_HS_IN_FS) // {PA_4, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF // Connected to I2S3_WS [CS43L22_LRCK] {PB_12, USB_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID {PB_13, USB_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS {PB_14, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM {PB_15, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP #else /* MBED_CONF_TARGET_USB_SPEED */ {PA_3, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 {PA_5, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_CK // Connected to SPI1_SCK [LIS302DL_SCL/SPC] {PB_0, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 {PB_1, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 {PB_5, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 {PB_10, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 // Connected to CLK_IN [MP45DT02_CLK] {PB_11, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D4 {PB_12, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 {PB_13, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 {PC_0, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP // Connected to OTG_FS_PowerSwitchOn {PC_2, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR {PC_3, USB_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT // Connected to PDM_OUT [MP45DT02_DOUT] #endif /* MBED_CONF_TARGET_USB_SPEED */ {NC, NC, 0} }; ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV2/PinNames.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_PINNAMES_H #define MBED_PINNAMES_H #include "cmsis.h" #include "PinNamesTypes.h" #ifdef __cplusplus extern "C" { #endif typedef enum { ALT0 = 0x100, ALT1 = 0x200, ALT2 = 0x300, ALT3 = 0x400 } ALTx; typedef enum { PA_0 = 0x00, PA_0_ALT0 = PA_0 | ALT0, PA_0_ALT1 = PA_0 | ALT1, PA_1 = 0x01, PA_1_ALT0 = PA_1 | ALT0, PA_1_ALT1 = PA_1 | ALT1, PA_2 = 0x02, PA_2_ALT0 = PA_2 | ALT0, PA_2_ALT1 = PA_2 | ALT1, PA_3 = 0x03, PA_3_ALT0 = PA_3 | ALT0, PA_3_ALT1 = PA_3 | ALT1, PA_4 = 0x04, PA_4_ALT0 = PA_4 | ALT0, PA_5 = 0x05, PA_5_ALT0 = PA_5 | ALT0, PA_6 = 0x06, PA_6_ALT0 = PA_6 | ALT0, PA_7 = 0x07, PA_7_ALT0 = PA_7 | ALT0, PA_7_ALT1 = PA_7 | ALT1, PA_7_ALT2 = PA_7 | ALT2, PA_8 = 0x08, PA_9 = 0x09, PA_10 = 0x0A, PA_11 = 0x0B, PA_12 = 0x0C, PA_13 = 0x0D, PA_14 = 0x0E, PA_15 = 0x0F, PA_15_ALT0 = PA_15 | ALT0, PB_0 = 0x10, PB_0_ALT0 = PB_0 | ALT0, PB_0_ALT1 = PB_0 | ALT1, PB_1 = 0x11, PB_1_ALT0 = PB_1 | ALT0, PB_1_ALT1 = PB_1 | ALT1, PB_2 = 0x12, PB_3 = 0x13, PB_3_ALT0 = PB_3 | ALT0, PB_4 = 0x14, PB_4_ALT0 = PB_4 | ALT0, PB_4_ALT1 = PB_4 | ALT1, PB_5 = 0x15, PB_5_ALT0 = PB_5 | ALT0, PB_5_ALT1 = PB_5 | ALT1, PB_6 = 0x16, PB_7 = 0x17, PB_8 = 0x18, PB_8_ALT0 = PB_8 | ALT0, PB_8_ALT1 = PB_8 | ALT1, PB_9 = 0x19, PB_9_ALT0 = PB_9 | ALT0, PB_9_ALT1 = PB_9 | ALT1, PB_10 = 0x1A, PB_11 = 0x1B, PB_12 = 0x1C, PB_13 = 0x1D, PB_14 = 0x1E, PB_14_ALT0 = PB_14 | ALT0, PB_14_ALT1 = PB_14 | ALT1, PB_15 = 0x1F, PB_15_ALT0 = PB_15 | ALT0, PB_15_ALT1 = PB_15 | ALT1, PC_0 = 0x20, PC_0_ALT0 = PC_0 | ALT0, PC_0_ALT1 = PC_0 | ALT1, PC_1 = 0x21, PC_1_ALT0 = PC_1 | ALT0, PC_1_ALT1 = PC_1 | ALT1, PC_2 = 0x22, PC_2_ALT0 = PC_2 | ALT0, PC_2_ALT1 = PC_2 | ALT1, PC_3 = 0x23, PC_3_ALT0 = PC_3 | ALT0, PC_3_ALT1 = PC_3 | ALT1, PC_4 = 0x24, PC_4_ALT0 = PC_4 | ALT0, PC_5 = 0x25, PC_5_ALT0 = PC_5 | ALT0, PC_6 = 0x26, PC_6_ALT0 = PC_6 | ALT0, PC_7 = 0x27, PC_7_ALT0 = PC_7 | ALT0, PC_8 = 0x28, PC_8_ALT0 = PC_8 | ALT0, PC_9 = 0x29, PC_9_ALT0 = PC_9 | ALT0, PC_10 = 0x2A, PC_10_ALT0 = PC_10 | ALT0, PC_11 = 0x2B, PC_11_ALT0 = PC_11 | ALT0, PC_12 = 0x2C, PC_13 = 0x2D, PC_14 = 0x2E, PC_15 = 0x2F, PD_0 = 0x30, PD_1 = 0x31, PD_2 = 0x32, PD_3 = 0x33, PD_4 = 0x34, PD_5 = 0x35, PD_6 = 0x36, PD_7 = 0x37, PD_8 = 0x38, PD_9 = 0x39, PD_10 = 0x3A, PD_11 = 0x3B, PD_12 = 0x3C, PD_13 = 0x3D, PD_14 = 0x3E, PD_15 = 0x3F, PE_0 = 0x40, PE_1 = 0x41, PE_2 = 0x42, PE_3 = 0x43, PE_4 = 0x44, PE_5 = 0x45, PE_6 = 0x46, PE_7 = 0x47, PE_8 = 0x48, PE_9 = 0x49, PE_10 = 0x4A, PE_11 = 0x4B, PE_12 = 0x4C, PE_13 = 0x4D, PE_14 = 0x4E, PE_15 = 0x4F, PF_0 = 0x50, PF_1 = 0x51, PF_2 = 0x52, PF_3 = 0x53, PF_4 = 0x54, PF_5 = 0x55, PF_6 = 0x56, PF_7 = 0x57, PF_8 = 0x58, PF_9 = 0x59, PF_10 = 0x5A, PF_11 = 0x5B, PF_12 = 0x5C, PF_13 = 0x5D, PF_14 = 0x5E, PF_15 = 0x5F, PG_0 = 0x60, PG_1 = 0x61, PG_2 = 0x62, PG_3 = 0x63, PG_4 = 0x64, PG_5 = 0x65, PG_6 = 0x66, PG_7 = 0x67, PG_8 = 0x68, PG_9 = 0x69, PG_10 = 0x6A, PG_11 = 0x6B, PG_12 = 0x6C, PG_13 = 0x6D, PG_14 = 0x6E, PG_15 = 0x6F, PH_0 = 0x70, PH_1 = 0x71, PH_2 = 0x72, PH_3 = 0x73, PH_4 = 0x74, PH_5 = 0x75, PH_6 = 0x76, PH_7 = 0x77, PH_8 = 0x78, PH_9 = 0x79, PH_10 = 0x7A, PH_11 = 0x7B, PH_12 = 0x7C, PH_13 = 0x7D, PH_14 = 0x7E, PH_15 = 0x7F, PI_0 = 0x80, PI_1 = 0x81, PI_2 = 0x82, PI_3 = 0x83, PI_4 = 0x84, PI_5 = 0x85, PI_6 = 0x86, PI_7 = 0x87, PI_8 = 0x88, PI_9 = 0x89, PI_10 = 0x8A, PI_11 = 0x8B, PI_12 = 0x8C, PI_13 = 0x8D, PI_14 = 0x8E, PI_15 = 0x8F, // ADC internal channels ADC_TEMP = 0xF0, ADC_VREF = 0xF1, ADC_VBAT = 0xF2, // STDIO for console print #ifdef MBED_CONF_TARGET_STDIO_UART_TX STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX, #else STDIO_UART_TX = PA_2, #endif #ifdef MBED_CONF_TARGET_STDIO_UART_RX STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX, #else STDIO_UART_RX = PA_3, #endif // Generic signals namings LED1 = PD_13, // LD3 as LD1 is not a user LED LED2 = PD_12, // LD4 as LD2 is not a user LED LED3 = PD_13, // orange LED4 = PD_12, // green LED5 = PD_14, // red LED6 = PD_15, // blue LED_RED = LED5, USER_BUTTON = PA_0, // Standardized button names BUTTON1 = USER_BUTTON, SERIAL_TX = STDIO_UART_TX, /* USART2 */ SERIAL_RX = STDIO_UART_RX, USBTX = STDIO_UART_TX, /* USART2 */ USBRX = STDIO_UART_RX, I2C_SCL = PB_8, /* I2C1 */ I2C_SDA = PB_9, SPI_MOSI = PA_7, SPI_MISO = PA_6, SPI_SCK = PA_5, SPI_CS = PB_6, PWM_OUT = PB_3, /**** USB FS pins ****/ USB_OTG_FS_DM = PA_11, USB_OTG_FS_DP = PA_12, USB_OTG_FS_ID = PA_10, USB_OTG_FS_SOF = PA_8, USB_OTG_FS_VBUS = PA_9, /**** USB HS pins ****/ USB_OTG_HS_DM = PB_14, USB_OTG_HS_DP = PB_15, USB_OTG_HS_ID = PB_12, USB_OTG_HS_SOF = PA_4, USB_OTG_HS_ULPI_CK = PA_5, USB_OTG_HS_ULPI_D0 = PA_3, USB_OTG_HS_ULPI_D1 = PB_0, USB_OTG_HS_ULPI_D2 = PB_1, USB_OTG_HS_ULPI_D3 = PB_10, USB_OTG_HS_ULPI_D4 = PB_11, USB_OTG_HS_ULPI_D5 = PB_12, USB_OTG_HS_ULPI_D6 = PB_13, USB_OTG_HS_ULPI_D7 = PB_5, USB_OTG_HS_ULPI_DIR = PC_2, USB_OTG_HS_ULPI_NXT = PC_3, USB_OTG_HS_ULPI_STP = PC_0, USB_OTG_HS_VBUS = PB_13, /**** ETHERNET pins ****/ ETH_COL = PA_3, ETH_CRS = PA_0, ETH_CRS_DV = PA_7, ETH_MDC = PC_1, ETH_MDIO = PA_2, ETH_PPS_OUT = PB_5, ETH_REF_CLK = PA_1, ETH_RXD0 = PC_4, ETH_RXD1 = PC_5, ETH_RXD2 = PB_0, ETH_RXD3 = PB_1, ETH_RX_CLK = PA_1, ETH_RX_DV = PA_7, ETH_RX_ER = PB_10, ETH_TXD0 = PB_12, ETH_TXD1 = PB_13, ETH_TXD2 = PC_2, ETH_TXD3 = PE_2, ETH_TXD3_ALT0 = PB_8, ETH_TX_CLK = PC_3, ETH_TX_EN = PB_11, /**** OSCILLATOR pins ****/ RCC_OSC32_IN = PC_14, RCC_OSC32_OUT = PC_15, RCC_OSC_IN = PH_0, RCC_OSC_OUT = PH_1, /**** DEBUG pins ****/ SYS_JTCK_SWCLK = PA_14, SYS_JTDI = PA_15, SYS_JTDO_SWO = PB_3, SYS_JTMS_SWDIO = PA_13, SYS_JTRST = PB_4, SYS_TRACECLK = PE_2, SYS_TRACED0 = PE_3, SYS_TRACED1 = PE_4, SYS_TRACED2 = PE_5, SYS_TRACED3 = PE_6, SYS_WKUP = PA_0, // Not connected NC = (int)0xFFFFFFFF } PinName; #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKRV2/system_clock.c ================================================ /* mbed Microcontroller Library * Copyright (c) 2006-2017 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * This file configures the system clock as follows: *----------------------------------------------------------------------------- * System clock source | 1- USE_PLL_HSE_EXTC (external 8 MHz clock) * | 2- USE_PLL_HSE_XTAL (external 8 MHz xtal) * | 3- USE_PLL_HSI (internal 16 MHz) *----------------------------------------------------------------------------- * SYSCLK(MHz) | 168 * AHBCLK (MHz) | 168 * APB1CLK (MHz) | 42 * APB2CLK (MHz) | 84 * USB capable | YES *----------------------------------------------------------------------------- **/ #include "stm32f4xx.h" #include "mbed_error.h" /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x8000 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ // clock source is selected with CLOCK_SOURCE in json config #define USE_PLL_HSE_EXTC 0x8 // Use external clock (ST Link MCO) #define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default) #define USE_PLL_HSI 0x2 // Use HSI internal clock #if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) uint8_t SetSysClock_PLL_HSE(uint8_t bypass); #endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ #if ((CLOCK_SOURCE) & USE_PLL_HSI) uint8_t SetSysClock_PLL_HSI(void); #endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ /** * @brief Setup the microcontroller system * Initialize the FPU setting, vector table location and External memory * configuration. * @param None * @retval None */ void SystemInit(void) { /* FPU settings ------------------------------------------------------------*/ #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */ #endif /* Reset the RCC clock configuration to the default reset state ------------*/ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset CFGR register */ RCC->CFGR = 0x00000000; /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset PLLCFGR register */ RCC->PLLCFGR = 0x24003010; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Disable all interrupts */ RCC->CIR = 0x00000000; #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ /* Configure the Vector Table location add offset address ------------------*/ #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ #endif } /** * @brief Configures the System clock source, PLL Multiplier and Divider factors, * AHB/APBx prescalers and Flash settings * @note This function should be called only once the RCC clock configuration * is reset to the default reset state (done in SystemInit() function). * @param None * @retval None */ void SetSysClock(void) { #if ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) /* 1- Try to start with HSE and external clock */ if (SetSysClock_PLL_HSE(1) == 0) #endif { #if ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) /* 2- If fail try to start with HSE and external xtal */ if (SetSysClock_PLL_HSE(0) == 0) #endif { #if ((CLOCK_SOURCE) & USE_PLL_HSI) /* 3- If fail start with HSI clock */ if (SetSysClock_PLL_HSI() == 0) #endif { { error("SetSysClock failed\n"); } } } } /* Output clock on MCO2 pin(PC9) for debugging purpose */ //HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_1); // 84 MHz } #if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) /******************************************************************************/ /* PLL (clocked by HSE) used as System clock source */ /******************************************************************************/ uint8_t SetSysClock_PLL_HSE(uint8_t bypass) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; /* The voltage scaling allows optimizing the power consumption when the device is clocked below the maximum system frequency, to update the voltage scaling value regarding system frequency refer to product datasheet. */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); /* Enable HSE oscillator and activate PLL with HSE as source */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; if (bypass == 0) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */ } else { RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; /* External 8 MHz clock on OSC_IN */ } RCC_OscInitStruct.HSIState = RCC_HSI_OFF; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 8; // VCO input clock = 1 MHz (8 MHz / 8) RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336) RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // PLLCLK = 168 MHz (336 MHz / 2) RCC_OscInitStruct.PLL.PLLQ = 7; // USB clock = 48 MHz (336 MHz / 7) --> OK for USB if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { return 0; // FAIL } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 168 MHz RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 168 MHz RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 42 MHz RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 84 MHz (SPI1 clock...) if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { return 0; // FAIL } /* Output clock on MCO1 pin(PA8) for debugging purpose */ /* if (bypass == 0) HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz else HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz */ return 1; // OK } #endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ #if ((CLOCK_SOURCE) & USE_PLL_HSI) /******************************************************************************/ /* PLL (clocked by HSI) used as System clock source */ /******************************************************************************/ uint8_t SetSysClock_PLL_HSI(void) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; /* The voltage scaling allows optimizing the power consumption when the device is clocked below the maximum system frequency, to update the voltage scaling value regarding system frequency refer to product datasheet. */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); /* Enable HSI oscillator and activate PLL with HSI as source */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSEState = RCC_HSE_OFF; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = 16; // VCO input clock = 1 MHz (16 MHz / 16) RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336) RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // PLLCLK = 168 MHz (336 MHz / 2) RCC_OscInitStruct.PLL.PLLQ = 7; // USB clock = 48 MHz (336 MHz / 7) --> freq is ok but not precise enough if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { return 0; // FAIL } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 168 MHz RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 168 MHz RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 42 MHz RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 84 MHz if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { return 0; // FAIL } /* Output clock on MCO1 pin(PA8) for debugging purpose */ //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz return 1; // OK } #endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKR_MINI_E3/PeripheralNames.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2014, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_PERIPHERALNAMES_H #define MBED_PERIPHERALNAMES_H #include "cmsis.h" #ifdef __cplusplus extern "C" { #endif typedef enum { ADC_1 = (int)ADC1_BASE, ADC_2 = (int)ADC2_BASE, ADC_3 = (int)ADC3_BASE } ADCName; typedef enum { DAC_1 = (int)DAC_BASE } DACName; typedef enum { UART_1 = (int)USART1_BASE, UART_2 = (int)USART2_BASE, UART_3 = (int)USART3_BASE, UART_4 = (int)UART4_BASE, UART_5 = (int)UART5_BASE } UARTName; #define DEVICE_SPI_COUNT 3 typedef enum { SPI_1 = (int)SPI1_BASE, SPI_2 = (int)SPI2_BASE, SPI_3 = (int)SPI3_BASE } SPIName; typedef enum { I2C_1 = (int)I2C1_BASE, I2C_2 = (int)I2C2_BASE } I2CName; typedef enum { PWM_1 = (int)TIM1_BASE, PWM_2 = (int)TIM2_BASE, PWM_3 = (int)TIM3_BASE, PWM_4 = (int)TIM4_BASE, PWM_5 = (int)TIM5_BASE, PWM_8 = (int)TIM8_BASE } PWMName; typedef enum { CAN_1 = (int)CAN1_BASE } CANName; typedef enum { USB_FS = (int)USB_BASE } USBName; #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKR_MINI_E3/PeripheralPins.c ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #include "PeripheralPins.h" #include "mbed_toolchain.h" //============================================================================== // Notes // // - The pins mentioned Px_y_ALTz are alternative possibilities which use other // HW peripheral instances. You can use them the same way as any other "normal" // pin (i.e. PwmOut pwm(PA_7_ALT0);). These pins are not displayed on the board // pinout image on mbed.org. // // - The pins which are connected to other components present on the board have // the comment "Connected to xxx". The pin function may not work properly in this // case. These pins may not be displayed on the board pinout image on mbed.org. // Please read the board reference manual and schematic for more information. // // - Warning: pins connected to the default STDIO_UART_TX and STDIO_UART_RX pins are commented // See https://os.mbed.com/teams/ST/wiki/STDIO for more information. // //============================================================================== //*** ADC *** MBED_WEAK const PinMap PinMap_ADC[] = { {PA_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 {PA_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 // {PA_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 // Connected to STDIO_UART_TX // {PA_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 // Connected to STDIO_UART_RX {PA_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 {PA_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 // Connected to LD2 [Green Led] {PA_6, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 {PA_7, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 {PB_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 {PB_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 {PC_0, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 {PC_1, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 {PC_2, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 {PC_3, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 {PC_4, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 {PC_5, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_ADC_Internal[] = { {ADC_TEMP, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, {ADC_VREF, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, {NC, NC, 0} }; //*** I2C *** MBED_WEAK const PinMap PinMap_I2C_SDA[] = { {PB_7, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 0)}, {PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 2)}, // GPIO_Remap_I2C1 {PB_11, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 0)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_I2C_SCL[] = { {PB_6, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 0)}, {PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 2)}, // GPIO_Remap_I2C1 {PB_10, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, 0)}, {NC, NC, 0} }; //*** PWM *** // TIM4 cannot be used because already used by the us_ticker MBED_WEAK const PinMap PinMap_PWM[] = { {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 1, 0)}, // TIM2_CH1 {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 2, 0)}, // TIM2_CH2 // {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 3, 0)}, // TIM2_CH3 // Connected to STDIO_UART_TX // {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 4, 0)}, // TIM2_CH4 // Connected to STDIO_UART_RX {PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 1, 0)}, // TIM3_CH1 {PA_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 2, 0)}, // TIM3_CH2 {PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 1, 0)}, // TIM1_CH1 {PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 2, 0)}, // TIM1_CH2 {PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 3, 0)}, // TIM1_CH3 {PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 4, 0)}, // TIM1_CH4 {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 8, 1, 0)}, // TIM2_CH1 {PB_0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 3, 0)}, // TIM3_CH3 {PB_1, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 4, 0)}, // TIM3_CH4 {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 8, 2, 0)}, // TIM2_CH2 // Connected to SWO {PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 7, 1, 0)}, // TIM3_CH1 {PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 7, 2, 0)}, // TIM3_CH2 // {PB_6, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 1, 0)}, // TIM4_CH1 // {PB_7, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 2, 0)}, // TIM4_CH2 // {PB_8, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 3, 0)}, // TIM4_CH3 // {PB_9, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 4, 0)}, // TIM4_CH4 {PB_10, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 8, 3, 0)}, // TIM2_CH3 {PB_11, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 8, 4, 0)}, // TIM2_CH4 {PB_13, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 1, 1)}, // TIM1_CH1N {PB_14, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 2, 1)}, // TIM1_CH2N {PB_15, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 0, 3, 1)}, // TIM1_CH3N {PC_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 9, 1, 0)}, // TIM3_CH1 {PC_7, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 9, 2, 0)}, // TIM3_CH2 {PC_8, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 9, 3, 0)}, // TIM3_CH3 {PC_9, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, 9, 4, 0)}, // TIM3_CH4 {NC, NC, 0} }; //*** SERIAL *** MBED_WEAK const PinMap PinMap_UART_TX[] = { {PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, // Connected to STDIO_UART_TX {PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 3)}, // GPIO_Remap_USART1 {PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 5)}, // GPIO_PartialRemap_USART3 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_RX[] = { {PA_3, UART_2, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 0)}, // Connected to STDIO_UART_RX {PA_10, UART_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 0)}, {PB_7, UART_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 3)}, // GPIO_Remap_USART1 {PB_11, UART_3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 0)}, {PC_11, UART_3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 5)}, // GPIO_PartialRemap_USART3 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_RTS[] = { {PA_1, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PA_12, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PB_14, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_UART_CTS[] = { {PA_0, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PA_11, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {PB_13, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, {NC, NC, 0} }; //*** SPI *** MBED_WEAK const PinMap PinMap_SPI_MOSI[] = { {PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {PB_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)}, // GPIO_Remap_SPI1 {PB_15, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_MISO[] = { {PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {PB_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)}, // GPIO_Remap_SPI1 {PB_14, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, // Connected to LD2 [Green Led] {PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)}, // GPIO_Remap_SPI1 // Connected to SWO {PB_13, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_SPI_SSEL[] = { {PA_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)}, // GPIO_Remap_SPI1 {PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {NC, NC, 0} }; //*** CAN *** MBED_WEAK const PinMap PinMap_CAN_RD[] = { {PA_11, CAN_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, {PB_8, CAN_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 10)}, // Remap CAN_RX to PB_8 {NC, NC, 0} }; MBED_WEAK const PinMap PinMap_CAN_TD[] = { {PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)}, {PB_9, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 10)}, // Remap CAN_TX to PB_9 {NC, NC, 0} }; //*** USBDEVICE *** MBED_WEAK const PinMap PinMap_USB_FS[] = { {PA_11, USB_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // USB_DM {PA_12, USB_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // USB_DP {NC, NC, 0} }; ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKR_MINI_E3/PinNames.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_PINNAMES_H #define MBED_PINNAMES_H #include "cmsis.h" #include "PinNamesTypes.h" #ifdef __cplusplus extern "C" { #endif typedef enum { PA_0 = 0x00, PA_1 = 0x01, PA_2 = 0x02, PA_3 = 0x03, PA_4 = 0x04, PA_5 = 0x05, PA_6 = 0x06, PA_7 = 0x07, PA_8 = 0x08, PA_9 = 0x09, PA_10 = 0x0A, PA_11 = 0x0B, PA_12 = 0x0C, PA_13 = 0x0D, PA_14 = 0x0E, PA_15 = 0x0F, PB_0 = 0x10, PB_1 = 0x11, PB_2 = 0x12, PB_3 = 0x13, PB_4 = 0x14, PB_5 = 0x15, PB_6 = 0x16, PB_7 = 0x17, PB_8 = 0x18, PB_9 = 0x19, PB_10 = 0x1A, PB_11 = 0x1B, PB_12 = 0x1C, PB_13 = 0x1D, PB_14 = 0x1E, PB_15 = 0x1F, PC_0 = 0x20, PC_1 = 0x21, PC_2 = 0x22, PC_3 = 0x23, PC_4 = 0x24, PC_5 = 0x25, PC_6 = 0x26, PC_7 = 0x27, PC_8 = 0x28, PC_9 = 0x29, PC_10 = 0x2A, PC_11 = 0x2B, PC_12 = 0x2C, PC_13 = 0x2D, PC_14 = 0x2E, PC_15 = 0x2F, PD_0 = 0x30, PD_1 = 0x31, PD_2 = 0x32, // ADC internal channels ADC_TEMP = 0xF0, ADC_VREF = 0xF1, // Arduino connector namings A0 = PA_0, A1 = PA_1, A2 = PA_4, A3 = PB_0, A4 = PC_1, A5 = PC_0, D0 = PA_3, D1 = PA_2, D2 = PA_10, D3 = PB_3, D4 = PB_5, D5 = PB_4, D6 = PB_10, D7 = PA_8, D8 = PA_9, D9 = PC_7, D10 = PB_6, D11 = PA_7, D12 = PA_6, D13 = PA_5, D14 = PB_9, D15 = PB_8, // STDIO for console print #ifdef MBED_CONF_TARGET_STDIO_UART_TX STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX, #else STDIO_UART_TX = PA_2, #endif #ifdef MBED_CONF_TARGET_STDIO_UART_RX STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX, #else STDIO_UART_RX = PA_3, #endif // Generic signals namings LED1 = PA_5, LED2 = PA_5, LED3 = PA_5, LED4 = PA_5, USER_BUTTON = PC_13, // Standardized button names BUTTON1 = USER_BUTTON, SERIAL_TX = STDIO_UART_TX, SERIAL_RX = STDIO_UART_RX, USBTX = STDIO_UART_TX, USBRX = STDIO_UART_RX, I2C_SCL = PB_8, I2C_SDA = PB_9, SPI_MOSI = PA_7, SPI_MISO = PA_6, SPI_SCK = PA_5, SPI_CS = PB_6, PWM_OUT = PB_3, /**** USB pins ****/ USB_DM = PA_11, USB_DP = PA_12, /**** OSCILLATOR pins ****/ RCC_OSC32_IN = PC_14, RCC_OSC32_OUT = PC_15, RCC_OSC_IN = PD_0, RCC_OSC_OUT = PD_1, /**** DEBUG pins ****/ SYS_JTCK_SWCLK = PA_14, SYS_JTDI = PA_15, SYS_JTDO_TRACESWO = PB_3, SYS_JTMS_SWDIO = PA_13, SYS_NJTRST = PB_4, SYS_WKUP = PA_0, // Not connected NC = (int)0xFFFFFFFF } PinName; #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_SKR_MINI_E3/system_clock.c ================================================ /* mbed Microcontroller Library * Copyright (c) 2006-2017 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * This file configures the system clock as follows: *------------------------------------------------------------------------------------------- * System clock source | 1- PLL_HSE_EXTC / DEVICE_USBDEVICE | 3- PLL_HSI / DEVICE_USBDEVICE * | (external 8 MHz clock) | (internal 8 MHz) * | 2- PLL_HSE_XTAL / DEVICE_USBDEVICE | * | (external 8 MHz xtal) | *------------------------------------------------------------------------------------------- * SYSCLK(MHz) | 72 / 72 | 64 / 48 *------------------------------------------------------------------------------------------- * AHBCLK (MHz) | 72 / 72 | 64 / 48 *------------------------------------------------------------------------------------------- * APB1CLK (MHz) | 36 / 36 | 32 / 24 *------------------------------------------------------------------------------------------- * APB2CLK (MHz) | 72 / 72 | 64 / 48 *------------------------------------------------------------------------------------------- */ #include "stm32f1xx.h" #include "mbed_error.h" /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ #define USE_PLL_HSE_EXTC 0x8 // Use external clock (ST Link MCO) #define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default) #define USE_PLL_HSI 0x2 // Use HSI internal clock #if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) uint8_t SetSysClock_PLL_HSE(uint8_t bypass); #endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ #if ((CLOCK_SOURCE) & USE_PLL_HSI) uint8_t SetSysClock_PLL_HSI(void); #endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= 0x00000001U; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= 0xF8FF0000U; #else RCC->CFGR &= 0xF0FF0000U; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= 0xFEF6FFFFU; /* Reset HSEBYP bit */ RCC->CR &= 0xFFFBFFFFU; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= 0xFF80FFFFU; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= 0xEBFFFFFFU; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000U; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000U; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000U; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000U; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000U; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Configures the System clock source, PLL Multiplier and Divider factors, * AHB/APBx prescalers and Flash settings * @note This function should be called only once the RCC clock configuration * is reset to the default reset state (done in SystemInit() function). * @param None * @retval None */ void SetSysClock(void) { #if ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) /* 1- Try to start with HSE and external clock */ if (SetSysClock_PLL_HSE(1) == 0) #endif { #if ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) /* 2- If fail try to start with HSE and external xtal */ if (SetSysClock_PLL_HSE(0) == 0) #endif { #if ((CLOCK_SOURCE) & USE_PLL_HSI) /* 3- If fail start with HSI clock */ if (SetSysClock_PLL_HSI() == 0) #endif { { error("SetSysClock failed\n"); } } } } /* Output clock on MCO1 pin(PA8) for debugging purpose */ //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_SYSCLK, RCC_MCODIV_1); // 72 MHz or 64 MHz } #if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) ) /******************************************************************************/ /* PLL (clocked by HSE) used as System clock source */ /******************************************************************************/ uint8_t SetSysClock_PLL_HSE(uint8_t bypass) { RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; #if (DEVICE_USBDEVICE) RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInit; #endif /* DEVICE_USBDEVICE */ /* Enable HSE oscillator and activate PLL with HSE as source */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; if (bypass == 0) { RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */ } else { RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; /* External 8 MHz clock on OSC_IN */ } RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; // 72 MHz (8 MHz * 9) if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { return 0; // FAIL } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 72 MHz RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 72 MHz RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 36 MHz RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 72 MHz if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { return 0; // FAIL } #if (DEVICE_USBDEVICE) /* USB clock selection */ RCC_PeriphCLKInit.PeriphClockSelection = RCC_PERIPHCLK_USB; RCC_PeriphCLKInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInit); #endif /* DEVICE_USBDEVICE */ /* Output clock on MCO1 pin(PA8) for debugging purpose */ //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz return 1; // OK } #endif /* ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) */ #if ((CLOCK_SOURCE) & USE_PLL_HSI) /******************************************************************************/ /* PLL (clocked by HSI) used as System clock source */ /******************************************************************************/ uint8_t SetSysClock_PLL_HSI(void) { RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; #if (DEVICE_USBDEVICE) RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInit; #endif /* DEVICE_USBDEVICE */ /* Enable HSI oscillator and activate PLL with HSI as source */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSEState = RCC_HSE_OFF; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2; #if (DEVICE_USBDEVICE) RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; // 48 MHz (8 MHz/2 * 12) #else /* DEVICE_USBDEVICE */ RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16; // 64 MHz (8 MHz/2 * 16) #endif /* DEVICE_USBDEVICE */ if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { return 0; // FAIL } #if (DEVICE_USBDEVICE) /* USB clock selection */ RCC_PeriphCLKInit.PeriphClockSelection = RCC_PERIPHCLK_USB; RCC_PeriphCLKInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL; HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInit); #endif /* DEVICE_USBDEVICE */ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 64 MHz RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 64 MHz RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 32 MHz RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 64 MHz if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { return 0; // FAIL } /* Output clock on MCO1 pin(PA8) for debugging purpose */ //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 8 MHz return 1; // OK } #endif /* ((CLOCK_SOURCE) & USE_PLL_HSI) */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/drivers/comms/RemoraComms.cpp ================================================ #include "mbed.h" #include "RemoraComms.h" #include "stm32f1xx_hal.h" RemoraComms::RemoraComms(volatile rxData_t* ptrRxData, volatile txData_t* ptrTxData, SPI_TypeDef* spiType, PinName interruptPin) : ptrRxData(ptrRxData), ptrTxData(ptrTxData), spiType(spiType), interruptPin(interruptPin), slaveSelect(interruptPin) { this->spiHandle.Instance = this->spiType; if (this->interruptPin == PA_4) { // interrupt pin is the NSS pin sharedSPI = false; HAL_NVIC_SetPriority(EXTI4_IRQn, 5, 0); } else if (this->interruptPin == PA_15) { // interrupt pin is not the NSS pin, ie the board shares the SPI bus with the SD card // configure the SPI in software NSS mode and always on sharedSPI = true; HAL_NVIC_SetPriority(EXTI15_10_IRQn , 5, 0); } else if (this->interruptPin == PC_1) { // interrupt pin is not the NSS pin, ie the board shares the SPI bus with the SD card // configure the SPI in software NSS mode and always on sharedSPI = true; HAL_NVIC_SetPriority(EXTI1_IRQn , 5, 0); } slaveSelect.rise(callback(this, &RemoraComms::processPacket)); } void RemoraComms::init() { if(this->spiHandle.Instance == SPI1) { printf("Initialising SPI1 slave\n"); GPIO_InitTypeDef GPIO_InitStruct; /**SPI1 GPIO Configuration PA4 ------> SPI1_NSS PA5 ------> SPI1_SCK PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI */ GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_6; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); __HAL_RCC_SPI1_CLK_ENABLE(); this->spiHandle.Init.Mode = SPI_MODE_SLAVE; this->spiHandle.Init.Direction = SPI_DIRECTION_2LINES; this->spiHandle.Init.DataSize = SPI_DATASIZE_8BIT; this->spiHandle.Init.CLKPolarity = SPI_POLARITY_LOW; this->spiHandle.Init.CLKPhase = SPI_PHASE_1EDGE; if (sharedSPI) { this->spiHandle.Init.NSS = SPI_NSS_SOFT; printf("SPI is shared with SD card\n"); } else { this->spiHandle.Init.NSS = SPI_NSS_HARD_INPUT; } this->spiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; this->spiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB; this->spiHandle.Init.TIMode = SPI_TIMODE_DISABLE; this->spiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; this->spiHandle.Init.CRCPolynomial = 10; HAL_SPI_Init(&this->spiHandle); if (sharedSPI) { // set SSI (Slave Select Internal) low, ie same as NSS going low CLEAR_BIT(this->spiHandle.Instance->CR1, SPI_CR1_SSI); } printf("Initialising DMA for SPI\n"); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_DMA1_CLK_ENABLE(); this->hdma_spi_tx.Instance = DMA1_Channel3; this->hdma_spi_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; this->hdma_spi_tx.Init.PeriphInc = DMA_PINC_DISABLE; this->hdma_spi_tx.Init.MemInc = DMA_MINC_ENABLE; this->hdma_spi_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; this->hdma_spi_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; this->hdma_spi_tx.Init.Mode = DMA_CIRCULAR; //this->hdma_spi_tx.Init.Mode = DMA_NORMAL; this->hdma_spi_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH; HAL_DMA_Init(&this->hdma_spi_tx); __HAL_LINKDMA(&this->spiHandle, hdmatx, this->hdma_spi_tx); //HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 0, 0); ///NVIC_SetVector(DMA1_Channel3_IRQn, (uint32_t)&DMA1_Channel3_IRQHandler); //HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn); this->hdma_spi_rx.Instance = DMA1_Channel2; this->hdma_spi_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; this->hdma_spi_rx.Init.PeriphInc = DMA_PINC_DISABLE; this->hdma_spi_rx.Init.MemInc = DMA_MINC_ENABLE; this->hdma_spi_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; this->hdma_spi_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; this->hdma_spi_rx.Init.Mode = DMA_CIRCULAR; //this->hdma_spi_rx.Init.Mode = DMA_NORMAL; this->hdma_spi_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH; HAL_DMA_Init(&this->hdma_spi_rx); __HAL_LINKDMA(&this->spiHandle,hdmarx,this->hdma_spi_rx); //HAL_NVIC_SetPriority(DMA1_Channel2_IRQn, 0, 0); //NVIC_SetVector(DMA1_Channel2_IRQn, (uint32_t)&DMA1_Channel2_IRQHandler); //HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn); } } void RemoraComms::start() { this->ptrTxData->header = PRU_DATA; HAL_SPI_TransmitReceive_DMA(&this->spiHandle, (uint8_t *)this->ptrTxData->txBuffer, (uint8_t *)this->spiRxBuffer.rxBuffer, SPI_BUFF_SIZE); } void RemoraComms::processPacket() { switch (this->spiRxBuffer.header) { case PRU_READ: this->SPIdata = true; this->rejectCnt = 0; // READ so do nothing with the received data break; case PRU_WRITE: this->SPIdata = true; this->rejectCnt = 0; // we've got a good WRITE header, move the data to rxData // **** would like to use DMA for this but cannot when the stream is in CIRCULAR mode for the SPI transfer **** // TODO: figure out how to use NORMAL mode for SPI... //this->status = HAL_DMA_Start(&hdma_memtomem_dma2_stream1, (uint32_t)&this->spiRxBuffer.rxBuffer, (uint32_t)this->rxData->rxBuffer, SPI_BUFF_SIZE); //if (this->status != HAL_OK) printf("F\n"); // Do it the slower way. This does not seem to impact performance but not great to stay in ISR context for longer.. :-( // ensure an atomic access to the rxBuffer // disable thread interrupts __disable_irq(); for (int i = 0; i < SPI_BUFF_SIZE; i++) { this->ptrRxData->rxBuffer[i] = this->spiRxBuffer.rxBuffer[i]; } // re-enable thread interrupts __enable_irq(); break; default: this->rejectCnt++; if (this->rejectCnt > 5) { this->SPIdataError = true; } // reset SPI somehow } HAL_SPI_TransmitReceive_DMA(&this->spiHandle, (uint8_t *)this->ptrTxData->txBuffer, (uint8_t *)this->spiRxBuffer.rxBuffer, SPI_BUFF_SIZE); } bool RemoraComms::getStatus(void) { return this->SPIdata; } void RemoraComms::setStatus(bool status) { this->SPIdata = status; } bool RemoraComms::getError(void) { return this->SPIdataError; } void RemoraComms::setError(bool error) { this->SPIdataError = error; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/drivers/comms/RemoraComms.h ================================================ #ifndef REMORASPI_H #define REMORASPI_H #include "mbed.h" #include "configuration.h" #include "remora.h" #include "stm32f1xx_hal.h" class RemoraComms { private: SPI_TypeDef* spiType; SPI_HandleTypeDef spiHandle; DMA_HandleTypeDef hdma_spi_tx; DMA_HandleTypeDef hdma_spi_rx; DMA_HandleTypeDef hdma_memtomem_dma2_stream1; HAL_StatusTypeDef status; volatile rxData_t* ptrRxData; volatile txData_t* ptrTxData; rxData_t spiRxBuffer; uint8_t rejectCnt; bool SPIdata; bool SPIdataError; PinName interruptPin; InterruptIn slaveSelect; bool sharedSPI; void processPacket(void); public: RemoraComms(volatile rxData_t*, volatile txData_t*, SPI_TypeDef*, PinName); void init(void); void start(void); bool getStatus(void); void setStatus(bool); bool getError(void); void setError(bool); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/drivers/pin/pin.cpp ================================================ #include "mbed.h" #include "pin.h" #include #include #include #include "stm32f1xx_hal.h" Pin::Pin(std::string portAndPin, int dir) : portAndPin(portAndPin), dir(dir) { // Set direction if (this->dir == INPUT) { this->mode = GPIO_MODE_INPUT; this->pull = GPIO_NOPULL; } else { this->mode = GPIO_MODE_OUTPUT_PP; this->pull = GPIO_NOPULL; } this->configPin(); } Pin::Pin(std::string portAndPin, int dir, int modifier) : portAndPin(portAndPin), dir(dir), modifier(modifier) { // Set direction if (this->dir == INPUT) { this->mode = GPIO_MODE_INPUT; // Set pin modifier switch(this->modifier) { case PULLUP: printf(" Setting pin as Pull Up\n"); this->pull = GPIO_PULLUP; break; case PULLDOWN: printf(" Setting pin as Pull Down\n"); this->pull = GPIO_PULLDOWN; break; case NONE: case PULLNONE: printf(" Setting pin as No Pull\n"); this->pull = GPIO_NOPULL; break; } } else { this->mode = GPIO_MODE_OUTPUT_PP; this->pull = GPIO_NOPULL; } this->configPin(); } void Pin::configPin() { printf("Creating Pin @\n"); //x can be (A..H) to select the GPIO peripheral for STM32F40XX and STM32F427X devices. GPIO_TypeDef* gpios[5] ={GPIOA,GPIOB,GPIOC,GPIOD,GPIOE}; if (this->portAndPin[0] == 'P') // PXXX e.g.PA2 PC15 { this->portIndex = this->portAndPin[1] - 'A'; this->pinNumber = this->portAndPin[3] - '0'; uint16_t pin2 = this->portAndPin[4] - '0'; if (pin2 <= 8) { this->pinNumber = this->pinNumber * 10 + pin2; } this->pin = 1 << this->pinNumber; // this is equivalent to GPIO_PIN_x definition } else { printf(" Invalid port and pin definition\n"); return; } printf(" port = GPIO%c\n", char('A' + this->portIndex)); printf(" pin = %d\n", this->pinNumber); // translate port index into something useful this->GPIOx = gpios[this->portIndex]; // enable the peripheral clock switch (portIndex){ case 0: __HAL_RCC_GPIOA_CLK_ENABLE(); break; case 1: __HAL_RCC_GPIOB_CLK_ENABLE(); break; case 2: __HAL_RCC_GPIOC_CLK_ENABLE(); break; case 3: __HAL_RCC_GPIOD_CLK_ENABLE(); break; case 4: __HAL_RCC_GPIOE_CLK_ENABLE(); break; } this->initPin(); } void Pin::initPin() { // Configure GPIO pin Output Level HAL_GPIO_WritePin(this->GPIOx, this->pin, GPIO_PIN_RESET); // Configure the GPIO pin this->GPIO_InitStruct.Pin = this->pin; this->GPIO_InitStruct.Mode = this->mode; this->GPIO_InitStruct.Pull = this->pull; this->GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(this->GPIOx, &this->GPIO_InitStruct); } void Pin::setAsOutput() { this->mode = GPIO_MODE_OUTPUT_PP; this->pull = GPIO_NOPULL; this->initPin(); } void Pin::setAsInput() { this->mode = GPIO_MODE_INPUT; this->pull = GPIO_NOPULL; this->initPin(); } void Pin::pull_none() { this->pull = GPIO_NOPULL; this->initPin(); } void Pin::pull_up() { this->pull = GPIO_PULLUP; this->initPin(); } void Pin::pull_down() { this->pull = GPIO_PULLDOWN; this->initPin(); } PinName Pin::pinToPinName() { printf("PinName = 0x%x\n", (this->portIndex << 4) | this->pinNumber); return static_cast((this->portIndex << 4) | this->pinNumber); } // If available on this pin, return mbed hardware pwm class for this pin PwmOut* Pin::hardware_pwm() { if (this->portIndex == 0) { if (this->pinNumber == 0) { return new mbed::PwmOut(PA_0); } if (this->pinNumber == 1) { return new mbed::PwmOut(PA_1); } //if (this->pinNumber == 2) { return new mbed::PwmOut(PA_2); } //if (this->pinNumber == 3) { return new mbed::PwmOut(PA_3); } if (this->pinNumber == 5) { return new mbed::PwmOut(PA_5); } if (this->pinNumber == 6) { return new mbed::PwmOut(PA_6); } if (this->pinNumber == 7) { return new mbed::PwmOut(PA_7); } } else if (this->portIndex == 1) { if (this->pinNumber == 0) { return new mbed::PwmOut(PB_0); } if (this->pinNumber == 1) { return new mbed::PwmOut(PB_1); } } else if (this->portIndex == 2) { if (this->pinNumber == 0) { return new mbed::PwmOut(PC_0); } if (this->pinNumber == 1) { return new mbed::PwmOut(PC_1); } if (this->pinNumber == 2) { return new mbed::PwmOut(PC_2); } if (this->pinNumber == 3) { return new mbed::PwmOut(PC_3); } if (this->pinNumber == 4) { return new mbed::PwmOut(PC_4); } if (this->pinNumber == 5) { return new mbed::PwmOut(PC_5); } } return nullptr; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/drivers/pin/pin.h ================================================ #ifndef PIN_H #define PIN_H #include "mbed.h" #include #include #include #include #include "stm32f1xx_hal.h" #define INPUT 0x0 #define OUTPUT 0x1 #define NONE 0b000 #define OPENDRAIN 0b001 #define PULLUP 0b010 #define PULLDOWN 0b011 #define PULLNONE 0b100 class Pin { private: std::string portAndPin; uint8_t dir; uint8_t modifier; uint8_t portIndex; uint16_t pinNumber; uint16_t pin; uint32_t mode; uint32_t pull; uint32_t speed; GPIO_TypeDef* GPIOx; GPIO_InitTypeDef GPIO_InitStruct = {0}; public: Pin(std::string, int); Pin(std::string, int, int); PwmOut* hardware_pwm(); void configPin(); void initPin(); void setAsOutput(); void setAsInput(); void pull_none(); void pull_up(); void pull_down(); PinName pinToPinName(); inline bool get() { return HAL_GPIO_ReadPin(this->GPIOx, this->pin); } inline void set(bool value) { if (value) { HAL_GPIO_WritePin(this->GPIOx, this->pin, GPIO_PIN_SET); } else { HAL_GPIO_WritePin(this->GPIOx, this->pin, GPIO_PIN_RESET); } } }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/drivers/qei/qeiDriver.cpp ================================================ #include "mbed.h" #include "qeiDriver.h" QEIdriver::QEIdriver() : qeiIndex(NC) { this->init(); } QEIdriver::QEIdriver(bool hasIndex) : hasIndex(hasIndex), qeiIndex(NC) { this->init();; } void QEIdriver::interruptHandler() { } uint32_t QEIdriver::get() { return false; } void QEIdriver::init() { printf(" Initialising hardware QEI module\n"); printf(" This target does not support a QEI module\n"); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/drivers/qei/qeiDriver.h ================================================ #ifndef QEIDRIVER_H #define QEIDRIVER_H #include "mbed.h" #include #include #include #include #include "stm32f1xx_hal.h" class QEIdriver { private: TIM_HandleTypeDef htim; TIM_Encoder_InitTypeDef sConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; InterruptIn qeiIndex; IRQn_Type irq; void interruptHandler(); public: bool hasIndex; bool indexDetected; int32_t indexCount; QEIdriver(); // for channel A & B QEIdriver(bool); // For channels A & B, and index void init(void); uint32_t get(void); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/thread/createThreads.h ================================================ #include "extern.h" void createThreads(void) { // Create the thread objects and set the interrupt vectors to RAM. This is needed // as we are using the SD bootloader that requires a different code starting // address. Also set interrupt priority with NVIC_SetPriority. baseThread = new pruThread(TIM1, TIM1_UP_IRQn, base_freq); NVIC_SetVector(TIM1_UP_IRQn, (uint32_t)TIM1_IRQHandler); NVIC_SetPriority(TIM1_UP_IRQn, 2); servoThread = new pruThread(TIM2, TIM2_IRQn , servo_freq); NVIC_SetVector(TIM2_IRQn , (uint32_t)TIM2_IRQHandler); NVIC_SetPriority(TIM2_IRQn , 3); commsThread = new pruThread(TIM3, TIM3_IRQn, PRU_COMMSFREQ); NVIC_SetVector(TIM3_IRQn, (uint32_t)TIM3_IRQHandler); NVIC_SetPriority(TIM3_IRQn, 4); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/thread/interrupt.cpp ================================================ #include "interrupt.h" #include "stm32f1xx_hal.h" #include // Define the vector table, it is only declared in the class declaration Interrupt* Interrupt::ISRVectorTable[] = {0}; // Constructor Interrupt::Interrupt(void){} // Methods void Interrupt::Register(int interruptNumber, Interrupt* intThisPtr) { printf("Registering interrupt for interrupt number = %d\n", interruptNumber); ISRVectorTable[interruptNumber] = intThisPtr; } void Interrupt::TIM1_Wrapper(void) { ISRVectorTable[TIM1_UP_IRQn]->ISR_Handler(); } void Interrupt::TIM2_Wrapper(void) { ISRVectorTable[TIM2_IRQn]->ISR_Handler(); } void Interrupt::TIM3_Wrapper(void) { ISRVectorTable[TIM3_IRQn]->ISR_Handler(); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/thread/interrupt.h ================================================ #ifndef INTERRUPT_H #define INTERRUPT_H // Base class for all interrupt derived classes #define PERIPH_COUNT_IRQn 60 // Total number of device interrupt sources class Interrupt { protected: static Interrupt* ISRVectorTable[PERIPH_COUNT_IRQn]; public: Interrupt(void); //static Interrupt* ISRVectorTable[PERIPH_COUNT_IRQn]; static void Register(int interruptNumber, Interrupt* intThisPtr); // wrapper functions to ISR_Handler() static void TIM1_Wrapper(); static void TIM2_Wrapper(); static void TIM3_Wrapper(); virtual void ISR_Handler(void) = 0; }; #endif /****** STM32 specific Interrupt Numbers ********************************************************************* WWDG_IRQn = 0, !< Window WatchDog Interrupt PVD_IRQn = 1, !< PVD through EXTI Line detection Interrupt TAMPER_IRQn = 2, !< Tamper Interrupt RTC_IRQn = 3, !< RTC global Interrupt FLASH_IRQn = 4, !< FLASH global Interrupt RCC_IRQn = 5, !< RCC global Interrupt EXTI0_IRQn = 6, !< EXTI Line0 Interrupt EXTI1_IRQn = 7, !< EXTI Line1 Interrupt EXTI2_IRQn = 8, !< EXTI Line2 Interrupt EXTI3_IRQn = 9, !< EXTI Line3 Interrupt EXTI4_IRQn = 10, !< EXTI Line4 Interrupt DMA1_Channel1_IRQn = 11, !< DMA1 Channel 1 global Interrupt DMA1_Channel2_IRQn = 12, !< DMA1 Channel 2 global Interrupt DMA1_Channel3_IRQn = 13, !< DMA1 Channel 3 global Interrupt DMA1_Channel4_IRQn = 14, !< DMA1 Channel 4 global Interrupt DMA1_Channel5_IRQn = 15, !< DMA1 Channel 5 global Interrupt DMA1_Channel6_IRQn = 16, !< DMA1 Channel 6 global Interrupt DMA1_Channel7_IRQn = 17, !< DMA1 Channel 7 global Interrupt ADC1_2_IRQn = 18, !< ADC1 and ADC2 global Interrupt USB_HP_CAN1_TX_IRQn = 19, !< USB Device High Priority or CAN1 TX Interrupts USB_LP_CAN1_RX0_IRQn = 20, !< USB Device Low Priority or CAN1 RX0 Interrupts CAN1_RX1_IRQn = 21, !< CAN1 RX1 Interrupt CAN1_SCE_IRQn = 22, !< CAN1 SCE Interrupt EXTI9_5_IRQn = 23, !< External Line[9:5] Interrupts TIM1_BRK_IRQn = 24, !< TIM1 Break Interrupt TIM1_UP_IRQn = 25, !< TIM1 Update Interrupt TIM1_TRG_COM_IRQn = 26, !< TIM1 Trigger and Commutation Interrupt TIM1_CC_IRQn = 27, !< TIM1 Capture Compare Interrupt TIM2_IRQn = 28, !< TIM2 global Interrupt TIM3_IRQn = 29, !< TIM3 global Interrupt TIM4_IRQn = 30, !< TIM4 global Interrupt I2C1_EV_IRQn = 31, !< I2C1 Event Interrupt I2C1_ER_IRQn = 32, !< I2C1 Error Interrupt I2C2_EV_IRQn = 33, !< I2C2 Event Interrupt I2C2_ER_IRQn = 34, !< I2C2 Error Interrupt SPI1_IRQn = 35, !< SPI1 global Interrupt SPI2_IRQn = 36, !< SPI2 global Interrupt USART1_IRQn = 37, !< USART1 global Interrupt USART2_IRQn = 38, !< USART2 global Interrupt USART3_IRQn = 39, !< USART3 global Interrupt EXTI15_10_IRQn = 40, !< External Line[15:10] Interrupts RTC_Alarm_IRQn = 41, !< RTC Alarm through EXTI Line Interrupt USBWakeUp_IRQn = 42, !< USB Device WakeUp from suspend through EXTI Line Interrupt TIM8_BRK_IRQn = 43, !< TIM8 Break Interrupt TIM8_UP_IRQn = 44, !< TIM8 Update Interrupt TIM8_TRG_COM_IRQn = 45, !< TIM8 Trigger and Commutation Interrupt TIM8_CC_IRQn = 46, !< TIM8 Capture Compare Interrupt ADC3_IRQn = 47, !< ADC3 global Interrupt FSMC_IRQn = 48, !< FSMC global Interrupt SDIO_IRQn = 49, !< SDIO global Interrupt TIM5_IRQn = 50, !< TIM5 global Interrupt SPI3_IRQn = 51, !< SPI3 global Interrupt UART4_IRQn = 52, !< UART4 global Interrupt UART5_IRQn = 53, !< UART5 global Interrupt TIM6_IRQn = 54, !< TIM6 global Interrupt TIM7_IRQn = 55, !< TIM7 global Interrupt DMA2_Channel1_IRQn = 56, !< DMA2 Channel 1 global Interrupt DMA2_Channel2_IRQn = 57, !< DMA2 Channel 2 global Interrupt DMA2_Channel3_IRQn = 58, !< DMA2 Channel 3 global Interrupt DMA2_Channel4_5_IRQn = 59, !< DMA2 Channel 4 and Channel 5 global Interrupt */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/thread/irqHandlers.h ================================================ #include "interrupt.h" void TIM1_IRQHandler() { if(TIM1->SR & TIM_SR_UIF) // if UIF flag is set { TIM1->SR &= ~TIM_SR_UIF; // clear UIF flag Interrupt::TIM1_Wrapper(); } } void TIM2_IRQHandler() { if(TIM2->SR & TIM_SR_UIF) // if UIF flag is set { TIM2->SR &= ~TIM_SR_UIF; // clear UIF flag Interrupt::TIM2_Wrapper(); } } void TIM3_IRQHandler() { if(TIM3->SR & TIM_SR_UIF) // if UIF flag is set { TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag Interrupt::TIM3_Wrapper(); } } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/thread/pruThread.cpp ================================================ #include "pruThread.h" #include "modules/module.h" using namespace std; // Thread constructor pruThread::pruThread(TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency) : timer(timer), irq(irq), frequency(frequency) { printf("Creating thread %d\n", this->frequency); } void pruThread::startThread(void) { TimerPtr = new pruTimer(this->timer, this->irq, this->frequency, this); } void pruThread::stopThread(void) { this->TimerPtr->stopTimer(); } void pruThread::registerModule(Module* module) { this->vThread.push_back(module); } void pruThread::unregisterModule(Module* module) { iter = std::remove(vThread.begin(),vThread.end(), module); vThread.erase(iter, vThread.end()); } void pruThread::run(void) { // iterate over the Thread pointer vector to run all instances of Module::runModule() for (iter = vThread.begin(); iter != vThread.end(); ++iter) (*iter)->runModule(); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/thread/pruThread.h ================================================ #ifndef PRUTHREAD_H #define PRUTHREAD_H #include "stm32f1xx_hal.h" #include "timer.h" // Standard Template Library (STL) includes #include #include using namespace std; class Module; class pruThread { private: pruTimer* TimerPtr; TIM_TypeDef* timer; IRQn_Type irq; uint32_t frequency; vector vThread; // vector containing pointers to Thread modules vector::iterator iter; public: pruThread(TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency); void registerModule(Module *module); void unregisterModule(Module *module); void startThread(void); void stopThread(void); void run(void); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/thread/timer.cpp ================================================ #include "mbed.h" #include "stm32f1xx_hal.h" #include #include #include "interrupt.h" #include "timerInterrupt.h" #include "timer.h" #include "pruThread.h" // Timer constructor pruTimer::pruTimer(TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency, pruThread* ownerPtr): timer(timer), irq(irq), frequency(frequency), timerOwnerPtr(ownerPtr) { interruptPtr = new TimerInterrupt(this->irq, this); // Instantiate a new Timer Interrupt object and pass "this" pointer this->startTimer(); } void pruTimer::timerTick(void) { //Do something here this->timerOwnerPtr->run(); } void pruTimer::startTimer(void) { uint32_t TIM_CLK; if (this->timer == TIM1) { printf(" power on Timer 1\n\r"); __HAL_RCC_TIM1_CLK_ENABLE(); TIM_CLK = APB2CLK; } else if (this->timer == TIM2) { printf(" power on Timer 2\n\r"); __HAL_RCC_TIM2_CLK_ENABLE(); TIM_CLK = APB1CLK; } else if (this->timer == TIM3) { printf(" power on Timer 30\n\r"); __HAL_RCC_TIM3_CLK_ENABLE(); TIM_CLK = APB1CLK; } //timer uptade frequency = TIM_CLK/(TIM_PSC+1)/(TIM_ARR + 1) this->timer->CR2 &= 0; // UG used as trigg output this->timer->PSC = TIM_PSC-1; // prescaler this->timer->ARR = ((TIM_CLK / TIM_PSC / this->frequency) - 1); // period this->timer->EGR = TIM_EGR_UG; // reinit the counter this->timer->DIER = TIM_DIER_UIE; // enable update interrupts this->timer->CR1 |= TIM_CR1_CEN; // enable timer NVIC_EnableIRQ(this->irq); } void pruTimer::stopTimer() { NVIC_DisableIRQ(this->irq); printf(" timer stop\n\r"); this->timer->CR1 &= (~(TIM_CR1_CEN)); // disable timer } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F1/thread/timer.h ================================================ #ifndef TIMER_H #define TIMER_H #include "mbed.h" #include #define TIM_PSC 1 #define APB1CLK SystemCoreClock #define APB2CLK SystemCoreClock class TimerInterrupt; // forward declatation class pruThread; // forward declatation class pruTimer { friend class TimerInterrupt; private: TimerInterrupt* interruptPtr; TIM_TypeDef* timer; IRQn_Type irq; uint32_t frequency; pruThread* timerOwnerPtr; void startTimer(void); void timerTick(); // Private timer tiggered method public: pruTimer(TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency, pruThread* ownerPtr); void stopTimer(void); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F103xC/device/TOOLCHAIN_ARM/startup_stm32f103xe.S ================================================ ;******************** (C) COPYRIGHT 2017 STMicroelectronics ******************** ;* File Name : startup_stm32f103xe.s ;* Author : MCD Application Team ;* Description : STM32F103xE Devices vector table for MDK-ARM toolchain. ;* This module performs: ;* - Set the initial SP ;* - Set the initial PC == Reset_Handler ;* - Set the vector table entries with the exceptions ISR address ;* - Configure the clock system ;* - Branches to __main in the C library (which eventually ;* calls main()). ;* After Reset the Cortex-M3 processor is in Thread mode, ;* priority is Privileged, and the Stack is set to Main. ;****************************************************************************** ;* @attention ;* ;* Copyright (c) 2017 STMicroelectronics. ;* All rights reserved. ;* ;* This software component is licensed by ST under BSD 3-Clause license, ;* the "License"; You may not use this file except in compliance with the ;* License. You may obtain a copy of the License at: ;* opensource.org/licenses/BSD-3-Clause ;* ;****************************************************************************** ; Amount of memory (in bytes) allocated for Stack ; Tailor this value to your application needs ; Stack Configuration ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ; Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3 Stack_Mem SPACE Stack_Size __initial_sp ; Heap Configuration ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ; Heap_Size EQU 0x00000200 AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit PRESERVE8 THUMB ; Vector Table Mapped to Address 0 at Reset AREA RESET, DATA, READONLY EXPORT __Vectors EXPORT __Vectors_End EXPORT __Vectors_Size __Vectors DCD __initial_sp ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; NMI Handler DCD HardFault_Handler ; Hard Fault Handler DCD MemManage_Handler ; MPU Fault Handler DCD BusFault_Handler ; Bus Fault Handler DCD UsageFault_Handler ; Usage Fault Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; SVCall Handler DCD DebugMon_Handler ; Debug Monitor Handler DCD 0 ; Reserved DCD PendSV_Handler ; PendSV Handler DCD SysTick_Handler ; SysTick Handler ; External Interrupts DCD WWDG_IRQHandler ; Window Watchdog DCD PVD_IRQHandler ; PVD through EXTI Line detect DCD TAMPER_IRQHandler ; Tamper DCD RTC_IRQHandler ; RTC DCD FLASH_IRQHandler ; Flash DCD RCC_IRQHandler ; RCC DCD EXTI0_IRQHandler ; EXTI Line 0 DCD EXTI1_IRQHandler ; EXTI Line 1 DCD EXTI2_IRQHandler ; EXTI Line 2 DCD EXTI3_IRQHandler ; EXTI Line 3 DCD EXTI4_IRQHandler ; EXTI Line 4 DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 DCD ADC1_2_IRQHandler ; ADC1 & ADC2 DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0 DCD CAN1_RX1_IRQHandler ; CAN1 RX1 DCD CAN1_SCE_IRQHandler ; CAN1 SCE DCD EXTI9_5_IRQHandler ; EXTI Line 9..5 DCD TIM1_BRK_IRQHandler ; TIM1 Break DCD TIM1_UP_IRQHandler ; TIM1 Update DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare DCD TIM2_IRQHandler ; TIM2 DCD TIM3_IRQHandler ; TIM3 DCD TIM4_IRQHandler ; TIM4 DCD I2C1_EV_IRQHandler ; I2C1 Event DCD I2C1_ER_IRQHandler ; I2C1 Error DCD I2C2_EV_IRQHandler ; I2C2 Event DCD I2C2_ER_IRQHandler ; I2C2 Error DCD SPI1_IRQHandler ; SPI1 DCD SPI2_IRQHandler ; SPI2 DCD USART1_IRQHandler ; USART1 DCD USART2_IRQHandler ; USART2 DCD USART3_IRQHandler ; USART3 DCD EXTI15_10_IRQHandler ; EXTI Line 15..10 DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend DCD TIM8_BRK_IRQHandler ; TIM8 Break DCD TIM8_UP_IRQHandler ; TIM8 Update DCD TIM8_TRG_COM_IRQHandler ; TIM8 Trigger and Commutation DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare DCD ADC3_IRQHandler ; ADC3 DCD FSMC_IRQHandler ; FSMC DCD SDIO_IRQHandler ; SDIO DCD TIM5_IRQHandler ; TIM5 DCD SPI3_IRQHandler ; SPI3 DCD UART4_IRQHandler ; UART4 DCD UART5_IRQHandler ; UART5 DCD TIM6_IRQHandler ; TIM6 DCD TIM7_IRQHandler ; TIM7 DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1 DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2 DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3 DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5 __Vectors_End __Vectors_Size EQU __Vectors_End - __Vectors AREA |.text|, CODE, READONLY ; Reset handler Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT __main IMPORT SystemInit LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP ; Dummy Exception Handlers (infinite loops which can be modified) NMI_Handler PROC EXPORT NMI_Handler [WEAK] B . ENDP HardFault_Handler\ PROC EXPORT HardFault_Handler [WEAK] B . ENDP MemManage_Handler\ PROC EXPORT MemManage_Handler [WEAK] B . ENDP BusFault_Handler\ PROC EXPORT BusFault_Handler [WEAK] B . ENDP UsageFault_Handler\ PROC EXPORT UsageFault_Handler [WEAK] B . ENDP SVC_Handler PROC EXPORT SVC_Handler [WEAK] B . ENDP DebugMon_Handler\ PROC EXPORT DebugMon_Handler [WEAK] B . ENDP PendSV_Handler PROC EXPORT PendSV_Handler [WEAK] B . ENDP SysTick_Handler PROC EXPORT SysTick_Handler [WEAK] B . ENDP Default_Handler PROC EXPORT WWDG_IRQHandler [WEAK] EXPORT PVD_IRQHandler [WEAK] EXPORT TAMPER_IRQHandler [WEAK] EXPORT RTC_IRQHandler [WEAK] EXPORT FLASH_IRQHandler [WEAK] EXPORT RCC_IRQHandler [WEAK] EXPORT EXTI0_IRQHandler [WEAK] EXPORT EXTI1_IRQHandler [WEAK] EXPORT EXTI2_IRQHandler [WEAK] EXPORT EXTI3_IRQHandler [WEAK] EXPORT EXTI4_IRQHandler [WEAK] EXPORT DMA1_Channel1_IRQHandler [WEAK] EXPORT DMA1_Channel2_IRQHandler [WEAK] EXPORT DMA1_Channel3_IRQHandler [WEAK] EXPORT DMA1_Channel4_IRQHandler [WEAK] EXPORT DMA1_Channel5_IRQHandler [WEAK] EXPORT DMA1_Channel6_IRQHandler [WEAK] EXPORT DMA1_Channel7_IRQHandler [WEAK] EXPORT ADC1_2_IRQHandler [WEAK] EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK] EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK] EXPORT CAN1_RX1_IRQHandler [WEAK] EXPORT CAN1_SCE_IRQHandler [WEAK] EXPORT EXTI9_5_IRQHandler [WEAK] EXPORT TIM1_BRK_IRQHandler [WEAK] EXPORT TIM1_UP_IRQHandler [WEAK] EXPORT TIM1_TRG_COM_IRQHandler [WEAK] EXPORT TIM1_CC_IRQHandler [WEAK] EXPORT TIM2_IRQHandler [WEAK] EXPORT TIM3_IRQHandler [WEAK] EXPORT TIM4_IRQHandler [WEAK] EXPORT I2C1_EV_IRQHandler [WEAK] EXPORT I2C1_ER_IRQHandler [WEAK] EXPORT I2C2_EV_IRQHandler [WEAK] EXPORT I2C2_ER_IRQHandler [WEAK] EXPORT SPI1_IRQHandler [WEAK] EXPORT SPI2_IRQHandler [WEAK] EXPORT USART1_IRQHandler [WEAK] EXPORT USART2_IRQHandler [WEAK] EXPORT USART3_IRQHandler [WEAK] EXPORT EXTI15_10_IRQHandler [WEAK] EXPORT RTC_Alarm_IRQHandler [WEAK] EXPORT USBWakeUp_IRQHandler [WEAK] EXPORT TIM8_BRK_IRQHandler [WEAK] EXPORT TIM8_UP_IRQHandler [WEAK] EXPORT TIM8_TRG_COM_IRQHandler [WEAK] EXPORT TIM8_CC_IRQHandler [WEAK] EXPORT ADC3_IRQHandler [WEAK] EXPORT FSMC_IRQHandler [WEAK] EXPORT SDIO_IRQHandler [WEAK] EXPORT TIM5_IRQHandler [WEAK] EXPORT SPI3_IRQHandler [WEAK] EXPORT UART4_IRQHandler [WEAK] EXPORT UART5_IRQHandler [WEAK] EXPORT TIM6_IRQHandler [WEAK] EXPORT TIM7_IRQHandler [WEAK] EXPORT DMA2_Channel1_IRQHandler [WEAK] EXPORT DMA2_Channel2_IRQHandler [WEAK] EXPORT DMA2_Channel3_IRQHandler [WEAK] EXPORT DMA2_Channel4_5_IRQHandler [WEAK] WWDG_IRQHandler PVD_IRQHandler TAMPER_IRQHandler RTC_IRQHandler FLASH_IRQHandler RCC_IRQHandler EXTI0_IRQHandler EXTI1_IRQHandler EXTI2_IRQHandler EXTI3_IRQHandler EXTI4_IRQHandler DMA1_Channel1_IRQHandler DMA1_Channel2_IRQHandler DMA1_Channel3_IRQHandler DMA1_Channel4_IRQHandler DMA1_Channel5_IRQHandler DMA1_Channel6_IRQHandler DMA1_Channel7_IRQHandler ADC1_2_IRQHandler USB_HP_CAN1_TX_IRQHandler USB_LP_CAN1_RX0_IRQHandler CAN1_RX1_IRQHandler CAN1_SCE_IRQHandler EXTI9_5_IRQHandler TIM1_BRK_IRQHandler TIM1_UP_IRQHandler TIM1_TRG_COM_IRQHandler TIM1_CC_IRQHandler TIM2_IRQHandler TIM3_IRQHandler TIM4_IRQHandler I2C1_EV_IRQHandler I2C1_ER_IRQHandler I2C2_EV_IRQHandler I2C2_ER_IRQHandler SPI1_IRQHandler SPI2_IRQHandler USART1_IRQHandler USART2_IRQHandler USART3_IRQHandler EXTI15_10_IRQHandler RTC_Alarm_IRQHandler USBWakeUp_IRQHandler TIM8_BRK_IRQHandler TIM8_UP_IRQHandler TIM8_TRG_COM_IRQHandler TIM8_CC_IRQHandler ADC3_IRQHandler FSMC_IRQHandler SDIO_IRQHandler TIM5_IRQHandler SPI3_IRQHandler UART4_IRQHandler UART5_IRQHandler TIM6_IRQHandler TIM7_IRQHandler DMA2_Channel1_IRQHandler DMA2_Channel2_IRQHandler DMA2_Channel3_IRQHandler DMA2_Channel4_5_IRQHandler B . ENDP ALIGN ;******************************************************************************* ; User Stack and Heap initialization ;******************************************************************************* END ;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE***** ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F103xC/device/TOOLCHAIN_ARM/stm32f103xe.sct ================================================ #! armclang -E --target=arm-arm-none-eabi -x c -mcpu=cortex-m3 ; Scatter-Loading Description File ; ; SPDX-License-Identifier: BSD-3-Clause ;****************************************************************************** ;* @attention ;* ;* Copyright (c) 2016-2020 STMicroelectronics. ;* All rights reserved. ;* ;* This software component is licensed by ST under BSD 3-Clause license, ;* the "License"; You may not use this file except in compliance with the ;* License. You may obtain a copy of the License at: ;* opensource.org/licenses/BSD-3-Clause ;* ;****************************************************************************** #include "../cmsis_nvic.h" #if !defined(MBED_APP_START) #define MBED_APP_START MBED_ROM_START #endif #if !defined(MBED_APP_SIZE) #define MBED_APP_SIZE MBED_ROM_SIZE #endif /* This value is normally defined by the tools to 0x1000 for bare metal and 0x400 for RTOS */ #if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE) # if defined(MBED_BOOT_STACK_SIZE) # define MBED_CONF_TARGET_BOOT_STACK_SIZE MBED_BOOT_STACK_SIZE # else # define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 # endif #endif /* Round up VECTORS_SIZE to 8 bytes */ #define VECTORS_SIZE (((NVIC_NUM_VECTORS * 4) + 7) AND ~7) LR_IROM1 MBED_APP_START MBED_APP_SIZE { ER_IROM1 MBED_APP_START MBED_APP_SIZE { *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 (MBED_RAM_START + VECTORS_SIZE) { ; RW data .ANY (+RW +ZI) } ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_START + MBED_RAM_SIZE - MBED_CONF_TARGET_BOOT_STACK_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16)) { ; Heap growing up } ARM_LIB_STACK (MBED_RAM_START + MBED_RAM_SIZE) EMPTY -MBED_CONF_TARGET_BOOT_STACK_SIZE { ; Stack region growing down } } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F103xC/device/cmsis_nvic.h ================================================ /* mbed Microcontroller Library * SPDX-License-Identifier: BSD-3-Clause ****************************************************************************** * @attention * *

© Copyright (c) 2016-2020 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ #ifndef MBED_CMSIS_NVIC_H #define MBED_CMSIS_NVIC_H #if !defined(MBED_ROM_START) #define MBED_ROM_START 0x8000000 #endif #if !defined(MBED_ROM_SIZE) #define MBED_ROM_SIZE 0x40000 // 256 KB #endif #if !defined(MBED_RAM_START) #define MBED_RAM_START 0x20000000 #endif #if !defined(MBED_RAM_SIZE) #define MBED_RAM_SIZE 0xC000 // 48 KB #endif #define NVIC_NUM_VECTORS 76 #define NVIC_RAM_VECTOR_ADDRESS MBED_RAM_START #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F103xC/device/stm32f103xe.h ================================================ /** ****************************************************************************** * @file stm32f103xe.h * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Header File. * This file contains all the peripheral register's definitions, bits * definitions and memory mapping for STM32F1xx devices. * * This file contains: * - Data structures and the address mapping for all peripherals * - Peripheral's registers declarations and bits definition * - Macros to access peripherals registers hardware * ****************************************************************************** * @attention * *

© Copyright (c) 2017 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f103xe * @{ */ #ifndef __STM32F103xE_H #define __STM32F103xE_H #ifdef __cplusplus extern "C" { #endif /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M3 Processor and Core Peripherals */ #define __CM3_REV 0x0200U /*!< Core Revision r2p0 */ #define __MPU_PRESENT 0U /*!< Other STM32 devices does not provide an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32 uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F10x Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ /*!< Interrupt Number Definition */ typedef enum { /****** Cortex-M3 Processor Exceptions Numbers ***************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /*!< 3 Cortex-M3 Hard Fault Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M3 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers *********************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMPER_IRQn = 2, /*!< Tamper Interrupt */ RTC_IRQn = 3, /*!< RTC global Interrupt */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Channel1_IRQn = 11, /*!< DMA1 Channel 1 global Interrupt */ DMA1_Channel2_IRQn = 12, /*!< DMA1 Channel 2 global Interrupt */ DMA1_Channel3_IRQn = 13, /*!< DMA1 Channel 3 global Interrupt */ DMA1_Channel4_IRQn = 14, /*!< DMA1 Channel 4 global Interrupt */ DMA1_Channel5_IRQn = 15, /*!< DMA1 Channel 5 global Interrupt */ DMA1_Channel6_IRQn = 16, /*!< DMA1 Channel 6 global Interrupt */ DMA1_Channel7_IRQn = 17, /*!< DMA1 Channel 7 global Interrupt */ ADC1_2_IRQn = 18, /*!< ADC1 and ADC2 global Interrupt */ USB_HP_CAN1_TX_IRQn = 19, /*!< USB Device High Priority or CAN1 TX Interrupts */ USB_LP_CAN1_RX0_IRQn = 20, /*!< USB Device Low Priority or CAN1 RX0 Interrupts */ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */ TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */ TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm through EXTI Line Interrupt */ USBWakeUp_IRQn = 42, /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */ TIM8_BRK_IRQn = 43, /*!< TIM8 Break Interrupt */ TIM8_UP_IRQn = 44, /*!< TIM8 Update Interrupt */ TIM8_TRG_COM_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */ ADC3_IRQn = 47, /*!< ADC3 global Interrupt */ FSMC_IRQn = 48, /*!< FSMC global Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ UART4_IRQn = 52, /*!< UART4 global Interrupt */ UART5_IRQn = 53, /*!< UART5 global Interrupt */ TIM6_IRQn = 54, /*!< TIM6 global Interrupt */ TIM7_IRQn = 55, /*!< TIM7 global Interrupt */ DMA2_Channel1_IRQn = 56, /*!< DMA2 Channel 1 global Interrupt */ DMA2_Channel2_IRQn = 57, /*!< DMA2 Channel 2 global Interrupt */ DMA2_Channel3_IRQn = 58, /*!< DMA2 Channel 3 global Interrupt */ DMA2_Channel4_5_IRQn = 59, /*!< DMA2 Channel 4 and Channel 5 global Interrupt */ } IRQn_Type; /** * @} */ #include "core_cm3.h" #include "system_stm32f1xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; __IO uint32_t CR1; __IO uint32_t CR2; __IO uint32_t SMPR1; __IO uint32_t SMPR2; __IO uint32_t JOFR1; __IO uint32_t JOFR2; __IO uint32_t JOFR3; __IO uint32_t JOFR4; __IO uint32_t HTR; __IO uint32_t LTR; __IO uint32_t SQR1; __IO uint32_t SQR2; __IO uint32_t SQR3; __IO uint32_t JSQR; __IO uint32_t JDR1; __IO uint32_t JDR2; __IO uint32_t JDR3; __IO uint32_t JDR4; __IO uint32_t DR; } ADC_TypeDef; typedef struct { __IO uint32_t SR; /*!< ADC status register, used for ADC multimode (bits common to several ADC instances). Address offset: ADC1 base address */ __IO uint32_t CR1; /*!< ADC control register 1, used for ADC multimode (bits common to several ADC instances). Address offset: ADC1 base address + 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, used for ADC multimode (bits common to several ADC instances). Address offset: ADC1 base address + 0x08 */ uint32_t RESERVED[16]; __IO uint32_t DR; /*!< ADC data register, used for ADC multimode (bits common to several ADC instances). Address offset: ADC1 base address + 0x4C */ } ADC_Common_TypeDef; /** * @brief Backup Registers */ typedef struct { uint32_t RESERVED0; __IO uint32_t DR1; __IO uint32_t DR2; __IO uint32_t DR3; __IO uint32_t DR4; __IO uint32_t DR5; __IO uint32_t DR6; __IO uint32_t DR7; __IO uint32_t DR8; __IO uint32_t DR9; __IO uint32_t DR10; __IO uint32_t RTCCR; __IO uint32_t CR; __IO uint32_t CSR; uint32_t RESERVED13[2]; __IO uint32_t DR11; __IO uint32_t DR12; __IO uint32_t DR13; __IO uint32_t DR14; __IO uint32_t DR15; __IO uint32_t DR16; __IO uint32_t DR17; __IO uint32_t DR18; __IO uint32_t DR19; __IO uint32_t DR20; __IO uint32_t DR21; __IO uint32_t DR22; __IO uint32_t DR23; __IO uint32_t DR24; __IO uint32_t DR25; __IO uint32_t DR26; __IO uint32_t DR27; __IO uint32_t DR28; __IO uint32_t DR29; __IO uint32_t DR30; __IO uint32_t DR31; __IO uint32_t DR32; __IO uint32_t DR33; __IO uint32_t DR34; __IO uint32_t DR35; __IO uint32_t DR36; __IO uint32_t DR37; __IO uint32_t DR38; __IO uint32_t DR39; __IO uint32_t DR40; __IO uint32_t DR41; __IO uint32_t DR42; } BKP_TypeDef; /** * @brief Controller Area Network TxMailBox */ typedef struct { __IO uint32_t TIR; __IO uint32_t TDTR; __IO uint32_t TDLR; __IO uint32_t TDHR; } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; __IO uint32_t RDTR; __IO uint32_t RDLR; __IO uint32_t RDHR; } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; __IO uint32_t FR2; } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; __IO uint32_t MSR; __IO uint32_t TSR; __IO uint32_t RF0R; __IO uint32_t RF1R; __IO uint32_t IER; __IO uint32_t ESR; __IO uint32_t BTR; uint32_t RESERVED0[88]; CAN_TxMailBox_TypeDef sTxMailBox[3]; CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; uint32_t RESERVED1[12]; __IO uint32_t FMR; __IO uint32_t FM1R; uint32_t RESERVED2; __IO uint32_t FS1R; uint32_t RESERVED3; __IO uint32_t FFA1R; uint32_t RESERVED4; __IO uint32_t FA1R; uint32_t RESERVED5[8]; CAN_FilterRegister_TypeDef sFilterRegister[14]; } CAN_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, Address offset: 0x05 */ uint16_t RESERVED1; /*!< Reserved, Address offset: 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief Digital to Analog Converter */ typedef struct { __IO uint32_t CR; __IO uint32_t SWTRIGR; __IO uint32_t DHR12R1; __IO uint32_t DHR12L1; __IO uint32_t DHR8R1; __IO uint32_t DHR12R2; __IO uint32_t DHR12L2; __IO uint32_t DHR8R2; __IO uint32_t DHR12RD; __IO uint32_t DHR12LD; __IO uint32_t DHR8RD; __IO uint32_t DOR1; __IO uint32_t DOR2; } DAC_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; __IO uint32_t CR; }DBGMCU_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CCR; __IO uint32_t CNDTR; __IO uint32_t CPAR; __IO uint32_t CMAR; } DMA_Channel_TypeDef; typedef struct { __IO uint32_t ISR; __IO uint32_t IFCR; } DMA_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; __IO uint32_t EMR; __IO uint32_t RTSR; __IO uint32_t FTSR; __IO uint32_t SWIER; __IO uint32_t PR; } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; __IO uint32_t KEYR; __IO uint32_t OPTKEYR; __IO uint32_t SR; __IO uint32_t CR; __IO uint32_t AR; __IO uint32_t RESERVED; __IO uint32_t OBR; __IO uint32_t WRPR; } FLASH_TypeDef; /** * @brief Option Bytes Registers */ typedef struct { __IO uint16_t RDP; __IO uint16_t USER; __IO uint16_t Data0; __IO uint16_t Data1; __IO uint16_t WRP0; __IO uint16_t WRP1; __IO uint16_t WRP2; __IO uint16_t WRP3; } OB_TypeDef; /** * @brief Flexible Static Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; } FSMC_Bank1_TypeDef; /** * @brief Flexible Static Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; } FSMC_Bank1E_TypeDef; /** * @brief Flexible Static Memory Controller Bank2 */ typedef struct { __IO uint32_t PCR2; /*!< NAND Flash control register 2, Address offset: 0x60 */ __IO uint32_t SR2; /*!< NAND Flash FIFO status and interrupt register 2, Address offset: 0x64 */ __IO uint32_t PMEM2; /*!< NAND Flash Common memory space timing register 2, Address offset: 0x68 */ __IO uint32_t PATT2; /*!< NAND Flash Attribute memory space timing register 2, Address offset: 0x6C */ uint32_t RESERVED0; /*!< Reserved, 0x70 */ __IO uint32_t ECCR2; /*!< NAND Flash ECC result registers 2, Address offset: 0x74 */ uint32_t RESERVED1; /*!< Reserved, 0x78 */ uint32_t RESERVED2; /*!< Reserved, 0x7C */ __IO uint32_t PCR3; /*!< NAND Flash control register 3, Address offset: 0x80 */ __IO uint32_t SR3; /*!< NAND Flash FIFO status and interrupt register 3, Address offset: 0x84 */ __IO uint32_t PMEM3; /*!< NAND Flash Common memory space timing register 3, Address offset: 0x88 */ __IO uint32_t PATT3; /*!< NAND Flash Attribute memory space timing register 3, Address offset: 0x8C */ uint32_t RESERVED3; /*!< Reserved, 0x90 */ __IO uint32_t ECCR3; /*!< NAND Flash ECC result registers 3, Address offset: 0x94 */ } FSMC_Bank2_3_TypeDef; /** * @brief Flexible Static Memory Controller Bank4 */ typedef struct { __IO uint32_t PCR4; __IO uint32_t SR4; __IO uint32_t PMEM4; __IO uint32_t PATT4; __IO uint32_t PIO4; } FSMC_Bank4_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t CRL; __IO uint32_t CRH; __IO uint32_t IDR; __IO uint32_t ODR; __IO uint32_t BSRR; __IO uint32_t BRR; __IO uint32_t LCKR; } GPIO_TypeDef; /** * @brief Alternate Function I/O */ typedef struct { __IO uint32_t EVCR; __IO uint32_t MAPR; __IO uint32_t EXTICR[4]; uint32_t RESERVED0; __IO uint32_t MAPR2; } AFIO_TypeDef; /** * @brief Inter Integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; __IO uint32_t CR2; __IO uint32_t OAR1; __IO uint32_t OAR2; __IO uint32_t DR; __IO uint32_t SR1; __IO uint32_t SR2; __IO uint32_t CCR; __IO uint32_t TRISE; } I2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; __IO uint32_t CSR; } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; __IO uint32_t CFGR; __IO uint32_t CIR; __IO uint32_t APB2RSTR; __IO uint32_t APB1RSTR; __IO uint32_t AHBENR; __IO uint32_t APB2ENR; __IO uint32_t APB1ENR; __IO uint32_t BDCR; __IO uint32_t CSR; } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t CRH; __IO uint32_t CRL; __IO uint32_t PRLH; __IO uint32_t PRLL; __IO uint32_t DIVH; __IO uint32_t DIVL; __IO uint32_t CNTH; __IO uint32_t CNTL; __IO uint32_t ALRH; __IO uint32_t ALRL; } RTC_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; __IO uint32_t CLKCR; __IO uint32_t ARG; __IO uint32_t CMD; __I uint32_t RESPCMD; __I uint32_t RESP1; __I uint32_t RESP2; __I uint32_t RESP3; __I uint32_t RESP4; __IO uint32_t DTIMER; __IO uint32_t DLEN; __IO uint32_t DCTRL; __I uint32_t DCOUNT; __I uint32_t STA; __IO uint32_t ICR; __IO uint32_t MASK; uint32_t RESERVED0[2]; __I uint32_t FIFOCNT; uint32_t RESERVED1[13]; __IO uint32_t FIFO; } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; __IO uint32_t CR2; __IO uint32_t SR; __IO uint32_t DR; __IO uint32_t CRCPR; __IO uint32_t RXCRCR; __IO uint32_t TXCRCR; __IO uint32_t I2SCFGR; __IO uint32_t I2SPR; } SPI_TypeDef; /** * @brief TIM Timers */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave Mode Control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler register, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer register, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ }TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Universal Serial Bus Full Speed Device */ typedef struct { __IO uint16_t EP0R; /*!< USB Endpoint 0 register, Address offset: 0x00 */ __IO uint16_t RESERVED0; /*!< Reserved */ __IO uint16_t EP1R; /*!< USB Endpoint 1 register, Address offset: 0x04 */ __IO uint16_t RESERVED1; /*!< Reserved */ __IO uint16_t EP2R; /*!< USB Endpoint 2 register, Address offset: 0x08 */ __IO uint16_t RESERVED2; /*!< Reserved */ __IO uint16_t EP3R; /*!< USB Endpoint 3 register, Address offset: 0x0C */ __IO uint16_t RESERVED3; /*!< Reserved */ __IO uint16_t EP4R; /*!< USB Endpoint 4 register, Address offset: 0x10 */ __IO uint16_t RESERVED4; /*!< Reserved */ __IO uint16_t EP5R; /*!< USB Endpoint 5 register, Address offset: 0x14 */ __IO uint16_t RESERVED5; /*!< Reserved */ __IO uint16_t EP6R; /*!< USB Endpoint 6 register, Address offset: 0x18 */ __IO uint16_t RESERVED6; /*!< Reserved */ __IO uint16_t EP7R; /*!< USB Endpoint 7 register, Address offset: 0x1C */ __IO uint16_t RESERVED7[17]; /*!< Reserved */ __IO uint16_t CNTR; /*!< Control register, Address offset: 0x40 */ __IO uint16_t RESERVED8; /*!< Reserved */ __IO uint16_t ISTR; /*!< Interrupt status register, Address offset: 0x44 */ __IO uint16_t RESERVED9; /*!< Reserved */ __IO uint16_t FNR; /*!< Frame number register, Address offset: 0x48 */ __IO uint16_t RESERVEDA; /*!< Reserved */ __IO uint16_t DADDR; /*!< Device address register, Address offset: 0x4C */ __IO uint16_t RESERVEDB; /*!< Reserved */ __IO uint16_t BTABLE; /*!< Buffer Table address register, Address offset: 0x50 */ __IO uint16_t RESERVEDC; /*!< Reserved */ } USB_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @} */ /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000UL /*!< FLASH base address in the alias region */ #define FLASH_BANK1_END 0x0807FFFFUL /*!< FLASH END address of bank1 */ #define SRAM_BASE 0x20000000UL /*!< SRAM base address in the alias region */ #define PERIPH_BASE 0x40000000UL /*!< Peripheral base address in the alias region */ #define SRAM_BB_BASE 0x22000000UL /*!< SRAM base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000UL /*!< Peripheral base address in the bit-band region */ #define FSMC_BASE 0x60000000UL /*!< FSMC base address */ #define FSMC_R_BASE 0xA0000000UL /*!< FSMC registers base address */ /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define AHBPERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define TIM2_BASE (APB1PERIPH_BASE + 0x00000000UL) #define TIM3_BASE (APB1PERIPH_BASE + 0x00000400UL) #define TIM4_BASE (APB1PERIPH_BASE + 0x00000800UL) #define TIM5_BASE (APB1PERIPH_BASE + 0x00000C00UL) #define TIM6_BASE (APB1PERIPH_BASE + 0x00001000UL) #define TIM7_BASE (APB1PERIPH_BASE + 0x00001400UL) #define RTC_BASE (APB1PERIPH_BASE + 0x00002800UL) #define WWDG_BASE (APB1PERIPH_BASE + 0x00002C00UL) #define IWDG_BASE (APB1PERIPH_BASE + 0x00003000UL) #define SPI2_BASE (APB1PERIPH_BASE + 0x00003800UL) #define SPI3_BASE (APB1PERIPH_BASE + 0x00003C00UL) #define USART2_BASE (APB1PERIPH_BASE + 0x00004400UL) #define USART3_BASE (APB1PERIPH_BASE + 0x00004800UL) #define UART4_BASE (APB1PERIPH_BASE + 0x00004C00UL) #define UART5_BASE (APB1PERIPH_BASE + 0x00005000UL) #define I2C1_BASE (APB1PERIPH_BASE + 0x00005400UL) #define I2C2_BASE (APB1PERIPH_BASE + 0x00005800UL) #define CAN1_BASE (APB1PERIPH_BASE + 0x00006400UL) #define BKP_BASE (APB1PERIPH_BASE + 0x00006C00UL) #define PWR_BASE (APB1PERIPH_BASE + 0x00007000UL) #define DAC_BASE (APB1PERIPH_BASE + 0x00007400UL) #define AFIO_BASE (APB2PERIPH_BASE + 0x00000000UL) #define EXTI_BASE (APB2PERIPH_BASE + 0x00000400UL) #define GPIOA_BASE (APB2PERIPH_BASE + 0x00000800UL) #define GPIOB_BASE (APB2PERIPH_BASE + 0x00000C00UL) #define GPIOC_BASE (APB2PERIPH_BASE + 0x00001000UL) #define GPIOD_BASE (APB2PERIPH_BASE + 0x00001400UL) #define GPIOE_BASE (APB2PERIPH_BASE + 0x00001800UL) #define GPIOF_BASE (APB2PERIPH_BASE + 0x00001C00UL) #define GPIOG_BASE (APB2PERIPH_BASE + 0x00002000UL) #define ADC1_BASE (APB2PERIPH_BASE + 0x00002400UL) #define ADC2_BASE (APB2PERIPH_BASE + 0x00002800UL) #define TIM1_BASE (APB2PERIPH_BASE + 0x00002C00UL) #define SPI1_BASE (APB2PERIPH_BASE + 0x00003000UL) #define TIM8_BASE (APB2PERIPH_BASE + 0x00003400UL) #define USART1_BASE (APB2PERIPH_BASE + 0x00003800UL) #define ADC3_BASE (APB2PERIPH_BASE + 0x00003C00UL) #define SDIO_BASE (PERIPH_BASE + 0x00018000UL) #define DMA1_BASE (AHBPERIPH_BASE + 0x00000000UL) #define DMA1_Channel1_BASE (AHBPERIPH_BASE + 0x00000008UL) #define DMA1_Channel2_BASE (AHBPERIPH_BASE + 0x0000001CUL) #define DMA1_Channel3_BASE (AHBPERIPH_BASE + 0x00000030UL) #define DMA1_Channel4_BASE (AHBPERIPH_BASE + 0x00000044UL) #define DMA1_Channel5_BASE (AHBPERIPH_BASE + 0x00000058UL) #define DMA1_Channel6_BASE (AHBPERIPH_BASE + 0x0000006CUL) #define DMA1_Channel7_BASE (AHBPERIPH_BASE + 0x00000080UL) #define DMA2_BASE (AHBPERIPH_BASE + 0x00000400UL) #define DMA2_Channel1_BASE (AHBPERIPH_BASE + 0x00000408UL) #define DMA2_Channel2_BASE (AHBPERIPH_BASE + 0x0000041CUL) #define DMA2_Channel3_BASE (AHBPERIPH_BASE + 0x00000430UL) #define DMA2_Channel4_BASE (AHBPERIPH_BASE + 0x00000444UL) #define DMA2_Channel5_BASE (AHBPERIPH_BASE + 0x00000458UL) #define RCC_BASE (AHBPERIPH_BASE + 0x00001000UL) #define CRC_BASE (AHBPERIPH_BASE + 0x00003000UL) #define FLASH_R_BASE (AHBPERIPH_BASE + 0x00002000UL) /*!< Flash registers base address */ #define FLASHSIZE_BASE 0x1FFFF7E0UL /*!< FLASH Size register base address */ #define UID_BASE 0x1FFFF7E8UL /*!< Unique device ID register base address */ #define OB_BASE 0x1FFFF800UL /*!< Flash Option Bytes base address */ #define FSMC_BANK1 (FSMC_BASE) /*!< FSMC Bank1 base address */ #define FSMC_BANK1_1 (FSMC_BANK1) /*!< FSMC Bank1_1 base address */ #define FSMC_BANK1_2 (FSMC_BANK1 + 0x04000000UL) /*!< FSMC Bank1_2 base address */ #define FSMC_BANK1_3 (FSMC_BANK1 + 0x08000000UL) /*!< FSMC Bank1_3 base address */ #define FSMC_BANK1_4 (FSMC_BANK1 + 0x0C000000UL) /*!< FSMC Bank1_4 base address */ #define FSMC_BANK2 (FSMC_BASE + 0x10000000UL) /*!< FSMC Bank2 base address */ #define FSMC_BANK3 (FSMC_BASE + 0x20000000UL) /*!< FSMC Bank3 base address */ #define FSMC_BANK4 (FSMC_BASE + 0x30000000UL) /*!< FSMC Bank4 base address */ #define FSMC_BANK1_R_BASE (FSMC_R_BASE + 0x00000000UL) /*!< FSMC Bank1 registers base address */ #define FSMC_BANK1E_R_BASE (FSMC_R_BASE + 0x00000104UL) /*!< FSMC Bank1E registers base address */ #define FSMC_BANK2_3_R_BASE (FSMC_R_BASE + 0x00000060UL) /*!< FSMC Bank2/Bank3 registers base address */ #define FSMC_BANK4_R_BASE (FSMC_R_BASE + 0x000000A0UL) /*!< FSMC Bank4 registers base address */ #define DBGMCU_BASE 0xE0042000UL /*!< Debug MCU registers base address */ /* USB device FS */ #define USB_BASE (APB1PERIPH_BASE + 0x00005C00UL) /*!< USB_IP Peripheral Registers base address */ #define USB_PMAADDR (APB1PERIPH_BASE + 0x00006000UL) /*!< USB_IP Packet Memory Area base address */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *)TIM2_BASE) #define TIM3 ((TIM_TypeDef *)TIM3_BASE) #define TIM4 ((TIM_TypeDef *)TIM4_BASE) #define TIM5 ((TIM_TypeDef *)TIM5_BASE) #define TIM6 ((TIM_TypeDef *)TIM6_BASE) #define TIM7 ((TIM_TypeDef *)TIM7_BASE) #define RTC ((RTC_TypeDef *)RTC_BASE) #define WWDG ((WWDG_TypeDef *)WWDG_BASE) #define IWDG ((IWDG_TypeDef *)IWDG_BASE) #define SPI2 ((SPI_TypeDef *)SPI2_BASE) #define SPI3 ((SPI_TypeDef *)SPI3_BASE) #define USART2 ((USART_TypeDef *)USART2_BASE) #define USART3 ((USART_TypeDef *)USART3_BASE) #define UART4 ((USART_TypeDef *)UART4_BASE) #define UART5 ((USART_TypeDef *)UART5_BASE) #define I2C1 ((I2C_TypeDef *)I2C1_BASE) #define I2C2 ((I2C_TypeDef *)I2C2_BASE) #define USB ((USB_TypeDef *)USB_BASE) #define CAN1 ((CAN_TypeDef *)CAN1_BASE) #define BKP ((BKP_TypeDef *)BKP_BASE) #define PWR ((PWR_TypeDef *)PWR_BASE) #define DAC1 ((DAC_TypeDef *)DAC_BASE) #define DAC ((DAC_TypeDef *)DAC_BASE) /* Kept for legacy purpose */ #define AFIO ((AFIO_TypeDef *)AFIO_BASE) #define EXTI ((EXTI_TypeDef *)EXTI_BASE) #define GPIOA ((GPIO_TypeDef *)GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *)GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *)GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *)GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *)GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *)GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *)GPIOG_BASE) #define ADC1 ((ADC_TypeDef *)ADC1_BASE) #define ADC2 ((ADC_TypeDef *)ADC2_BASE) #define ADC3 ((ADC_TypeDef *)ADC3_BASE) #define ADC12_COMMON ((ADC_Common_TypeDef *)ADC1_BASE) #define TIM1 ((TIM_TypeDef *)TIM1_BASE) #define SPI1 ((SPI_TypeDef *)SPI1_BASE) #define TIM8 ((TIM_TypeDef *)TIM8_BASE) #define USART1 ((USART_TypeDef *)USART1_BASE) #define SDIO ((SDIO_TypeDef *)SDIO_BASE) #define DMA1 ((DMA_TypeDef *)DMA1_BASE) #define DMA2 ((DMA_TypeDef *)DMA2_BASE) #define DMA1_Channel1 ((DMA_Channel_TypeDef *)DMA1_Channel1_BASE) #define DMA1_Channel2 ((DMA_Channel_TypeDef *)DMA1_Channel2_BASE) #define DMA1_Channel3 ((DMA_Channel_TypeDef *)DMA1_Channel3_BASE) #define DMA1_Channel4 ((DMA_Channel_TypeDef *)DMA1_Channel4_BASE) #define DMA1_Channel5 ((DMA_Channel_TypeDef *)DMA1_Channel5_BASE) #define DMA1_Channel6 ((DMA_Channel_TypeDef *)DMA1_Channel6_BASE) #define DMA1_Channel7 ((DMA_Channel_TypeDef *)DMA1_Channel7_BASE) #define DMA2_Channel1 ((DMA_Channel_TypeDef *)DMA2_Channel1_BASE) #define DMA2_Channel2 ((DMA_Channel_TypeDef *)DMA2_Channel2_BASE) #define DMA2_Channel3 ((DMA_Channel_TypeDef *)DMA2_Channel3_BASE) #define DMA2_Channel4 ((DMA_Channel_TypeDef *)DMA2_Channel4_BASE) #define DMA2_Channel5 ((DMA_Channel_TypeDef *)DMA2_Channel5_BASE) #define RCC ((RCC_TypeDef *)RCC_BASE) #define CRC ((CRC_TypeDef *)CRC_BASE) #define FLASH ((FLASH_TypeDef *)FLASH_R_BASE) #define OB ((OB_TypeDef *)OB_BASE) #define FSMC_Bank1 ((FSMC_Bank1_TypeDef *)FSMC_BANK1_R_BASE) #define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *)FSMC_BANK1E_R_BASE) #define FSMC_Bank2_3 ((FSMC_Bank2_3_TypeDef *)FSMC_BANK2_3_R_BASE) #define FSMC_Bank4 ((FSMC_Bank4_TypeDef *)FSMC_BANK4_R_BASE) #define DBGMCU ((DBGMCU_TypeDef *)DBGMCU_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* CRC calculation unit (CRC) */ /* */ /******************************************************************************/ /******************* Bit definition for CRC_DR register *********************/ #define CRC_DR_DR_Pos (0U) #define CRC_DR_DR_Msk (0xFFFFFFFFUL << CRC_DR_DR_Pos) /*!< 0xFFFFFFFF */ #define CRC_DR_DR CRC_DR_DR_Msk /*!< Data register bits */ /******************* Bit definition for CRC_IDR register ********************/ #define CRC_IDR_IDR_Pos (0U) #define CRC_IDR_IDR_Msk (0xFFUL << CRC_IDR_IDR_Pos) /*!< 0x000000FF */ #define CRC_IDR_IDR CRC_IDR_IDR_Msk /*!< General-purpose 8-bit data register bits */ /******************** Bit definition for CRC_CR register ********************/ #define CRC_CR_RESET_Pos (0U) #define CRC_CR_RESET_Msk (0x1UL << CRC_CR_RESET_Pos) /*!< 0x00000001 */ #define CRC_CR_RESET CRC_CR_RESET_Msk /*!< RESET bit */ /******************************************************************************/ /* */ /* Power Control */ /* */ /******************************************************************************/ /******************** Bit definition for PWR_CR register ********************/ #define PWR_CR_LPDS_Pos (0U) #define PWR_CR_LPDS_Msk (0x1UL << PWR_CR_LPDS_Pos) /*!< 0x00000001 */ #define PWR_CR_LPDS PWR_CR_LPDS_Msk /*!< Low-Power Deepsleep */ #define PWR_CR_PDDS_Pos (1U) #define PWR_CR_PDDS_Msk (0x1UL << PWR_CR_PDDS_Pos) /*!< 0x00000002 */ #define PWR_CR_PDDS PWR_CR_PDDS_Msk /*!< Power Down Deepsleep */ #define PWR_CR_CWUF_Pos (2U) #define PWR_CR_CWUF_Msk (0x1UL << PWR_CR_CWUF_Pos) /*!< 0x00000004 */ #define PWR_CR_CWUF PWR_CR_CWUF_Msk /*!< Clear Wakeup Flag */ #define PWR_CR_CSBF_Pos (3U) #define PWR_CR_CSBF_Msk (0x1UL << PWR_CR_CSBF_Pos) /*!< 0x00000008 */ #define PWR_CR_CSBF PWR_CR_CSBF_Msk /*!< Clear Standby Flag */ #define PWR_CR_PVDE_Pos (4U) #define PWR_CR_PVDE_Msk (0x1UL << PWR_CR_PVDE_Pos) /*!< 0x00000010 */ #define PWR_CR_PVDE PWR_CR_PVDE_Msk /*!< Power Voltage Detector Enable */ #define PWR_CR_PLS_Pos (5U) #define PWR_CR_PLS_Msk (0x7UL << PWR_CR_PLS_Pos) /*!< 0x000000E0 */ #define PWR_CR_PLS PWR_CR_PLS_Msk /*!< PLS[2:0] bits (PVD Level Selection) */ #define PWR_CR_PLS_0 (0x1UL << PWR_CR_PLS_Pos) /*!< 0x00000020 */ #define PWR_CR_PLS_1 (0x2UL << PWR_CR_PLS_Pos) /*!< 0x00000040 */ #define PWR_CR_PLS_2 (0x4UL << PWR_CR_PLS_Pos) /*!< 0x00000080 */ /*!< PVD level configuration */ #define PWR_CR_PLS_LEV0 0x00000000U /*!< PVD level 2.2V */ #define PWR_CR_PLS_LEV1 0x00000020U /*!< PVD level 2.3V */ #define PWR_CR_PLS_LEV2 0x00000040U /*!< PVD level 2.4V */ #define PWR_CR_PLS_LEV3 0x00000060U /*!< PVD level 2.5V */ #define PWR_CR_PLS_LEV4 0x00000080U /*!< PVD level 2.6V */ #define PWR_CR_PLS_LEV5 0x000000A0U /*!< PVD level 2.7V */ #define PWR_CR_PLS_LEV6 0x000000C0U /*!< PVD level 2.8V */ #define PWR_CR_PLS_LEV7 0x000000E0U /*!< PVD level 2.9V */ /* Legacy defines */ #define PWR_CR_PLS_2V2 PWR_CR_PLS_LEV0 #define PWR_CR_PLS_2V3 PWR_CR_PLS_LEV1 #define PWR_CR_PLS_2V4 PWR_CR_PLS_LEV2 #define PWR_CR_PLS_2V5 PWR_CR_PLS_LEV3 #define PWR_CR_PLS_2V6 PWR_CR_PLS_LEV4 #define PWR_CR_PLS_2V7 PWR_CR_PLS_LEV5 #define PWR_CR_PLS_2V8 PWR_CR_PLS_LEV6 #define PWR_CR_PLS_2V9 PWR_CR_PLS_LEV7 #define PWR_CR_DBP_Pos (8U) #define PWR_CR_DBP_Msk (0x1UL << PWR_CR_DBP_Pos) /*!< 0x00000100 */ #define PWR_CR_DBP PWR_CR_DBP_Msk /*!< Disable Backup Domain write protection */ /******************* Bit definition for PWR_CSR register ********************/ #define PWR_CSR_WUF_Pos (0U) #define PWR_CSR_WUF_Msk (0x1UL << PWR_CSR_WUF_Pos) /*!< 0x00000001 */ #define PWR_CSR_WUF PWR_CSR_WUF_Msk /*!< Wakeup Flag */ #define PWR_CSR_SBF_Pos (1U) #define PWR_CSR_SBF_Msk (0x1UL << PWR_CSR_SBF_Pos) /*!< 0x00000002 */ #define PWR_CSR_SBF PWR_CSR_SBF_Msk /*!< Standby Flag */ #define PWR_CSR_PVDO_Pos (2U) #define PWR_CSR_PVDO_Msk (0x1UL << PWR_CSR_PVDO_Pos) /*!< 0x00000004 */ #define PWR_CSR_PVDO PWR_CSR_PVDO_Msk /*!< PVD Output */ #define PWR_CSR_EWUP_Pos (8U) #define PWR_CSR_EWUP_Msk (0x1UL << PWR_CSR_EWUP_Pos) /*!< 0x00000100 */ #define PWR_CSR_EWUP PWR_CSR_EWUP_Msk /*!< Enable WKUP pin */ /******************************************************************************/ /* */ /* Backup registers */ /* */ /******************************************************************************/ /******************* Bit definition for BKP_DR1 register ********************/ #define BKP_DR1_D_Pos (0U) #define BKP_DR1_D_Msk (0xFFFFUL << BKP_DR1_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR1_D BKP_DR1_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR2 register ********************/ #define BKP_DR2_D_Pos (0U) #define BKP_DR2_D_Msk (0xFFFFUL << BKP_DR2_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR2_D BKP_DR2_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR3 register ********************/ #define BKP_DR3_D_Pos (0U) #define BKP_DR3_D_Msk (0xFFFFUL << BKP_DR3_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR3_D BKP_DR3_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR4 register ********************/ #define BKP_DR4_D_Pos (0U) #define BKP_DR4_D_Msk (0xFFFFUL << BKP_DR4_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR4_D BKP_DR4_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR5 register ********************/ #define BKP_DR5_D_Pos (0U) #define BKP_DR5_D_Msk (0xFFFFUL << BKP_DR5_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR5_D BKP_DR5_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR6 register ********************/ #define BKP_DR6_D_Pos (0U) #define BKP_DR6_D_Msk (0xFFFFUL << BKP_DR6_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR6_D BKP_DR6_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR7 register ********************/ #define BKP_DR7_D_Pos (0U) #define BKP_DR7_D_Msk (0xFFFFUL << BKP_DR7_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR7_D BKP_DR7_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR8 register ********************/ #define BKP_DR8_D_Pos (0U) #define BKP_DR8_D_Msk (0xFFFFUL << BKP_DR8_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR8_D BKP_DR8_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR9 register ********************/ #define BKP_DR9_D_Pos (0U) #define BKP_DR9_D_Msk (0xFFFFUL << BKP_DR9_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR9_D BKP_DR9_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR10 register *******************/ #define BKP_DR10_D_Pos (0U) #define BKP_DR10_D_Msk (0xFFFFUL << BKP_DR10_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR10_D BKP_DR10_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR11 register *******************/ #define BKP_DR11_D_Pos (0U) #define BKP_DR11_D_Msk (0xFFFFUL << BKP_DR11_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR11_D BKP_DR11_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR12 register *******************/ #define BKP_DR12_D_Pos (0U) #define BKP_DR12_D_Msk (0xFFFFUL << BKP_DR12_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR12_D BKP_DR12_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR13 register *******************/ #define BKP_DR13_D_Pos (0U) #define BKP_DR13_D_Msk (0xFFFFUL << BKP_DR13_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR13_D BKP_DR13_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR14 register *******************/ #define BKP_DR14_D_Pos (0U) #define BKP_DR14_D_Msk (0xFFFFUL << BKP_DR14_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR14_D BKP_DR14_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR15 register *******************/ #define BKP_DR15_D_Pos (0U) #define BKP_DR15_D_Msk (0xFFFFUL << BKP_DR15_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR15_D BKP_DR15_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR16 register *******************/ #define BKP_DR16_D_Pos (0U) #define BKP_DR16_D_Msk (0xFFFFUL << BKP_DR16_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR16_D BKP_DR16_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR17 register *******************/ #define BKP_DR17_D_Pos (0U) #define BKP_DR17_D_Msk (0xFFFFUL << BKP_DR17_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR17_D BKP_DR17_D_Msk /*!< Backup data */ /****************** Bit definition for BKP_DR18 register ********************/ #define BKP_DR18_D_Pos (0U) #define BKP_DR18_D_Msk (0xFFFFUL << BKP_DR18_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR18_D BKP_DR18_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR19 register *******************/ #define BKP_DR19_D_Pos (0U) #define BKP_DR19_D_Msk (0xFFFFUL << BKP_DR19_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR19_D BKP_DR19_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR20 register *******************/ #define BKP_DR20_D_Pos (0U) #define BKP_DR20_D_Msk (0xFFFFUL << BKP_DR20_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR20_D BKP_DR20_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR21 register *******************/ #define BKP_DR21_D_Pos (0U) #define BKP_DR21_D_Msk (0xFFFFUL << BKP_DR21_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR21_D BKP_DR21_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR22 register *******************/ #define BKP_DR22_D_Pos (0U) #define BKP_DR22_D_Msk (0xFFFFUL << BKP_DR22_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR22_D BKP_DR22_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR23 register *******************/ #define BKP_DR23_D_Pos (0U) #define BKP_DR23_D_Msk (0xFFFFUL << BKP_DR23_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR23_D BKP_DR23_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR24 register *******************/ #define BKP_DR24_D_Pos (0U) #define BKP_DR24_D_Msk (0xFFFFUL << BKP_DR24_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR24_D BKP_DR24_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR25 register *******************/ #define BKP_DR25_D_Pos (0U) #define BKP_DR25_D_Msk (0xFFFFUL << BKP_DR25_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR25_D BKP_DR25_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR26 register *******************/ #define BKP_DR26_D_Pos (0U) #define BKP_DR26_D_Msk (0xFFFFUL << BKP_DR26_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR26_D BKP_DR26_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR27 register *******************/ #define BKP_DR27_D_Pos (0U) #define BKP_DR27_D_Msk (0xFFFFUL << BKP_DR27_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR27_D BKP_DR27_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR28 register *******************/ #define BKP_DR28_D_Pos (0U) #define BKP_DR28_D_Msk (0xFFFFUL << BKP_DR28_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR28_D BKP_DR28_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR29 register *******************/ #define BKP_DR29_D_Pos (0U) #define BKP_DR29_D_Msk (0xFFFFUL << BKP_DR29_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR29_D BKP_DR29_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR30 register *******************/ #define BKP_DR30_D_Pos (0U) #define BKP_DR30_D_Msk (0xFFFFUL << BKP_DR30_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR30_D BKP_DR30_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR31 register *******************/ #define BKP_DR31_D_Pos (0U) #define BKP_DR31_D_Msk (0xFFFFUL << BKP_DR31_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR31_D BKP_DR31_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR32 register *******************/ #define BKP_DR32_D_Pos (0U) #define BKP_DR32_D_Msk (0xFFFFUL << BKP_DR32_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR32_D BKP_DR32_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR33 register *******************/ #define BKP_DR33_D_Pos (0U) #define BKP_DR33_D_Msk (0xFFFFUL << BKP_DR33_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR33_D BKP_DR33_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR34 register *******************/ #define BKP_DR34_D_Pos (0U) #define BKP_DR34_D_Msk (0xFFFFUL << BKP_DR34_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR34_D BKP_DR34_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR35 register *******************/ #define BKP_DR35_D_Pos (0U) #define BKP_DR35_D_Msk (0xFFFFUL << BKP_DR35_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR35_D BKP_DR35_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR36 register *******************/ #define BKP_DR36_D_Pos (0U) #define BKP_DR36_D_Msk (0xFFFFUL << BKP_DR36_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR36_D BKP_DR36_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR37 register *******************/ #define BKP_DR37_D_Pos (0U) #define BKP_DR37_D_Msk (0xFFFFUL << BKP_DR37_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR37_D BKP_DR37_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR38 register *******************/ #define BKP_DR38_D_Pos (0U) #define BKP_DR38_D_Msk (0xFFFFUL << BKP_DR38_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR38_D BKP_DR38_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR39 register *******************/ #define BKP_DR39_D_Pos (0U) #define BKP_DR39_D_Msk (0xFFFFUL << BKP_DR39_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR39_D BKP_DR39_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR40 register *******************/ #define BKP_DR40_D_Pos (0U) #define BKP_DR40_D_Msk (0xFFFFUL << BKP_DR40_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR40_D BKP_DR40_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR41 register *******************/ #define BKP_DR41_D_Pos (0U) #define BKP_DR41_D_Msk (0xFFFFUL << BKP_DR41_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR41_D BKP_DR41_D_Msk /*!< Backup data */ /******************* Bit definition for BKP_DR42 register *******************/ #define BKP_DR42_D_Pos (0U) #define BKP_DR42_D_Msk (0xFFFFUL << BKP_DR42_D_Pos) /*!< 0x0000FFFF */ #define BKP_DR42_D BKP_DR42_D_Msk /*!< Backup data */ #define RTC_BKP_NUMBER 42 /****************** Bit definition for BKP_RTCCR register *******************/ #define BKP_RTCCR_CAL_Pos (0U) #define BKP_RTCCR_CAL_Msk (0x7FUL << BKP_RTCCR_CAL_Pos) /*!< 0x0000007F */ #define BKP_RTCCR_CAL BKP_RTCCR_CAL_Msk /*!< Calibration value */ #define BKP_RTCCR_CCO_Pos (7U) #define BKP_RTCCR_CCO_Msk (0x1UL << BKP_RTCCR_CCO_Pos) /*!< 0x00000080 */ #define BKP_RTCCR_CCO BKP_RTCCR_CCO_Msk /*!< Calibration Clock Output */ #define BKP_RTCCR_ASOE_Pos (8U) #define BKP_RTCCR_ASOE_Msk (0x1UL << BKP_RTCCR_ASOE_Pos) /*!< 0x00000100 */ #define BKP_RTCCR_ASOE BKP_RTCCR_ASOE_Msk /*!< Alarm or Second Output Enable */ #define BKP_RTCCR_ASOS_Pos (9U) #define BKP_RTCCR_ASOS_Msk (0x1UL << BKP_RTCCR_ASOS_Pos) /*!< 0x00000200 */ #define BKP_RTCCR_ASOS BKP_RTCCR_ASOS_Msk /*!< Alarm or Second Output Selection */ /******************** Bit definition for BKP_CR register ********************/ #define BKP_CR_TPE_Pos (0U) #define BKP_CR_TPE_Msk (0x1UL << BKP_CR_TPE_Pos) /*!< 0x00000001 */ #define BKP_CR_TPE BKP_CR_TPE_Msk /*!< TAMPER pin enable */ #define BKP_CR_TPAL_Pos (1U) #define BKP_CR_TPAL_Msk (0x1UL << BKP_CR_TPAL_Pos) /*!< 0x00000002 */ #define BKP_CR_TPAL BKP_CR_TPAL_Msk /*!< TAMPER pin active level */ /******************* Bit definition for BKP_CSR register ********************/ #define BKP_CSR_CTE_Pos (0U) #define BKP_CSR_CTE_Msk (0x1UL << BKP_CSR_CTE_Pos) /*!< 0x00000001 */ #define BKP_CSR_CTE BKP_CSR_CTE_Msk /*!< Clear Tamper event */ #define BKP_CSR_CTI_Pos (1U) #define BKP_CSR_CTI_Msk (0x1UL << BKP_CSR_CTI_Pos) /*!< 0x00000002 */ #define BKP_CSR_CTI BKP_CSR_CTI_Msk /*!< Clear Tamper Interrupt */ #define BKP_CSR_TPIE_Pos (2U) #define BKP_CSR_TPIE_Msk (0x1UL << BKP_CSR_TPIE_Pos) /*!< 0x00000004 */ #define BKP_CSR_TPIE BKP_CSR_TPIE_Msk /*!< TAMPER Pin interrupt enable */ #define BKP_CSR_TEF_Pos (8U) #define BKP_CSR_TEF_Msk (0x1UL << BKP_CSR_TEF_Pos) /*!< 0x00000100 */ #define BKP_CSR_TEF BKP_CSR_TEF_Msk /*!< Tamper Event Flag */ #define BKP_CSR_TIF_Pos (9U) #define BKP_CSR_TIF_Msk (0x1UL << BKP_CSR_TIF_Pos) /*!< 0x00000200 */ #define BKP_CSR_TIF BKP_CSR_TIF_Msk /*!< Tamper Interrupt Flag */ /******************************************************************************/ /* */ /* Reset and Clock Control */ /* */ /******************************************************************************/ /******************** Bit definition for RCC_CR register ********************/ #define RCC_CR_HSION_Pos (0U) #define RCC_CR_HSION_Msk (0x1UL << RCC_CR_HSION_Pos) /*!< 0x00000001 */ #define RCC_CR_HSION RCC_CR_HSION_Msk /*!< Internal High Speed clock enable */ #define RCC_CR_HSIRDY_Pos (1U) #define RCC_CR_HSIRDY_Msk (0x1UL << RCC_CR_HSIRDY_Pos) /*!< 0x00000002 */ #define RCC_CR_HSIRDY RCC_CR_HSIRDY_Msk /*!< Internal High Speed clock ready flag */ #define RCC_CR_HSITRIM_Pos (3U) #define RCC_CR_HSITRIM_Msk (0x1FUL << RCC_CR_HSITRIM_Pos) /*!< 0x000000F8 */ #define RCC_CR_HSITRIM RCC_CR_HSITRIM_Msk /*!< Internal High Speed clock trimming */ #define RCC_CR_HSICAL_Pos (8U) #define RCC_CR_HSICAL_Msk (0xFFUL << RCC_CR_HSICAL_Pos) /*!< 0x0000FF00 */ #define RCC_CR_HSICAL RCC_CR_HSICAL_Msk /*!< Internal High Speed clock Calibration */ #define RCC_CR_HSEON_Pos (16U) #define RCC_CR_HSEON_Msk (0x1UL << RCC_CR_HSEON_Pos) /*!< 0x00010000 */ #define RCC_CR_HSEON RCC_CR_HSEON_Msk /*!< External High Speed clock enable */ #define RCC_CR_HSERDY_Pos (17U) #define RCC_CR_HSERDY_Msk (0x1UL << RCC_CR_HSERDY_Pos) /*!< 0x00020000 */ #define RCC_CR_HSERDY RCC_CR_HSERDY_Msk /*!< External High Speed clock ready flag */ #define RCC_CR_HSEBYP_Pos (18U) #define RCC_CR_HSEBYP_Msk (0x1UL << RCC_CR_HSEBYP_Pos) /*!< 0x00040000 */ #define RCC_CR_HSEBYP RCC_CR_HSEBYP_Msk /*!< External High Speed clock Bypass */ #define RCC_CR_CSSON_Pos (19U) #define RCC_CR_CSSON_Msk (0x1UL << RCC_CR_CSSON_Pos) /*!< 0x00080000 */ #define RCC_CR_CSSON RCC_CR_CSSON_Msk /*!< Clock Security System enable */ #define RCC_CR_PLLON_Pos (24U) #define RCC_CR_PLLON_Msk (0x1UL << RCC_CR_PLLON_Pos) /*!< 0x01000000 */ #define RCC_CR_PLLON RCC_CR_PLLON_Msk /*!< PLL enable */ #define RCC_CR_PLLRDY_Pos (25U) #define RCC_CR_PLLRDY_Msk (0x1UL << RCC_CR_PLLRDY_Pos) /*!< 0x02000000 */ #define RCC_CR_PLLRDY RCC_CR_PLLRDY_Msk /*!< PLL clock ready flag */ /******************* Bit definition for RCC_CFGR register *******************/ /*!< SW configuration */ #define RCC_CFGR_SW_Pos (0U) #define RCC_CFGR_SW_Msk (0x3UL << RCC_CFGR_SW_Pos) /*!< 0x00000003 */ #define RCC_CFGR_SW RCC_CFGR_SW_Msk /*!< SW[1:0] bits (System clock Switch) */ #define RCC_CFGR_SW_0 (0x1UL << RCC_CFGR_SW_Pos) /*!< 0x00000001 */ #define RCC_CFGR_SW_1 (0x2UL << RCC_CFGR_SW_Pos) /*!< 0x00000002 */ #define RCC_CFGR_SW_HSI 0x00000000U /*!< HSI selected as system clock */ #define RCC_CFGR_SW_HSE 0x00000001U /*!< HSE selected as system clock */ #define RCC_CFGR_SW_PLL 0x00000002U /*!< PLL selected as system clock */ /*!< SWS configuration */ #define RCC_CFGR_SWS_Pos (2U) #define RCC_CFGR_SWS_Msk (0x3UL << RCC_CFGR_SWS_Pos) /*!< 0x0000000C */ #define RCC_CFGR_SWS RCC_CFGR_SWS_Msk /*!< SWS[1:0] bits (System Clock Switch Status) */ #define RCC_CFGR_SWS_0 (0x1UL << RCC_CFGR_SWS_Pos) /*!< 0x00000004 */ #define RCC_CFGR_SWS_1 (0x2UL << RCC_CFGR_SWS_Pos) /*!< 0x00000008 */ #define RCC_CFGR_SWS_HSI 0x00000000U /*!< HSI oscillator used as system clock */ #define RCC_CFGR_SWS_HSE 0x00000004U /*!< HSE oscillator used as system clock */ #define RCC_CFGR_SWS_PLL 0x00000008U /*!< PLL used as system clock */ /*!< HPRE configuration */ #define RCC_CFGR_HPRE_Pos (4U) #define RCC_CFGR_HPRE_Msk (0xFUL << RCC_CFGR_HPRE_Pos) /*!< 0x000000F0 */ #define RCC_CFGR_HPRE RCC_CFGR_HPRE_Msk /*!< HPRE[3:0] bits (AHB prescaler) */ #define RCC_CFGR_HPRE_0 (0x1UL << RCC_CFGR_HPRE_Pos) /*!< 0x00000010 */ #define RCC_CFGR_HPRE_1 (0x2UL << RCC_CFGR_HPRE_Pos) /*!< 0x00000020 */ #define RCC_CFGR_HPRE_2 (0x4UL << RCC_CFGR_HPRE_Pos) /*!< 0x00000040 */ #define RCC_CFGR_HPRE_3 (0x8UL << RCC_CFGR_HPRE_Pos) /*!< 0x00000080 */ #define RCC_CFGR_HPRE_DIV1 0x00000000U /*!< SYSCLK not divided */ #define RCC_CFGR_HPRE_DIV2 0x00000080U /*!< SYSCLK divided by 2 */ #define RCC_CFGR_HPRE_DIV4 0x00000090U /*!< SYSCLK divided by 4 */ #define RCC_CFGR_HPRE_DIV8 0x000000A0U /*!< SYSCLK divided by 8 */ #define RCC_CFGR_HPRE_DIV16 0x000000B0U /*!< SYSCLK divided by 16 */ #define RCC_CFGR_HPRE_DIV64 0x000000C0U /*!< SYSCLK divided by 64 */ #define RCC_CFGR_HPRE_DIV128 0x000000D0U /*!< SYSCLK divided by 128 */ #define RCC_CFGR_HPRE_DIV256 0x000000E0U /*!< SYSCLK divided by 256 */ #define RCC_CFGR_HPRE_DIV512 0x000000F0U /*!< SYSCLK divided by 512 */ /*!< PPRE1 configuration */ #define RCC_CFGR_PPRE1_Pos (8U) #define RCC_CFGR_PPRE1_Msk (0x7UL << RCC_CFGR_PPRE1_Pos) /*!< 0x00000700 */ #define RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_Msk /*!< PRE1[2:0] bits (APB1 prescaler) */ #define RCC_CFGR_PPRE1_0 (0x1UL << RCC_CFGR_PPRE1_Pos) /*!< 0x00000100 */ #define RCC_CFGR_PPRE1_1 (0x2UL << RCC_CFGR_PPRE1_Pos) /*!< 0x00000200 */ #define RCC_CFGR_PPRE1_2 (0x4UL << RCC_CFGR_PPRE1_Pos) /*!< 0x00000400 */ #define RCC_CFGR_PPRE1_DIV1 0x00000000U /*!< HCLK not divided */ #define RCC_CFGR_PPRE1_DIV2 0x00000400U /*!< HCLK divided by 2 */ #define RCC_CFGR_PPRE1_DIV4 0x00000500U /*!< HCLK divided by 4 */ #define RCC_CFGR_PPRE1_DIV8 0x00000600U /*!< HCLK divided by 8 */ #define RCC_CFGR_PPRE1_DIV16 0x00000700U /*!< HCLK divided by 16 */ /*!< PPRE2 configuration */ #define RCC_CFGR_PPRE2_Pos (11U) #define RCC_CFGR_PPRE2_Msk (0x7UL << RCC_CFGR_PPRE2_Pos) /*!< 0x00003800 */ #define RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_Msk /*!< PRE2[2:0] bits (APB2 prescaler) */ #define RCC_CFGR_PPRE2_0 (0x1UL << RCC_CFGR_PPRE2_Pos) /*!< 0x00000800 */ #define RCC_CFGR_PPRE2_1 (0x2UL << RCC_CFGR_PPRE2_Pos) /*!< 0x00001000 */ #define RCC_CFGR_PPRE2_2 (0x4UL << RCC_CFGR_PPRE2_Pos) /*!< 0x00002000 */ #define RCC_CFGR_PPRE2_DIV1 0x00000000U /*!< HCLK not divided */ #define RCC_CFGR_PPRE2_DIV2 0x00002000U /*!< HCLK divided by 2 */ #define RCC_CFGR_PPRE2_DIV4 0x00002800U /*!< HCLK divided by 4 */ #define RCC_CFGR_PPRE2_DIV8 0x00003000U /*!< HCLK divided by 8 */ #define RCC_CFGR_PPRE2_DIV16 0x00003800U /*!< HCLK divided by 16 */ /*!< ADCPPRE configuration */ #define RCC_CFGR_ADCPRE_Pos (14U) #define RCC_CFGR_ADCPRE_Msk (0x3UL << RCC_CFGR_ADCPRE_Pos) /*!< 0x0000C000 */ #define RCC_CFGR_ADCPRE RCC_CFGR_ADCPRE_Msk /*!< ADCPRE[1:0] bits (ADC prescaler) */ #define RCC_CFGR_ADCPRE_0 (0x1UL << RCC_CFGR_ADCPRE_Pos) /*!< 0x00004000 */ #define RCC_CFGR_ADCPRE_1 (0x2UL << RCC_CFGR_ADCPRE_Pos) /*!< 0x00008000 */ #define RCC_CFGR_ADCPRE_DIV2 0x00000000U /*!< PCLK2 divided by 2 */ #define RCC_CFGR_ADCPRE_DIV4 0x00004000U /*!< PCLK2 divided by 4 */ #define RCC_CFGR_ADCPRE_DIV6 0x00008000U /*!< PCLK2 divided by 6 */ #define RCC_CFGR_ADCPRE_DIV8 0x0000C000U /*!< PCLK2 divided by 8 */ #define RCC_CFGR_PLLSRC_Pos (16U) #define RCC_CFGR_PLLSRC_Msk (0x1UL << RCC_CFGR_PLLSRC_Pos) /*!< 0x00010000 */ #define RCC_CFGR_PLLSRC RCC_CFGR_PLLSRC_Msk /*!< PLL entry clock source */ #define RCC_CFGR_PLLXTPRE_Pos (17U) #define RCC_CFGR_PLLXTPRE_Msk (0x1UL << RCC_CFGR_PLLXTPRE_Pos) /*!< 0x00020000 */ #define RCC_CFGR_PLLXTPRE RCC_CFGR_PLLXTPRE_Msk /*!< HSE divider for PLL entry */ /*!< PLLMUL configuration */ #define RCC_CFGR_PLLMULL_Pos (18U) #define RCC_CFGR_PLLMULL_Msk (0xFUL << RCC_CFGR_PLLMULL_Pos) /*!< 0x003C0000 */ #define RCC_CFGR_PLLMULL RCC_CFGR_PLLMULL_Msk /*!< PLLMUL[3:0] bits (PLL multiplication factor) */ #define RCC_CFGR_PLLMULL_0 (0x1UL << RCC_CFGR_PLLMULL_Pos) /*!< 0x00040000 */ #define RCC_CFGR_PLLMULL_1 (0x2UL << RCC_CFGR_PLLMULL_Pos) /*!< 0x00080000 */ #define RCC_CFGR_PLLMULL_2 (0x4UL << RCC_CFGR_PLLMULL_Pos) /*!< 0x00100000 */ #define RCC_CFGR_PLLMULL_3 (0x8UL << RCC_CFGR_PLLMULL_Pos) /*!< 0x00200000 */ #define RCC_CFGR_PLLXTPRE_HSE 0x00000000U /*!< HSE clock not divided for PLL entry */ #define RCC_CFGR_PLLXTPRE_HSE_DIV2 0x00020000U /*!< HSE clock divided by 2 for PLL entry */ #define RCC_CFGR_PLLMULL2 0x00000000U /*!< PLL input clock*2 */ #define RCC_CFGR_PLLMULL3_Pos (18U) #define RCC_CFGR_PLLMULL3_Msk (0x1UL << RCC_CFGR_PLLMULL3_Pos) /*!< 0x00040000 */ #define RCC_CFGR_PLLMULL3 RCC_CFGR_PLLMULL3_Msk /*!< PLL input clock*3 */ #define RCC_CFGR_PLLMULL4_Pos (19U) #define RCC_CFGR_PLLMULL4_Msk (0x1UL << RCC_CFGR_PLLMULL4_Pos) /*!< 0x00080000 */ #define RCC_CFGR_PLLMULL4 RCC_CFGR_PLLMULL4_Msk /*!< PLL input clock*4 */ #define RCC_CFGR_PLLMULL5_Pos (18U) #define RCC_CFGR_PLLMULL5_Msk (0x3UL << RCC_CFGR_PLLMULL5_Pos) /*!< 0x000C0000 */ #define RCC_CFGR_PLLMULL5 RCC_CFGR_PLLMULL5_Msk /*!< PLL input clock*5 */ #define RCC_CFGR_PLLMULL6_Pos (20U) #define RCC_CFGR_PLLMULL6_Msk (0x1UL << RCC_CFGR_PLLMULL6_Pos) /*!< 0x00100000 */ #define RCC_CFGR_PLLMULL6 RCC_CFGR_PLLMULL6_Msk /*!< PLL input clock*6 */ #define RCC_CFGR_PLLMULL7_Pos (18U) #define RCC_CFGR_PLLMULL7_Msk (0x5UL << RCC_CFGR_PLLMULL7_Pos) /*!< 0x00140000 */ #define RCC_CFGR_PLLMULL7 RCC_CFGR_PLLMULL7_Msk /*!< PLL input clock*7 */ #define RCC_CFGR_PLLMULL8_Pos (19U) #define RCC_CFGR_PLLMULL8_Msk (0x3UL << RCC_CFGR_PLLMULL8_Pos) /*!< 0x00180000 */ #define RCC_CFGR_PLLMULL8 RCC_CFGR_PLLMULL8_Msk /*!< PLL input clock*8 */ #define RCC_CFGR_PLLMULL9_Pos (18U) #define RCC_CFGR_PLLMULL9_Msk (0x7UL << RCC_CFGR_PLLMULL9_Pos) /*!< 0x001C0000 */ #define RCC_CFGR_PLLMULL9 RCC_CFGR_PLLMULL9_Msk /*!< PLL input clock*9 */ #define RCC_CFGR_PLLMULL10_Pos (21U) #define RCC_CFGR_PLLMULL10_Msk (0x1UL << RCC_CFGR_PLLMULL10_Pos) /*!< 0x00200000 */ #define RCC_CFGR_PLLMULL10 RCC_CFGR_PLLMULL10_Msk /*!< PLL input clock10 */ #define RCC_CFGR_PLLMULL11_Pos (18U) #define RCC_CFGR_PLLMULL11_Msk (0x9UL << RCC_CFGR_PLLMULL11_Pos) /*!< 0x00240000 */ #define RCC_CFGR_PLLMULL11 RCC_CFGR_PLLMULL11_Msk /*!< PLL input clock*11 */ #define RCC_CFGR_PLLMULL12_Pos (19U) #define RCC_CFGR_PLLMULL12_Msk (0x5UL << RCC_CFGR_PLLMULL12_Pos) /*!< 0x00280000 */ #define RCC_CFGR_PLLMULL12 RCC_CFGR_PLLMULL12_Msk /*!< PLL input clock*12 */ #define RCC_CFGR_PLLMULL13_Pos (18U) #define RCC_CFGR_PLLMULL13_Msk (0xBUL << RCC_CFGR_PLLMULL13_Pos) /*!< 0x002C0000 */ #define RCC_CFGR_PLLMULL13 RCC_CFGR_PLLMULL13_Msk /*!< PLL input clock*13 */ #define RCC_CFGR_PLLMULL14_Pos (20U) #define RCC_CFGR_PLLMULL14_Msk (0x3UL << RCC_CFGR_PLLMULL14_Pos) /*!< 0x00300000 */ #define RCC_CFGR_PLLMULL14 RCC_CFGR_PLLMULL14_Msk /*!< PLL input clock*14 */ #define RCC_CFGR_PLLMULL15_Pos (18U) #define RCC_CFGR_PLLMULL15_Msk (0xDUL << RCC_CFGR_PLLMULL15_Pos) /*!< 0x00340000 */ #define RCC_CFGR_PLLMULL15 RCC_CFGR_PLLMULL15_Msk /*!< PLL input clock*15 */ #define RCC_CFGR_PLLMULL16_Pos (19U) #define RCC_CFGR_PLLMULL16_Msk (0x7UL << RCC_CFGR_PLLMULL16_Pos) /*!< 0x00380000 */ #define RCC_CFGR_PLLMULL16 RCC_CFGR_PLLMULL16_Msk /*!< PLL input clock*16 */ #define RCC_CFGR_USBPRE_Pos (22U) #define RCC_CFGR_USBPRE_Msk (0x1UL << RCC_CFGR_USBPRE_Pos) /*!< 0x00400000 */ #define RCC_CFGR_USBPRE RCC_CFGR_USBPRE_Msk /*!< USB Device prescaler */ /*!< MCO configuration */ #define RCC_CFGR_MCO_Pos (24U) #define RCC_CFGR_MCO_Msk (0x7UL << RCC_CFGR_MCO_Pos) /*!< 0x07000000 */ #define RCC_CFGR_MCO RCC_CFGR_MCO_Msk /*!< MCO[2:0] bits (Microcontroller Clock Output) */ #define RCC_CFGR_MCO_0 (0x1UL << RCC_CFGR_MCO_Pos) /*!< 0x01000000 */ #define RCC_CFGR_MCO_1 (0x2UL << RCC_CFGR_MCO_Pos) /*!< 0x02000000 */ #define RCC_CFGR_MCO_2 (0x4UL << RCC_CFGR_MCO_Pos) /*!< 0x04000000 */ #define RCC_CFGR_MCO_NOCLOCK 0x00000000U /*!< No clock */ #define RCC_CFGR_MCO_SYSCLK 0x04000000U /*!< System clock selected as MCO source */ #define RCC_CFGR_MCO_HSI 0x05000000U /*!< HSI clock selected as MCO source */ #define RCC_CFGR_MCO_HSE 0x06000000U /*!< HSE clock selected as MCO source */ #define RCC_CFGR_MCO_PLLCLK_DIV2 0x07000000U /*!< PLL clock divided by 2 selected as MCO source */ /* Reference defines */ #define RCC_CFGR_MCOSEL RCC_CFGR_MCO #define RCC_CFGR_MCOSEL_0 RCC_CFGR_MCO_0 #define RCC_CFGR_MCOSEL_1 RCC_CFGR_MCO_1 #define RCC_CFGR_MCOSEL_2 RCC_CFGR_MCO_2 #define RCC_CFGR_MCOSEL_NOCLOCK RCC_CFGR_MCO_NOCLOCK #define RCC_CFGR_MCOSEL_SYSCLK RCC_CFGR_MCO_SYSCLK #define RCC_CFGR_MCOSEL_HSI RCC_CFGR_MCO_HSI #define RCC_CFGR_MCOSEL_HSE RCC_CFGR_MCO_HSE #define RCC_CFGR_MCOSEL_PLL_DIV2 RCC_CFGR_MCO_PLLCLK_DIV2 /*!<****************** Bit definition for RCC_CIR register ********************/ #define RCC_CIR_LSIRDYF_Pos (0U) #define RCC_CIR_LSIRDYF_Msk (0x1UL << RCC_CIR_LSIRDYF_Pos) /*!< 0x00000001 */ #define RCC_CIR_LSIRDYF RCC_CIR_LSIRDYF_Msk /*!< LSI Ready Interrupt flag */ #define RCC_CIR_LSERDYF_Pos (1U) #define RCC_CIR_LSERDYF_Msk (0x1UL << RCC_CIR_LSERDYF_Pos) /*!< 0x00000002 */ #define RCC_CIR_LSERDYF RCC_CIR_LSERDYF_Msk /*!< LSE Ready Interrupt flag */ #define RCC_CIR_HSIRDYF_Pos (2U) #define RCC_CIR_HSIRDYF_Msk (0x1UL << RCC_CIR_HSIRDYF_Pos) /*!< 0x00000004 */ #define RCC_CIR_HSIRDYF RCC_CIR_HSIRDYF_Msk /*!< HSI Ready Interrupt flag */ #define RCC_CIR_HSERDYF_Pos (3U) #define RCC_CIR_HSERDYF_Msk (0x1UL << RCC_CIR_HSERDYF_Pos) /*!< 0x00000008 */ #define RCC_CIR_HSERDYF RCC_CIR_HSERDYF_Msk /*!< HSE Ready Interrupt flag */ #define RCC_CIR_PLLRDYF_Pos (4U) #define RCC_CIR_PLLRDYF_Msk (0x1UL << RCC_CIR_PLLRDYF_Pos) /*!< 0x00000010 */ #define RCC_CIR_PLLRDYF RCC_CIR_PLLRDYF_Msk /*!< PLL Ready Interrupt flag */ #define RCC_CIR_CSSF_Pos (7U) #define RCC_CIR_CSSF_Msk (0x1UL << RCC_CIR_CSSF_Pos) /*!< 0x00000080 */ #define RCC_CIR_CSSF RCC_CIR_CSSF_Msk /*!< Clock Security System Interrupt flag */ #define RCC_CIR_LSIRDYIE_Pos (8U) #define RCC_CIR_LSIRDYIE_Msk (0x1UL << RCC_CIR_LSIRDYIE_Pos) /*!< 0x00000100 */ #define RCC_CIR_LSIRDYIE RCC_CIR_LSIRDYIE_Msk /*!< LSI Ready Interrupt Enable */ #define RCC_CIR_LSERDYIE_Pos (9U) #define RCC_CIR_LSERDYIE_Msk (0x1UL << RCC_CIR_LSERDYIE_Pos) /*!< 0x00000200 */ #define RCC_CIR_LSERDYIE RCC_CIR_LSERDYIE_Msk /*!< LSE Ready Interrupt Enable */ #define RCC_CIR_HSIRDYIE_Pos (10U) #define RCC_CIR_HSIRDYIE_Msk (0x1UL << RCC_CIR_HSIRDYIE_Pos) /*!< 0x00000400 */ #define RCC_CIR_HSIRDYIE RCC_CIR_HSIRDYIE_Msk /*!< HSI Ready Interrupt Enable */ #define RCC_CIR_HSERDYIE_Pos (11U) #define RCC_CIR_HSERDYIE_Msk (0x1UL << RCC_CIR_HSERDYIE_Pos) /*!< 0x00000800 */ #define RCC_CIR_HSERDYIE RCC_CIR_HSERDYIE_Msk /*!< HSE Ready Interrupt Enable */ #define RCC_CIR_PLLRDYIE_Pos (12U) #define RCC_CIR_PLLRDYIE_Msk (0x1UL << RCC_CIR_PLLRDYIE_Pos) /*!< 0x00001000 */ #define RCC_CIR_PLLRDYIE RCC_CIR_PLLRDYIE_Msk /*!< PLL Ready Interrupt Enable */ #define RCC_CIR_LSIRDYC_Pos (16U) #define RCC_CIR_LSIRDYC_Msk (0x1UL << RCC_CIR_LSIRDYC_Pos) /*!< 0x00010000 */ #define RCC_CIR_LSIRDYC RCC_CIR_LSIRDYC_Msk /*!< LSI Ready Interrupt Clear */ #define RCC_CIR_LSERDYC_Pos (17U) #define RCC_CIR_LSERDYC_Msk (0x1UL << RCC_CIR_LSERDYC_Pos) /*!< 0x00020000 */ #define RCC_CIR_LSERDYC RCC_CIR_LSERDYC_Msk /*!< LSE Ready Interrupt Clear */ #define RCC_CIR_HSIRDYC_Pos (18U) #define RCC_CIR_HSIRDYC_Msk (0x1UL << RCC_CIR_HSIRDYC_Pos) /*!< 0x00040000 */ #define RCC_CIR_HSIRDYC RCC_CIR_HSIRDYC_Msk /*!< HSI Ready Interrupt Clear */ #define RCC_CIR_HSERDYC_Pos (19U) #define RCC_CIR_HSERDYC_Msk (0x1UL << RCC_CIR_HSERDYC_Pos) /*!< 0x00080000 */ #define RCC_CIR_HSERDYC RCC_CIR_HSERDYC_Msk /*!< HSE Ready Interrupt Clear */ #define RCC_CIR_PLLRDYC_Pos (20U) #define RCC_CIR_PLLRDYC_Msk (0x1UL << RCC_CIR_PLLRDYC_Pos) /*!< 0x00100000 */ #define RCC_CIR_PLLRDYC RCC_CIR_PLLRDYC_Msk /*!< PLL Ready Interrupt Clear */ #define RCC_CIR_CSSC_Pos (23U) #define RCC_CIR_CSSC_Msk (0x1UL << RCC_CIR_CSSC_Pos) /*!< 0x00800000 */ #define RCC_CIR_CSSC RCC_CIR_CSSC_Msk /*!< Clock Security System Interrupt Clear */ /***************** Bit definition for RCC_APB2RSTR register *****************/ #define RCC_APB2RSTR_AFIORST_Pos (0U) #define RCC_APB2RSTR_AFIORST_Msk (0x1UL << RCC_APB2RSTR_AFIORST_Pos) /*!< 0x00000001 */ #define RCC_APB2RSTR_AFIORST RCC_APB2RSTR_AFIORST_Msk /*!< Alternate Function I/O reset */ #define RCC_APB2RSTR_IOPARST_Pos (2U) #define RCC_APB2RSTR_IOPARST_Msk (0x1UL << RCC_APB2RSTR_IOPARST_Pos) /*!< 0x00000004 */ #define RCC_APB2RSTR_IOPARST RCC_APB2RSTR_IOPARST_Msk /*!< I/O port A reset */ #define RCC_APB2RSTR_IOPBRST_Pos (3U) #define RCC_APB2RSTR_IOPBRST_Msk (0x1UL << RCC_APB2RSTR_IOPBRST_Pos) /*!< 0x00000008 */ #define RCC_APB2RSTR_IOPBRST RCC_APB2RSTR_IOPBRST_Msk /*!< I/O port B reset */ #define RCC_APB2RSTR_IOPCRST_Pos (4U) #define RCC_APB2RSTR_IOPCRST_Msk (0x1UL << RCC_APB2RSTR_IOPCRST_Pos) /*!< 0x00000010 */ #define RCC_APB2RSTR_IOPCRST RCC_APB2RSTR_IOPCRST_Msk /*!< I/O port C reset */ #define RCC_APB2RSTR_IOPDRST_Pos (5U) #define RCC_APB2RSTR_IOPDRST_Msk (0x1UL << RCC_APB2RSTR_IOPDRST_Pos) /*!< 0x00000020 */ #define RCC_APB2RSTR_IOPDRST RCC_APB2RSTR_IOPDRST_Msk /*!< I/O port D reset */ #define RCC_APB2RSTR_ADC1RST_Pos (9U) #define RCC_APB2RSTR_ADC1RST_Msk (0x1UL << RCC_APB2RSTR_ADC1RST_Pos) /*!< 0x00000200 */ #define RCC_APB2RSTR_ADC1RST RCC_APB2RSTR_ADC1RST_Msk /*!< ADC 1 interface reset */ #define RCC_APB2RSTR_ADC2RST_Pos (10U) #define RCC_APB2RSTR_ADC2RST_Msk (0x1UL << RCC_APB2RSTR_ADC2RST_Pos) /*!< 0x00000400 */ #define RCC_APB2RSTR_ADC2RST RCC_APB2RSTR_ADC2RST_Msk /*!< ADC 2 interface reset */ #define RCC_APB2RSTR_TIM1RST_Pos (11U) #define RCC_APB2RSTR_TIM1RST_Msk (0x1UL << RCC_APB2RSTR_TIM1RST_Pos) /*!< 0x00000800 */ #define RCC_APB2RSTR_TIM1RST RCC_APB2RSTR_TIM1RST_Msk /*!< TIM1 Timer reset */ #define RCC_APB2RSTR_SPI1RST_Pos (12U) #define RCC_APB2RSTR_SPI1RST_Msk (0x1UL << RCC_APB2RSTR_SPI1RST_Pos) /*!< 0x00001000 */ #define RCC_APB2RSTR_SPI1RST RCC_APB2RSTR_SPI1RST_Msk /*!< SPI 1 reset */ #define RCC_APB2RSTR_USART1RST_Pos (14U) #define RCC_APB2RSTR_USART1RST_Msk (0x1UL << RCC_APB2RSTR_USART1RST_Pos) /*!< 0x00004000 */ #define RCC_APB2RSTR_USART1RST RCC_APB2RSTR_USART1RST_Msk /*!< USART1 reset */ #define RCC_APB2RSTR_IOPERST_Pos (6U) #define RCC_APB2RSTR_IOPERST_Msk (0x1UL << RCC_APB2RSTR_IOPERST_Pos) /*!< 0x00000040 */ #define RCC_APB2RSTR_IOPERST RCC_APB2RSTR_IOPERST_Msk /*!< I/O port E reset */ #define RCC_APB2RSTR_IOPFRST_Pos (7U) #define RCC_APB2RSTR_IOPFRST_Msk (0x1UL << RCC_APB2RSTR_IOPFRST_Pos) /*!< 0x00000080 */ #define RCC_APB2RSTR_IOPFRST RCC_APB2RSTR_IOPFRST_Msk /*!< I/O port F reset */ #define RCC_APB2RSTR_IOPGRST_Pos (8U) #define RCC_APB2RSTR_IOPGRST_Msk (0x1UL << RCC_APB2RSTR_IOPGRST_Pos) /*!< 0x00000100 */ #define RCC_APB2RSTR_IOPGRST RCC_APB2RSTR_IOPGRST_Msk /*!< I/O port G reset */ #define RCC_APB2RSTR_TIM8RST_Pos (13U) #define RCC_APB2RSTR_TIM8RST_Msk (0x1UL << RCC_APB2RSTR_TIM8RST_Pos) /*!< 0x00002000 */ #define RCC_APB2RSTR_TIM8RST RCC_APB2RSTR_TIM8RST_Msk /*!< TIM8 Timer reset */ #define RCC_APB2RSTR_ADC3RST_Pos (15U) #define RCC_APB2RSTR_ADC3RST_Msk (0x1UL << RCC_APB2RSTR_ADC3RST_Pos) /*!< 0x00008000 */ #define RCC_APB2RSTR_ADC3RST RCC_APB2RSTR_ADC3RST_Msk /*!< ADC3 interface reset */ /***************** Bit definition for RCC_APB1RSTR register *****************/ #define RCC_APB1RSTR_TIM2RST_Pos (0U) #define RCC_APB1RSTR_TIM2RST_Msk (0x1UL << RCC_APB1RSTR_TIM2RST_Pos) /*!< 0x00000001 */ #define RCC_APB1RSTR_TIM2RST RCC_APB1RSTR_TIM2RST_Msk /*!< Timer 2 reset */ #define RCC_APB1RSTR_TIM3RST_Pos (1U) #define RCC_APB1RSTR_TIM3RST_Msk (0x1UL << RCC_APB1RSTR_TIM3RST_Pos) /*!< 0x00000002 */ #define RCC_APB1RSTR_TIM3RST RCC_APB1RSTR_TIM3RST_Msk /*!< Timer 3 reset */ #define RCC_APB1RSTR_WWDGRST_Pos (11U) #define RCC_APB1RSTR_WWDGRST_Msk (0x1UL << RCC_APB1RSTR_WWDGRST_Pos) /*!< 0x00000800 */ #define RCC_APB1RSTR_WWDGRST RCC_APB1RSTR_WWDGRST_Msk /*!< Window Watchdog reset */ #define RCC_APB1RSTR_USART2RST_Pos (17U) #define RCC_APB1RSTR_USART2RST_Msk (0x1UL << RCC_APB1RSTR_USART2RST_Pos) /*!< 0x00020000 */ #define RCC_APB1RSTR_USART2RST RCC_APB1RSTR_USART2RST_Msk /*!< USART 2 reset */ #define RCC_APB1RSTR_I2C1RST_Pos (21U) #define RCC_APB1RSTR_I2C1RST_Msk (0x1UL << RCC_APB1RSTR_I2C1RST_Pos) /*!< 0x00200000 */ #define RCC_APB1RSTR_I2C1RST RCC_APB1RSTR_I2C1RST_Msk /*!< I2C 1 reset */ #define RCC_APB1RSTR_CAN1RST_Pos (25U) #define RCC_APB1RSTR_CAN1RST_Msk (0x1UL << RCC_APB1RSTR_CAN1RST_Pos) /*!< 0x02000000 */ #define RCC_APB1RSTR_CAN1RST RCC_APB1RSTR_CAN1RST_Msk /*!< CAN1 reset */ #define RCC_APB1RSTR_BKPRST_Pos (27U) #define RCC_APB1RSTR_BKPRST_Msk (0x1UL << RCC_APB1RSTR_BKPRST_Pos) /*!< 0x08000000 */ #define RCC_APB1RSTR_BKPRST RCC_APB1RSTR_BKPRST_Msk /*!< Backup interface reset */ #define RCC_APB1RSTR_PWRRST_Pos (28U) #define RCC_APB1RSTR_PWRRST_Msk (0x1UL << RCC_APB1RSTR_PWRRST_Pos) /*!< 0x10000000 */ #define RCC_APB1RSTR_PWRRST RCC_APB1RSTR_PWRRST_Msk /*!< Power interface reset */ #define RCC_APB1RSTR_TIM4RST_Pos (2U) #define RCC_APB1RSTR_TIM4RST_Msk (0x1UL << RCC_APB1RSTR_TIM4RST_Pos) /*!< 0x00000004 */ #define RCC_APB1RSTR_TIM4RST RCC_APB1RSTR_TIM4RST_Msk /*!< Timer 4 reset */ #define RCC_APB1RSTR_SPI2RST_Pos (14U) #define RCC_APB1RSTR_SPI2RST_Msk (0x1UL << RCC_APB1RSTR_SPI2RST_Pos) /*!< 0x00004000 */ #define RCC_APB1RSTR_SPI2RST RCC_APB1RSTR_SPI2RST_Msk /*!< SPI 2 reset */ #define RCC_APB1RSTR_USART3RST_Pos (18U) #define RCC_APB1RSTR_USART3RST_Msk (0x1UL << RCC_APB1RSTR_USART3RST_Pos) /*!< 0x00040000 */ #define RCC_APB1RSTR_USART3RST RCC_APB1RSTR_USART3RST_Msk /*!< USART 3 reset */ #define RCC_APB1RSTR_I2C2RST_Pos (22U) #define RCC_APB1RSTR_I2C2RST_Msk (0x1UL << RCC_APB1RSTR_I2C2RST_Pos) /*!< 0x00400000 */ #define RCC_APB1RSTR_I2C2RST RCC_APB1RSTR_I2C2RST_Msk /*!< I2C 2 reset */ #define RCC_APB1RSTR_USBRST_Pos (23U) #define RCC_APB1RSTR_USBRST_Msk (0x1UL << RCC_APB1RSTR_USBRST_Pos) /*!< 0x00800000 */ #define RCC_APB1RSTR_USBRST RCC_APB1RSTR_USBRST_Msk /*!< USB Device reset */ #define RCC_APB1RSTR_TIM5RST_Pos (3U) #define RCC_APB1RSTR_TIM5RST_Msk (0x1UL << RCC_APB1RSTR_TIM5RST_Pos) /*!< 0x00000008 */ #define RCC_APB1RSTR_TIM5RST RCC_APB1RSTR_TIM5RST_Msk /*!< Timer 5 reset */ #define RCC_APB1RSTR_TIM6RST_Pos (4U) #define RCC_APB1RSTR_TIM6RST_Msk (0x1UL << RCC_APB1RSTR_TIM6RST_Pos) /*!< 0x00000010 */ #define RCC_APB1RSTR_TIM6RST RCC_APB1RSTR_TIM6RST_Msk /*!< Timer 6 reset */ #define RCC_APB1RSTR_TIM7RST_Pos (5U) #define RCC_APB1RSTR_TIM7RST_Msk (0x1UL << RCC_APB1RSTR_TIM7RST_Pos) /*!< 0x00000020 */ #define RCC_APB1RSTR_TIM7RST RCC_APB1RSTR_TIM7RST_Msk /*!< Timer 7 reset */ #define RCC_APB1RSTR_SPI3RST_Pos (15U) #define RCC_APB1RSTR_SPI3RST_Msk (0x1UL << RCC_APB1RSTR_SPI3RST_Pos) /*!< 0x00008000 */ #define RCC_APB1RSTR_SPI3RST RCC_APB1RSTR_SPI3RST_Msk /*!< SPI 3 reset */ #define RCC_APB1RSTR_UART4RST_Pos (19U) #define RCC_APB1RSTR_UART4RST_Msk (0x1UL << RCC_APB1RSTR_UART4RST_Pos) /*!< 0x00080000 */ #define RCC_APB1RSTR_UART4RST RCC_APB1RSTR_UART4RST_Msk /*!< UART 4 reset */ #define RCC_APB1RSTR_UART5RST_Pos (20U) #define RCC_APB1RSTR_UART5RST_Msk (0x1UL << RCC_APB1RSTR_UART5RST_Pos) /*!< 0x00100000 */ #define RCC_APB1RSTR_UART5RST RCC_APB1RSTR_UART5RST_Msk /*!< UART 5 reset */ #define RCC_APB1RSTR_DACRST_Pos (29U) #define RCC_APB1RSTR_DACRST_Msk (0x1UL << RCC_APB1RSTR_DACRST_Pos) /*!< 0x20000000 */ #define RCC_APB1RSTR_DACRST RCC_APB1RSTR_DACRST_Msk /*!< DAC interface reset */ /****************** Bit definition for RCC_AHBENR register ******************/ #define RCC_AHBENR_DMA1EN_Pos (0U) #define RCC_AHBENR_DMA1EN_Msk (0x1UL << RCC_AHBENR_DMA1EN_Pos) /*!< 0x00000001 */ #define RCC_AHBENR_DMA1EN RCC_AHBENR_DMA1EN_Msk /*!< DMA1 clock enable */ #define RCC_AHBENR_SRAMEN_Pos (2U) #define RCC_AHBENR_SRAMEN_Msk (0x1UL << RCC_AHBENR_SRAMEN_Pos) /*!< 0x00000004 */ #define RCC_AHBENR_SRAMEN RCC_AHBENR_SRAMEN_Msk /*!< SRAM interface clock enable */ #define RCC_AHBENR_FLITFEN_Pos (4U) #define RCC_AHBENR_FLITFEN_Msk (0x1UL << RCC_AHBENR_FLITFEN_Pos) /*!< 0x00000010 */ #define RCC_AHBENR_FLITFEN RCC_AHBENR_FLITFEN_Msk /*!< FLITF clock enable */ #define RCC_AHBENR_CRCEN_Pos (6U) #define RCC_AHBENR_CRCEN_Msk (0x1UL << RCC_AHBENR_CRCEN_Pos) /*!< 0x00000040 */ #define RCC_AHBENR_CRCEN RCC_AHBENR_CRCEN_Msk /*!< CRC clock enable */ #define RCC_AHBENR_DMA2EN_Pos (1U) #define RCC_AHBENR_DMA2EN_Msk (0x1UL << RCC_AHBENR_DMA2EN_Pos) /*!< 0x00000002 */ #define RCC_AHBENR_DMA2EN RCC_AHBENR_DMA2EN_Msk /*!< DMA2 clock enable */ #define RCC_AHBENR_FSMCEN_Pos (8U) #define RCC_AHBENR_FSMCEN_Msk (0x1UL << RCC_AHBENR_FSMCEN_Pos) /*!< 0x00000100 */ #define RCC_AHBENR_FSMCEN RCC_AHBENR_FSMCEN_Msk /*!< FSMC clock enable */ #define RCC_AHBENR_SDIOEN_Pos (10U) #define RCC_AHBENR_SDIOEN_Msk (0x1UL << RCC_AHBENR_SDIOEN_Pos) /*!< 0x00000400 */ #define RCC_AHBENR_SDIOEN RCC_AHBENR_SDIOEN_Msk /*!< SDIO clock enable */ /****************** Bit definition for RCC_APB2ENR register *****************/ #define RCC_APB2ENR_AFIOEN_Pos (0U) #define RCC_APB2ENR_AFIOEN_Msk (0x1UL << RCC_APB2ENR_AFIOEN_Pos) /*!< 0x00000001 */ #define RCC_APB2ENR_AFIOEN RCC_APB2ENR_AFIOEN_Msk /*!< Alternate Function I/O clock enable */ #define RCC_APB2ENR_IOPAEN_Pos (2U) #define RCC_APB2ENR_IOPAEN_Msk (0x1UL << RCC_APB2ENR_IOPAEN_Pos) /*!< 0x00000004 */ #define RCC_APB2ENR_IOPAEN RCC_APB2ENR_IOPAEN_Msk /*!< I/O port A clock enable */ #define RCC_APB2ENR_IOPBEN_Pos (3U) #define RCC_APB2ENR_IOPBEN_Msk (0x1UL << RCC_APB2ENR_IOPBEN_Pos) /*!< 0x00000008 */ #define RCC_APB2ENR_IOPBEN RCC_APB2ENR_IOPBEN_Msk /*!< I/O port B clock enable */ #define RCC_APB2ENR_IOPCEN_Pos (4U) #define RCC_APB2ENR_IOPCEN_Msk (0x1UL << RCC_APB2ENR_IOPCEN_Pos) /*!< 0x00000010 */ #define RCC_APB2ENR_IOPCEN RCC_APB2ENR_IOPCEN_Msk /*!< I/O port C clock enable */ #define RCC_APB2ENR_IOPDEN_Pos (5U) #define RCC_APB2ENR_IOPDEN_Msk (0x1UL << RCC_APB2ENR_IOPDEN_Pos) /*!< 0x00000020 */ #define RCC_APB2ENR_IOPDEN RCC_APB2ENR_IOPDEN_Msk /*!< I/O port D clock enable */ #define RCC_APB2ENR_ADC1EN_Pos (9U) #define RCC_APB2ENR_ADC1EN_Msk (0x1UL << RCC_APB2ENR_ADC1EN_Pos) /*!< 0x00000200 */ #define RCC_APB2ENR_ADC1EN RCC_APB2ENR_ADC1EN_Msk /*!< ADC 1 interface clock enable */ #define RCC_APB2ENR_ADC2EN_Pos (10U) #define RCC_APB2ENR_ADC2EN_Msk (0x1UL << RCC_APB2ENR_ADC2EN_Pos) /*!< 0x00000400 */ #define RCC_APB2ENR_ADC2EN RCC_APB2ENR_ADC2EN_Msk /*!< ADC 2 interface clock enable */ #define RCC_APB2ENR_TIM1EN_Pos (11U) #define RCC_APB2ENR_TIM1EN_Msk (0x1UL << RCC_APB2ENR_TIM1EN_Pos) /*!< 0x00000800 */ #define RCC_APB2ENR_TIM1EN RCC_APB2ENR_TIM1EN_Msk /*!< TIM1 Timer clock enable */ #define RCC_APB2ENR_SPI1EN_Pos (12U) #define RCC_APB2ENR_SPI1EN_Msk (0x1UL << RCC_APB2ENR_SPI1EN_Pos) /*!< 0x00001000 */ #define RCC_APB2ENR_SPI1EN RCC_APB2ENR_SPI1EN_Msk /*!< SPI 1 clock enable */ #define RCC_APB2ENR_USART1EN_Pos (14U) #define RCC_APB2ENR_USART1EN_Msk (0x1UL << RCC_APB2ENR_USART1EN_Pos) /*!< 0x00004000 */ #define RCC_APB2ENR_USART1EN RCC_APB2ENR_USART1EN_Msk /*!< USART1 clock enable */ #define RCC_APB2ENR_IOPEEN_Pos (6U) #define RCC_APB2ENR_IOPEEN_Msk (0x1UL << RCC_APB2ENR_IOPEEN_Pos) /*!< 0x00000040 */ #define RCC_APB2ENR_IOPEEN RCC_APB2ENR_IOPEEN_Msk /*!< I/O port E clock enable */ #define RCC_APB2ENR_IOPFEN_Pos (7U) #define RCC_APB2ENR_IOPFEN_Msk (0x1UL << RCC_APB2ENR_IOPFEN_Pos) /*!< 0x00000080 */ #define RCC_APB2ENR_IOPFEN RCC_APB2ENR_IOPFEN_Msk /*!< I/O port F clock enable */ #define RCC_APB2ENR_IOPGEN_Pos (8U) #define RCC_APB2ENR_IOPGEN_Msk (0x1UL << RCC_APB2ENR_IOPGEN_Pos) /*!< 0x00000100 */ #define RCC_APB2ENR_IOPGEN RCC_APB2ENR_IOPGEN_Msk /*!< I/O port G clock enable */ #define RCC_APB2ENR_TIM8EN_Pos (13U) #define RCC_APB2ENR_TIM8EN_Msk (0x1UL << RCC_APB2ENR_TIM8EN_Pos) /*!< 0x00002000 */ #define RCC_APB2ENR_TIM8EN RCC_APB2ENR_TIM8EN_Msk /*!< TIM8 Timer clock enable */ #define RCC_APB2ENR_ADC3EN_Pos (15U) #define RCC_APB2ENR_ADC3EN_Msk (0x1UL << RCC_APB2ENR_ADC3EN_Pos) /*!< 0x00008000 */ #define RCC_APB2ENR_ADC3EN RCC_APB2ENR_ADC3EN_Msk /*!< DMA1 clock enable */ /***************** Bit definition for RCC_APB1ENR register ******************/ #define RCC_APB1ENR_TIM2EN_Pos (0U) #define RCC_APB1ENR_TIM2EN_Msk (0x1UL << RCC_APB1ENR_TIM2EN_Pos) /*!< 0x00000001 */ #define RCC_APB1ENR_TIM2EN RCC_APB1ENR_TIM2EN_Msk /*!< Timer 2 clock enabled*/ #define RCC_APB1ENR_TIM3EN_Pos (1U) #define RCC_APB1ENR_TIM3EN_Msk (0x1UL << RCC_APB1ENR_TIM3EN_Pos) /*!< 0x00000002 */ #define RCC_APB1ENR_TIM3EN RCC_APB1ENR_TIM3EN_Msk /*!< Timer 3 clock enable */ #define RCC_APB1ENR_WWDGEN_Pos (11U) #define RCC_APB1ENR_WWDGEN_Msk (0x1UL << RCC_APB1ENR_WWDGEN_Pos) /*!< 0x00000800 */ #define RCC_APB1ENR_WWDGEN RCC_APB1ENR_WWDGEN_Msk /*!< Window Watchdog clock enable */ #define RCC_APB1ENR_USART2EN_Pos (17U) #define RCC_APB1ENR_USART2EN_Msk (0x1UL << RCC_APB1ENR_USART2EN_Pos) /*!< 0x00020000 */ #define RCC_APB1ENR_USART2EN RCC_APB1ENR_USART2EN_Msk /*!< USART 2 clock enable */ #define RCC_APB1ENR_I2C1EN_Pos (21U) #define RCC_APB1ENR_I2C1EN_Msk (0x1UL << RCC_APB1ENR_I2C1EN_Pos) /*!< 0x00200000 */ #define RCC_APB1ENR_I2C1EN RCC_APB1ENR_I2C1EN_Msk /*!< I2C 1 clock enable */ #define RCC_APB1ENR_CAN1EN_Pos (25U) #define RCC_APB1ENR_CAN1EN_Msk (0x1UL << RCC_APB1ENR_CAN1EN_Pos) /*!< 0x02000000 */ #define RCC_APB1ENR_CAN1EN RCC_APB1ENR_CAN1EN_Msk /*!< CAN1 clock enable */ #define RCC_APB1ENR_BKPEN_Pos (27U) #define RCC_APB1ENR_BKPEN_Msk (0x1UL << RCC_APB1ENR_BKPEN_Pos) /*!< 0x08000000 */ #define RCC_APB1ENR_BKPEN RCC_APB1ENR_BKPEN_Msk /*!< Backup interface clock enable */ #define RCC_APB1ENR_PWREN_Pos (28U) #define RCC_APB1ENR_PWREN_Msk (0x1UL << RCC_APB1ENR_PWREN_Pos) /*!< 0x10000000 */ #define RCC_APB1ENR_PWREN RCC_APB1ENR_PWREN_Msk /*!< Power interface clock enable */ #define RCC_APB1ENR_TIM4EN_Pos (2U) #define RCC_APB1ENR_TIM4EN_Msk (0x1UL << RCC_APB1ENR_TIM4EN_Pos) /*!< 0x00000004 */ #define RCC_APB1ENR_TIM4EN RCC_APB1ENR_TIM4EN_Msk /*!< Timer 4 clock enable */ #define RCC_APB1ENR_SPI2EN_Pos (14U) #define RCC_APB1ENR_SPI2EN_Msk (0x1UL << RCC_APB1ENR_SPI2EN_Pos) /*!< 0x00004000 */ #define RCC_APB1ENR_SPI2EN RCC_APB1ENR_SPI2EN_Msk /*!< SPI 2 clock enable */ #define RCC_APB1ENR_USART3EN_Pos (18U) #define RCC_APB1ENR_USART3EN_Msk (0x1UL << RCC_APB1ENR_USART3EN_Pos) /*!< 0x00040000 */ #define RCC_APB1ENR_USART3EN RCC_APB1ENR_USART3EN_Msk /*!< USART 3 clock enable */ #define RCC_APB1ENR_I2C2EN_Pos (22U) #define RCC_APB1ENR_I2C2EN_Msk (0x1UL << RCC_APB1ENR_I2C2EN_Pos) /*!< 0x00400000 */ #define RCC_APB1ENR_I2C2EN RCC_APB1ENR_I2C2EN_Msk /*!< I2C 2 clock enable */ #define RCC_APB1ENR_USBEN_Pos (23U) #define RCC_APB1ENR_USBEN_Msk (0x1UL << RCC_APB1ENR_USBEN_Pos) /*!< 0x00800000 */ #define RCC_APB1ENR_USBEN RCC_APB1ENR_USBEN_Msk /*!< USB Device clock enable */ #define RCC_APB1ENR_TIM5EN_Pos (3U) #define RCC_APB1ENR_TIM5EN_Msk (0x1UL << RCC_APB1ENR_TIM5EN_Pos) /*!< 0x00000008 */ #define RCC_APB1ENR_TIM5EN RCC_APB1ENR_TIM5EN_Msk /*!< Timer 5 clock enable */ #define RCC_APB1ENR_TIM6EN_Pos (4U) #define RCC_APB1ENR_TIM6EN_Msk (0x1UL << RCC_APB1ENR_TIM6EN_Pos) /*!< 0x00000010 */ #define RCC_APB1ENR_TIM6EN RCC_APB1ENR_TIM6EN_Msk /*!< Timer 6 clock enable */ #define RCC_APB1ENR_TIM7EN_Pos (5U) #define RCC_APB1ENR_TIM7EN_Msk (0x1UL << RCC_APB1ENR_TIM7EN_Pos) /*!< 0x00000020 */ #define RCC_APB1ENR_TIM7EN RCC_APB1ENR_TIM7EN_Msk /*!< Timer 7 clock enable */ #define RCC_APB1ENR_SPI3EN_Pos (15U) #define RCC_APB1ENR_SPI3EN_Msk (0x1UL << RCC_APB1ENR_SPI3EN_Pos) /*!< 0x00008000 */ #define RCC_APB1ENR_SPI3EN RCC_APB1ENR_SPI3EN_Msk /*!< SPI 3 clock enable */ #define RCC_APB1ENR_UART4EN_Pos (19U) #define RCC_APB1ENR_UART4EN_Msk (0x1UL << RCC_APB1ENR_UART4EN_Pos) /*!< 0x00080000 */ #define RCC_APB1ENR_UART4EN RCC_APB1ENR_UART4EN_Msk /*!< UART 4 clock enable */ #define RCC_APB1ENR_UART5EN_Pos (20U) #define RCC_APB1ENR_UART5EN_Msk (0x1UL << RCC_APB1ENR_UART5EN_Pos) /*!< 0x00100000 */ #define RCC_APB1ENR_UART5EN RCC_APB1ENR_UART5EN_Msk /*!< UART 5 clock enable */ #define RCC_APB1ENR_DACEN_Pos (29U) #define RCC_APB1ENR_DACEN_Msk (0x1UL << RCC_APB1ENR_DACEN_Pos) /*!< 0x20000000 */ #define RCC_APB1ENR_DACEN RCC_APB1ENR_DACEN_Msk /*!< DAC interface clock enable */ /******************* Bit definition for RCC_BDCR register *******************/ #define RCC_BDCR_LSEON_Pos (0U) #define RCC_BDCR_LSEON_Msk (0x1UL << RCC_BDCR_LSEON_Pos) /*!< 0x00000001 */ #define RCC_BDCR_LSEON RCC_BDCR_LSEON_Msk /*!< External Low Speed oscillator enable */ #define RCC_BDCR_LSERDY_Pos (1U) #define RCC_BDCR_LSERDY_Msk (0x1UL << RCC_BDCR_LSERDY_Pos) /*!< 0x00000002 */ #define RCC_BDCR_LSERDY RCC_BDCR_LSERDY_Msk /*!< External Low Speed oscillator Ready */ #define RCC_BDCR_LSEBYP_Pos (2U) #define RCC_BDCR_LSEBYP_Msk (0x1UL << RCC_BDCR_LSEBYP_Pos) /*!< 0x00000004 */ #define RCC_BDCR_LSEBYP RCC_BDCR_LSEBYP_Msk /*!< External Low Speed oscillator Bypass */ #define RCC_BDCR_RTCSEL_Pos (8U) #define RCC_BDCR_RTCSEL_Msk (0x3UL << RCC_BDCR_RTCSEL_Pos) /*!< 0x00000300 */ #define RCC_BDCR_RTCSEL RCC_BDCR_RTCSEL_Msk /*!< RTCSEL[1:0] bits (RTC clock source selection) */ #define RCC_BDCR_RTCSEL_0 (0x1UL << RCC_BDCR_RTCSEL_Pos) /*!< 0x00000100 */ #define RCC_BDCR_RTCSEL_1 (0x2UL << RCC_BDCR_RTCSEL_Pos) /*!< 0x00000200 */ /*!< RTC congiguration */ #define RCC_BDCR_RTCSEL_NOCLOCK 0x00000000U /*!< No clock */ #define RCC_BDCR_RTCSEL_LSE 0x00000100U /*!< LSE oscillator clock used as RTC clock */ #define RCC_BDCR_RTCSEL_LSI 0x00000200U /*!< LSI oscillator clock used as RTC clock */ #define RCC_BDCR_RTCSEL_HSE 0x00000300U /*!< HSE oscillator clock divided by 128 used as RTC clock */ #define RCC_BDCR_RTCEN_Pos (15U) #define RCC_BDCR_RTCEN_Msk (0x1UL << RCC_BDCR_RTCEN_Pos) /*!< 0x00008000 */ #define RCC_BDCR_RTCEN RCC_BDCR_RTCEN_Msk /*!< RTC clock enable */ #define RCC_BDCR_BDRST_Pos (16U) #define RCC_BDCR_BDRST_Msk (0x1UL << RCC_BDCR_BDRST_Pos) /*!< 0x00010000 */ #define RCC_BDCR_BDRST RCC_BDCR_BDRST_Msk /*!< Backup domain software reset */ /******************* Bit definition for RCC_CSR register ********************/ #define RCC_CSR_LSION_Pos (0U) #define RCC_CSR_LSION_Msk (0x1UL << RCC_CSR_LSION_Pos) /*!< 0x00000001 */ #define RCC_CSR_LSION RCC_CSR_LSION_Msk /*!< Internal Low Speed oscillator enable */ #define RCC_CSR_LSIRDY_Pos (1U) #define RCC_CSR_LSIRDY_Msk (0x1UL << RCC_CSR_LSIRDY_Pos) /*!< 0x00000002 */ #define RCC_CSR_LSIRDY RCC_CSR_LSIRDY_Msk /*!< Internal Low Speed oscillator Ready */ #define RCC_CSR_RMVF_Pos (24U) #define RCC_CSR_RMVF_Msk (0x1UL << RCC_CSR_RMVF_Pos) /*!< 0x01000000 */ #define RCC_CSR_RMVF RCC_CSR_RMVF_Msk /*!< Remove reset flag */ #define RCC_CSR_PINRSTF_Pos (26U) #define RCC_CSR_PINRSTF_Msk (0x1UL << RCC_CSR_PINRSTF_Pos) /*!< 0x04000000 */ #define RCC_CSR_PINRSTF RCC_CSR_PINRSTF_Msk /*!< PIN reset flag */ #define RCC_CSR_PORRSTF_Pos (27U) #define RCC_CSR_PORRSTF_Msk (0x1UL << RCC_CSR_PORRSTF_Pos) /*!< 0x08000000 */ #define RCC_CSR_PORRSTF RCC_CSR_PORRSTF_Msk /*!< POR/PDR reset flag */ #define RCC_CSR_SFTRSTF_Pos (28U) #define RCC_CSR_SFTRSTF_Msk (0x1UL << RCC_CSR_SFTRSTF_Pos) /*!< 0x10000000 */ #define RCC_CSR_SFTRSTF RCC_CSR_SFTRSTF_Msk /*!< Software Reset flag */ #define RCC_CSR_IWDGRSTF_Pos (29U) #define RCC_CSR_IWDGRSTF_Msk (0x1UL << RCC_CSR_IWDGRSTF_Pos) /*!< 0x20000000 */ #define RCC_CSR_IWDGRSTF RCC_CSR_IWDGRSTF_Msk /*!< Independent Watchdog reset flag */ #define RCC_CSR_WWDGRSTF_Pos (30U) #define RCC_CSR_WWDGRSTF_Msk (0x1UL << RCC_CSR_WWDGRSTF_Pos) /*!< 0x40000000 */ #define RCC_CSR_WWDGRSTF RCC_CSR_WWDGRSTF_Msk /*!< Window watchdog reset flag */ #define RCC_CSR_LPWRRSTF_Pos (31U) #define RCC_CSR_LPWRRSTF_Msk (0x1UL << RCC_CSR_LPWRRSTF_Pos) /*!< 0x80000000 */ #define RCC_CSR_LPWRRSTF RCC_CSR_LPWRRSTF_Msk /*!< Low-Power reset flag */ /******************************************************************************/ /* */ /* General Purpose and Alternate Function I/O */ /* */ /******************************************************************************/ /******************* Bit definition for GPIO_CRL register *******************/ #define GPIO_CRL_MODE_Pos (0U) #define GPIO_CRL_MODE_Msk (0x33333333UL << GPIO_CRL_MODE_Pos) /*!< 0x33333333 */ #define GPIO_CRL_MODE GPIO_CRL_MODE_Msk /*!< Port x mode bits */ #define GPIO_CRL_MODE0_Pos (0U) #define GPIO_CRL_MODE0_Msk (0x3UL << GPIO_CRL_MODE0_Pos) /*!< 0x00000003 */ #define GPIO_CRL_MODE0 GPIO_CRL_MODE0_Msk /*!< MODE0[1:0] bits (Port x mode bits, pin 0) */ #define GPIO_CRL_MODE0_0 (0x1UL << GPIO_CRL_MODE0_Pos) /*!< 0x00000001 */ #define GPIO_CRL_MODE0_1 (0x2UL << GPIO_CRL_MODE0_Pos) /*!< 0x00000002 */ #define GPIO_CRL_MODE1_Pos (4U) #define GPIO_CRL_MODE1_Msk (0x3UL << GPIO_CRL_MODE1_Pos) /*!< 0x00000030 */ #define GPIO_CRL_MODE1 GPIO_CRL_MODE1_Msk /*!< MODE1[1:0] bits (Port x mode bits, pin 1) */ #define GPIO_CRL_MODE1_0 (0x1UL << GPIO_CRL_MODE1_Pos) /*!< 0x00000010 */ #define GPIO_CRL_MODE1_1 (0x2UL << GPIO_CRL_MODE1_Pos) /*!< 0x00000020 */ #define GPIO_CRL_MODE2_Pos (8U) #define GPIO_CRL_MODE2_Msk (0x3UL << GPIO_CRL_MODE2_Pos) /*!< 0x00000300 */ #define GPIO_CRL_MODE2 GPIO_CRL_MODE2_Msk /*!< MODE2[1:0] bits (Port x mode bits, pin 2) */ #define GPIO_CRL_MODE2_0 (0x1UL << GPIO_CRL_MODE2_Pos) /*!< 0x00000100 */ #define GPIO_CRL_MODE2_1 (0x2UL << GPIO_CRL_MODE2_Pos) /*!< 0x00000200 */ #define GPIO_CRL_MODE3_Pos (12U) #define GPIO_CRL_MODE3_Msk (0x3UL << GPIO_CRL_MODE3_Pos) /*!< 0x00003000 */ #define GPIO_CRL_MODE3 GPIO_CRL_MODE3_Msk /*!< MODE3[1:0] bits (Port x mode bits, pin 3) */ #define GPIO_CRL_MODE3_0 (0x1UL << GPIO_CRL_MODE3_Pos) /*!< 0x00001000 */ #define GPIO_CRL_MODE3_1 (0x2UL << GPIO_CRL_MODE3_Pos) /*!< 0x00002000 */ #define GPIO_CRL_MODE4_Pos (16U) #define GPIO_CRL_MODE4_Msk (0x3UL << GPIO_CRL_MODE4_Pos) /*!< 0x00030000 */ #define GPIO_CRL_MODE4 GPIO_CRL_MODE4_Msk /*!< MODE4[1:0] bits (Port x mode bits, pin 4) */ #define GPIO_CRL_MODE4_0 (0x1UL << GPIO_CRL_MODE4_Pos) /*!< 0x00010000 */ #define GPIO_CRL_MODE4_1 (0x2UL << GPIO_CRL_MODE4_Pos) /*!< 0x00020000 */ #define GPIO_CRL_MODE5_Pos (20U) #define GPIO_CRL_MODE5_Msk (0x3UL << GPIO_CRL_MODE5_Pos) /*!< 0x00300000 */ #define GPIO_CRL_MODE5 GPIO_CRL_MODE5_Msk /*!< MODE5[1:0] bits (Port x mode bits, pin 5) */ #define GPIO_CRL_MODE5_0 (0x1UL << GPIO_CRL_MODE5_Pos) /*!< 0x00100000 */ #define GPIO_CRL_MODE5_1 (0x2UL << GPIO_CRL_MODE5_Pos) /*!< 0x00200000 */ #define GPIO_CRL_MODE6_Pos (24U) #define GPIO_CRL_MODE6_Msk (0x3UL << GPIO_CRL_MODE6_Pos) /*!< 0x03000000 */ #define GPIO_CRL_MODE6 GPIO_CRL_MODE6_Msk /*!< MODE6[1:0] bits (Port x mode bits, pin 6) */ #define GPIO_CRL_MODE6_0 (0x1UL << GPIO_CRL_MODE6_Pos) /*!< 0x01000000 */ #define GPIO_CRL_MODE6_1 (0x2UL << GPIO_CRL_MODE6_Pos) /*!< 0x02000000 */ #define GPIO_CRL_MODE7_Pos (28U) #define GPIO_CRL_MODE7_Msk (0x3UL << GPIO_CRL_MODE7_Pos) /*!< 0x30000000 */ #define GPIO_CRL_MODE7 GPIO_CRL_MODE7_Msk /*!< MODE7[1:0] bits (Port x mode bits, pin 7) */ #define GPIO_CRL_MODE7_0 (0x1UL << GPIO_CRL_MODE7_Pos) /*!< 0x10000000 */ #define GPIO_CRL_MODE7_1 (0x2UL << GPIO_CRL_MODE7_Pos) /*!< 0x20000000 */ #define GPIO_CRL_CNF_Pos (2U) #define GPIO_CRL_CNF_Msk (0x33333333UL << GPIO_CRL_CNF_Pos) /*!< 0xCCCCCCCC */ #define GPIO_CRL_CNF GPIO_CRL_CNF_Msk /*!< Port x configuration bits */ #define GPIO_CRL_CNF0_Pos (2U) #define GPIO_CRL_CNF0_Msk (0x3UL << GPIO_CRL_CNF0_Pos) /*!< 0x0000000C */ #define GPIO_CRL_CNF0 GPIO_CRL_CNF0_Msk /*!< CNF0[1:0] bits (Port x configuration bits, pin 0) */ #define GPIO_CRL_CNF0_0 (0x1UL << GPIO_CRL_CNF0_Pos) /*!< 0x00000004 */ #define GPIO_CRL_CNF0_1 (0x2UL << GPIO_CRL_CNF0_Pos) /*!< 0x00000008 */ #define GPIO_CRL_CNF1_Pos (6U) #define GPIO_CRL_CNF1_Msk (0x3UL << GPIO_CRL_CNF1_Pos) /*!< 0x000000C0 */ #define GPIO_CRL_CNF1 GPIO_CRL_CNF1_Msk /*!< CNF1[1:0] bits (Port x configuration bits, pin 1) */ #define GPIO_CRL_CNF1_0 (0x1UL << GPIO_CRL_CNF1_Pos) /*!< 0x00000040 */ #define GPIO_CRL_CNF1_1 (0x2UL << GPIO_CRL_CNF1_Pos) /*!< 0x00000080 */ #define GPIO_CRL_CNF2_Pos (10U) #define GPIO_CRL_CNF2_Msk (0x3UL << GPIO_CRL_CNF2_Pos) /*!< 0x00000C00 */ #define GPIO_CRL_CNF2 GPIO_CRL_CNF2_Msk /*!< CNF2[1:0] bits (Port x configuration bits, pin 2) */ #define GPIO_CRL_CNF2_0 (0x1UL << GPIO_CRL_CNF2_Pos) /*!< 0x00000400 */ #define GPIO_CRL_CNF2_1 (0x2UL << GPIO_CRL_CNF2_Pos) /*!< 0x00000800 */ #define GPIO_CRL_CNF3_Pos (14U) #define GPIO_CRL_CNF3_Msk (0x3UL << GPIO_CRL_CNF3_Pos) /*!< 0x0000C000 */ #define GPIO_CRL_CNF3 GPIO_CRL_CNF3_Msk /*!< CNF3[1:0] bits (Port x configuration bits, pin 3) */ #define GPIO_CRL_CNF3_0 (0x1UL << GPIO_CRL_CNF3_Pos) /*!< 0x00004000 */ #define GPIO_CRL_CNF3_1 (0x2UL << GPIO_CRL_CNF3_Pos) /*!< 0x00008000 */ #define GPIO_CRL_CNF4_Pos (18U) #define GPIO_CRL_CNF4_Msk (0x3UL << GPIO_CRL_CNF4_Pos) /*!< 0x000C0000 */ #define GPIO_CRL_CNF4 GPIO_CRL_CNF4_Msk /*!< CNF4[1:0] bits (Port x configuration bits, pin 4) */ #define GPIO_CRL_CNF4_0 (0x1UL << GPIO_CRL_CNF4_Pos) /*!< 0x00040000 */ #define GPIO_CRL_CNF4_1 (0x2UL << GPIO_CRL_CNF4_Pos) /*!< 0x00080000 */ #define GPIO_CRL_CNF5_Pos (22U) #define GPIO_CRL_CNF5_Msk (0x3UL << GPIO_CRL_CNF5_Pos) /*!< 0x00C00000 */ #define GPIO_CRL_CNF5 GPIO_CRL_CNF5_Msk /*!< CNF5[1:0] bits (Port x configuration bits, pin 5) */ #define GPIO_CRL_CNF5_0 (0x1UL << GPIO_CRL_CNF5_Pos) /*!< 0x00400000 */ #define GPIO_CRL_CNF5_1 (0x2UL << GPIO_CRL_CNF5_Pos) /*!< 0x00800000 */ #define GPIO_CRL_CNF6_Pos (26U) #define GPIO_CRL_CNF6_Msk (0x3UL << GPIO_CRL_CNF6_Pos) /*!< 0x0C000000 */ #define GPIO_CRL_CNF6 GPIO_CRL_CNF6_Msk /*!< CNF6[1:0] bits (Port x configuration bits, pin 6) */ #define GPIO_CRL_CNF6_0 (0x1UL << GPIO_CRL_CNF6_Pos) /*!< 0x04000000 */ #define GPIO_CRL_CNF6_1 (0x2UL << GPIO_CRL_CNF6_Pos) /*!< 0x08000000 */ #define GPIO_CRL_CNF7_Pos (30U) #define GPIO_CRL_CNF7_Msk (0x3UL << GPIO_CRL_CNF7_Pos) /*!< 0xC0000000 */ #define GPIO_CRL_CNF7 GPIO_CRL_CNF7_Msk /*!< CNF7[1:0] bits (Port x configuration bits, pin 7) */ #define GPIO_CRL_CNF7_0 (0x1UL << GPIO_CRL_CNF7_Pos) /*!< 0x40000000 */ #define GPIO_CRL_CNF7_1 (0x2UL << GPIO_CRL_CNF7_Pos) /*!< 0x80000000 */ /******************* Bit definition for GPIO_CRH register *******************/ #define GPIO_CRH_MODE_Pos (0U) #define GPIO_CRH_MODE_Msk (0x33333333UL << GPIO_CRH_MODE_Pos) /*!< 0x33333333 */ #define GPIO_CRH_MODE GPIO_CRH_MODE_Msk /*!< Port x mode bits */ #define GPIO_CRH_MODE8_Pos (0U) #define GPIO_CRH_MODE8_Msk (0x3UL << GPIO_CRH_MODE8_Pos) /*!< 0x00000003 */ #define GPIO_CRH_MODE8 GPIO_CRH_MODE8_Msk /*!< MODE8[1:0] bits (Port x mode bits, pin 8) */ #define GPIO_CRH_MODE8_0 (0x1UL << GPIO_CRH_MODE8_Pos) /*!< 0x00000001 */ #define GPIO_CRH_MODE8_1 (0x2UL << GPIO_CRH_MODE8_Pos) /*!< 0x00000002 */ #define GPIO_CRH_MODE9_Pos (4U) #define GPIO_CRH_MODE9_Msk (0x3UL << GPIO_CRH_MODE9_Pos) /*!< 0x00000030 */ #define GPIO_CRH_MODE9 GPIO_CRH_MODE9_Msk /*!< MODE9[1:0] bits (Port x mode bits, pin 9) */ #define GPIO_CRH_MODE9_0 (0x1UL << GPIO_CRH_MODE9_Pos) /*!< 0x00000010 */ #define GPIO_CRH_MODE9_1 (0x2UL << GPIO_CRH_MODE9_Pos) /*!< 0x00000020 */ #define GPIO_CRH_MODE10_Pos (8U) #define GPIO_CRH_MODE10_Msk (0x3UL << GPIO_CRH_MODE10_Pos) /*!< 0x00000300 */ #define GPIO_CRH_MODE10 GPIO_CRH_MODE10_Msk /*!< MODE10[1:0] bits (Port x mode bits, pin 10) */ #define GPIO_CRH_MODE10_0 (0x1UL << GPIO_CRH_MODE10_Pos) /*!< 0x00000100 */ #define GPIO_CRH_MODE10_1 (0x2UL << GPIO_CRH_MODE10_Pos) /*!< 0x00000200 */ #define GPIO_CRH_MODE11_Pos (12U) #define GPIO_CRH_MODE11_Msk (0x3UL << GPIO_CRH_MODE11_Pos) /*!< 0x00003000 */ #define GPIO_CRH_MODE11 GPIO_CRH_MODE11_Msk /*!< MODE11[1:0] bits (Port x mode bits, pin 11) */ #define GPIO_CRH_MODE11_0 (0x1UL << GPIO_CRH_MODE11_Pos) /*!< 0x00001000 */ #define GPIO_CRH_MODE11_1 (0x2UL << GPIO_CRH_MODE11_Pos) /*!< 0x00002000 */ #define GPIO_CRH_MODE12_Pos (16U) #define GPIO_CRH_MODE12_Msk (0x3UL << GPIO_CRH_MODE12_Pos) /*!< 0x00030000 */ #define GPIO_CRH_MODE12 GPIO_CRH_MODE12_Msk /*!< MODE12[1:0] bits (Port x mode bits, pin 12) */ #define GPIO_CRH_MODE12_0 (0x1UL << GPIO_CRH_MODE12_Pos) /*!< 0x00010000 */ #define GPIO_CRH_MODE12_1 (0x2UL << GPIO_CRH_MODE12_Pos) /*!< 0x00020000 */ #define GPIO_CRH_MODE13_Pos (20U) #define GPIO_CRH_MODE13_Msk (0x3UL << GPIO_CRH_MODE13_Pos) /*!< 0x00300000 */ #define GPIO_CRH_MODE13 GPIO_CRH_MODE13_Msk /*!< MODE13[1:0] bits (Port x mode bits, pin 13) */ #define GPIO_CRH_MODE13_0 (0x1UL << GPIO_CRH_MODE13_Pos) /*!< 0x00100000 */ #define GPIO_CRH_MODE13_1 (0x2UL << GPIO_CRH_MODE13_Pos) /*!< 0x00200000 */ #define GPIO_CRH_MODE14_Pos (24U) #define GPIO_CRH_MODE14_Msk (0x3UL << GPIO_CRH_MODE14_Pos) /*!< 0x03000000 */ #define GPIO_CRH_MODE14 GPIO_CRH_MODE14_Msk /*!< MODE14[1:0] bits (Port x mode bits, pin 14) */ #define GPIO_CRH_MODE14_0 (0x1UL << GPIO_CRH_MODE14_Pos) /*!< 0x01000000 */ #define GPIO_CRH_MODE14_1 (0x2UL << GPIO_CRH_MODE14_Pos) /*!< 0x02000000 */ #define GPIO_CRH_MODE15_Pos (28U) #define GPIO_CRH_MODE15_Msk (0x3UL << GPIO_CRH_MODE15_Pos) /*!< 0x30000000 */ #define GPIO_CRH_MODE15 GPIO_CRH_MODE15_Msk /*!< MODE15[1:0] bits (Port x mode bits, pin 15) */ #define GPIO_CRH_MODE15_0 (0x1UL << GPIO_CRH_MODE15_Pos) /*!< 0x10000000 */ #define GPIO_CRH_MODE15_1 (0x2UL << GPIO_CRH_MODE15_Pos) /*!< 0x20000000 */ #define GPIO_CRH_CNF_Pos (2U) #define GPIO_CRH_CNF_Msk (0x33333333UL << GPIO_CRH_CNF_Pos) /*!< 0xCCCCCCCC */ #define GPIO_CRH_CNF GPIO_CRH_CNF_Msk /*!< Port x configuration bits */ #define GPIO_CRH_CNF8_Pos (2U) #define GPIO_CRH_CNF8_Msk (0x3UL << GPIO_CRH_CNF8_Pos) /*!< 0x0000000C */ #define GPIO_CRH_CNF8 GPIO_CRH_CNF8_Msk /*!< CNF8[1:0] bits (Port x configuration bits, pin 8) */ #define GPIO_CRH_CNF8_0 (0x1UL << GPIO_CRH_CNF8_Pos) /*!< 0x00000004 */ #define GPIO_CRH_CNF8_1 (0x2UL << GPIO_CRH_CNF8_Pos) /*!< 0x00000008 */ #define GPIO_CRH_CNF9_Pos (6U) #define GPIO_CRH_CNF9_Msk (0x3UL << GPIO_CRH_CNF9_Pos) /*!< 0x000000C0 */ #define GPIO_CRH_CNF9 GPIO_CRH_CNF9_Msk /*!< CNF9[1:0] bits (Port x configuration bits, pin 9) */ #define GPIO_CRH_CNF9_0 (0x1UL << GPIO_CRH_CNF9_Pos) /*!< 0x00000040 */ #define GPIO_CRH_CNF9_1 (0x2UL << GPIO_CRH_CNF9_Pos) /*!< 0x00000080 */ #define GPIO_CRH_CNF10_Pos (10U) #define GPIO_CRH_CNF10_Msk (0x3UL << GPIO_CRH_CNF10_Pos) /*!< 0x00000C00 */ #define GPIO_CRH_CNF10 GPIO_CRH_CNF10_Msk /*!< CNF10[1:0] bits (Port x configuration bits, pin 10) */ #define GPIO_CRH_CNF10_0 (0x1UL << GPIO_CRH_CNF10_Pos) /*!< 0x00000400 */ #define GPIO_CRH_CNF10_1 (0x2UL << GPIO_CRH_CNF10_Pos) /*!< 0x00000800 */ #define GPIO_CRH_CNF11_Pos (14U) #define GPIO_CRH_CNF11_Msk (0x3UL << GPIO_CRH_CNF11_Pos) /*!< 0x0000C000 */ #define GPIO_CRH_CNF11 GPIO_CRH_CNF11_Msk /*!< CNF11[1:0] bits (Port x configuration bits, pin 11) */ #define GPIO_CRH_CNF11_0 (0x1UL << GPIO_CRH_CNF11_Pos) /*!< 0x00004000 */ #define GPIO_CRH_CNF11_1 (0x2UL << GPIO_CRH_CNF11_Pos) /*!< 0x00008000 */ #define GPIO_CRH_CNF12_Pos (18U) #define GPIO_CRH_CNF12_Msk (0x3UL << GPIO_CRH_CNF12_Pos) /*!< 0x000C0000 */ #define GPIO_CRH_CNF12 GPIO_CRH_CNF12_Msk /*!< CNF12[1:0] bits (Port x configuration bits, pin 12) */ #define GPIO_CRH_CNF12_0 (0x1UL << GPIO_CRH_CNF12_Pos) /*!< 0x00040000 */ #define GPIO_CRH_CNF12_1 (0x2UL << GPIO_CRH_CNF12_Pos) /*!< 0x00080000 */ #define GPIO_CRH_CNF13_Pos (22U) #define GPIO_CRH_CNF13_Msk (0x3UL << GPIO_CRH_CNF13_Pos) /*!< 0x00C00000 */ #define GPIO_CRH_CNF13 GPIO_CRH_CNF13_Msk /*!< CNF13[1:0] bits (Port x configuration bits, pin 13) */ #define GPIO_CRH_CNF13_0 (0x1UL << GPIO_CRH_CNF13_Pos) /*!< 0x00400000 */ #define GPIO_CRH_CNF13_1 (0x2UL << GPIO_CRH_CNF13_Pos) /*!< 0x00800000 */ #define GPIO_CRH_CNF14_Pos (26U) #define GPIO_CRH_CNF14_Msk (0x3UL << GPIO_CRH_CNF14_Pos) /*!< 0x0C000000 */ #define GPIO_CRH_CNF14 GPIO_CRH_CNF14_Msk /*!< CNF14[1:0] bits (Port x configuration bits, pin 14) */ #define GPIO_CRH_CNF14_0 (0x1UL << GPIO_CRH_CNF14_Pos) /*!< 0x04000000 */ #define GPIO_CRH_CNF14_1 (0x2UL << GPIO_CRH_CNF14_Pos) /*!< 0x08000000 */ #define GPIO_CRH_CNF15_Pos (30U) #define GPIO_CRH_CNF15_Msk (0x3UL << GPIO_CRH_CNF15_Pos) /*!< 0xC0000000 */ #define GPIO_CRH_CNF15 GPIO_CRH_CNF15_Msk /*!< CNF15[1:0] bits (Port x configuration bits, pin 15) */ #define GPIO_CRH_CNF15_0 (0x1UL << GPIO_CRH_CNF15_Pos) /*!< 0x40000000 */ #define GPIO_CRH_CNF15_1 (0x2UL << GPIO_CRH_CNF15_Pos) /*!< 0x80000000 */ /*!<****************** Bit definition for GPIO_IDR register *******************/ #define GPIO_IDR_IDR0_Pos (0U) #define GPIO_IDR_IDR0_Msk (0x1UL << GPIO_IDR_IDR0_Pos) /*!< 0x00000001 */ #define GPIO_IDR_IDR0 GPIO_IDR_IDR0_Msk /*!< Port input data, bit 0 */ #define GPIO_IDR_IDR1_Pos (1U) #define GPIO_IDR_IDR1_Msk (0x1UL << GPIO_IDR_IDR1_Pos) /*!< 0x00000002 */ #define GPIO_IDR_IDR1 GPIO_IDR_IDR1_Msk /*!< Port input data, bit 1 */ #define GPIO_IDR_IDR2_Pos (2U) #define GPIO_IDR_IDR2_Msk (0x1UL << GPIO_IDR_IDR2_Pos) /*!< 0x00000004 */ #define GPIO_IDR_IDR2 GPIO_IDR_IDR2_Msk /*!< Port input data, bit 2 */ #define GPIO_IDR_IDR3_Pos (3U) #define GPIO_IDR_IDR3_Msk (0x1UL << GPIO_IDR_IDR3_Pos) /*!< 0x00000008 */ #define GPIO_IDR_IDR3 GPIO_IDR_IDR3_Msk /*!< Port input data, bit 3 */ #define GPIO_IDR_IDR4_Pos (4U) #define GPIO_IDR_IDR4_Msk (0x1UL << GPIO_IDR_IDR4_Pos) /*!< 0x00000010 */ #define GPIO_IDR_IDR4 GPIO_IDR_IDR4_Msk /*!< Port input data, bit 4 */ #define GPIO_IDR_IDR5_Pos (5U) #define GPIO_IDR_IDR5_Msk (0x1UL << GPIO_IDR_IDR5_Pos) /*!< 0x00000020 */ #define GPIO_IDR_IDR5 GPIO_IDR_IDR5_Msk /*!< Port input data, bit 5 */ #define GPIO_IDR_IDR6_Pos (6U) #define GPIO_IDR_IDR6_Msk (0x1UL << GPIO_IDR_IDR6_Pos) /*!< 0x00000040 */ #define GPIO_IDR_IDR6 GPIO_IDR_IDR6_Msk /*!< Port input data, bit 6 */ #define GPIO_IDR_IDR7_Pos (7U) #define GPIO_IDR_IDR7_Msk (0x1UL << GPIO_IDR_IDR7_Pos) /*!< 0x00000080 */ #define GPIO_IDR_IDR7 GPIO_IDR_IDR7_Msk /*!< Port input data, bit 7 */ #define GPIO_IDR_IDR8_Pos (8U) #define GPIO_IDR_IDR8_Msk (0x1UL << GPIO_IDR_IDR8_Pos) /*!< 0x00000100 */ #define GPIO_IDR_IDR8 GPIO_IDR_IDR8_Msk /*!< Port input data, bit 8 */ #define GPIO_IDR_IDR9_Pos (9U) #define GPIO_IDR_IDR9_Msk (0x1UL << GPIO_IDR_IDR9_Pos) /*!< 0x00000200 */ #define GPIO_IDR_IDR9 GPIO_IDR_IDR9_Msk /*!< Port input data, bit 9 */ #define GPIO_IDR_IDR10_Pos (10U) #define GPIO_IDR_IDR10_Msk (0x1UL << GPIO_IDR_IDR10_Pos) /*!< 0x00000400 */ #define GPIO_IDR_IDR10 GPIO_IDR_IDR10_Msk /*!< Port input data, bit 10 */ #define GPIO_IDR_IDR11_Pos (11U) #define GPIO_IDR_IDR11_Msk (0x1UL << GPIO_IDR_IDR11_Pos) /*!< 0x00000800 */ #define GPIO_IDR_IDR11 GPIO_IDR_IDR11_Msk /*!< Port input data, bit 11 */ #define GPIO_IDR_IDR12_Pos (12U) #define GPIO_IDR_IDR12_Msk (0x1UL << GPIO_IDR_IDR12_Pos) /*!< 0x00001000 */ #define GPIO_IDR_IDR12 GPIO_IDR_IDR12_Msk /*!< Port input data, bit 12 */ #define GPIO_IDR_IDR13_Pos (13U) #define GPIO_IDR_IDR13_Msk (0x1UL << GPIO_IDR_IDR13_Pos) /*!< 0x00002000 */ #define GPIO_IDR_IDR13 GPIO_IDR_IDR13_Msk /*!< Port input data, bit 13 */ #define GPIO_IDR_IDR14_Pos (14U) #define GPIO_IDR_IDR14_Msk (0x1UL << GPIO_IDR_IDR14_Pos) /*!< 0x00004000 */ #define GPIO_IDR_IDR14 GPIO_IDR_IDR14_Msk /*!< Port input data, bit 14 */ #define GPIO_IDR_IDR15_Pos (15U) #define GPIO_IDR_IDR15_Msk (0x1UL << GPIO_IDR_IDR15_Pos) /*!< 0x00008000 */ #define GPIO_IDR_IDR15 GPIO_IDR_IDR15_Msk /*!< Port input data, bit 15 */ /******************* Bit definition for GPIO_ODR register *******************/ #define GPIO_ODR_ODR0_Pos (0U) #define GPIO_ODR_ODR0_Msk (0x1UL << GPIO_ODR_ODR0_Pos) /*!< 0x00000001 */ #define GPIO_ODR_ODR0 GPIO_ODR_ODR0_Msk /*!< Port output data, bit 0 */ #define GPIO_ODR_ODR1_Pos (1U) #define GPIO_ODR_ODR1_Msk (0x1UL << GPIO_ODR_ODR1_Pos) /*!< 0x00000002 */ #define GPIO_ODR_ODR1 GPIO_ODR_ODR1_Msk /*!< Port output data, bit 1 */ #define GPIO_ODR_ODR2_Pos (2U) #define GPIO_ODR_ODR2_Msk (0x1UL << GPIO_ODR_ODR2_Pos) /*!< 0x00000004 */ #define GPIO_ODR_ODR2 GPIO_ODR_ODR2_Msk /*!< Port output data, bit 2 */ #define GPIO_ODR_ODR3_Pos (3U) #define GPIO_ODR_ODR3_Msk (0x1UL << GPIO_ODR_ODR3_Pos) /*!< 0x00000008 */ #define GPIO_ODR_ODR3 GPIO_ODR_ODR3_Msk /*!< Port output data, bit 3 */ #define GPIO_ODR_ODR4_Pos (4U) #define GPIO_ODR_ODR4_Msk (0x1UL << GPIO_ODR_ODR4_Pos) /*!< 0x00000010 */ #define GPIO_ODR_ODR4 GPIO_ODR_ODR4_Msk /*!< Port output data, bit 4 */ #define GPIO_ODR_ODR5_Pos (5U) #define GPIO_ODR_ODR5_Msk (0x1UL << GPIO_ODR_ODR5_Pos) /*!< 0x00000020 */ #define GPIO_ODR_ODR5 GPIO_ODR_ODR5_Msk /*!< Port output data, bit 5 */ #define GPIO_ODR_ODR6_Pos (6U) #define GPIO_ODR_ODR6_Msk (0x1UL << GPIO_ODR_ODR6_Pos) /*!< 0x00000040 */ #define GPIO_ODR_ODR6 GPIO_ODR_ODR6_Msk /*!< Port output data, bit 6 */ #define GPIO_ODR_ODR7_Pos (7U) #define GPIO_ODR_ODR7_Msk (0x1UL << GPIO_ODR_ODR7_Pos) /*!< 0x00000080 */ #define GPIO_ODR_ODR7 GPIO_ODR_ODR7_Msk /*!< Port output data, bit 7 */ #define GPIO_ODR_ODR8_Pos (8U) #define GPIO_ODR_ODR8_Msk (0x1UL << GPIO_ODR_ODR8_Pos) /*!< 0x00000100 */ #define GPIO_ODR_ODR8 GPIO_ODR_ODR8_Msk /*!< Port output data, bit 8 */ #define GPIO_ODR_ODR9_Pos (9U) #define GPIO_ODR_ODR9_Msk (0x1UL << GPIO_ODR_ODR9_Pos) /*!< 0x00000200 */ #define GPIO_ODR_ODR9 GPIO_ODR_ODR9_Msk /*!< Port output data, bit 9 */ #define GPIO_ODR_ODR10_Pos (10U) #define GPIO_ODR_ODR10_Msk (0x1UL << GPIO_ODR_ODR10_Pos) /*!< 0x00000400 */ #define GPIO_ODR_ODR10 GPIO_ODR_ODR10_Msk /*!< Port output data, bit 10 */ #define GPIO_ODR_ODR11_Pos (11U) #define GPIO_ODR_ODR11_Msk (0x1UL << GPIO_ODR_ODR11_Pos) /*!< 0x00000800 */ #define GPIO_ODR_ODR11 GPIO_ODR_ODR11_Msk /*!< Port output data, bit 11 */ #define GPIO_ODR_ODR12_Pos (12U) #define GPIO_ODR_ODR12_Msk (0x1UL << GPIO_ODR_ODR12_Pos) /*!< 0x00001000 */ #define GPIO_ODR_ODR12 GPIO_ODR_ODR12_Msk /*!< Port output data, bit 12 */ #define GPIO_ODR_ODR13_Pos (13U) #define GPIO_ODR_ODR13_Msk (0x1UL << GPIO_ODR_ODR13_Pos) /*!< 0x00002000 */ #define GPIO_ODR_ODR13 GPIO_ODR_ODR13_Msk /*!< Port output data, bit 13 */ #define GPIO_ODR_ODR14_Pos (14U) #define GPIO_ODR_ODR14_Msk (0x1UL << GPIO_ODR_ODR14_Pos) /*!< 0x00004000 */ #define GPIO_ODR_ODR14 GPIO_ODR_ODR14_Msk /*!< Port output data, bit 14 */ #define GPIO_ODR_ODR15_Pos (15U) #define GPIO_ODR_ODR15_Msk (0x1UL << GPIO_ODR_ODR15_Pos) /*!< 0x00008000 */ #define GPIO_ODR_ODR15 GPIO_ODR_ODR15_Msk /*!< Port output data, bit 15 */ /****************** Bit definition for GPIO_BSRR register *******************/ #define GPIO_BSRR_BS0_Pos (0U) #define GPIO_BSRR_BS0_Msk (0x1UL << GPIO_BSRR_BS0_Pos) /*!< 0x00000001 */ #define GPIO_BSRR_BS0 GPIO_BSRR_BS0_Msk /*!< Port x Set bit 0 */ #define GPIO_BSRR_BS1_Pos (1U) #define GPIO_BSRR_BS1_Msk (0x1UL << GPIO_BSRR_BS1_Pos) /*!< 0x00000002 */ #define GPIO_BSRR_BS1 GPIO_BSRR_BS1_Msk /*!< Port x Set bit 1 */ #define GPIO_BSRR_BS2_Pos (2U) #define GPIO_BSRR_BS2_Msk (0x1UL << GPIO_BSRR_BS2_Pos) /*!< 0x00000004 */ #define GPIO_BSRR_BS2 GPIO_BSRR_BS2_Msk /*!< Port x Set bit 2 */ #define GPIO_BSRR_BS3_Pos (3U) #define GPIO_BSRR_BS3_Msk (0x1UL << GPIO_BSRR_BS3_Pos) /*!< 0x00000008 */ #define GPIO_BSRR_BS3 GPIO_BSRR_BS3_Msk /*!< Port x Set bit 3 */ #define GPIO_BSRR_BS4_Pos (4U) #define GPIO_BSRR_BS4_Msk (0x1UL << GPIO_BSRR_BS4_Pos) /*!< 0x00000010 */ #define GPIO_BSRR_BS4 GPIO_BSRR_BS4_Msk /*!< Port x Set bit 4 */ #define GPIO_BSRR_BS5_Pos (5U) #define GPIO_BSRR_BS5_Msk (0x1UL << GPIO_BSRR_BS5_Pos) /*!< 0x00000020 */ #define GPIO_BSRR_BS5 GPIO_BSRR_BS5_Msk /*!< Port x Set bit 5 */ #define GPIO_BSRR_BS6_Pos (6U) #define GPIO_BSRR_BS6_Msk (0x1UL << GPIO_BSRR_BS6_Pos) /*!< 0x00000040 */ #define GPIO_BSRR_BS6 GPIO_BSRR_BS6_Msk /*!< Port x Set bit 6 */ #define GPIO_BSRR_BS7_Pos (7U) #define GPIO_BSRR_BS7_Msk (0x1UL << GPIO_BSRR_BS7_Pos) /*!< 0x00000080 */ #define GPIO_BSRR_BS7 GPIO_BSRR_BS7_Msk /*!< Port x Set bit 7 */ #define GPIO_BSRR_BS8_Pos (8U) #define GPIO_BSRR_BS8_Msk (0x1UL << GPIO_BSRR_BS8_Pos) /*!< 0x00000100 */ #define GPIO_BSRR_BS8 GPIO_BSRR_BS8_Msk /*!< Port x Set bit 8 */ #define GPIO_BSRR_BS9_Pos (9U) #define GPIO_BSRR_BS9_Msk (0x1UL << GPIO_BSRR_BS9_Pos) /*!< 0x00000200 */ #define GPIO_BSRR_BS9 GPIO_BSRR_BS9_Msk /*!< Port x Set bit 9 */ #define GPIO_BSRR_BS10_Pos (10U) #define GPIO_BSRR_BS10_Msk (0x1UL << GPIO_BSRR_BS10_Pos) /*!< 0x00000400 */ #define GPIO_BSRR_BS10 GPIO_BSRR_BS10_Msk /*!< Port x Set bit 10 */ #define GPIO_BSRR_BS11_Pos (11U) #define GPIO_BSRR_BS11_Msk (0x1UL << GPIO_BSRR_BS11_Pos) /*!< 0x00000800 */ #define GPIO_BSRR_BS11 GPIO_BSRR_BS11_Msk /*!< Port x Set bit 11 */ #define GPIO_BSRR_BS12_Pos (12U) #define GPIO_BSRR_BS12_Msk (0x1UL << GPIO_BSRR_BS12_Pos) /*!< 0x00001000 */ #define GPIO_BSRR_BS12 GPIO_BSRR_BS12_Msk /*!< Port x Set bit 12 */ #define GPIO_BSRR_BS13_Pos (13U) #define GPIO_BSRR_BS13_Msk (0x1UL << GPIO_BSRR_BS13_Pos) /*!< 0x00002000 */ #define GPIO_BSRR_BS13 GPIO_BSRR_BS13_Msk /*!< Port x Set bit 13 */ #define GPIO_BSRR_BS14_Pos (14U) #define GPIO_BSRR_BS14_Msk (0x1UL << GPIO_BSRR_BS14_Pos) /*!< 0x00004000 */ #define GPIO_BSRR_BS14 GPIO_BSRR_BS14_Msk /*!< Port x Set bit 14 */ #define GPIO_BSRR_BS15_Pos (15U) #define GPIO_BSRR_BS15_Msk (0x1UL << GPIO_BSRR_BS15_Pos) /*!< 0x00008000 */ #define GPIO_BSRR_BS15 GPIO_BSRR_BS15_Msk /*!< Port x Set bit 15 */ #define GPIO_BSRR_BR0_Pos (16U) #define GPIO_BSRR_BR0_Msk (0x1UL << GPIO_BSRR_BR0_Pos) /*!< 0x00010000 */ #define GPIO_BSRR_BR0 GPIO_BSRR_BR0_Msk /*!< Port x Reset bit 0 */ #define GPIO_BSRR_BR1_Pos (17U) #define GPIO_BSRR_BR1_Msk (0x1UL << GPIO_BSRR_BR1_Pos) /*!< 0x00020000 */ #define GPIO_BSRR_BR1 GPIO_BSRR_BR1_Msk /*!< Port x Reset bit 1 */ #define GPIO_BSRR_BR2_Pos (18U) #define GPIO_BSRR_BR2_Msk (0x1UL << GPIO_BSRR_BR2_Pos) /*!< 0x00040000 */ #define GPIO_BSRR_BR2 GPIO_BSRR_BR2_Msk /*!< Port x Reset bit 2 */ #define GPIO_BSRR_BR3_Pos (19U) #define GPIO_BSRR_BR3_Msk (0x1UL << GPIO_BSRR_BR3_Pos) /*!< 0x00080000 */ #define GPIO_BSRR_BR3 GPIO_BSRR_BR3_Msk /*!< Port x Reset bit 3 */ #define GPIO_BSRR_BR4_Pos (20U) #define GPIO_BSRR_BR4_Msk (0x1UL << GPIO_BSRR_BR4_Pos) /*!< 0x00100000 */ #define GPIO_BSRR_BR4 GPIO_BSRR_BR4_Msk /*!< Port x Reset bit 4 */ #define GPIO_BSRR_BR5_Pos (21U) #define GPIO_BSRR_BR5_Msk (0x1UL << GPIO_BSRR_BR5_Pos) /*!< 0x00200000 */ #define GPIO_BSRR_BR5 GPIO_BSRR_BR5_Msk /*!< Port x Reset bit 5 */ #define GPIO_BSRR_BR6_Pos (22U) #define GPIO_BSRR_BR6_Msk (0x1UL << GPIO_BSRR_BR6_Pos) /*!< 0x00400000 */ #define GPIO_BSRR_BR6 GPIO_BSRR_BR6_Msk /*!< Port x Reset bit 6 */ #define GPIO_BSRR_BR7_Pos (23U) #define GPIO_BSRR_BR7_Msk (0x1UL << GPIO_BSRR_BR7_Pos) /*!< 0x00800000 */ #define GPIO_BSRR_BR7 GPIO_BSRR_BR7_Msk /*!< Port x Reset bit 7 */ #define GPIO_BSRR_BR8_Pos (24U) #define GPIO_BSRR_BR8_Msk (0x1UL << GPIO_BSRR_BR8_Pos) /*!< 0x01000000 */ #define GPIO_BSRR_BR8 GPIO_BSRR_BR8_Msk /*!< Port x Reset bit 8 */ #define GPIO_BSRR_BR9_Pos (25U) #define GPIO_BSRR_BR9_Msk (0x1UL << GPIO_BSRR_BR9_Pos) /*!< 0x02000000 */ #define GPIO_BSRR_BR9 GPIO_BSRR_BR9_Msk /*!< Port x Reset bit 9 */ #define GPIO_BSRR_BR10_Pos (26U) #define GPIO_BSRR_BR10_Msk (0x1UL << GPIO_BSRR_BR10_Pos) /*!< 0x04000000 */ #define GPIO_BSRR_BR10 GPIO_BSRR_BR10_Msk /*!< Port x Reset bit 10 */ #define GPIO_BSRR_BR11_Pos (27U) #define GPIO_BSRR_BR11_Msk (0x1UL << GPIO_BSRR_BR11_Pos) /*!< 0x08000000 */ #define GPIO_BSRR_BR11 GPIO_BSRR_BR11_Msk /*!< Port x Reset bit 11 */ #define GPIO_BSRR_BR12_Pos (28U) #define GPIO_BSRR_BR12_Msk (0x1UL << GPIO_BSRR_BR12_Pos) /*!< 0x10000000 */ #define GPIO_BSRR_BR12 GPIO_BSRR_BR12_Msk /*!< Port x Reset bit 12 */ #define GPIO_BSRR_BR13_Pos (29U) #define GPIO_BSRR_BR13_Msk (0x1UL << GPIO_BSRR_BR13_Pos) /*!< 0x20000000 */ #define GPIO_BSRR_BR13 GPIO_BSRR_BR13_Msk /*!< Port x Reset bit 13 */ #define GPIO_BSRR_BR14_Pos (30U) #define GPIO_BSRR_BR14_Msk (0x1UL << GPIO_BSRR_BR14_Pos) /*!< 0x40000000 */ #define GPIO_BSRR_BR14 GPIO_BSRR_BR14_Msk /*!< Port x Reset bit 14 */ #define GPIO_BSRR_BR15_Pos (31U) #define GPIO_BSRR_BR15_Msk (0x1UL << GPIO_BSRR_BR15_Pos) /*!< 0x80000000 */ #define GPIO_BSRR_BR15 GPIO_BSRR_BR15_Msk /*!< Port x Reset bit 15 */ /******************* Bit definition for GPIO_BRR register *******************/ #define GPIO_BRR_BR0_Pos (0U) #define GPIO_BRR_BR0_Msk (0x1UL << GPIO_BRR_BR0_Pos) /*!< 0x00000001 */ #define GPIO_BRR_BR0 GPIO_BRR_BR0_Msk /*!< Port x Reset bit 0 */ #define GPIO_BRR_BR1_Pos (1U) #define GPIO_BRR_BR1_Msk (0x1UL << GPIO_BRR_BR1_Pos) /*!< 0x00000002 */ #define GPIO_BRR_BR1 GPIO_BRR_BR1_Msk /*!< Port x Reset bit 1 */ #define GPIO_BRR_BR2_Pos (2U) #define GPIO_BRR_BR2_Msk (0x1UL << GPIO_BRR_BR2_Pos) /*!< 0x00000004 */ #define GPIO_BRR_BR2 GPIO_BRR_BR2_Msk /*!< Port x Reset bit 2 */ #define GPIO_BRR_BR3_Pos (3U) #define GPIO_BRR_BR3_Msk (0x1UL << GPIO_BRR_BR3_Pos) /*!< 0x00000008 */ #define GPIO_BRR_BR3 GPIO_BRR_BR3_Msk /*!< Port x Reset bit 3 */ #define GPIO_BRR_BR4_Pos (4U) #define GPIO_BRR_BR4_Msk (0x1UL << GPIO_BRR_BR4_Pos) /*!< 0x00000010 */ #define GPIO_BRR_BR4 GPIO_BRR_BR4_Msk /*!< Port x Reset bit 4 */ #define GPIO_BRR_BR5_Pos (5U) #define GPIO_BRR_BR5_Msk (0x1UL << GPIO_BRR_BR5_Pos) /*!< 0x00000020 */ #define GPIO_BRR_BR5 GPIO_BRR_BR5_Msk /*!< Port x Reset bit 5 */ #define GPIO_BRR_BR6_Pos (6U) #define GPIO_BRR_BR6_Msk (0x1UL << GPIO_BRR_BR6_Pos) /*!< 0x00000040 */ #define GPIO_BRR_BR6 GPIO_BRR_BR6_Msk /*!< Port x Reset bit 6 */ #define GPIO_BRR_BR7_Pos (7U) #define GPIO_BRR_BR7_Msk (0x1UL << GPIO_BRR_BR7_Pos) /*!< 0x00000080 */ #define GPIO_BRR_BR7 GPIO_BRR_BR7_Msk /*!< Port x Reset bit 7 */ #define GPIO_BRR_BR8_Pos (8U) #define GPIO_BRR_BR8_Msk (0x1UL << GPIO_BRR_BR8_Pos) /*!< 0x00000100 */ #define GPIO_BRR_BR8 GPIO_BRR_BR8_Msk /*!< Port x Reset bit 8 */ #define GPIO_BRR_BR9_Pos (9U) #define GPIO_BRR_BR9_Msk (0x1UL << GPIO_BRR_BR9_Pos) /*!< 0x00000200 */ #define GPIO_BRR_BR9 GPIO_BRR_BR9_Msk /*!< Port x Reset bit 9 */ #define GPIO_BRR_BR10_Pos (10U) #define GPIO_BRR_BR10_Msk (0x1UL << GPIO_BRR_BR10_Pos) /*!< 0x00000400 */ #define GPIO_BRR_BR10 GPIO_BRR_BR10_Msk /*!< Port x Reset bit 10 */ #define GPIO_BRR_BR11_Pos (11U) #define GPIO_BRR_BR11_Msk (0x1UL << GPIO_BRR_BR11_Pos) /*!< 0x00000800 */ #define GPIO_BRR_BR11 GPIO_BRR_BR11_Msk /*!< Port x Reset bit 11 */ #define GPIO_BRR_BR12_Pos (12U) #define GPIO_BRR_BR12_Msk (0x1UL << GPIO_BRR_BR12_Pos) /*!< 0x00001000 */ #define GPIO_BRR_BR12 GPIO_BRR_BR12_Msk /*!< Port x Reset bit 12 */ #define GPIO_BRR_BR13_Pos (13U) #define GPIO_BRR_BR13_Msk (0x1UL << GPIO_BRR_BR13_Pos) /*!< 0x00002000 */ #define GPIO_BRR_BR13 GPIO_BRR_BR13_Msk /*!< Port x Reset bit 13 */ #define GPIO_BRR_BR14_Pos (14U) #define GPIO_BRR_BR14_Msk (0x1UL << GPIO_BRR_BR14_Pos) /*!< 0x00004000 */ #define GPIO_BRR_BR14 GPIO_BRR_BR14_Msk /*!< Port x Reset bit 14 */ #define GPIO_BRR_BR15_Pos (15U) #define GPIO_BRR_BR15_Msk (0x1UL << GPIO_BRR_BR15_Pos) /*!< 0x00008000 */ #define GPIO_BRR_BR15 GPIO_BRR_BR15_Msk /*!< Port x Reset bit 15 */ /****************** Bit definition for GPIO_LCKR register *******************/ #define GPIO_LCKR_LCK0_Pos (0U) #define GPIO_LCKR_LCK0_Msk (0x1UL << GPIO_LCKR_LCK0_Pos) /*!< 0x00000001 */ #define GPIO_LCKR_LCK0 GPIO_LCKR_LCK0_Msk /*!< Port x Lock bit 0 */ #define GPIO_LCKR_LCK1_Pos (1U) #define GPIO_LCKR_LCK1_Msk (0x1UL << GPIO_LCKR_LCK1_Pos) /*!< 0x00000002 */ #define GPIO_LCKR_LCK1 GPIO_LCKR_LCK1_Msk /*!< Port x Lock bit 1 */ #define GPIO_LCKR_LCK2_Pos (2U) #define GPIO_LCKR_LCK2_Msk (0x1UL << GPIO_LCKR_LCK2_Pos) /*!< 0x00000004 */ #define GPIO_LCKR_LCK2 GPIO_LCKR_LCK2_Msk /*!< Port x Lock bit 2 */ #define GPIO_LCKR_LCK3_Pos (3U) #define GPIO_LCKR_LCK3_Msk (0x1UL << GPIO_LCKR_LCK3_Pos) /*!< 0x00000008 */ #define GPIO_LCKR_LCK3 GPIO_LCKR_LCK3_Msk /*!< Port x Lock bit 3 */ #define GPIO_LCKR_LCK4_Pos (4U) #define GPIO_LCKR_LCK4_Msk (0x1UL << GPIO_LCKR_LCK4_Pos) /*!< 0x00000010 */ #define GPIO_LCKR_LCK4 GPIO_LCKR_LCK4_Msk /*!< Port x Lock bit 4 */ #define GPIO_LCKR_LCK5_Pos (5U) #define GPIO_LCKR_LCK5_Msk (0x1UL << GPIO_LCKR_LCK5_Pos) /*!< 0x00000020 */ #define GPIO_LCKR_LCK5 GPIO_LCKR_LCK5_Msk /*!< Port x Lock bit 5 */ #define GPIO_LCKR_LCK6_Pos (6U) #define GPIO_LCKR_LCK6_Msk (0x1UL << GPIO_LCKR_LCK6_Pos) /*!< 0x00000040 */ #define GPIO_LCKR_LCK6 GPIO_LCKR_LCK6_Msk /*!< Port x Lock bit 6 */ #define GPIO_LCKR_LCK7_Pos (7U) #define GPIO_LCKR_LCK7_Msk (0x1UL << GPIO_LCKR_LCK7_Pos) /*!< 0x00000080 */ #define GPIO_LCKR_LCK7 GPIO_LCKR_LCK7_Msk /*!< Port x Lock bit 7 */ #define GPIO_LCKR_LCK8_Pos (8U) #define GPIO_LCKR_LCK8_Msk (0x1UL << GPIO_LCKR_LCK8_Pos) /*!< 0x00000100 */ #define GPIO_LCKR_LCK8 GPIO_LCKR_LCK8_Msk /*!< Port x Lock bit 8 */ #define GPIO_LCKR_LCK9_Pos (9U) #define GPIO_LCKR_LCK9_Msk (0x1UL << GPIO_LCKR_LCK9_Pos) /*!< 0x00000200 */ #define GPIO_LCKR_LCK9 GPIO_LCKR_LCK9_Msk /*!< Port x Lock bit 9 */ #define GPIO_LCKR_LCK10_Pos (10U) #define GPIO_LCKR_LCK10_Msk (0x1UL << GPIO_LCKR_LCK10_Pos) /*!< 0x00000400 */ #define GPIO_LCKR_LCK10 GPIO_LCKR_LCK10_Msk /*!< Port x Lock bit 10 */ #define GPIO_LCKR_LCK11_Pos (11U) #define GPIO_LCKR_LCK11_Msk (0x1UL << GPIO_LCKR_LCK11_Pos) /*!< 0x00000800 */ #define GPIO_LCKR_LCK11 GPIO_LCKR_LCK11_Msk /*!< Port x Lock bit 11 */ #define GPIO_LCKR_LCK12_Pos (12U) #define GPIO_LCKR_LCK12_Msk (0x1UL << GPIO_LCKR_LCK12_Pos) /*!< 0x00001000 */ #define GPIO_LCKR_LCK12 GPIO_LCKR_LCK12_Msk /*!< Port x Lock bit 12 */ #define GPIO_LCKR_LCK13_Pos (13U) #define GPIO_LCKR_LCK13_Msk (0x1UL << GPIO_LCKR_LCK13_Pos) /*!< 0x00002000 */ #define GPIO_LCKR_LCK13 GPIO_LCKR_LCK13_Msk /*!< Port x Lock bit 13 */ #define GPIO_LCKR_LCK14_Pos (14U) #define GPIO_LCKR_LCK14_Msk (0x1UL << GPIO_LCKR_LCK14_Pos) /*!< 0x00004000 */ #define GPIO_LCKR_LCK14 GPIO_LCKR_LCK14_Msk /*!< Port x Lock bit 14 */ #define GPIO_LCKR_LCK15_Pos (15U) #define GPIO_LCKR_LCK15_Msk (0x1UL << GPIO_LCKR_LCK15_Pos) /*!< 0x00008000 */ #define GPIO_LCKR_LCK15 GPIO_LCKR_LCK15_Msk /*!< Port x Lock bit 15 */ #define GPIO_LCKR_LCKK_Pos (16U) #define GPIO_LCKR_LCKK_Msk (0x1UL << GPIO_LCKR_LCKK_Pos) /*!< 0x00010000 */ #define GPIO_LCKR_LCKK GPIO_LCKR_LCKK_Msk /*!< Lock key */ /*----------------------------------------------------------------------------*/ /****************** Bit definition for AFIO_EVCR register *******************/ #define AFIO_EVCR_PIN_Pos (0U) #define AFIO_EVCR_PIN_Msk (0xFUL << AFIO_EVCR_PIN_Pos) /*!< 0x0000000F */ #define AFIO_EVCR_PIN AFIO_EVCR_PIN_Msk /*!< PIN[3:0] bits (Pin selection) */ #define AFIO_EVCR_PIN_0 (0x1UL << AFIO_EVCR_PIN_Pos) /*!< 0x00000001 */ #define AFIO_EVCR_PIN_1 (0x2UL << AFIO_EVCR_PIN_Pos) /*!< 0x00000002 */ #define AFIO_EVCR_PIN_2 (0x4UL << AFIO_EVCR_PIN_Pos) /*!< 0x00000004 */ #define AFIO_EVCR_PIN_3 (0x8UL << AFIO_EVCR_PIN_Pos) /*!< 0x00000008 */ /*!< PIN configuration */ #define AFIO_EVCR_PIN_PX0 0x00000000U /*!< Pin 0 selected */ #define AFIO_EVCR_PIN_PX1_Pos (0U) #define AFIO_EVCR_PIN_PX1_Msk (0x1UL << AFIO_EVCR_PIN_PX1_Pos) /*!< 0x00000001 */ #define AFIO_EVCR_PIN_PX1 AFIO_EVCR_PIN_PX1_Msk /*!< Pin 1 selected */ #define AFIO_EVCR_PIN_PX2_Pos (1U) #define AFIO_EVCR_PIN_PX2_Msk (0x1UL << AFIO_EVCR_PIN_PX2_Pos) /*!< 0x00000002 */ #define AFIO_EVCR_PIN_PX2 AFIO_EVCR_PIN_PX2_Msk /*!< Pin 2 selected */ #define AFIO_EVCR_PIN_PX3_Pos (0U) #define AFIO_EVCR_PIN_PX3_Msk (0x3UL << AFIO_EVCR_PIN_PX3_Pos) /*!< 0x00000003 */ #define AFIO_EVCR_PIN_PX3 AFIO_EVCR_PIN_PX3_Msk /*!< Pin 3 selected */ #define AFIO_EVCR_PIN_PX4_Pos (2U) #define AFIO_EVCR_PIN_PX4_Msk (0x1UL << AFIO_EVCR_PIN_PX4_Pos) /*!< 0x00000004 */ #define AFIO_EVCR_PIN_PX4 AFIO_EVCR_PIN_PX4_Msk /*!< Pin 4 selected */ #define AFIO_EVCR_PIN_PX5_Pos (0U) #define AFIO_EVCR_PIN_PX5_Msk (0x5UL << AFIO_EVCR_PIN_PX5_Pos) /*!< 0x00000005 */ #define AFIO_EVCR_PIN_PX5 AFIO_EVCR_PIN_PX5_Msk /*!< Pin 5 selected */ #define AFIO_EVCR_PIN_PX6_Pos (1U) #define AFIO_EVCR_PIN_PX6_Msk (0x3UL << AFIO_EVCR_PIN_PX6_Pos) /*!< 0x00000006 */ #define AFIO_EVCR_PIN_PX6 AFIO_EVCR_PIN_PX6_Msk /*!< Pin 6 selected */ #define AFIO_EVCR_PIN_PX7_Pos (0U) #define AFIO_EVCR_PIN_PX7_Msk (0x7UL << AFIO_EVCR_PIN_PX7_Pos) /*!< 0x00000007 */ #define AFIO_EVCR_PIN_PX7 AFIO_EVCR_PIN_PX7_Msk /*!< Pin 7 selected */ #define AFIO_EVCR_PIN_PX8_Pos (3U) #define AFIO_EVCR_PIN_PX8_Msk (0x1UL << AFIO_EVCR_PIN_PX8_Pos) /*!< 0x00000008 */ #define AFIO_EVCR_PIN_PX8 AFIO_EVCR_PIN_PX8_Msk /*!< Pin 8 selected */ #define AFIO_EVCR_PIN_PX9_Pos (0U) #define AFIO_EVCR_PIN_PX9_Msk (0x9UL << AFIO_EVCR_PIN_PX9_Pos) /*!< 0x00000009 */ #define AFIO_EVCR_PIN_PX9 AFIO_EVCR_PIN_PX9_Msk /*!< Pin 9 selected */ #define AFIO_EVCR_PIN_PX10_Pos (1U) #define AFIO_EVCR_PIN_PX10_Msk (0x5UL << AFIO_EVCR_PIN_PX10_Pos) /*!< 0x0000000A */ #define AFIO_EVCR_PIN_PX10 AFIO_EVCR_PIN_PX10_Msk /*!< Pin 10 selected */ #define AFIO_EVCR_PIN_PX11_Pos (0U) #define AFIO_EVCR_PIN_PX11_Msk (0xBUL << AFIO_EVCR_PIN_PX11_Pos) /*!< 0x0000000B */ #define AFIO_EVCR_PIN_PX11 AFIO_EVCR_PIN_PX11_Msk /*!< Pin 11 selected */ #define AFIO_EVCR_PIN_PX12_Pos (2U) #define AFIO_EVCR_PIN_PX12_Msk (0x3UL << AFIO_EVCR_PIN_PX12_Pos) /*!< 0x0000000C */ #define AFIO_EVCR_PIN_PX12 AFIO_EVCR_PIN_PX12_Msk /*!< Pin 12 selected */ #define AFIO_EVCR_PIN_PX13_Pos (0U) #define AFIO_EVCR_PIN_PX13_Msk (0xDUL << AFIO_EVCR_PIN_PX13_Pos) /*!< 0x0000000D */ #define AFIO_EVCR_PIN_PX13 AFIO_EVCR_PIN_PX13_Msk /*!< Pin 13 selected */ #define AFIO_EVCR_PIN_PX14_Pos (1U) #define AFIO_EVCR_PIN_PX14_Msk (0x7UL << AFIO_EVCR_PIN_PX14_Pos) /*!< 0x0000000E */ #define AFIO_EVCR_PIN_PX14 AFIO_EVCR_PIN_PX14_Msk /*!< Pin 14 selected */ #define AFIO_EVCR_PIN_PX15_Pos (0U) #define AFIO_EVCR_PIN_PX15_Msk (0xFUL << AFIO_EVCR_PIN_PX15_Pos) /*!< 0x0000000F */ #define AFIO_EVCR_PIN_PX15 AFIO_EVCR_PIN_PX15_Msk /*!< Pin 15 selected */ #define AFIO_EVCR_PORT_Pos (4U) #define AFIO_EVCR_PORT_Msk (0x7UL << AFIO_EVCR_PORT_Pos) /*!< 0x00000070 */ #define AFIO_EVCR_PORT AFIO_EVCR_PORT_Msk /*!< PORT[2:0] bits (Port selection) */ #define AFIO_EVCR_PORT_0 (0x1UL << AFIO_EVCR_PORT_Pos) /*!< 0x00000010 */ #define AFIO_EVCR_PORT_1 (0x2UL << AFIO_EVCR_PORT_Pos) /*!< 0x00000020 */ #define AFIO_EVCR_PORT_2 (0x4UL << AFIO_EVCR_PORT_Pos) /*!< 0x00000040 */ /*!< PORT configuration */ #define AFIO_EVCR_PORT_PA 0x00000000 /*!< Port A selected */ #define AFIO_EVCR_PORT_PB_Pos (4U) #define AFIO_EVCR_PORT_PB_Msk (0x1UL << AFIO_EVCR_PORT_PB_Pos) /*!< 0x00000010 */ #define AFIO_EVCR_PORT_PB AFIO_EVCR_PORT_PB_Msk /*!< Port B selected */ #define AFIO_EVCR_PORT_PC_Pos (5U) #define AFIO_EVCR_PORT_PC_Msk (0x1UL << AFIO_EVCR_PORT_PC_Pos) /*!< 0x00000020 */ #define AFIO_EVCR_PORT_PC AFIO_EVCR_PORT_PC_Msk /*!< Port C selected */ #define AFIO_EVCR_PORT_PD_Pos (4U) #define AFIO_EVCR_PORT_PD_Msk (0x3UL << AFIO_EVCR_PORT_PD_Pos) /*!< 0x00000030 */ #define AFIO_EVCR_PORT_PD AFIO_EVCR_PORT_PD_Msk /*!< Port D selected */ #define AFIO_EVCR_PORT_PE_Pos (6U) #define AFIO_EVCR_PORT_PE_Msk (0x1UL << AFIO_EVCR_PORT_PE_Pos) /*!< 0x00000040 */ #define AFIO_EVCR_PORT_PE AFIO_EVCR_PORT_PE_Msk /*!< Port E selected */ #define AFIO_EVCR_EVOE_Pos (7U) #define AFIO_EVCR_EVOE_Msk (0x1UL << AFIO_EVCR_EVOE_Pos) /*!< 0x00000080 */ #define AFIO_EVCR_EVOE AFIO_EVCR_EVOE_Msk /*!< Event Output Enable */ /****************** Bit definition for AFIO_MAPR register *******************/ #define AFIO_MAPR_SPI1_REMAP_Pos (0U) #define AFIO_MAPR_SPI1_REMAP_Msk (0x1UL << AFIO_MAPR_SPI1_REMAP_Pos) /*!< 0x00000001 */ #define AFIO_MAPR_SPI1_REMAP AFIO_MAPR_SPI1_REMAP_Msk /*!< SPI1 remapping */ #define AFIO_MAPR_I2C1_REMAP_Pos (1U) #define AFIO_MAPR_I2C1_REMAP_Msk (0x1UL << AFIO_MAPR_I2C1_REMAP_Pos) /*!< 0x00000002 */ #define AFIO_MAPR_I2C1_REMAP AFIO_MAPR_I2C1_REMAP_Msk /*!< I2C1 remapping */ #define AFIO_MAPR_USART1_REMAP_Pos (2U) #define AFIO_MAPR_USART1_REMAP_Msk (0x1UL << AFIO_MAPR_USART1_REMAP_Pos) /*!< 0x00000004 */ #define AFIO_MAPR_USART1_REMAP AFIO_MAPR_USART1_REMAP_Msk /*!< USART1 remapping */ #define AFIO_MAPR_USART2_REMAP_Pos (3U) #define AFIO_MAPR_USART2_REMAP_Msk (0x1UL << AFIO_MAPR_USART2_REMAP_Pos) /*!< 0x00000008 */ #define AFIO_MAPR_USART2_REMAP AFIO_MAPR_USART2_REMAP_Msk /*!< USART2 remapping */ #define AFIO_MAPR_USART3_REMAP_Pos (4U) #define AFIO_MAPR_USART3_REMAP_Msk (0x3UL << AFIO_MAPR_USART3_REMAP_Pos) /*!< 0x00000030 */ #define AFIO_MAPR_USART3_REMAP AFIO_MAPR_USART3_REMAP_Msk /*!< USART3_REMAP[1:0] bits (USART3 remapping) */ #define AFIO_MAPR_USART3_REMAP_0 (0x1UL << AFIO_MAPR_USART3_REMAP_Pos) /*!< 0x00000010 */ #define AFIO_MAPR_USART3_REMAP_1 (0x2UL << AFIO_MAPR_USART3_REMAP_Pos) /*!< 0x00000020 */ /* USART3_REMAP configuration */ #define AFIO_MAPR_USART3_REMAP_NOREMAP 0x00000000U /*!< No remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14) */ #define AFIO_MAPR_USART3_REMAP_PARTIALREMAP_Pos (4U) #define AFIO_MAPR_USART3_REMAP_PARTIALREMAP_Msk (0x1UL << AFIO_MAPR_USART3_REMAP_PARTIALREMAP_Pos) /*!< 0x00000010 */ #define AFIO_MAPR_USART3_REMAP_PARTIALREMAP AFIO_MAPR_USART3_REMAP_PARTIALREMAP_Msk /*!< Partial remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14) */ #define AFIO_MAPR_USART3_REMAP_FULLREMAP_Pos (4U) #define AFIO_MAPR_USART3_REMAP_FULLREMAP_Msk (0x3UL << AFIO_MAPR_USART3_REMAP_FULLREMAP_Pos) /*!< 0x00000030 */ #define AFIO_MAPR_USART3_REMAP_FULLREMAP AFIO_MAPR_USART3_REMAP_FULLREMAP_Msk /*!< Full remap (TX/PD8, RX/PD9, CK/PD10, CTS/PD11, RTS/PD12) */ #define AFIO_MAPR_TIM1_REMAP_Pos (6U) #define AFIO_MAPR_TIM1_REMAP_Msk (0x3UL << AFIO_MAPR_TIM1_REMAP_Pos) /*!< 0x000000C0 */ #define AFIO_MAPR_TIM1_REMAP AFIO_MAPR_TIM1_REMAP_Msk /*!< TIM1_REMAP[1:0] bits (TIM1 remapping) */ #define AFIO_MAPR_TIM1_REMAP_0 (0x1UL << AFIO_MAPR_TIM1_REMAP_Pos) /*!< 0x00000040 */ #define AFIO_MAPR_TIM1_REMAP_1 (0x2UL << AFIO_MAPR_TIM1_REMAP_Pos) /*!< 0x00000080 */ /*!< TIM1_REMAP configuration */ #define AFIO_MAPR_TIM1_REMAP_NOREMAP 0x00000000U /*!< No remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15) */ #define AFIO_MAPR_TIM1_REMAP_PARTIALREMAP_Pos (6U) #define AFIO_MAPR_TIM1_REMAP_PARTIALREMAP_Msk (0x1UL << AFIO_MAPR_TIM1_REMAP_PARTIALREMAP_Pos) /*!< 0x00000040 */ #define AFIO_MAPR_TIM1_REMAP_PARTIALREMAP AFIO_MAPR_TIM1_REMAP_PARTIALREMAP_Msk /*!< Partial remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PA6, CH1N/PA7, CH2N/PB0, CH3N/PB1) */ #define AFIO_MAPR_TIM1_REMAP_FULLREMAP_Pos (6U) #define AFIO_MAPR_TIM1_REMAP_FULLREMAP_Msk (0x3UL << AFIO_MAPR_TIM1_REMAP_FULLREMAP_Pos) /*!< 0x000000C0 */ #define AFIO_MAPR_TIM1_REMAP_FULLREMAP AFIO_MAPR_TIM1_REMAP_FULLREMAP_Msk /*!< Full remap (ETR/PE7, CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15, CH1N/PE8, CH2N/PE10, CH3N/PE12) */ #define AFIO_MAPR_TIM2_REMAP_Pos (8U) #define AFIO_MAPR_TIM2_REMAP_Msk (0x3UL << AFIO_MAPR_TIM2_REMAP_Pos) /*!< 0x00000300 */ #define AFIO_MAPR_TIM2_REMAP AFIO_MAPR_TIM2_REMAP_Msk /*!< TIM2_REMAP[1:0] bits (TIM2 remapping) */ #define AFIO_MAPR_TIM2_REMAP_0 (0x1UL << AFIO_MAPR_TIM2_REMAP_Pos) /*!< 0x00000100 */ #define AFIO_MAPR_TIM2_REMAP_1 (0x2UL << AFIO_MAPR_TIM2_REMAP_Pos) /*!< 0x00000200 */ /*!< TIM2_REMAP configuration */ #define AFIO_MAPR_TIM2_REMAP_NOREMAP 0x00000000U /*!< No remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3) */ #define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1_Pos (8U) #define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1_Msk (0x1UL << AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1_Pos) /*!< 0x00000100 */ #define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1 AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1_Msk /*!< Partial remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2, CH4/PA3) */ #define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2_Pos (9U) #define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2_Msk (0x1UL << AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2_Pos) /*!< 0x00000200 */ #define AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2 AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2_Msk /*!< Partial remap (CH1/ETR/PA0, CH2/PA1, CH3/PB10, CH4/PB11) */ #define AFIO_MAPR_TIM2_REMAP_FULLREMAP_Pos (8U) #define AFIO_MAPR_TIM2_REMAP_FULLREMAP_Msk (0x3UL << AFIO_MAPR_TIM2_REMAP_FULLREMAP_Pos) /*!< 0x00000300 */ #define AFIO_MAPR_TIM2_REMAP_FULLREMAP AFIO_MAPR_TIM2_REMAP_FULLREMAP_Msk /*!< Full remap (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11) */ #define AFIO_MAPR_TIM3_REMAP_Pos (10U) #define AFIO_MAPR_TIM3_REMAP_Msk (0x3UL << AFIO_MAPR_TIM3_REMAP_Pos) /*!< 0x00000C00 */ #define AFIO_MAPR_TIM3_REMAP AFIO_MAPR_TIM3_REMAP_Msk /*!< TIM3_REMAP[1:0] bits (TIM3 remapping) */ #define AFIO_MAPR_TIM3_REMAP_0 (0x1UL << AFIO_MAPR_TIM3_REMAP_Pos) /*!< 0x00000400 */ #define AFIO_MAPR_TIM3_REMAP_1 (0x2UL << AFIO_MAPR_TIM3_REMAP_Pos) /*!< 0x00000800 */ /*!< TIM3_REMAP configuration */ #define AFIO_MAPR_TIM3_REMAP_NOREMAP 0x00000000U /*!< No remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1) */ #define AFIO_MAPR_TIM3_REMAP_PARTIALREMAP_Pos (11U) #define AFIO_MAPR_TIM3_REMAP_PARTIALREMAP_Msk (0x1UL << AFIO_MAPR_TIM3_REMAP_PARTIALREMAP_Pos) /*!< 0x00000800 */ #define AFIO_MAPR_TIM3_REMAP_PARTIALREMAP AFIO_MAPR_TIM3_REMAP_PARTIALREMAP_Msk /*!< Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1) */ #define AFIO_MAPR_TIM3_REMAP_FULLREMAP_Pos (10U) #define AFIO_MAPR_TIM3_REMAP_FULLREMAP_Msk (0x3UL << AFIO_MAPR_TIM3_REMAP_FULLREMAP_Pos) /*!< 0x00000C00 */ #define AFIO_MAPR_TIM3_REMAP_FULLREMAP AFIO_MAPR_TIM3_REMAP_FULLREMAP_Msk /*!< Full remap (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9) */ #define AFIO_MAPR_TIM4_REMAP_Pos (12U) #define AFIO_MAPR_TIM4_REMAP_Msk (0x1UL << AFIO_MAPR_TIM4_REMAP_Pos) /*!< 0x00001000 */ #define AFIO_MAPR_TIM4_REMAP AFIO_MAPR_TIM4_REMAP_Msk /*!< TIM4_REMAP bit (TIM4 remapping) */ #define AFIO_MAPR_CAN_REMAP_Pos (13U) #define AFIO_MAPR_CAN_REMAP_Msk (0x3UL << AFIO_MAPR_CAN_REMAP_Pos) /*!< 0x00006000 */ #define AFIO_MAPR_CAN_REMAP AFIO_MAPR_CAN_REMAP_Msk /*!< CAN_REMAP[1:0] bits (CAN Alternate function remapping) */ #define AFIO_MAPR_CAN_REMAP_0 (0x1UL << AFIO_MAPR_CAN_REMAP_Pos) /*!< 0x00002000 */ #define AFIO_MAPR_CAN_REMAP_1 (0x2UL << AFIO_MAPR_CAN_REMAP_Pos) /*!< 0x00004000 */ /*!< CAN_REMAP configuration */ #define AFIO_MAPR_CAN_REMAP_REMAP1 0x00000000U /*!< CANRX mapped to PA11, CANTX mapped to PA12 */ #define AFIO_MAPR_CAN_REMAP_REMAP2_Pos (14U) #define AFIO_MAPR_CAN_REMAP_REMAP2_Msk (0x1UL << AFIO_MAPR_CAN_REMAP_REMAP2_Pos) /*!< 0x00004000 */ #define AFIO_MAPR_CAN_REMAP_REMAP2 AFIO_MAPR_CAN_REMAP_REMAP2_Msk /*!< CANRX mapped to PB8, CANTX mapped to PB9 */ #define AFIO_MAPR_CAN_REMAP_REMAP3_Pos (13U) #define AFIO_MAPR_CAN_REMAP_REMAP3_Msk (0x3UL << AFIO_MAPR_CAN_REMAP_REMAP3_Pos) /*!< 0x00006000 */ #define AFIO_MAPR_CAN_REMAP_REMAP3 AFIO_MAPR_CAN_REMAP_REMAP3_Msk /*!< CANRX mapped to PD0, CANTX mapped to PD1 */ #define AFIO_MAPR_PD01_REMAP_Pos (15U) #define AFIO_MAPR_PD01_REMAP_Msk (0x1UL << AFIO_MAPR_PD01_REMAP_Pos) /*!< 0x00008000 */ #define AFIO_MAPR_PD01_REMAP AFIO_MAPR_PD01_REMAP_Msk /*!< Port D0/Port D1 mapping on OSC_IN/OSC_OUT */ #define AFIO_MAPR_TIM5CH4_IREMAP_Pos (16U) #define AFIO_MAPR_TIM5CH4_IREMAP_Msk (0x1UL << AFIO_MAPR_TIM5CH4_IREMAP_Pos) /*!< 0x00010000 */ #define AFIO_MAPR_TIM5CH4_IREMAP AFIO_MAPR_TIM5CH4_IREMAP_Msk /*!< TIM5 Channel4 Internal Remap */ #define AFIO_MAPR_ADC1_ETRGINJ_REMAP_Pos (17U) #define AFIO_MAPR_ADC1_ETRGINJ_REMAP_Msk (0x1UL << AFIO_MAPR_ADC1_ETRGINJ_REMAP_Pos) /*!< 0x00020000 */ #define AFIO_MAPR_ADC1_ETRGINJ_REMAP AFIO_MAPR_ADC1_ETRGINJ_REMAP_Msk /*!< ADC 1 External Trigger Injected Conversion remapping */ #define AFIO_MAPR_ADC1_ETRGREG_REMAP_Pos (18U) #define AFIO_MAPR_ADC1_ETRGREG_REMAP_Msk (0x1UL << AFIO_MAPR_ADC1_ETRGREG_REMAP_Pos) /*!< 0x00040000 */ #define AFIO_MAPR_ADC1_ETRGREG_REMAP AFIO_MAPR_ADC1_ETRGREG_REMAP_Msk /*!< ADC 1 External Trigger Regular Conversion remapping */ #define AFIO_MAPR_ADC2_ETRGINJ_REMAP_Pos (19U) #define AFIO_MAPR_ADC2_ETRGINJ_REMAP_Msk (0x1UL << AFIO_MAPR_ADC2_ETRGINJ_REMAP_Pos) /*!< 0x00080000 */ #define AFIO_MAPR_ADC2_ETRGINJ_REMAP AFIO_MAPR_ADC2_ETRGINJ_REMAP_Msk /*!< ADC 2 External Trigger Injected Conversion remapping */ #define AFIO_MAPR_ADC2_ETRGREG_REMAP_Pos (20U) #define AFIO_MAPR_ADC2_ETRGREG_REMAP_Msk (0x1UL << AFIO_MAPR_ADC2_ETRGREG_REMAP_Pos) /*!< 0x00100000 */ #define AFIO_MAPR_ADC2_ETRGREG_REMAP AFIO_MAPR_ADC2_ETRGREG_REMAP_Msk /*!< ADC 2 External Trigger Regular Conversion remapping */ /*!< SWJ_CFG configuration */ #define AFIO_MAPR_SWJ_CFG_Pos (24U) #define AFIO_MAPR_SWJ_CFG_Msk (0x7UL << AFIO_MAPR_SWJ_CFG_Pos) /*!< 0x07000000 */ #define AFIO_MAPR_SWJ_CFG AFIO_MAPR_SWJ_CFG_Msk /*!< SWJ_CFG[2:0] bits (Serial Wire JTAG configuration) */ #define AFIO_MAPR_SWJ_CFG_0 (0x1UL << AFIO_MAPR_SWJ_CFG_Pos) /*!< 0x01000000 */ #define AFIO_MAPR_SWJ_CFG_1 (0x2UL << AFIO_MAPR_SWJ_CFG_Pos) /*!< 0x02000000 */ #define AFIO_MAPR_SWJ_CFG_2 (0x4UL << AFIO_MAPR_SWJ_CFG_Pos) /*!< 0x04000000 */ #define AFIO_MAPR_SWJ_CFG_RESET 0x00000000U /*!< Full SWJ (JTAG-DP + SW-DP) : Reset State */ #define AFIO_MAPR_SWJ_CFG_NOJNTRST_Pos (24U) #define AFIO_MAPR_SWJ_CFG_NOJNTRST_Msk (0x1UL << AFIO_MAPR_SWJ_CFG_NOJNTRST_Pos) /*!< 0x01000000 */ #define AFIO_MAPR_SWJ_CFG_NOJNTRST AFIO_MAPR_SWJ_CFG_NOJNTRST_Msk /*!< Full SWJ (JTAG-DP + SW-DP) but without JNTRST */ #define AFIO_MAPR_SWJ_CFG_JTAGDISABLE_Pos (25U) #define AFIO_MAPR_SWJ_CFG_JTAGDISABLE_Msk (0x1UL << AFIO_MAPR_SWJ_CFG_JTAGDISABLE_Pos) /*!< 0x02000000 */ #define AFIO_MAPR_SWJ_CFG_JTAGDISABLE AFIO_MAPR_SWJ_CFG_JTAGDISABLE_Msk /*!< JTAG-DP Disabled and SW-DP Enabled */ #define AFIO_MAPR_SWJ_CFG_DISABLE_Pos (26U) #define AFIO_MAPR_SWJ_CFG_DISABLE_Msk (0x1UL << AFIO_MAPR_SWJ_CFG_DISABLE_Pos) /*!< 0x04000000 */ #define AFIO_MAPR_SWJ_CFG_DISABLE AFIO_MAPR_SWJ_CFG_DISABLE_Msk /*!< JTAG-DP Disabled and SW-DP Disabled */ /***************** Bit definition for AFIO_EXTICR1 register *****************/ #define AFIO_EXTICR1_EXTI0_Pos (0U) #define AFIO_EXTICR1_EXTI0_Msk (0xFUL << AFIO_EXTICR1_EXTI0_Pos) /*!< 0x0000000F */ #define AFIO_EXTICR1_EXTI0 AFIO_EXTICR1_EXTI0_Msk /*!< EXTI 0 configuration */ #define AFIO_EXTICR1_EXTI1_Pos (4U) #define AFIO_EXTICR1_EXTI1_Msk (0xFUL << AFIO_EXTICR1_EXTI1_Pos) /*!< 0x000000F0 */ #define AFIO_EXTICR1_EXTI1 AFIO_EXTICR1_EXTI1_Msk /*!< EXTI 1 configuration */ #define AFIO_EXTICR1_EXTI2_Pos (8U) #define AFIO_EXTICR1_EXTI2_Msk (0xFUL << AFIO_EXTICR1_EXTI2_Pos) /*!< 0x00000F00 */ #define AFIO_EXTICR1_EXTI2 AFIO_EXTICR1_EXTI2_Msk /*!< EXTI 2 configuration */ #define AFIO_EXTICR1_EXTI3_Pos (12U) #define AFIO_EXTICR1_EXTI3_Msk (0xFUL << AFIO_EXTICR1_EXTI3_Pos) /*!< 0x0000F000 */ #define AFIO_EXTICR1_EXTI3 AFIO_EXTICR1_EXTI3_Msk /*!< EXTI 3 configuration */ /*!< EXTI0 configuration */ #define AFIO_EXTICR1_EXTI0_PA 0x00000000U /*!< PA[0] pin */ #define AFIO_EXTICR1_EXTI0_PB_Pos (0U) #define AFIO_EXTICR1_EXTI0_PB_Msk (0x1UL << AFIO_EXTICR1_EXTI0_PB_Pos) /*!< 0x00000001 */ #define AFIO_EXTICR1_EXTI0_PB AFIO_EXTICR1_EXTI0_PB_Msk /*!< PB[0] pin */ #define AFIO_EXTICR1_EXTI0_PC_Pos (1U) #define AFIO_EXTICR1_EXTI0_PC_Msk (0x1UL << AFIO_EXTICR1_EXTI0_PC_Pos) /*!< 0x00000002 */ #define AFIO_EXTICR1_EXTI0_PC AFIO_EXTICR1_EXTI0_PC_Msk /*!< PC[0] pin */ #define AFIO_EXTICR1_EXTI0_PD_Pos (0U) #define AFIO_EXTICR1_EXTI0_PD_Msk (0x3UL << AFIO_EXTICR1_EXTI0_PD_Pos) /*!< 0x00000003 */ #define AFIO_EXTICR1_EXTI0_PD AFIO_EXTICR1_EXTI0_PD_Msk /*!< PD[0] pin */ #define AFIO_EXTICR1_EXTI0_PE_Pos (2U) #define AFIO_EXTICR1_EXTI0_PE_Msk (0x1UL << AFIO_EXTICR1_EXTI0_PE_Pos) /*!< 0x00000004 */ #define AFIO_EXTICR1_EXTI0_PE AFIO_EXTICR1_EXTI0_PE_Msk /*!< PE[0] pin */ #define AFIO_EXTICR1_EXTI0_PF_Pos (0U) #define AFIO_EXTICR1_EXTI0_PF_Msk (0x5UL << AFIO_EXTICR1_EXTI0_PF_Pos) /*!< 0x00000005 */ #define AFIO_EXTICR1_EXTI0_PF AFIO_EXTICR1_EXTI0_PF_Msk /*!< PF[0] pin */ #define AFIO_EXTICR1_EXTI0_PG_Pos (1U) #define AFIO_EXTICR1_EXTI0_PG_Msk (0x3UL << AFIO_EXTICR1_EXTI0_PG_Pos) /*!< 0x00000006 */ #define AFIO_EXTICR1_EXTI0_PG AFIO_EXTICR1_EXTI0_PG_Msk /*!< PG[0] pin */ /*!< EXTI1 configuration */ #define AFIO_EXTICR1_EXTI1_PA 0x00000000U /*!< PA[1] pin */ #define AFIO_EXTICR1_EXTI1_PB_Pos (4U) #define AFIO_EXTICR1_EXTI1_PB_Msk (0x1UL << AFIO_EXTICR1_EXTI1_PB_Pos) /*!< 0x00000010 */ #define AFIO_EXTICR1_EXTI1_PB AFIO_EXTICR1_EXTI1_PB_Msk /*!< PB[1] pin */ #define AFIO_EXTICR1_EXTI1_PC_Pos (5U) #define AFIO_EXTICR1_EXTI1_PC_Msk (0x1UL << AFIO_EXTICR1_EXTI1_PC_Pos) /*!< 0x00000020 */ #define AFIO_EXTICR1_EXTI1_PC AFIO_EXTICR1_EXTI1_PC_Msk /*!< PC[1] pin */ #define AFIO_EXTICR1_EXTI1_PD_Pos (4U) #define AFIO_EXTICR1_EXTI1_PD_Msk (0x3UL << AFIO_EXTICR1_EXTI1_PD_Pos) /*!< 0x00000030 */ #define AFIO_EXTICR1_EXTI1_PD AFIO_EXTICR1_EXTI1_PD_Msk /*!< PD[1] pin */ #define AFIO_EXTICR1_EXTI1_PE_Pos (6U) #define AFIO_EXTICR1_EXTI1_PE_Msk (0x1UL << AFIO_EXTICR1_EXTI1_PE_Pos) /*!< 0x00000040 */ #define AFIO_EXTICR1_EXTI1_PE AFIO_EXTICR1_EXTI1_PE_Msk /*!< PE[1] pin */ #define AFIO_EXTICR1_EXTI1_PF_Pos (4U) #define AFIO_EXTICR1_EXTI1_PF_Msk (0x5UL << AFIO_EXTICR1_EXTI1_PF_Pos) /*!< 0x00000050 */ #define AFIO_EXTICR1_EXTI1_PF AFIO_EXTICR1_EXTI1_PF_Msk /*!< PF[1] pin */ #define AFIO_EXTICR1_EXTI1_PG_Pos (5U) #define AFIO_EXTICR1_EXTI1_PG_Msk (0x3UL << AFIO_EXTICR1_EXTI1_PG_Pos) /*!< 0x00000060 */ #define AFIO_EXTICR1_EXTI1_PG AFIO_EXTICR1_EXTI1_PG_Msk /*!< PG[1] pin */ /*!< EXTI2 configuration */ #define AFIO_EXTICR1_EXTI2_PA 0x00000000U /*!< PA[2] pin */ #define AFIO_EXTICR1_EXTI2_PB_Pos (8U) #define AFIO_EXTICR1_EXTI2_PB_Msk (0x1UL << AFIO_EXTICR1_EXTI2_PB_Pos) /*!< 0x00000100 */ #define AFIO_EXTICR1_EXTI2_PB AFIO_EXTICR1_EXTI2_PB_Msk /*!< PB[2] pin */ #define AFIO_EXTICR1_EXTI2_PC_Pos (9U) #define AFIO_EXTICR1_EXTI2_PC_Msk (0x1UL << AFIO_EXTICR1_EXTI2_PC_Pos) /*!< 0x00000200 */ #define AFIO_EXTICR1_EXTI2_PC AFIO_EXTICR1_EXTI2_PC_Msk /*!< PC[2] pin */ #define AFIO_EXTICR1_EXTI2_PD_Pos (8U) #define AFIO_EXTICR1_EXTI2_PD_Msk (0x3UL << AFIO_EXTICR1_EXTI2_PD_Pos) /*!< 0x00000300 */ #define AFIO_EXTICR1_EXTI2_PD AFIO_EXTICR1_EXTI2_PD_Msk /*!< PD[2] pin */ #define AFIO_EXTICR1_EXTI2_PE_Pos (10U) #define AFIO_EXTICR1_EXTI2_PE_Msk (0x1UL << AFIO_EXTICR1_EXTI2_PE_Pos) /*!< 0x00000400 */ #define AFIO_EXTICR1_EXTI2_PE AFIO_EXTICR1_EXTI2_PE_Msk /*!< PE[2] pin */ #define AFIO_EXTICR1_EXTI2_PF_Pos (8U) #define AFIO_EXTICR1_EXTI2_PF_Msk (0x5UL << AFIO_EXTICR1_EXTI2_PF_Pos) /*!< 0x00000500 */ #define AFIO_EXTICR1_EXTI2_PF AFIO_EXTICR1_EXTI2_PF_Msk /*!< PF[2] pin */ #define AFIO_EXTICR1_EXTI2_PG_Pos (9U) #define AFIO_EXTICR1_EXTI2_PG_Msk (0x3UL << AFIO_EXTICR1_EXTI2_PG_Pos) /*!< 0x00000600 */ #define AFIO_EXTICR1_EXTI2_PG AFIO_EXTICR1_EXTI2_PG_Msk /*!< PG[2] pin */ /*!< EXTI3 configuration */ #define AFIO_EXTICR1_EXTI3_PA 0x00000000U /*!< PA[3] pin */ #define AFIO_EXTICR1_EXTI3_PB_Pos (12U) #define AFIO_EXTICR1_EXTI3_PB_Msk (0x1UL << AFIO_EXTICR1_EXTI3_PB_Pos) /*!< 0x00001000 */ #define AFIO_EXTICR1_EXTI3_PB AFIO_EXTICR1_EXTI3_PB_Msk /*!< PB[3] pin */ #define AFIO_EXTICR1_EXTI3_PC_Pos (13U) #define AFIO_EXTICR1_EXTI3_PC_Msk (0x1UL << AFIO_EXTICR1_EXTI3_PC_Pos) /*!< 0x00002000 */ #define AFIO_EXTICR1_EXTI3_PC AFIO_EXTICR1_EXTI3_PC_Msk /*!< PC[3] pin */ #define AFIO_EXTICR1_EXTI3_PD_Pos (12U) #define AFIO_EXTICR1_EXTI3_PD_Msk (0x3UL << AFIO_EXTICR1_EXTI3_PD_Pos) /*!< 0x00003000 */ #define AFIO_EXTICR1_EXTI3_PD AFIO_EXTICR1_EXTI3_PD_Msk /*!< PD[3] pin */ #define AFIO_EXTICR1_EXTI3_PE_Pos (14U) #define AFIO_EXTICR1_EXTI3_PE_Msk (0x1UL << AFIO_EXTICR1_EXTI3_PE_Pos) /*!< 0x00004000 */ #define AFIO_EXTICR1_EXTI3_PE AFIO_EXTICR1_EXTI3_PE_Msk /*!< PE[3] pin */ #define AFIO_EXTICR1_EXTI3_PF_Pos (12U) #define AFIO_EXTICR1_EXTI3_PF_Msk (0x5UL << AFIO_EXTICR1_EXTI3_PF_Pos) /*!< 0x00005000 */ #define AFIO_EXTICR1_EXTI3_PF AFIO_EXTICR1_EXTI3_PF_Msk /*!< PF[3] pin */ #define AFIO_EXTICR1_EXTI3_PG_Pos (13U) #define AFIO_EXTICR1_EXTI3_PG_Msk (0x3UL << AFIO_EXTICR1_EXTI3_PG_Pos) /*!< 0x00006000 */ #define AFIO_EXTICR1_EXTI3_PG AFIO_EXTICR1_EXTI3_PG_Msk /*!< PG[3] pin */ /***************** Bit definition for AFIO_EXTICR2 register *****************/ #define AFIO_EXTICR2_EXTI4_Pos (0U) #define AFIO_EXTICR2_EXTI4_Msk (0xFUL << AFIO_EXTICR2_EXTI4_Pos) /*!< 0x0000000F */ #define AFIO_EXTICR2_EXTI4 AFIO_EXTICR2_EXTI4_Msk /*!< EXTI 4 configuration */ #define AFIO_EXTICR2_EXTI5_Pos (4U) #define AFIO_EXTICR2_EXTI5_Msk (0xFUL << AFIO_EXTICR2_EXTI5_Pos) /*!< 0x000000F0 */ #define AFIO_EXTICR2_EXTI5 AFIO_EXTICR2_EXTI5_Msk /*!< EXTI 5 configuration */ #define AFIO_EXTICR2_EXTI6_Pos (8U) #define AFIO_EXTICR2_EXTI6_Msk (0xFUL << AFIO_EXTICR2_EXTI6_Pos) /*!< 0x00000F00 */ #define AFIO_EXTICR2_EXTI6 AFIO_EXTICR2_EXTI6_Msk /*!< EXTI 6 configuration */ #define AFIO_EXTICR2_EXTI7_Pos (12U) #define AFIO_EXTICR2_EXTI7_Msk (0xFUL << AFIO_EXTICR2_EXTI7_Pos) /*!< 0x0000F000 */ #define AFIO_EXTICR2_EXTI7 AFIO_EXTICR2_EXTI7_Msk /*!< EXTI 7 configuration */ /*!< EXTI4 configuration */ #define AFIO_EXTICR2_EXTI4_PA 0x00000000U /*!< PA[4] pin */ #define AFIO_EXTICR2_EXTI4_PB_Pos (0U) #define AFIO_EXTICR2_EXTI4_PB_Msk (0x1UL << AFIO_EXTICR2_EXTI4_PB_Pos) /*!< 0x00000001 */ #define AFIO_EXTICR2_EXTI4_PB AFIO_EXTICR2_EXTI4_PB_Msk /*!< PB[4] pin */ #define AFIO_EXTICR2_EXTI4_PC_Pos (1U) #define AFIO_EXTICR2_EXTI4_PC_Msk (0x1UL << AFIO_EXTICR2_EXTI4_PC_Pos) /*!< 0x00000002 */ #define AFIO_EXTICR2_EXTI4_PC AFIO_EXTICR2_EXTI4_PC_Msk /*!< PC[4] pin */ #define AFIO_EXTICR2_EXTI4_PD_Pos (0U) #define AFIO_EXTICR2_EXTI4_PD_Msk (0x3UL << AFIO_EXTICR2_EXTI4_PD_Pos) /*!< 0x00000003 */ #define AFIO_EXTICR2_EXTI4_PD AFIO_EXTICR2_EXTI4_PD_Msk /*!< PD[4] pin */ #define AFIO_EXTICR2_EXTI4_PE_Pos (2U) #define AFIO_EXTICR2_EXTI4_PE_Msk (0x1UL << AFIO_EXTICR2_EXTI4_PE_Pos) /*!< 0x00000004 */ #define AFIO_EXTICR2_EXTI4_PE AFIO_EXTICR2_EXTI4_PE_Msk /*!< PE[4] pin */ #define AFIO_EXTICR2_EXTI4_PF_Pos (0U) #define AFIO_EXTICR2_EXTI4_PF_Msk (0x5UL << AFIO_EXTICR2_EXTI4_PF_Pos) /*!< 0x00000005 */ #define AFIO_EXTICR2_EXTI4_PF AFIO_EXTICR2_EXTI4_PF_Msk /*!< PF[4] pin */ #define AFIO_EXTICR2_EXTI4_PG_Pos (1U) #define AFIO_EXTICR2_EXTI4_PG_Msk (0x3UL << AFIO_EXTICR2_EXTI4_PG_Pos) /*!< 0x00000006 */ #define AFIO_EXTICR2_EXTI4_PG AFIO_EXTICR2_EXTI4_PG_Msk /*!< PG[4] pin */ /* EXTI5 configuration */ #define AFIO_EXTICR2_EXTI5_PA 0x00000000U /*!< PA[5] pin */ #define AFIO_EXTICR2_EXTI5_PB_Pos (4U) #define AFIO_EXTICR2_EXTI5_PB_Msk (0x1UL << AFIO_EXTICR2_EXTI5_PB_Pos) /*!< 0x00000010 */ #define AFIO_EXTICR2_EXTI5_PB AFIO_EXTICR2_EXTI5_PB_Msk /*!< PB[5] pin */ #define AFIO_EXTICR2_EXTI5_PC_Pos (5U) #define AFIO_EXTICR2_EXTI5_PC_Msk (0x1UL << AFIO_EXTICR2_EXTI5_PC_Pos) /*!< 0x00000020 */ #define AFIO_EXTICR2_EXTI5_PC AFIO_EXTICR2_EXTI5_PC_Msk /*!< PC[5] pin */ #define AFIO_EXTICR2_EXTI5_PD_Pos (4U) #define AFIO_EXTICR2_EXTI5_PD_Msk (0x3UL << AFIO_EXTICR2_EXTI5_PD_Pos) /*!< 0x00000030 */ #define AFIO_EXTICR2_EXTI5_PD AFIO_EXTICR2_EXTI5_PD_Msk /*!< PD[5] pin */ #define AFIO_EXTICR2_EXTI5_PE_Pos (6U) #define AFIO_EXTICR2_EXTI5_PE_Msk (0x1UL << AFIO_EXTICR2_EXTI5_PE_Pos) /*!< 0x00000040 */ #define AFIO_EXTICR2_EXTI5_PE AFIO_EXTICR2_EXTI5_PE_Msk /*!< PE[5] pin */ #define AFIO_EXTICR2_EXTI5_PF_Pos (4U) #define AFIO_EXTICR2_EXTI5_PF_Msk (0x5UL << AFIO_EXTICR2_EXTI5_PF_Pos) /*!< 0x00000050 */ #define AFIO_EXTICR2_EXTI5_PF AFIO_EXTICR2_EXTI5_PF_Msk /*!< PF[5] pin */ #define AFIO_EXTICR2_EXTI5_PG_Pos (5U) #define AFIO_EXTICR2_EXTI5_PG_Msk (0x3UL << AFIO_EXTICR2_EXTI5_PG_Pos) /*!< 0x00000060 */ #define AFIO_EXTICR2_EXTI5_PG AFIO_EXTICR2_EXTI5_PG_Msk /*!< PG[5] pin */ /*!< EXTI6 configuration */ #define AFIO_EXTICR2_EXTI6_PA 0x00000000U /*!< PA[6] pin */ #define AFIO_EXTICR2_EXTI6_PB_Pos (8U) #define AFIO_EXTICR2_EXTI6_PB_Msk (0x1UL << AFIO_EXTICR2_EXTI6_PB_Pos) /*!< 0x00000100 */ #define AFIO_EXTICR2_EXTI6_PB AFIO_EXTICR2_EXTI6_PB_Msk /*!< PB[6] pin */ #define AFIO_EXTICR2_EXTI6_PC_Pos (9U) #define AFIO_EXTICR2_EXTI6_PC_Msk (0x1UL << AFIO_EXTICR2_EXTI6_PC_Pos) /*!< 0x00000200 */ #define AFIO_EXTICR2_EXTI6_PC AFIO_EXTICR2_EXTI6_PC_Msk /*!< PC[6] pin */ #define AFIO_EXTICR2_EXTI6_PD_Pos (8U) #define AFIO_EXTICR2_EXTI6_PD_Msk (0x3UL << AFIO_EXTICR2_EXTI6_PD_Pos) /*!< 0x00000300 */ #define AFIO_EXTICR2_EXTI6_PD AFIO_EXTICR2_EXTI6_PD_Msk /*!< PD[6] pin */ #define AFIO_EXTICR2_EXTI6_PE_Pos (10U) #define AFIO_EXTICR2_EXTI6_PE_Msk (0x1UL << AFIO_EXTICR2_EXTI6_PE_Pos) /*!< 0x00000400 */ #define AFIO_EXTICR2_EXTI6_PE AFIO_EXTICR2_EXTI6_PE_Msk /*!< PE[6] pin */ #define AFIO_EXTICR2_EXTI6_PF_Pos (8U) #define AFIO_EXTICR2_EXTI6_PF_Msk (0x5UL << AFIO_EXTICR2_EXTI6_PF_Pos) /*!< 0x00000500 */ #define AFIO_EXTICR2_EXTI6_PF AFIO_EXTICR2_EXTI6_PF_Msk /*!< PF[6] pin */ #define AFIO_EXTICR2_EXTI6_PG_Pos (9U) #define AFIO_EXTICR2_EXTI6_PG_Msk (0x3UL << AFIO_EXTICR2_EXTI6_PG_Pos) /*!< 0x00000600 */ #define AFIO_EXTICR2_EXTI6_PG AFIO_EXTICR2_EXTI6_PG_Msk /*!< PG[6] pin */ /*!< EXTI7 configuration */ #define AFIO_EXTICR2_EXTI7_PA 0x00000000U /*!< PA[7] pin */ #define AFIO_EXTICR2_EXTI7_PB_Pos (12U) #define AFIO_EXTICR2_EXTI7_PB_Msk (0x1UL << AFIO_EXTICR2_EXTI7_PB_Pos) /*!< 0x00001000 */ #define AFIO_EXTICR2_EXTI7_PB AFIO_EXTICR2_EXTI7_PB_Msk /*!< PB[7] pin */ #define AFIO_EXTICR2_EXTI7_PC_Pos (13U) #define AFIO_EXTICR2_EXTI7_PC_Msk (0x1UL << AFIO_EXTICR2_EXTI7_PC_Pos) /*!< 0x00002000 */ #define AFIO_EXTICR2_EXTI7_PC AFIO_EXTICR2_EXTI7_PC_Msk /*!< PC[7] pin */ #define AFIO_EXTICR2_EXTI7_PD_Pos (12U) #define AFIO_EXTICR2_EXTI7_PD_Msk (0x3UL << AFIO_EXTICR2_EXTI7_PD_Pos) /*!< 0x00003000 */ #define AFIO_EXTICR2_EXTI7_PD AFIO_EXTICR2_EXTI7_PD_Msk /*!< PD[7] pin */ #define AFIO_EXTICR2_EXTI7_PE_Pos (14U) #define AFIO_EXTICR2_EXTI7_PE_Msk (0x1UL << AFIO_EXTICR2_EXTI7_PE_Pos) /*!< 0x00004000 */ #define AFIO_EXTICR2_EXTI7_PE AFIO_EXTICR2_EXTI7_PE_Msk /*!< PE[7] pin */ #define AFIO_EXTICR2_EXTI7_PF_Pos (12U) #define AFIO_EXTICR2_EXTI7_PF_Msk (0x5UL << AFIO_EXTICR2_EXTI7_PF_Pos) /*!< 0x00005000 */ #define AFIO_EXTICR2_EXTI7_PF AFIO_EXTICR2_EXTI7_PF_Msk /*!< PF[7] pin */ #define AFIO_EXTICR2_EXTI7_PG_Pos (13U) #define AFIO_EXTICR2_EXTI7_PG_Msk (0x3UL << AFIO_EXTICR2_EXTI7_PG_Pos) /*!< 0x00006000 */ #define AFIO_EXTICR2_EXTI7_PG AFIO_EXTICR2_EXTI7_PG_Msk /*!< PG[7] pin */ /***************** Bit definition for AFIO_EXTICR3 register *****************/ #define AFIO_EXTICR3_EXTI8_Pos (0U) #define AFIO_EXTICR3_EXTI8_Msk (0xFUL << AFIO_EXTICR3_EXTI8_Pos) /*!< 0x0000000F */ #define AFIO_EXTICR3_EXTI8 AFIO_EXTICR3_EXTI8_Msk /*!< EXTI 8 configuration */ #define AFIO_EXTICR3_EXTI9_Pos (4U) #define AFIO_EXTICR3_EXTI9_Msk (0xFUL << AFIO_EXTICR3_EXTI9_Pos) /*!< 0x000000F0 */ #define AFIO_EXTICR3_EXTI9 AFIO_EXTICR3_EXTI9_Msk /*!< EXTI 9 configuration */ #define AFIO_EXTICR3_EXTI10_Pos (8U) #define AFIO_EXTICR3_EXTI10_Msk (0xFUL << AFIO_EXTICR3_EXTI10_Pos) /*!< 0x00000F00 */ #define AFIO_EXTICR3_EXTI10 AFIO_EXTICR3_EXTI10_Msk /*!< EXTI 10 configuration */ #define AFIO_EXTICR3_EXTI11_Pos (12U) #define AFIO_EXTICR3_EXTI11_Msk (0xFUL << AFIO_EXTICR3_EXTI11_Pos) /*!< 0x0000F000 */ #define AFIO_EXTICR3_EXTI11 AFIO_EXTICR3_EXTI11_Msk /*!< EXTI 11 configuration */ /*!< EXTI8 configuration */ #define AFIO_EXTICR3_EXTI8_PA 0x00000000U /*!< PA[8] pin */ #define AFIO_EXTICR3_EXTI8_PB_Pos (0U) #define AFIO_EXTICR3_EXTI8_PB_Msk (0x1UL << AFIO_EXTICR3_EXTI8_PB_Pos) /*!< 0x00000001 */ #define AFIO_EXTICR3_EXTI8_PB AFIO_EXTICR3_EXTI8_PB_Msk /*!< PB[8] pin */ #define AFIO_EXTICR3_EXTI8_PC_Pos (1U) #define AFIO_EXTICR3_EXTI8_PC_Msk (0x1UL << AFIO_EXTICR3_EXTI8_PC_Pos) /*!< 0x00000002 */ #define AFIO_EXTICR3_EXTI8_PC AFIO_EXTICR3_EXTI8_PC_Msk /*!< PC[8] pin */ #define AFIO_EXTICR3_EXTI8_PD_Pos (0U) #define AFIO_EXTICR3_EXTI8_PD_Msk (0x3UL << AFIO_EXTICR3_EXTI8_PD_Pos) /*!< 0x00000003 */ #define AFIO_EXTICR3_EXTI8_PD AFIO_EXTICR3_EXTI8_PD_Msk /*!< PD[8] pin */ #define AFIO_EXTICR3_EXTI8_PE_Pos (2U) #define AFIO_EXTICR3_EXTI8_PE_Msk (0x1UL << AFIO_EXTICR3_EXTI8_PE_Pos) /*!< 0x00000004 */ #define AFIO_EXTICR3_EXTI8_PE AFIO_EXTICR3_EXTI8_PE_Msk /*!< PE[8] pin */ #define AFIO_EXTICR3_EXTI8_PF_Pos (0U) #define AFIO_EXTICR3_EXTI8_PF_Msk (0x5UL << AFIO_EXTICR3_EXTI8_PF_Pos) /*!< 0x00000005 */ #define AFIO_EXTICR3_EXTI8_PF AFIO_EXTICR3_EXTI8_PF_Msk /*!< PF[8] pin */ #define AFIO_EXTICR3_EXTI8_PG_Pos (1U) #define AFIO_EXTICR3_EXTI8_PG_Msk (0x3UL << AFIO_EXTICR3_EXTI8_PG_Pos) /*!< 0x00000006 */ #define AFIO_EXTICR3_EXTI8_PG AFIO_EXTICR3_EXTI8_PG_Msk /*!< PG[8] pin */ /*!< EXTI9 configuration */ #define AFIO_EXTICR3_EXTI9_PA 0x00000000U /*!< PA[9] pin */ #define AFIO_EXTICR3_EXTI9_PB_Pos (4U) #define AFIO_EXTICR3_EXTI9_PB_Msk (0x1UL << AFIO_EXTICR3_EXTI9_PB_Pos) /*!< 0x00000010 */ #define AFIO_EXTICR3_EXTI9_PB AFIO_EXTICR3_EXTI9_PB_Msk /*!< PB[9] pin */ #define AFIO_EXTICR3_EXTI9_PC_Pos (5U) #define AFIO_EXTICR3_EXTI9_PC_Msk (0x1UL << AFIO_EXTICR3_EXTI9_PC_Pos) /*!< 0x00000020 */ #define AFIO_EXTICR3_EXTI9_PC AFIO_EXTICR3_EXTI9_PC_Msk /*!< PC[9] pin */ #define AFIO_EXTICR3_EXTI9_PD_Pos (4U) #define AFIO_EXTICR3_EXTI9_PD_Msk (0x3UL << AFIO_EXTICR3_EXTI9_PD_Pos) /*!< 0x00000030 */ #define AFIO_EXTICR3_EXTI9_PD AFIO_EXTICR3_EXTI9_PD_Msk /*!< PD[9] pin */ #define AFIO_EXTICR3_EXTI9_PE_Pos (6U) #define AFIO_EXTICR3_EXTI9_PE_Msk (0x1UL << AFIO_EXTICR3_EXTI9_PE_Pos) /*!< 0x00000040 */ #define AFIO_EXTICR3_EXTI9_PE AFIO_EXTICR3_EXTI9_PE_Msk /*!< PE[9] pin */ #define AFIO_EXTICR3_EXTI9_PF_Pos (4U) #define AFIO_EXTICR3_EXTI9_PF_Msk (0x5UL << AFIO_EXTICR3_EXTI9_PF_Pos) /*!< 0x00000050 */ #define AFIO_EXTICR3_EXTI9_PF AFIO_EXTICR3_EXTI9_PF_Msk /*!< PF[9] pin */ #define AFIO_EXTICR3_EXTI9_PG_Pos (5U) #define AFIO_EXTICR3_EXTI9_PG_Msk (0x3UL << AFIO_EXTICR3_EXTI9_PG_Pos) /*!< 0x00000060 */ #define AFIO_EXTICR3_EXTI9_PG AFIO_EXTICR3_EXTI9_PG_Msk /*!< PG[9] pin */ /*!< EXTI10 configuration */ #define AFIO_EXTICR3_EXTI10_PA 0x00000000U /*!< PA[10] pin */ #define AFIO_EXTICR3_EXTI10_PB_Pos (8U) #define AFIO_EXTICR3_EXTI10_PB_Msk (0x1UL << AFIO_EXTICR3_EXTI10_PB_Pos) /*!< 0x00000100 */ #define AFIO_EXTICR3_EXTI10_PB AFIO_EXTICR3_EXTI10_PB_Msk /*!< PB[10] pin */ #define AFIO_EXTICR3_EXTI10_PC_Pos (9U) #define AFIO_EXTICR3_EXTI10_PC_Msk (0x1UL << AFIO_EXTICR3_EXTI10_PC_Pos) /*!< 0x00000200 */ #define AFIO_EXTICR3_EXTI10_PC AFIO_EXTICR3_EXTI10_PC_Msk /*!< PC[10] pin */ #define AFIO_EXTICR3_EXTI10_PD_Pos (8U) #define AFIO_EXTICR3_EXTI10_PD_Msk (0x3UL << AFIO_EXTICR3_EXTI10_PD_Pos) /*!< 0x00000300 */ #define AFIO_EXTICR3_EXTI10_PD AFIO_EXTICR3_EXTI10_PD_Msk /*!< PD[10] pin */ #define AFIO_EXTICR3_EXTI10_PE_Pos (10U) #define AFIO_EXTICR3_EXTI10_PE_Msk (0x1UL << AFIO_EXTICR3_EXTI10_PE_Pos) /*!< 0x00000400 */ #define AFIO_EXTICR3_EXTI10_PE AFIO_EXTICR3_EXTI10_PE_Msk /*!< PE[10] pin */ #define AFIO_EXTICR3_EXTI10_PF_Pos (8U) #define AFIO_EXTICR3_EXTI10_PF_Msk (0x5UL << AFIO_EXTICR3_EXTI10_PF_Pos) /*!< 0x00000500 */ #define AFIO_EXTICR3_EXTI10_PF AFIO_EXTICR3_EXTI10_PF_Msk /*!< PF[10] pin */ #define AFIO_EXTICR3_EXTI10_PG_Pos (9U) #define AFIO_EXTICR3_EXTI10_PG_Msk (0x3UL << AFIO_EXTICR3_EXTI10_PG_Pos) /*!< 0x00000600 */ #define AFIO_EXTICR3_EXTI10_PG AFIO_EXTICR3_EXTI10_PG_Msk /*!< PG[10] pin */ /*!< EXTI11 configuration */ #define AFIO_EXTICR3_EXTI11_PA 0x00000000U /*!< PA[11] pin */ #define AFIO_EXTICR3_EXTI11_PB_Pos (12U) #define AFIO_EXTICR3_EXTI11_PB_Msk (0x1UL << AFIO_EXTICR3_EXTI11_PB_Pos) /*!< 0x00001000 */ #define AFIO_EXTICR3_EXTI11_PB AFIO_EXTICR3_EXTI11_PB_Msk /*!< PB[11] pin */ #define AFIO_EXTICR3_EXTI11_PC_Pos (13U) #define AFIO_EXTICR3_EXTI11_PC_Msk (0x1UL << AFIO_EXTICR3_EXTI11_PC_Pos) /*!< 0x00002000 */ #define AFIO_EXTICR3_EXTI11_PC AFIO_EXTICR3_EXTI11_PC_Msk /*!< PC[11] pin */ #define AFIO_EXTICR3_EXTI11_PD_Pos (12U) #define AFIO_EXTICR3_EXTI11_PD_Msk (0x3UL << AFIO_EXTICR3_EXTI11_PD_Pos) /*!< 0x00003000 */ #define AFIO_EXTICR3_EXTI11_PD AFIO_EXTICR3_EXTI11_PD_Msk /*!< PD[11] pin */ #define AFIO_EXTICR3_EXTI11_PE_Pos (14U) #define AFIO_EXTICR3_EXTI11_PE_Msk (0x1UL << AFIO_EXTICR3_EXTI11_PE_Pos) /*!< 0x00004000 */ #define AFIO_EXTICR3_EXTI11_PE AFIO_EXTICR3_EXTI11_PE_Msk /*!< PE[11] pin */ #define AFIO_EXTICR3_EXTI11_PF_Pos (12U) #define AFIO_EXTICR3_EXTI11_PF_Msk (0x5UL << AFIO_EXTICR3_EXTI11_PF_Pos) /*!< 0x00005000 */ #define AFIO_EXTICR3_EXTI11_PF AFIO_EXTICR3_EXTI11_PF_Msk /*!< PF[11] pin */ #define AFIO_EXTICR3_EXTI11_PG_Pos (13U) #define AFIO_EXTICR3_EXTI11_PG_Msk (0x3UL << AFIO_EXTICR3_EXTI11_PG_Pos) /*!< 0x00006000 */ #define AFIO_EXTICR3_EXTI11_PG AFIO_EXTICR3_EXTI11_PG_Msk /*!< PG[11] pin */ /***************** Bit definition for AFIO_EXTICR4 register *****************/ #define AFIO_EXTICR4_EXTI12_Pos (0U) #define AFIO_EXTICR4_EXTI12_Msk (0xFUL << AFIO_EXTICR4_EXTI12_Pos) /*!< 0x0000000F */ #define AFIO_EXTICR4_EXTI12 AFIO_EXTICR4_EXTI12_Msk /*!< EXTI 12 configuration */ #define AFIO_EXTICR4_EXTI13_Pos (4U) #define AFIO_EXTICR4_EXTI13_Msk (0xFUL << AFIO_EXTICR4_EXTI13_Pos) /*!< 0x000000F0 */ #define AFIO_EXTICR4_EXTI13 AFIO_EXTICR4_EXTI13_Msk /*!< EXTI 13 configuration */ #define AFIO_EXTICR4_EXTI14_Pos (8U) #define AFIO_EXTICR4_EXTI14_Msk (0xFUL << AFIO_EXTICR4_EXTI14_Pos) /*!< 0x00000F00 */ #define AFIO_EXTICR4_EXTI14 AFIO_EXTICR4_EXTI14_Msk /*!< EXTI 14 configuration */ #define AFIO_EXTICR4_EXTI15_Pos (12U) #define AFIO_EXTICR4_EXTI15_Msk (0xFUL << AFIO_EXTICR4_EXTI15_Pos) /*!< 0x0000F000 */ #define AFIO_EXTICR4_EXTI15 AFIO_EXTICR4_EXTI15_Msk /*!< EXTI 15 configuration */ /* EXTI12 configuration */ #define AFIO_EXTICR4_EXTI12_PA 0x00000000U /*!< PA[12] pin */ #define AFIO_EXTICR4_EXTI12_PB_Pos (0U) #define AFIO_EXTICR4_EXTI12_PB_Msk (0x1UL << AFIO_EXTICR4_EXTI12_PB_Pos) /*!< 0x00000001 */ #define AFIO_EXTICR4_EXTI12_PB AFIO_EXTICR4_EXTI12_PB_Msk /*!< PB[12] pin */ #define AFIO_EXTICR4_EXTI12_PC_Pos (1U) #define AFIO_EXTICR4_EXTI12_PC_Msk (0x1UL << AFIO_EXTICR4_EXTI12_PC_Pos) /*!< 0x00000002 */ #define AFIO_EXTICR4_EXTI12_PC AFIO_EXTICR4_EXTI12_PC_Msk /*!< PC[12] pin */ #define AFIO_EXTICR4_EXTI12_PD_Pos (0U) #define AFIO_EXTICR4_EXTI12_PD_Msk (0x3UL << AFIO_EXTICR4_EXTI12_PD_Pos) /*!< 0x00000003 */ #define AFIO_EXTICR4_EXTI12_PD AFIO_EXTICR4_EXTI12_PD_Msk /*!< PD[12] pin */ #define AFIO_EXTICR4_EXTI12_PE_Pos (2U) #define AFIO_EXTICR4_EXTI12_PE_Msk (0x1UL << AFIO_EXTICR4_EXTI12_PE_Pos) /*!< 0x00000004 */ #define AFIO_EXTICR4_EXTI12_PE AFIO_EXTICR4_EXTI12_PE_Msk /*!< PE[12] pin */ #define AFIO_EXTICR4_EXTI12_PF_Pos (0U) #define AFIO_EXTICR4_EXTI12_PF_Msk (0x5UL << AFIO_EXTICR4_EXTI12_PF_Pos) /*!< 0x00000005 */ #define AFIO_EXTICR4_EXTI12_PF AFIO_EXTICR4_EXTI12_PF_Msk /*!< PF[12] pin */ #define AFIO_EXTICR4_EXTI12_PG_Pos (1U) #define AFIO_EXTICR4_EXTI12_PG_Msk (0x3UL << AFIO_EXTICR4_EXTI12_PG_Pos) /*!< 0x00000006 */ #define AFIO_EXTICR4_EXTI12_PG AFIO_EXTICR4_EXTI12_PG_Msk /*!< PG[12] pin */ /* EXTI13 configuration */ #define AFIO_EXTICR4_EXTI13_PA 0x00000000U /*!< PA[13] pin */ #define AFIO_EXTICR4_EXTI13_PB_Pos (4U) #define AFIO_EXTICR4_EXTI13_PB_Msk (0x1UL << AFIO_EXTICR4_EXTI13_PB_Pos) /*!< 0x00000010 */ #define AFIO_EXTICR4_EXTI13_PB AFIO_EXTICR4_EXTI13_PB_Msk /*!< PB[13] pin */ #define AFIO_EXTICR4_EXTI13_PC_Pos (5U) #define AFIO_EXTICR4_EXTI13_PC_Msk (0x1UL << AFIO_EXTICR4_EXTI13_PC_Pos) /*!< 0x00000020 */ #define AFIO_EXTICR4_EXTI13_PC AFIO_EXTICR4_EXTI13_PC_Msk /*!< PC[13] pin */ #define AFIO_EXTICR4_EXTI13_PD_Pos (4U) #define AFIO_EXTICR4_EXTI13_PD_Msk (0x3UL << AFIO_EXTICR4_EXTI13_PD_Pos) /*!< 0x00000030 */ #define AFIO_EXTICR4_EXTI13_PD AFIO_EXTICR4_EXTI13_PD_Msk /*!< PD[13] pin */ #define AFIO_EXTICR4_EXTI13_PE_Pos (6U) #define AFIO_EXTICR4_EXTI13_PE_Msk (0x1UL << AFIO_EXTICR4_EXTI13_PE_Pos) /*!< 0x00000040 */ #define AFIO_EXTICR4_EXTI13_PE AFIO_EXTICR4_EXTI13_PE_Msk /*!< PE[13] pin */ #define AFIO_EXTICR4_EXTI13_PF_Pos (4U) #define AFIO_EXTICR4_EXTI13_PF_Msk (0x5UL << AFIO_EXTICR4_EXTI13_PF_Pos) /*!< 0x00000050 */ #define AFIO_EXTICR4_EXTI13_PF AFIO_EXTICR4_EXTI13_PF_Msk /*!< PF[13] pin */ #define AFIO_EXTICR4_EXTI13_PG_Pos (5U) #define AFIO_EXTICR4_EXTI13_PG_Msk (0x3UL << AFIO_EXTICR4_EXTI13_PG_Pos) /*!< 0x00000060 */ #define AFIO_EXTICR4_EXTI13_PG AFIO_EXTICR4_EXTI13_PG_Msk /*!< PG[13] pin */ /*!< EXTI14 configuration */ #define AFIO_EXTICR4_EXTI14_PA 0x00000000U /*!< PA[14] pin */ #define AFIO_EXTICR4_EXTI14_PB_Pos (8U) #define AFIO_EXTICR4_EXTI14_PB_Msk (0x1UL << AFIO_EXTICR4_EXTI14_PB_Pos) /*!< 0x00000100 */ #define AFIO_EXTICR4_EXTI14_PB AFIO_EXTICR4_EXTI14_PB_Msk /*!< PB[14] pin */ #define AFIO_EXTICR4_EXTI14_PC_Pos (9U) #define AFIO_EXTICR4_EXTI14_PC_Msk (0x1UL << AFIO_EXTICR4_EXTI14_PC_Pos) /*!< 0x00000200 */ #define AFIO_EXTICR4_EXTI14_PC AFIO_EXTICR4_EXTI14_PC_Msk /*!< PC[14] pin */ #define AFIO_EXTICR4_EXTI14_PD_Pos (8U) #define AFIO_EXTICR4_EXTI14_PD_Msk (0x3UL << AFIO_EXTICR4_EXTI14_PD_Pos) /*!< 0x00000300 */ #define AFIO_EXTICR4_EXTI14_PD AFIO_EXTICR4_EXTI14_PD_Msk /*!< PD[14] pin */ #define AFIO_EXTICR4_EXTI14_PE_Pos (10U) #define AFIO_EXTICR4_EXTI14_PE_Msk (0x1UL << AFIO_EXTICR4_EXTI14_PE_Pos) /*!< 0x00000400 */ #define AFIO_EXTICR4_EXTI14_PE AFIO_EXTICR4_EXTI14_PE_Msk /*!< PE[14] pin */ #define AFIO_EXTICR4_EXTI14_PF_Pos (8U) #define AFIO_EXTICR4_EXTI14_PF_Msk (0x5UL << AFIO_EXTICR4_EXTI14_PF_Pos) /*!< 0x00000500 */ #define AFIO_EXTICR4_EXTI14_PF AFIO_EXTICR4_EXTI14_PF_Msk /*!< PF[14] pin */ #define AFIO_EXTICR4_EXTI14_PG_Pos (9U) #define AFIO_EXTICR4_EXTI14_PG_Msk (0x3UL << AFIO_EXTICR4_EXTI14_PG_Pos) /*!< 0x00000600 */ #define AFIO_EXTICR4_EXTI14_PG AFIO_EXTICR4_EXTI14_PG_Msk /*!< PG[14] pin */ /*!< EXTI15 configuration */ #define AFIO_EXTICR4_EXTI15_PA 0x00000000U /*!< PA[15] pin */ #define AFIO_EXTICR4_EXTI15_PB_Pos (12U) #define AFIO_EXTICR4_EXTI15_PB_Msk (0x1UL << AFIO_EXTICR4_EXTI15_PB_Pos) /*!< 0x00001000 */ #define AFIO_EXTICR4_EXTI15_PB AFIO_EXTICR4_EXTI15_PB_Msk /*!< PB[15] pin */ #define AFIO_EXTICR4_EXTI15_PC_Pos (13U) #define AFIO_EXTICR4_EXTI15_PC_Msk (0x1UL << AFIO_EXTICR4_EXTI15_PC_Pos) /*!< 0x00002000 */ #define AFIO_EXTICR4_EXTI15_PC AFIO_EXTICR4_EXTI15_PC_Msk /*!< PC[15] pin */ #define AFIO_EXTICR4_EXTI15_PD_Pos (12U) #define AFIO_EXTICR4_EXTI15_PD_Msk (0x3UL << AFIO_EXTICR4_EXTI15_PD_Pos) /*!< 0x00003000 */ #define AFIO_EXTICR4_EXTI15_PD AFIO_EXTICR4_EXTI15_PD_Msk /*!< PD[15] pin */ #define AFIO_EXTICR4_EXTI15_PE_Pos (14U) #define AFIO_EXTICR4_EXTI15_PE_Msk (0x1UL << AFIO_EXTICR4_EXTI15_PE_Pos) /*!< 0x00004000 */ #define AFIO_EXTICR4_EXTI15_PE AFIO_EXTICR4_EXTI15_PE_Msk /*!< PE[15] pin */ #define AFIO_EXTICR4_EXTI15_PF_Pos (12U) #define AFIO_EXTICR4_EXTI15_PF_Msk (0x5UL << AFIO_EXTICR4_EXTI15_PF_Pos) /*!< 0x00005000 */ #define AFIO_EXTICR4_EXTI15_PF AFIO_EXTICR4_EXTI15_PF_Msk /*!< PF[15] pin */ #define AFIO_EXTICR4_EXTI15_PG_Pos (13U) #define AFIO_EXTICR4_EXTI15_PG_Msk (0x3UL << AFIO_EXTICR4_EXTI15_PG_Pos) /*!< 0x00006000 */ #define AFIO_EXTICR4_EXTI15_PG AFIO_EXTICR4_EXTI15_PG_Msk /*!< PG[15] pin */ /****************** Bit definition for AFIO_MAPR2 register ******************/ #define AFIO_MAPR2_FSMC_NADV_REMAP_Pos (10U) #define AFIO_MAPR2_FSMC_NADV_REMAP_Msk (0x1UL << AFIO_MAPR2_FSMC_NADV_REMAP_Pos) /*!< 0x00000400 */ #define AFIO_MAPR2_FSMC_NADV_REMAP AFIO_MAPR2_FSMC_NADV_REMAP_Msk /*!< FSMC NADV remapping */ /******************************************************************************/ /* */ /* External Interrupt/Event Controller */ /* */ /******************************************************************************/ /******************* Bit definition for EXTI_IMR register *******************/ #define EXTI_IMR_MR0_Pos (0U) #define EXTI_IMR_MR0_Msk (0x1UL << EXTI_IMR_MR0_Pos) /*!< 0x00000001 */ #define EXTI_IMR_MR0 EXTI_IMR_MR0_Msk /*!< Interrupt Mask on line 0 */ #define EXTI_IMR_MR1_Pos (1U) #define EXTI_IMR_MR1_Msk (0x1UL << EXTI_IMR_MR1_Pos) /*!< 0x00000002 */ #define EXTI_IMR_MR1 EXTI_IMR_MR1_Msk /*!< Interrupt Mask on line 1 */ #define EXTI_IMR_MR2_Pos (2U) #define EXTI_IMR_MR2_Msk (0x1UL << EXTI_IMR_MR2_Pos) /*!< 0x00000004 */ #define EXTI_IMR_MR2 EXTI_IMR_MR2_Msk /*!< Interrupt Mask on line 2 */ #define EXTI_IMR_MR3_Pos (3U) #define EXTI_IMR_MR3_Msk (0x1UL << EXTI_IMR_MR3_Pos) /*!< 0x00000008 */ #define EXTI_IMR_MR3 EXTI_IMR_MR3_Msk /*!< Interrupt Mask on line 3 */ #define EXTI_IMR_MR4_Pos (4U) #define EXTI_IMR_MR4_Msk (0x1UL << EXTI_IMR_MR4_Pos) /*!< 0x00000010 */ #define EXTI_IMR_MR4 EXTI_IMR_MR4_Msk /*!< Interrupt Mask on line 4 */ #define EXTI_IMR_MR5_Pos (5U) #define EXTI_IMR_MR5_Msk (0x1UL << EXTI_IMR_MR5_Pos) /*!< 0x00000020 */ #define EXTI_IMR_MR5 EXTI_IMR_MR5_Msk /*!< Interrupt Mask on line 5 */ #define EXTI_IMR_MR6_Pos (6U) #define EXTI_IMR_MR6_Msk (0x1UL << EXTI_IMR_MR6_Pos) /*!< 0x00000040 */ #define EXTI_IMR_MR6 EXTI_IMR_MR6_Msk /*!< Interrupt Mask on line 6 */ #define EXTI_IMR_MR7_Pos (7U) #define EXTI_IMR_MR7_Msk (0x1UL << EXTI_IMR_MR7_Pos) /*!< 0x00000080 */ #define EXTI_IMR_MR7 EXTI_IMR_MR7_Msk /*!< Interrupt Mask on line 7 */ #define EXTI_IMR_MR8_Pos (8U) #define EXTI_IMR_MR8_Msk (0x1UL << EXTI_IMR_MR8_Pos) /*!< 0x00000100 */ #define EXTI_IMR_MR8 EXTI_IMR_MR8_Msk /*!< Interrupt Mask on line 8 */ #define EXTI_IMR_MR9_Pos (9U) #define EXTI_IMR_MR9_Msk (0x1UL << EXTI_IMR_MR9_Pos) /*!< 0x00000200 */ #define EXTI_IMR_MR9 EXTI_IMR_MR9_Msk /*!< Interrupt Mask on line 9 */ #define EXTI_IMR_MR10_Pos (10U) #define EXTI_IMR_MR10_Msk (0x1UL << EXTI_IMR_MR10_Pos) /*!< 0x00000400 */ #define EXTI_IMR_MR10 EXTI_IMR_MR10_Msk /*!< Interrupt Mask on line 10 */ #define EXTI_IMR_MR11_Pos (11U) #define EXTI_IMR_MR11_Msk (0x1UL << EXTI_IMR_MR11_Pos) /*!< 0x00000800 */ #define EXTI_IMR_MR11 EXTI_IMR_MR11_Msk /*!< Interrupt Mask on line 11 */ #define EXTI_IMR_MR12_Pos (12U) #define EXTI_IMR_MR12_Msk (0x1UL << EXTI_IMR_MR12_Pos) /*!< 0x00001000 */ #define EXTI_IMR_MR12 EXTI_IMR_MR12_Msk /*!< Interrupt Mask on line 12 */ #define EXTI_IMR_MR13_Pos (13U) #define EXTI_IMR_MR13_Msk (0x1UL << EXTI_IMR_MR13_Pos) /*!< 0x00002000 */ #define EXTI_IMR_MR13 EXTI_IMR_MR13_Msk /*!< Interrupt Mask on line 13 */ #define EXTI_IMR_MR14_Pos (14U) #define EXTI_IMR_MR14_Msk (0x1UL << EXTI_IMR_MR14_Pos) /*!< 0x00004000 */ #define EXTI_IMR_MR14 EXTI_IMR_MR14_Msk /*!< Interrupt Mask on line 14 */ #define EXTI_IMR_MR15_Pos (15U) #define EXTI_IMR_MR15_Msk (0x1UL << EXTI_IMR_MR15_Pos) /*!< 0x00008000 */ #define EXTI_IMR_MR15 EXTI_IMR_MR15_Msk /*!< Interrupt Mask on line 15 */ #define EXTI_IMR_MR16_Pos (16U) #define EXTI_IMR_MR16_Msk (0x1UL << EXTI_IMR_MR16_Pos) /*!< 0x00010000 */ #define EXTI_IMR_MR16 EXTI_IMR_MR16_Msk /*!< Interrupt Mask on line 16 */ #define EXTI_IMR_MR17_Pos (17U) #define EXTI_IMR_MR17_Msk (0x1UL << EXTI_IMR_MR17_Pos) /*!< 0x00020000 */ #define EXTI_IMR_MR17 EXTI_IMR_MR17_Msk /*!< Interrupt Mask on line 17 */ #define EXTI_IMR_MR18_Pos (18U) #define EXTI_IMR_MR18_Msk (0x1UL << EXTI_IMR_MR18_Pos) /*!< 0x00040000 */ #define EXTI_IMR_MR18 EXTI_IMR_MR18_Msk /*!< Interrupt Mask on line 18 */ /* References Defines */ #define EXTI_IMR_IM0 EXTI_IMR_MR0 #define EXTI_IMR_IM1 EXTI_IMR_MR1 #define EXTI_IMR_IM2 EXTI_IMR_MR2 #define EXTI_IMR_IM3 EXTI_IMR_MR3 #define EXTI_IMR_IM4 EXTI_IMR_MR4 #define EXTI_IMR_IM5 EXTI_IMR_MR5 #define EXTI_IMR_IM6 EXTI_IMR_MR6 #define EXTI_IMR_IM7 EXTI_IMR_MR7 #define EXTI_IMR_IM8 EXTI_IMR_MR8 #define EXTI_IMR_IM9 EXTI_IMR_MR9 #define EXTI_IMR_IM10 EXTI_IMR_MR10 #define EXTI_IMR_IM11 EXTI_IMR_MR11 #define EXTI_IMR_IM12 EXTI_IMR_MR12 #define EXTI_IMR_IM13 EXTI_IMR_MR13 #define EXTI_IMR_IM14 EXTI_IMR_MR14 #define EXTI_IMR_IM15 EXTI_IMR_MR15 #define EXTI_IMR_IM16 EXTI_IMR_MR16 #define EXTI_IMR_IM17 EXTI_IMR_MR17 #define EXTI_IMR_IM18 EXTI_IMR_MR18 #define EXTI_IMR_IM 0x0007FFFFU /*!< Interrupt Mask All */ /******************* Bit definition for EXTI_EMR register *******************/ #define EXTI_EMR_MR0_Pos (0U) #define EXTI_EMR_MR0_Msk (0x1UL << EXTI_EMR_MR0_Pos) /*!< 0x00000001 */ #define EXTI_EMR_MR0 EXTI_EMR_MR0_Msk /*!< Event Mask on line 0 */ #define EXTI_EMR_MR1_Pos (1U) #define EXTI_EMR_MR1_Msk (0x1UL << EXTI_EMR_MR1_Pos) /*!< 0x00000002 */ #define EXTI_EMR_MR1 EXTI_EMR_MR1_Msk /*!< Event Mask on line 1 */ #define EXTI_EMR_MR2_Pos (2U) #define EXTI_EMR_MR2_Msk (0x1UL << EXTI_EMR_MR2_Pos) /*!< 0x00000004 */ #define EXTI_EMR_MR2 EXTI_EMR_MR2_Msk /*!< Event Mask on line 2 */ #define EXTI_EMR_MR3_Pos (3U) #define EXTI_EMR_MR3_Msk (0x1UL << EXTI_EMR_MR3_Pos) /*!< 0x00000008 */ #define EXTI_EMR_MR3 EXTI_EMR_MR3_Msk /*!< Event Mask on line 3 */ #define EXTI_EMR_MR4_Pos (4U) #define EXTI_EMR_MR4_Msk (0x1UL << EXTI_EMR_MR4_Pos) /*!< 0x00000010 */ #define EXTI_EMR_MR4 EXTI_EMR_MR4_Msk /*!< Event Mask on line 4 */ #define EXTI_EMR_MR5_Pos (5U) #define EXTI_EMR_MR5_Msk (0x1UL << EXTI_EMR_MR5_Pos) /*!< 0x00000020 */ #define EXTI_EMR_MR5 EXTI_EMR_MR5_Msk /*!< Event Mask on line 5 */ #define EXTI_EMR_MR6_Pos (6U) #define EXTI_EMR_MR6_Msk (0x1UL << EXTI_EMR_MR6_Pos) /*!< 0x00000040 */ #define EXTI_EMR_MR6 EXTI_EMR_MR6_Msk /*!< Event Mask on line 6 */ #define EXTI_EMR_MR7_Pos (7U) #define EXTI_EMR_MR7_Msk (0x1UL << EXTI_EMR_MR7_Pos) /*!< 0x00000080 */ #define EXTI_EMR_MR7 EXTI_EMR_MR7_Msk /*!< Event Mask on line 7 */ #define EXTI_EMR_MR8_Pos (8U) #define EXTI_EMR_MR8_Msk (0x1UL << EXTI_EMR_MR8_Pos) /*!< 0x00000100 */ #define EXTI_EMR_MR8 EXTI_EMR_MR8_Msk /*!< Event Mask on line 8 */ #define EXTI_EMR_MR9_Pos (9U) #define EXTI_EMR_MR9_Msk (0x1UL << EXTI_EMR_MR9_Pos) /*!< 0x00000200 */ #define EXTI_EMR_MR9 EXTI_EMR_MR9_Msk /*!< Event Mask on line 9 */ #define EXTI_EMR_MR10_Pos (10U) #define EXTI_EMR_MR10_Msk (0x1UL << EXTI_EMR_MR10_Pos) /*!< 0x00000400 */ #define EXTI_EMR_MR10 EXTI_EMR_MR10_Msk /*!< Event Mask on line 10 */ #define EXTI_EMR_MR11_Pos (11U) #define EXTI_EMR_MR11_Msk (0x1UL << EXTI_EMR_MR11_Pos) /*!< 0x00000800 */ #define EXTI_EMR_MR11 EXTI_EMR_MR11_Msk /*!< Event Mask on line 11 */ #define EXTI_EMR_MR12_Pos (12U) #define EXTI_EMR_MR12_Msk (0x1UL << EXTI_EMR_MR12_Pos) /*!< 0x00001000 */ #define EXTI_EMR_MR12 EXTI_EMR_MR12_Msk /*!< Event Mask on line 12 */ #define EXTI_EMR_MR13_Pos (13U) #define EXTI_EMR_MR13_Msk (0x1UL << EXTI_EMR_MR13_Pos) /*!< 0x00002000 */ #define EXTI_EMR_MR13 EXTI_EMR_MR13_Msk /*!< Event Mask on line 13 */ #define EXTI_EMR_MR14_Pos (14U) #define EXTI_EMR_MR14_Msk (0x1UL << EXTI_EMR_MR14_Pos) /*!< 0x00004000 */ #define EXTI_EMR_MR14 EXTI_EMR_MR14_Msk /*!< Event Mask on line 14 */ #define EXTI_EMR_MR15_Pos (15U) #define EXTI_EMR_MR15_Msk (0x1UL << EXTI_EMR_MR15_Pos) /*!< 0x00008000 */ #define EXTI_EMR_MR15 EXTI_EMR_MR15_Msk /*!< Event Mask on line 15 */ #define EXTI_EMR_MR16_Pos (16U) #define EXTI_EMR_MR16_Msk (0x1UL << EXTI_EMR_MR16_Pos) /*!< 0x00010000 */ #define EXTI_EMR_MR16 EXTI_EMR_MR16_Msk /*!< Event Mask on line 16 */ #define EXTI_EMR_MR17_Pos (17U) #define EXTI_EMR_MR17_Msk (0x1UL << EXTI_EMR_MR17_Pos) /*!< 0x00020000 */ #define EXTI_EMR_MR17 EXTI_EMR_MR17_Msk /*!< Event Mask on line 17 */ #define EXTI_EMR_MR18_Pos (18U) #define EXTI_EMR_MR18_Msk (0x1UL << EXTI_EMR_MR18_Pos) /*!< 0x00040000 */ #define EXTI_EMR_MR18 EXTI_EMR_MR18_Msk /*!< Event Mask on line 18 */ /* References Defines */ #define EXTI_EMR_EM0 EXTI_EMR_MR0 #define EXTI_EMR_EM1 EXTI_EMR_MR1 #define EXTI_EMR_EM2 EXTI_EMR_MR2 #define EXTI_EMR_EM3 EXTI_EMR_MR3 #define EXTI_EMR_EM4 EXTI_EMR_MR4 #define EXTI_EMR_EM5 EXTI_EMR_MR5 #define EXTI_EMR_EM6 EXTI_EMR_MR6 #define EXTI_EMR_EM7 EXTI_EMR_MR7 #define EXTI_EMR_EM8 EXTI_EMR_MR8 #define EXTI_EMR_EM9 EXTI_EMR_MR9 #define EXTI_EMR_EM10 EXTI_EMR_MR10 #define EXTI_EMR_EM11 EXTI_EMR_MR11 #define EXTI_EMR_EM12 EXTI_EMR_MR12 #define EXTI_EMR_EM13 EXTI_EMR_MR13 #define EXTI_EMR_EM14 EXTI_EMR_MR14 #define EXTI_EMR_EM15 EXTI_EMR_MR15 #define EXTI_EMR_EM16 EXTI_EMR_MR16 #define EXTI_EMR_EM17 EXTI_EMR_MR17 #define EXTI_EMR_EM18 EXTI_EMR_MR18 /****************** Bit definition for EXTI_RTSR register *******************/ #define EXTI_RTSR_TR0_Pos (0U) #define EXTI_RTSR_TR0_Msk (0x1UL << EXTI_RTSR_TR0_Pos) /*!< 0x00000001 */ #define EXTI_RTSR_TR0 EXTI_RTSR_TR0_Msk /*!< Rising trigger event configuration bit of line 0 */ #define EXTI_RTSR_TR1_Pos (1U) #define EXTI_RTSR_TR1_Msk (0x1UL << EXTI_RTSR_TR1_Pos) /*!< 0x00000002 */ #define EXTI_RTSR_TR1 EXTI_RTSR_TR1_Msk /*!< Rising trigger event configuration bit of line 1 */ #define EXTI_RTSR_TR2_Pos (2U) #define EXTI_RTSR_TR2_Msk (0x1UL << EXTI_RTSR_TR2_Pos) /*!< 0x00000004 */ #define EXTI_RTSR_TR2 EXTI_RTSR_TR2_Msk /*!< Rising trigger event configuration bit of line 2 */ #define EXTI_RTSR_TR3_Pos (3U) #define EXTI_RTSR_TR3_Msk (0x1UL << EXTI_RTSR_TR3_Pos) /*!< 0x00000008 */ #define EXTI_RTSR_TR3 EXTI_RTSR_TR3_Msk /*!< Rising trigger event configuration bit of line 3 */ #define EXTI_RTSR_TR4_Pos (4U) #define EXTI_RTSR_TR4_Msk (0x1UL << EXTI_RTSR_TR4_Pos) /*!< 0x00000010 */ #define EXTI_RTSR_TR4 EXTI_RTSR_TR4_Msk /*!< Rising trigger event configuration bit of line 4 */ #define EXTI_RTSR_TR5_Pos (5U) #define EXTI_RTSR_TR5_Msk (0x1UL << EXTI_RTSR_TR5_Pos) /*!< 0x00000020 */ #define EXTI_RTSR_TR5 EXTI_RTSR_TR5_Msk /*!< Rising trigger event configuration bit of line 5 */ #define EXTI_RTSR_TR6_Pos (6U) #define EXTI_RTSR_TR6_Msk (0x1UL << EXTI_RTSR_TR6_Pos) /*!< 0x00000040 */ #define EXTI_RTSR_TR6 EXTI_RTSR_TR6_Msk /*!< Rising trigger event configuration bit of line 6 */ #define EXTI_RTSR_TR7_Pos (7U) #define EXTI_RTSR_TR7_Msk (0x1UL << EXTI_RTSR_TR7_Pos) /*!< 0x00000080 */ #define EXTI_RTSR_TR7 EXTI_RTSR_TR7_Msk /*!< Rising trigger event configuration bit of line 7 */ #define EXTI_RTSR_TR8_Pos (8U) #define EXTI_RTSR_TR8_Msk (0x1UL << EXTI_RTSR_TR8_Pos) /*!< 0x00000100 */ #define EXTI_RTSR_TR8 EXTI_RTSR_TR8_Msk /*!< Rising trigger event configuration bit of line 8 */ #define EXTI_RTSR_TR9_Pos (9U) #define EXTI_RTSR_TR9_Msk (0x1UL << EXTI_RTSR_TR9_Pos) /*!< 0x00000200 */ #define EXTI_RTSR_TR9 EXTI_RTSR_TR9_Msk /*!< Rising trigger event configuration bit of line 9 */ #define EXTI_RTSR_TR10_Pos (10U) #define EXTI_RTSR_TR10_Msk (0x1UL << EXTI_RTSR_TR10_Pos) /*!< 0x00000400 */ #define EXTI_RTSR_TR10 EXTI_RTSR_TR10_Msk /*!< Rising trigger event configuration bit of line 10 */ #define EXTI_RTSR_TR11_Pos (11U) #define EXTI_RTSR_TR11_Msk (0x1UL << EXTI_RTSR_TR11_Pos) /*!< 0x00000800 */ #define EXTI_RTSR_TR11 EXTI_RTSR_TR11_Msk /*!< Rising trigger event configuration bit of line 11 */ #define EXTI_RTSR_TR12_Pos (12U) #define EXTI_RTSR_TR12_Msk (0x1UL << EXTI_RTSR_TR12_Pos) /*!< 0x00001000 */ #define EXTI_RTSR_TR12 EXTI_RTSR_TR12_Msk /*!< Rising trigger event configuration bit of line 12 */ #define EXTI_RTSR_TR13_Pos (13U) #define EXTI_RTSR_TR13_Msk (0x1UL << EXTI_RTSR_TR13_Pos) /*!< 0x00002000 */ #define EXTI_RTSR_TR13 EXTI_RTSR_TR13_Msk /*!< Rising trigger event configuration bit of line 13 */ #define EXTI_RTSR_TR14_Pos (14U) #define EXTI_RTSR_TR14_Msk (0x1UL << EXTI_RTSR_TR14_Pos) /*!< 0x00004000 */ #define EXTI_RTSR_TR14 EXTI_RTSR_TR14_Msk /*!< Rising trigger event configuration bit of line 14 */ #define EXTI_RTSR_TR15_Pos (15U) #define EXTI_RTSR_TR15_Msk (0x1UL << EXTI_RTSR_TR15_Pos) /*!< 0x00008000 */ #define EXTI_RTSR_TR15 EXTI_RTSR_TR15_Msk /*!< Rising trigger event configuration bit of line 15 */ #define EXTI_RTSR_TR16_Pos (16U) #define EXTI_RTSR_TR16_Msk (0x1UL << EXTI_RTSR_TR16_Pos) /*!< 0x00010000 */ #define EXTI_RTSR_TR16 EXTI_RTSR_TR16_Msk /*!< Rising trigger event configuration bit of line 16 */ #define EXTI_RTSR_TR17_Pos (17U) #define EXTI_RTSR_TR17_Msk (0x1UL << EXTI_RTSR_TR17_Pos) /*!< 0x00020000 */ #define EXTI_RTSR_TR17 EXTI_RTSR_TR17_Msk /*!< Rising trigger event configuration bit of line 17 */ #define EXTI_RTSR_TR18_Pos (18U) #define EXTI_RTSR_TR18_Msk (0x1UL << EXTI_RTSR_TR18_Pos) /*!< 0x00040000 */ #define EXTI_RTSR_TR18 EXTI_RTSR_TR18_Msk /*!< Rising trigger event configuration bit of line 18 */ /* References Defines */ #define EXTI_RTSR_RT0 EXTI_RTSR_TR0 #define EXTI_RTSR_RT1 EXTI_RTSR_TR1 #define EXTI_RTSR_RT2 EXTI_RTSR_TR2 #define EXTI_RTSR_RT3 EXTI_RTSR_TR3 #define EXTI_RTSR_RT4 EXTI_RTSR_TR4 #define EXTI_RTSR_RT5 EXTI_RTSR_TR5 #define EXTI_RTSR_RT6 EXTI_RTSR_TR6 #define EXTI_RTSR_RT7 EXTI_RTSR_TR7 #define EXTI_RTSR_RT8 EXTI_RTSR_TR8 #define EXTI_RTSR_RT9 EXTI_RTSR_TR9 #define EXTI_RTSR_RT10 EXTI_RTSR_TR10 #define EXTI_RTSR_RT11 EXTI_RTSR_TR11 #define EXTI_RTSR_RT12 EXTI_RTSR_TR12 #define EXTI_RTSR_RT13 EXTI_RTSR_TR13 #define EXTI_RTSR_RT14 EXTI_RTSR_TR14 #define EXTI_RTSR_RT15 EXTI_RTSR_TR15 #define EXTI_RTSR_RT16 EXTI_RTSR_TR16 #define EXTI_RTSR_RT17 EXTI_RTSR_TR17 #define EXTI_RTSR_RT18 EXTI_RTSR_TR18 /****************** Bit definition for EXTI_FTSR register *******************/ #define EXTI_FTSR_TR0_Pos (0U) #define EXTI_FTSR_TR0_Msk (0x1UL << EXTI_FTSR_TR0_Pos) /*!< 0x00000001 */ #define EXTI_FTSR_TR0 EXTI_FTSR_TR0_Msk /*!< Falling trigger event configuration bit of line 0 */ #define EXTI_FTSR_TR1_Pos (1U) #define EXTI_FTSR_TR1_Msk (0x1UL << EXTI_FTSR_TR1_Pos) /*!< 0x00000002 */ #define EXTI_FTSR_TR1 EXTI_FTSR_TR1_Msk /*!< Falling trigger event configuration bit of line 1 */ #define EXTI_FTSR_TR2_Pos (2U) #define EXTI_FTSR_TR2_Msk (0x1UL << EXTI_FTSR_TR2_Pos) /*!< 0x00000004 */ #define EXTI_FTSR_TR2 EXTI_FTSR_TR2_Msk /*!< Falling trigger event configuration bit of line 2 */ #define EXTI_FTSR_TR3_Pos (3U) #define EXTI_FTSR_TR3_Msk (0x1UL << EXTI_FTSR_TR3_Pos) /*!< 0x00000008 */ #define EXTI_FTSR_TR3 EXTI_FTSR_TR3_Msk /*!< Falling trigger event configuration bit of line 3 */ #define EXTI_FTSR_TR4_Pos (4U) #define EXTI_FTSR_TR4_Msk (0x1UL << EXTI_FTSR_TR4_Pos) /*!< 0x00000010 */ #define EXTI_FTSR_TR4 EXTI_FTSR_TR4_Msk /*!< Falling trigger event configuration bit of line 4 */ #define EXTI_FTSR_TR5_Pos (5U) #define EXTI_FTSR_TR5_Msk (0x1UL << EXTI_FTSR_TR5_Pos) /*!< 0x00000020 */ #define EXTI_FTSR_TR5 EXTI_FTSR_TR5_Msk /*!< Falling trigger event configuration bit of line 5 */ #define EXTI_FTSR_TR6_Pos (6U) #define EXTI_FTSR_TR6_Msk (0x1UL << EXTI_FTSR_TR6_Pos) /*!< 0x00000040 */ #define EXTI_FTSR_TR6 EXTI_FTSR_TR6_Msk /*!< Falling trigger event configuration bit of line 6 */ #define EXTI_FTSR_TR7_Pos (7U) #define EXTI_FTSR_TR7_Msk (0x1UL << EXTI_FTSR_TR7_Pos) /*!< 0x00000080 */ #define EXTI_FTSR_TR7 EXTI_FTSR_TR7_Msk /*!< Falling trigger event configuration bit of line 7 */ #define EXTI_FTSR_TR8_Pos (8U) #define EXTI_FTSR_TR8_Msk (0x1UL << EXTI_FTSR_TR8_Pos) /*!< 0x00000100 */ #define EXTI_FTSR_TR8 EXTI_FTSR_TR8_Msk /*!< Falling trigger event configuration bit of line 8 */ #define EXTI_FTSR_TR9_Pos (9U) #define EXTI_FTSR_TR9_Msk (0x1UL << EXTI_FTSR_TR9_Pos) /*!< 0x00000200 */ #define EXTI_FTSR_TR9 EXTI_FTSR_TR9_Msk /*!< Falling trigger event configuration bit of line 9 */ #define EXTI_FTSR_TR10_Pos (10U) #define EXTI_FTSR_TR10_Msk (0x1UL << EXTI_FTSR_TR10_Pos) /*!< 0x00000400 */ #define EXTI_FTSR_TR10 EXTI_FTSR_TR10_Msk /*!< Falling trigger event configuration bit of line 10 */ #define EXTI_FTSR_TR11_Pos (11U) #define EXTI_FTSR_TR11_Msk (0x1UL << EXTI_FTSR_TR11_Pos) /*!< 0x00000800 */ #define EXTI_FTSR_TR11 EXTI_FTSR_TR11_Msk /*!< Falling trigger event configuration bit of line 11 */ #define EXTI_FTSR_TR12_Pos (12U) #define EXTI_FTSR_TR12_Msk (0x1UL << EXTI_FTSR_TR12_Pos) /*!< 0x00001000 */ #define EXTI_FTSR_TR12 EXTI_FTSR_TR12_Msk /*!< Falling trigger event configuration bit of line 12 */ #define EXTI_FTSR_TR13_Pos (13U) #define EXTI_FTSR_TR13_Msk (0x1UL << EXTI_FTSR_TR13_Pos) /*!< 0x00002000 */ #define EXTI_FTSR_TR13 EXTI_FTSR_TR13_Msk /*!< Falling trigger event configuration bit of line 13 */ #define EXTI_FTSR_TR14_Pos (14U) #define EXTI_FTSR_TR14_Msk (0x1UL << EXTI_FTSR_TR14_Pos) /*!< 0x00004000 */ #define EXTI_FTSR_TR14 EXTI_FTSR_TR14_Msk /*!< Falling trigger event configuration bit of line 14 */ #define EXTI_FTSR_TR15_Pos (15U) #define EXTI_FTSR_TR15_Msk (0x1UL << EXTI_FTSR_TR15_Pos) /*!< 0x00008000 */ #define EXTI_FTSR_TR15 EXTI_FTSR_TR15_Msk /*!< Falling trigger event configuration bit of line 15 */ #define EXTI_FTSR_TR16_Pos (16U) #define EXTI_FTSR_TR16_Msk (0x1UL << EXTI_FTSR_TR16_Pos) /*!< 0x00010000 */ #define EXTI_FTSR_TR16 EXTI_FTSR_TR16_Msk /*!< Falling trigger event configuration bit of line 16 */ #define EXTI_FTSR_TR17_Pos (17U) #define EXTI_FTSR_TR17_Msk (0x1UL << EXTI_FTSR_TR17_Pos) /*!< 0x00020000 */ #define EXTI_FTSR_TR17 EXTI_FTSR_TR17_Msk /*!< Falling trigger event configuration bit of line 17 */ #define EXTI_FTSR_TR18_Pos (18U) #define EXTI_FTSR_TR18_Msk (0x1UL << EXTI_FTSR_TR18_Pos) /*!< 0x00040000 */ #define EXTI_FTSR_TR18 EXTI_FTSR_TR18_Msk /*!< Falling trigger event configuration bit of line 18 */ /* References Defines */ #define EXTI_FTSR_FT0 EXTI_FTSR_TR0 #define EXTI_FTSR_FT1 EXTI_FTSR_TR1 #define EXTI_FTSR_FT2 EXTI_FTSR_TR2 #define EXTI_FTSR_FT3 EXTI_FTSR_TR3 #define EXTI_FTSR_FT4 EXTI_FTSR_TR4 #define EXTI_FTSR_FT5 EXTI_FTSR_TR5 #define EXTI_FTSR_FT6 EXTI_FTSR_TR6 #define EXTI_FTSR_FT7 EXTI_FTSR_TR7 #define EXTI_FTSR_FT8 EXTI_FTSR_TR8 #define EXTI_FTSR_FT9 EXTI_FTSR_TR9 #define EXTI_FTSR_FT10 EXTI_FTSR_TR10 #define EXTI_FTSR_FT11 EXTI_FTSR_TR11 #define EXTI_FTSR_FT12 EXTI_FTSR_TR12 #define EXTI_FTSR_FT13 EXTI_FTSR_TR13 #define EXTI_FTSR_FT14 EXTI_FTSR_TR14 #define EXTI_FTSR_FT15 EXTI_FTSR_TR15 #define EXTI_FTSR_FT16 EXTI_FTSR_TR16 #define EXTI_FTSR_FT17 EXTI_FTSR_TR17 #define EXTI_FTSR_FT18 EXTI_FTSR_TR18 /****************** Bit definition for EXTI_SWIER register ******************/ #define EXTI_SWIER_SWIER0_Pos (0U) #define EXTI_SWIER_SWIER0_Msk (0x1UL << EXTI_SWIER_SWIER0_Pos) /*!< 0x00000001 */ #define EXTI_SWIER_SWIER0 EXTI_SWIER_SWIER0_Msk /*!< Software Interrupt on line 0 */ #define EXTI_SWIER_SWIER1_Pos (1U) #define EXTI_SWIER_SWIER1_Msk (0x1UL << EXTI_SWIER_SWIER1_Pos) /*!< 0x00000002 */ #define EXTI_SWIER_SWIER1 EXTI_SWIER_SWIER1_Msk /*!< Software Interrupt on line 1 */ #define EXTI_SWIER_SWIER2_Pos (2U) #define EXTI_SWIER_SWIER2_Msk (0x1UL << EXTI_SWIER_SWIER2_Pos) /*!< 0x00000004 */ #define EXTI_SWIER_SWIER2 EXTI_SWIER_SWIER2_Msk /*!< Software Interrupt on line 2 */ #define EXTI_SWIER_SWIER3_Pos (3U) #define EXTI_SWIER_SWIER3_Msk (0x1UL << EXTI_SWIER_SWIER3_Pos) /*!< 0x00000008 */ #define EXTI_SWIER_SWIER3 EXTI_SWIER_SWIER3_Msk /*!< Software Interrupt on line 3 */ #define EXTI_SWIER_SWIER4_Pos (4U) #define EXTI_SWIER_SWIER4_Msk (0x1UL << EXTI_SWIER_SWIER4_Pos) /*!< 0x00000010 */ #define EXTI_SWIER_SWIER4 EXTI_SWIER_SWIER4_Msk /*!< Software Interrupt on line 4 */ #define EXTI_SWIER_SWIER5_Pos (5U) #define EXTI_SWIER_SWIER5_Msk (0x1UL << EXTI_SWIER_SWIER5_Pos) /*!< 0x00000020 */ #define EXTI_SWIER_SWIER5 EXTI_SWIER_SWIER5_Msk /*!< Software Interrupt on line 5 */ #define EXTI_SWIER_SWIER6_Pos (6U) #define EXTI_SWIER_SWIER6_Msk (0x1UL << EXTI_SWIER_SWIER6_Pos) /*!< 0x00000040 */ #define EXTI_SWIER_SWIER6 EXTI_SWIER_SWIER6_Msk /*!< Software Interrupt on line 6 */ #define EXTI_SWIER_SWIER7_Pos (7U) #define EXTI_SWIER_SWIER7_Msk (0x1UL << EXTI_SWIER_SWIER7_Pos) /*!< 0x00000080 */ #define EXTI_SWIER_SWIER7 EXTI_SWIER_SWIER7_Msk /*!< Software Interrupt on line 7 */ #define EXTI_SWIER_SWIER8_Pos (8U) #define EXTI_SWIER_SWIER8_Msk (0x1UL << EXTI_SWIER_SWIER8_Pos) /*!< 0x00000100 */ #define EXTI_SWIER_SWIER8 EXTI_SWIER_SWIER8_Msk /*!< Software Interrupt on line 8 */ #define EXTI_SWIER_SWIER9_Pos (9U) #define EXTI_SWIER_SWIER9_Msk (0x1UL << EXTI_SWIER_SWIER9_Pos) /*!< 0x00000200 */ #define EXTI_SWIER_SWIER9 EXTI_SWIER_SWIER9_Msk /*!< Software Interrupt on line 9 */ #define EXTI_SWIER_SWIER10_Pos (10U) #define EXTI_SWIER_SWIER10_Msk (0x1UL << EXTI_SWIER_SWIER10_Pos) /*!< 0x00000400 */ #define EXTI_SWIER_SWIER10 EXTI_SWIER_SWIER10_Msk /*!< Software Interrupt on line 10 */ #define EXTI_SWIER_SWIER11_Pos (11U) #define EXTI_SWIER_SWIER11_Msk (0x1UL << EXTI_SWIER_SWIER11_Pos) /*!< 0x00000800 */ #define EXTI_SWIER_SWIER11 EXTI_SWIER_SWIER11_Msk /*!< Software Interrupt on line 11 */ #define EXTI_SWIER_SWIER12_Pos (12U) #define EXTI_SWIER_SWIER12_Msk (0x1UL << EXTI_SWIER_SWIER12_Pos) /*!< 0x00001000 */ #define EXTI_SWIER_SWIER12 EXTI_SWIER_SWIER12_Msk /*!< Software Interrupt on line 12 */ #define EXTI_SWIER_SWIER13_Pos (13U) #define EXTI_SWIER_SWIER13_Msk (0x1UL << EXTI_SWIER_SWIER13_Pos) /*!< 0x00002000 */ #define EXTI_SWIER_SWIER13 EXTI_SWIER_SWIER13_Msk /*!< Software Interrupt on line 13 */ #define EXTI_SWIER_SWIER14_Pos (14U) #define EXTI_SWIER_SWIER14_Msk (0x1UL << EXTI_SWIER_SWIER14_Pos) /*!< 0x00004000 */ #define EXTI_SWIER_SWIER14 EXTI_SWIER_SWIER14_Msk /*!< Software Interrupt on line 14 */ #define EXTI_SWIER_SWIER15_Pos (15U) #define EXTI_SWIER_SWIER15_Msk (0x1UL << EXTI_SWIER_SWIER15_Pos) /*!< 0x00008000 */ #define EXTI_SWIER_SWIER15 EXTI_SWIER_SWIER15_Msk /*!< Software Interrupt on line 15 */ #define EXTI_SWIER_SWIER16_Pos (16U) #define EXTI_SWIER_SWIER16_Msk (0x1UL << EXTI_SWIER_SWIER16_Pos) /*!< 0x00010000 */ #define EXTI_SWIER_SWIER16 EXTI_SWIER_SWIER16_Msk /*!< Software Interrupt on line 16 */ #define EXTI_SWIER_SWIER17_Pos (17U) #define EXTI_SWIER_SWIER17_Msk (0x1UL << EXTI_SWIER_SWIER17_Pos) /*!< 0x00020000 */ #define EXTI_SWIER_SWIER17 EXTI_SWIER_SWIER17_Msk /*!< Software Interrupt on line 17 */ #define EXTI_SWIER_SWIER18_Pos (18U) #define EXTI_SWIER_SWIER18_Msk (0x1UL << EXTI_SWIER_SWIER18_Pos) /*!< 0x00040000 */ #define EXTI_SWIER_SWIER18 EXTI_SWIER_SWIER18_Msk /*!< Software Interrupt on line 18 */ /* References Defines */ #define EXTI_SWIER_SWI0 EXTI_SWIER_SWIER0 #define EXTI_SWIER_SWI1 EXTI_SWIER_SWIER1 #define EXTI_SWIER_SWI2 EXTI_SWIER_SWIER2 #define EXTI_SWIER_SWI3 EXTI_SWIER_SWIER3 #define EXTI_SWIER_SWI4 EXTI_SWIER_SWIER4 #define EXTI_SWIER_SWI5 EXTI_SWIER_SWIER5 #define EXTI_SWIER_SWI6 EXTI_SWIER_SWIER6 #define EXTI_SWIER_SWI7 EXTI_SWIER_SWIER7 #define EXTI_SWIER_SWI8 EXTI_SWIER_SWIER8 #define EXTI_SWIER_SWI9 EXTI_SWIER_SWIER9 #define EXTI_SWIER_SWI10 EXTI_SWIER_SWIER10 #define EXTI_SWIER_SWI11 EXTI_SWIER_SWIER11 #define EXTI_SWIER_SWI12 EXTI_SWIER_SWIER12 #define EXTI_SWIER_SWI13 EXTI_SWIER_SWIER13 #define EXTI_SWIER_SWI14 EXTI_SWIER_SWIER14 #define EXTI_SWIER_SWI15 EXTI_SWIER_SWIER15 #define EXTI_SWIER_SWI16 EXTI_SWIER_SWIER16 #define EXTI_SWIER_SWI17 EXTI_SWIER_SWIER17 #define EXTI_SWIER_SWI18 EXTI_SWIER_SWIER18 /******************* Bit definition for EXTI_PR register ********************/ #define EXTI_PR_PR0_Pos (0U) #define EXTI_PR_PR0_Msk (0x1UL << EXTI_PR_PR0_Pos) /*!< 0x00000001 */ #define EXTI_PR_PR0 EXTI_PR_PR0_Msk /*!< Pending bit for line 0 */ #define EXTI_PR_PR1_Pos (1U) #define EXTI_PR_PR1_Msk (0x1UL << EXTI_PR_PR1_Pos) /*!< 0x00000002 */ #define EXTI_PR_PR1 EXTI_PR_PR1_Msk /*!< Pending bit for line 1 */ #define EXTI_PR_PR2_Pos (2U) #define EXTI_PR_PR2_Msk (0x1UL << EXTI_PR_PR2_Pos) /*!< 0x00000004 */ #define EXTI_PR_PR2 EXTI_PR_PR2_Msk /*!< Pending bit for line 2 */ #define EXTI_PR_PR3_Pos (3U) #define EXTI_PR_PR3_Msk (0x1UL << EXTI_PR_PR3_Pos) /*!< 0x00000008 */ #define EXTI_PR_PR3 EXTI_PR_PR3_Msk /*!< Pending bit for line 3 */ #define EXTI_PR_PR4_Pos (4U) #define EXTI_PR_PR4_Msk (0x1UL << EXTI_PR_PR4_Pos) /*!< 0x00000010 */ #define EXTI_PR_PR4 EXTI_PR_PR4_Msk /*!< Pending bit for line 4 */ #define EXTI_PR_PR5_Pos (5U) #define EXTI_PR_PR5_Msk (0x1UL << EXTI_PR_PR5_Pos) /*!< 0x00000020 */ #define EXTI_PR_PR5 EXTI_PR_PR5_Msk /*!< Pending bit for line 5 */ #define EXTI_PR_PR6_Pos (6U) #define EXTI_PR_PR6_Msk (0x1UL << EXTI_PR_PR6_Pos) /*!< 0x00000040 */ #define EXTI_PR_PR6 EXTI_PR_PR6_Msk /*!< Pending bit for line 6 */ #define EXTI_PR_PR7_Pos (7U) #define EXTI_PR_PR7_Msk (0x1UL << EXTI_PR_PR7_Pos) /*!< 0x00000080 */ #define EXTI_PR_PR7 EXTI_PR_PR7_Msk /*!< Pending bit for line 7 */ #define EXTI_PR_PR8_Pos (8U) #define EXTI_PR_PR8_Msk (0x1UL << EXTI_PR_PR8_Pos) /*!< 0x00000100 */ #define EXTI_PR_PR8 EXTI_PR_PR8_Msk /*!< Pending bit for line 8 */ #define EXTI_PR_PR9_Pos (9U) #define EXTI_PR_PR9_Msk (0x1UL << EXTI_PR_PR9_Pos) /*!< 0x00000200 */ #define EXTI_PR_PR9 EXTI_PR_PR9_Msk /*!< Pending bit for line 9 */ #define EXTI_PR_PR10_Pos (10U) #define EXTI_PR_PR10_Msk (0x1UL << EXTI_PR_PR10_Pos) /*!< 0x00000400 */ #define EXTI_PR_PR10 EXTI_PR_PR10_Msk /*!< Pending bit for line 10 */ #define EXTI_PR_PR11_Pos (11U) #define EXTI_PR_PR11_Msk (0x1UL << EXTI_PR_PR11_Pos) /*!< 0x00000800 */ #define EXTI_PR_PR11 EXTI_PR_PR11_Msk /*!< Pending bit for line 11 */ #define EXTI_PR_PR12_Pos (12U) #define EXTI_PR_PR12_Msk (0x1UL << EXTI_PR_PR12_Pos) /*!< 0x00001000 */ #define EXTI_PR_PR12 EXTI_PR_PR12_Msk /*!< Pending bit for line 12 */ #define EXTI_PR_PR13_Pos (13U) #define EXTI_PR_PR13_Msk (0x1UL << EXTI_PR_PR13_Pos) /*!< 0x00002000 */ #define EXTI_PR_PR13 EXTI_PR_PR13_Msk /*!< Pending bit for line 13 */ #define EXTI_PR_PR14_Pos (14U) #define EXTI_PR_PR14_Msk (0x1UL << EXTI_PR_PR14_Pos) /*!< 0x00004000 */ #define EXTI_PR_PR14 EXTI_PR_PR14_Msk /*!< Pending bit for line 14 */ #define EXTI_PR_PR15_Pos (15U) #define EXTI_PR_PR15_Msk (0x1UL << EXTI_PR_PR15_Pos) /*!< 0x00008000 */ #define EXTI_PR_PR15 EXTI_PR_PR15_Msk /*!< Pending bit for line 15 */ #define EXTI_PR_PR16_Pos (16U) #define EXTI_PR_PR16_Msk (0x1UL << EXTI_PR_PR16_Pos) /*!< 0x00010000 */ #define EXTI_PR_PR16 EXTI_PR_PR16_Msk /*!< Pending bit for line 16 */ #define EXTI_PR_PR17_Pos (17U) #define EXTI_PR_PR17_Msk (0x1UL << EXTI_PR_PR17_Pos) /*!< 0x00020000 */ #define EXTI_PR_PR17 EXTI_PR_PR17_Msk /*!< Pending bit for line 17 */ #define EXTI_PR_PR18_Pos (18U) #define EXTI_PR_PR18_Msk (0x1UL << EXTI_PR_PR18_Pos) /*!< 0x00040000 */ #define EXTI_PR_PR18 EXTI_PR_PR18_Msk /*!< Pending bit for line 18 */ /* References Defines */ #define EXTI_PR_PIF0 EXTI_PR_PR0 #define EXTI_PR_PIF1 EXTI_PR_PR1 #define EXTI_PR_PIF2 EXTI_PR_PR2 #define EXTI_PR_PIF3 EXTI_PR_PR3 #define EXTI_PR_PIF4 EXTI_PR_PR4 #define EXTI_PR_PIF5 EXTI_PR_PR5 #define EXTI_PR_PIF6 EXTI_PR_PR6 #define EXTI_PR_PIF7 EXTI_PR_PR7 #define EXTI_PR_PIF8 EXTI_PR_PR8 #define EXTI_PR_PIF9 EXTI_PR_PR9 #define EXTI_PR_PIF10 EXTI_PR_PR10 #define EXTI_PR_PIF11 EXTI_PR_PR11 #define EXTI_PR_PIF12 EXTI_PR_PR12 #define EXTI_PR_PIF13 EXTI_PR_PR13 #define EXTI_PR_PIF14 EXTI_PR_PR14 #define EXTI_PR_PIF15 EXTI_PR_PR15 #define EXTI_PR_PIF16 EXTI_PR_PR16 #define EXTI_PR_PIF17 EXTI_PR_PR17 #define EXTI_PR_PIF18 EXTI_PR_PR18 /******************************************************************************/ /* */ /* DMA Controller */ /* */ /******************************************************************************/ /******************* Bit definition for DMA_ISR register ********************/ #define DMA_ISR_GIF1_Pos (0U) #define DMA_ISR_GIF1_Msk (0x1UL << DMA_ISR_GIF1_Pos) /*!< 0x00000001 */ #define DMA_ISR_GIF1 DMA_ISR_GIF1_Msk /*!< Channel 1 Global interrupt flag */ #define DMA_ISR_TCIF1_Pos (1U) #define DMA_ISR_TCIF1_Msk (0x1UL << DMA_ISR_TCIF1_Pos) /*!< 0x00000002 */ #define DMA_ISR_TCIF1 DMA_ISR_TCIF1_Msk /*!< Channel 1 Transfer Complete flag */ #define DMA_ISR_HTIF1_Pos (2U) #define DMA_ISR_HTIF1_Msk (0x1UL << DMA_ISR_HTIF1_Pos) /*!< 0x00000004 */ #define DMA_ISR_HTIF1 DMA_ISR_HTIF1_Msk /*!< Channel 1 Half Transfer flag */ #define DMA_ISR_TEIF1_Pos (3U) #define DMA_ISR_TEIF1_Msk (0x1UL << DMA_ISR_TEIF1_Pos) /*!< 0x00000008 */ #define DMA_ISR_TEIF1 DMA_ISR_TEIF1_Msk /*!< Channel 1 Transfer Error flag */ #define DMA_ISR_GIF2_Pos (4U) #define DMA_ISR_GIF2_Msk (0x1UL << DMA_ISR_GIF2_Pos) /*!< 0x00000010 */ #define DMA_ISR_GIF2 DMA_ISR_GIF2_Msk /*!< Channel 2 Global interrupt flag */ #define DMA_ISR_TCIF2_Pos (5U) #define DMA_ISR_TCIF2_Msk (0x1UL << DMA_ISR_TCIF2_Pos) /*!< 0x00000020 */ #define DMA_ISR_TCIF2 DMA_ISR_TCIF2_Msk /*!< Channel 2 Transfer Complete flag */ #define DMA_ISR_HTIF2_Pos (6U) #define DMA_ISR_HTIF2_Msk (0x1UL << DMA_ISR_HTIF2_Pos) /*!< 0x00000040 */ #define DMA_ISR_HTIF2 DMA_ISR_HTIF2_Msk /*!< Channel 2 Half Transfer flag */ #define DMA_ISR_TEIF2_Pos (7U) #define DMA_ISR_TEIF2_Msk (0x1UL << DMA_ISR_TEIF2_Pos) /*!< 0x00000080 */ #define DMA_ISR_TEIF2 DMA_ISR_TEIF2_Msk /*!< Channel 2 Transfer Error flag */ #define DMA_ISR_GIF3_Pos (8U) #define DMA_ISR_GIF3_Msk (0x1UL << DMA_ISR_GIF3_Pos) /*!< 0x00000100 */ #define DMA_ISR_GIF3 DMA_ISR_GIF3_Msk /*!< Channel 3 Global interrupt flag */ #define DMA_ISR_TCIF3_Pos (9U) #define DMA_ISR_TCIF3_Msk (0x1UL << DMA_ISR_TCIF3_Pos) /*!< 0x00000200 */ #define DMA_ISR_TCIF3 DMA_ISR_TCIF3_Msk /*!< Channel 3 Transfer Complete flag */ #define DMA_ISR_HTIF3_Pos (10U) #define DMA_ISR_HTIF3_Msk (0x1UL << DMA_ISR_HTIF3_Pos) /*!< 0x00000400 */ #define DMA_ISR_HTIF3 DMA_ISR_HTIF3_Msk /*!< Channel 3 Half Transfer flag */ #define DMA_ISR_TEIF3_Pos (11U) #define DMA_ISR_TEIF3_Msk (0x1UL << DMA_ISR_TEIF3_Pos) /*!< 0x00000800 */ #define DMA_ISR_TEIF3 DMA_ISR_TEIF3_Msk /*!< Channel 3 Transfer Error flag */ #define DMA_ISR_GIF4_Pos (12U) #define DMA_ISR_GIF4_Msk (0x1UL << DMA_ISR_GIF4_Pos) /*!< 0x00001000 */ #define DMA_ISR_GIF4 DMA_ISR_GIF4_Msk /*!< Channel 4 Global interrupt flag */ #define DMA_ISR_TCIF4_Pos (13U) #define DMA_ISR_TCIF4_Msk (0x1UL << DMA_ISR_TCIF4_Pos) /*!< 0x00002000 */ #define DMA_ISR_TCIF4 DMA_ISR_TCIF4_Msk /*!< Channel 4 Transfer Complete flag */ #define DMA_ISR_HTIF4_Pos (14U) #define DMA_ISR_HTIF4_Msk (0x1UL << DMA_ISR_HTIF4_Pos) /*!< 0x00004000 */ #define DMA_ISR_HTIF4 DMA_ISR_HTIF4_Msk /*!< Channel 4 Half Transfer flag */ #define DMA_ISR_TEIF4_Pos (15U) #define DMA_ISR_TEIF4_Msk (0x1UL << DMA_ISR_TEIF4_Pos) /*!< 0x00008000 */ #define DMA_ISR_TEIF4 DMA_ISR_TEIF4_Msk /*!< Channel 4 Transfer Error flag */ #define DMA_ISR_GIF5_Pos (16U) #define DMA_ISR_GIF5_Msk (0x1UL << DMA_ISR_GIF5_Pos) /*!< 0x00010000 */ #define DMA_ISR_GIF5 DMA_ISR_GIF5_Msk /*!< Channel 5 Global interrupt flag */ #define DMA_ISR_TCIF5_Pos (17U) #define DMA_ISR_TCIF5_Msk (0x1UL << DMA_ISR_TCIF5_Pos) /*!< 0x00020000 */ #define DMA_ISR_TCIF5 DMA_ISR_TCIF5_Msk /*!< Channel 5 Transfer Complete flag */ #define DMA_ISR_HTIF5_Pos (18U) #define DMA_ISR_HTIF5_Msk (0x1UL << DMA_ISR_HTIF5_Pos) /*!< 0x00040000 */ #define DMA_ISR_HTIF5 DMA_ISR_HTIF5_Msk /*!< Channel 5 Half Transfer flag */ #define DMA_ISR_TEIF5_Pos (19U) #define DMA_ISR_TEIF5_Msk (0x1UL << DMA_ISR_TEIF5_Pos) /*!< 0x00080000 */ #define DMA_ISR_TEIF5 DMA_ISR_TEIF5_Msk /*!< Channel 5 Transfer Error flag */ #define DMA_ISR_GIF6_Pos (20U) #define DMA_ISR_GIF6_Msk (0x1UL << DMA_ISR_GIF6_Pos) /*!< 0x00100000 */ #define DMA_ISR_GIF6 DMA_ISR_GIF6_Msk /*!< Channel 6 Global interrupt flag */ #define DMA_ISR_TCIF6_Pos (21U) #define DMA_ISR_TCIF6_Msk (0x1UL << DMA_ISR_TCIF6_Pos) /*!< 0x00200000 */ #define DMA_ISR_TCIF6 DMA_ISR_TCIF6_Msk /*!< Channel 6 Transfer Complete flag */ #define DMA_ISR_HTIF6_Pos (22U) #define DMA_ISR_HTIF6_Msk (0x1UL << DMA_ISR_HTIF6_Pos) /*!< 0x00400000 */ #define DMA_ISR_HTIF6 DMA_ISR_HTIF6_Msk /*!< Channel 6 Half Transfer flag */ #define DMA_ISR_TEIF6_Pos (23U) #define DMA_ISR_TEIF6_Msk (0x1UL << DMA_ISR_TEIF6_Pos) /*!< 0x00800000 */ #define DMA_ISR_TEIF6 DMA_ISR_TEIF6_Msk /*!< Channel 6 Transfer Error flag */ #define DMA_ISR_GIF7_Pos (24U) #define DMA_ISR_GIF7_Msk (0x1UL << DMA_ISR_GIF7_Pos) /*!< 0x01000000 */ #define DMA_ISR_GIF7 DMA_ISR_GIF7_Msk /*!< Channel 7 Global interrupt flag */ #define DMA_ISR_TCIF7_Pos (25U) #define DMA_ISR_TCIF7_Msk (0x1UL << DMA_ISR_TCIF7_Pos) /*!< 0x02000000 */ #define DMA_ISR_TCIF7 DMA_ISR_TCIF7_Msk /*!< Channel 7 Transfer Complete flag */ #define DMA_ISR_HTIF7_Pos (26U) #define DMA_ISR_HTIF7_Msk (0x1UL << DMA_ISR_HTIF7_Pos) /*!< 0x04000000 */ #define DMA_ISR_HTIF7 DMA_ISR_HTIF7_Msk /*!< Channel 7 Half Transfer flag */ #define DMA_ISR_TEIF7_Pos (27U) #define DMA_ISR_TEIF7_Msk (0x1UL << DMA_ISR_TEIF7_Pos) /*!< 0x08000000 */ #define DMA_ISR_TEIF7 DMA_ISR_TEIF7_Msk /*!< Channel 7 Transfer Error flag */ /******************* Bit definition for DMA_IFCR register *******************/ #define DMA_IFCR_CGIF1_Pos (0U) #define DMA_IFCR_CGIF1_Msk (0x1UL << DMA_IFCR_CGIF1_Pos) /*!< 0x00000001 */ #define DMA_IFCR_CGIF1 DMA_IFCR_CGIF1_Msk /*!< Channel 1 Global interrupt clear */ #define DMA_IFCR_CTCIF1_Pos (1U) #define DMA_IFCR_CTCIF1_Msk (0x1UL << DMA_IFCR_CTCIF1_Pos) /*!< 0x00000002 */ #define DMA_IFCR_CTCIF1 DMA_IFCR_CTCIF1_Msk /*!< Channel 1 Transfer Complete clear */ #define DMA_IFCR_CHTIF1_Pos (2U) #define DMA_IFCR_CHTIF1_Msk (0x1UL << DMA_IFCR_CHTIF1_Pos) /*!< 0x00000004 */ #define DMA_IFCR_CHTIF1 DMA_IFCR_CHTIF1_Msk /*!< Channel 1 Half Transfer clear */ #define DMA_IFCR_CTEIF1_Pos (3U) #define DMA_IFCR_CTEIF1_Msk (0x1UL << DMA_IFCR_CTEIF1_Pos) /*!< 0x00000008 */ #define DMA_IFCR_CTEIF1 DMA_IFCR_CTEIF1_Msk /*!< Channel 1 Transfer Error clear */ #define DMA_IFCR_CGIF2_Pos (4U) #define DMA_IFCR_CGIF2_Msk (0x1UL << DMA_IFCR_CGIF2_Pos) /*!< 0x00000010 */ #define DMA_IFCR_CGIF2 DMA_IFCR_CGIF2_Msk /*!< Channel 2 Global interrupt clear */ #define DMA_IFCR_CTCIF2_Pos (5U) #define DMA_IFCR_CTCIF2_Msk (0x1UL << DMA_IFCR_CTCIF2_Pos) /*!< 0x00000020 */ #define DMA_IFCR_CTCIF2 DMA_IFCR_CTCIF2_Msk /*!< Channel 2 Transfer Complete clear */ #define DMA_IFCR_CHTIF2_Pos (6U) #define DMA_IFCR_CHTIF2_Msk (0x1UL << DMA_IFCR_CHTIF2_Pos) /*!< 0x00000040 */ #define DMA_IFCR_CHTIF2 DMA_IFCR_CHTIF2_Msk /*!< Channel 2 Half Transfer clear */ #define DMA_IFCR_CTEIF2_Pos (7U) #define DMA_IFCR_CTEIF2_Msk (0x1UL << DMA_IFCR_CTEIF2_Pos) /*!< 0x00000080 */ #define DMA_IFCR_CTEIF2 DMA_IFCR_CTEIF2_Msk /*!< Channel 2 Transfer Error clear */ #define DMA_IFCR_CGIF3_Pos (8U) #define DMA_IFCR_CGIF3_Msk (0x1UL << DMA_IFCR_CGIF3_Pos) /*!< 0x00000100 */ #define DMA_IFCR_CGIF3 DMA_IFCR_CGIF3_Msk /*!< Channel 3 Global interrupt clear */ #define DMA_IFCR_CTCIF3_Pos (9U) #define DMA_IFCR_CTCIF3_Msk (0x1UL << DMA_IFCR_CTCIF3_Pos) /*!< 0x00000200 */ #define DMA_IFCR_CTCIF3 DMA_IFCR_CTCIF3_Msk /*!< Channel 3 Transfer Complete clear */ #define DMA_IFCR_CHTIF3_Pos (10U) #define DMA_IFCR_CHTIF3_Msk (0x1UL << DMA_IFCR_CHTIF3_Pos) /*!< 0x00000400 */ #define DMA_IFCR_CHTIF3 DMA_IFCR_CHTIF3_Msk /*!< Channel 3 Half Transfer clear */ #define DMA_IFCR_CTEIF3_Pos (11U) #define DMA_IFCR_CTEIF3_Msk (0x1UL << DMA_IFCR_CTEIF3_Pos) /*!< 0x00000800 */ #define DMA_IFCR_CTEIF3 DMA_IFCR_CTEIF3_Msk /*!< Channel 3 Transfer Error clear */ #define DMA_IFCR_CGIF4_Pos (12U) #define DMA_IFCR_CGIF4_Msk (0x1UL << DMA_IFCR_CGIF4_Pos) /*!< 0x00001000 */ #define DMA_IFCR_CGIF4 DMA_IFCR_CGIF4_Msk /*!< Channel 4 Global interrupt clear */ #define DMA_IFCR_CTCIF4_Pos (13U) #define DMA_IFCR_CTCIF4_Msk (0x1UL << DMA_IFCR_CTCIF4_Pos) /*!< 0x00002000 */ #define DMA_IFCR_CTCIF4 DMA_IFCR_CTCIF4_Msk /*!< Channel 4 Transfer Complete clear */ #define DMA_IFCR_CHTIF4_Pos (14U) #define DMA_IFCR_CHTIF4_Msk (0x1UL << DMA_IFCR_CHTIF4_Pos) /*!< 0x00004000 */ #define DMA_IFCR_CHTIF4 DMA_IFCR_CHTIF4_Msk /*!< Channel 4 Half Transfer clear */ #define DMA_IFCR_CTEIF4_Pos (15U) #define DMA_IFCR_CTEIF4_Msk (0x1UL << DMA_IFCR_CTEIF4_Pos) /*!< 0x00008000 */ #define DMA_IFCR_CTEIF4 DMA_IFCR_CTEIF4_Msk /*!< Channel 4 Transfer Error clear */ #define DMA_IFCR_CGIF5_Pos (16U) #define DMA_IFCR_CGIF5_Msk (0x1UL << DMA_IFCR_CGIF5_Pos) /*!< 0x00010000 */ #define DMA_IFCR_CGIF5 DMA_IFCR_CGIF5_Msk /*!< Channel 5 Global interrupt clear */ #define DMA_IFCR_CTCIF5_Pos (17U) #define DMA_IFCR_CTCIF5_Msk (0x1UL << DMA_IFCR_CTCIF5_Pos) /*!< 0x00020000 */ #define DMA_IFCR_CTCIF5 DMA_IFCR_CTCIF5_Msk /*!< Channel 5 Transfer Complete clear */ #define DMA_IFCR_CHTIF5_Pos (18U) #define DMA_IFCR_CHTIF5_Msk (0x1UL << DMA_IFCR_CHTIF5_Pos) /*!< 0x00040000 */ #define DMA_IFCR_CHTIF5 DMA_IFCR_CHTIF5_Msk /*!< Channel 5 Half Transfer clear */ #define DMA_IFCR_CTEIF5_Pos (19U) #define DMA_IFCR_CTEIF5_Msk (0x1UL << DMA_IFCR_CTEIF5_Pos) /*!< 0x00080000 */ #define DMA_IFCR_CTEIF5 DMA_IFCR_CTEIF5_Msk /*!< Channel 5 Transfer Error clear */ #define DMA_IFCR_CGIF6_Pos (20U) #define DMA_IFCR_CGIF6_Msk (0x1UL << DMA_IFCR_CGIF6_Pos) /*!< 0x00100000 */ #define DMA_IFCR_CGIF6 DMA_IFCR_CGIF6_Msk /*!< Channel 6 Global interrupt clear */ #define DMA_IFCR_CTCIF6_Pos (21U) #define DMA_IFCR_CTCIF6_Msk (0x1UL << DMA_IFCR_CTCIF6_Pos) /*!< 0x00200000 */ #define DMA_IFCR_CTCIF6 DMA_IFCR_CTCIF6_Msk /*!< Channel 6 Transfer Complete clear */ #define DMA_IFCR_CHTIF6_Pos (22U) #define DMA_IFCR_CHTIF6_Msk (0x1UL << DMA_IFCR_CHTIF6_Pos) /*!< 0x00400000 */ #define DMA_IFCR_CHTIF6 DMA_IFCR_CHTIF6_Msk /*!< Channel 6 Half Transfer clear */ #define DMA_IFCR_CTEIF6_Pos (23U) #define DMA_IFCR_CTEIF6_Msk (0x1UL << DMA_IFCR_CTEIF6_Pos) /*!< 0x00800000 */ #define DMA_IFCR_CTEIF6 DMA_IFCR_CTEIF6_Msk /*!< Channel 6 Transfer Error clear */ #define DMA_IFCR_CGIF7_Pos (24U) #define DMA_IFCR_CGIF7_Msk (0x1UL << DMA_IFCR_CGIF7_Pos) /*!< 0x01000000 */ #define DMA_IFCR_CGIF7 DMA_IFCR_CGIF7_Msk /*!< Channel 7 Global interrupt clear */ #define DMA_IFCR_CTCIF7_Pos (25U) #define DMA_IFCR_CTCIF7_Msk (0x1UL << DMA_IFCR_CTCIF7_Pos) /*!< 0x02000000 */ #define DMA_IFCR_CTCIF7 DMA_IFCR_CTCIF7_Msk /*!< Channel 7 Transfer Complete clear */ #define DMA_IFCR_CHTIF7_Pos (26U) #define DMA_IFCR_CHTIF7_Msk (0x1UL << DMA_IFCR_CHTIF7_Pos) /*!< 0x04000000 */ #define DMA_IFCR_CHTIF7 DMA_IFCR_CHTIF7_Msk /*!< Channel 7 Half Transfer clear */ #define DMA_IFCR_CTEIF7_Pos (27U) #define DMA_IFCR_CTEIF7_Msk (0x1UL << DMA_IFCR_CTEIF7_Pos) /*!< 0x08000000 */ #define DMA_IFCR_CTEIF7 DMA_IFCR_CTEIF7_Msk /*!< Channel 7 Transfer Error clear */ /******************* Bit definition for DMA_CCR register *******************/ #define DMA_CCR_EN_Pos (0U) #define DMA_CCR_EN_Msk (0x1UL << DMA_CCR_EN_Pos) /*!< 0x00000001 */ #define DMA_CCR_EN DMA_CCR_EN_Msk /*!< Channel enable */ #define DMA_CCR_TCIE_Pos (1U) #define DMA_CCR_TCIE_Msk (0x1UL << DMA_CCR_TCIE_Pos) /*!< 0x00000002 */ #define DMA_CCR_TCIE DMA_CCR_TCIE_Msk /*!< Transfer complete interrupt enable */ #define DMA_CCR_HTIE_Pos (2U) #define DMA_CCR_HTIE_Msk (0x1UL << DMA_CCR_HTIE_Pos) /*!< 0x00000004 */ #define DMA_CCR_HTIE DMA_CCR_HTIE_Msk /*!< Half Transfer interrupt enable */ #define DMA_CCR_TEIE_Pos (3U) #define DMA_CCR_TEIE_Msk (0x1UL << DMA_CCR_TEIE_Pos) /*!< 0x00000008 */ #define DMA_CCR_TEIE DMA_CCR_TEIE_Msk /*!< Transfer error interrupt enable */ #define DMA_CCR_DIR_Pos (4U) #define DMA_CCR_DIR_Msk (0x1UL << DMA_CCR_DIR_Pos) /*!< 0x00000010 */ #define DMA_CCR_DIR DMA_CCR_DIR_Msk /*!< Data transfer direction */ #define DMA_CCR_CIRC_Pos (5U) #define DMA_CCR_CIRC_Msk (0x1UL << DMA_CCR_CIRC_Pos) /*!< 0x00000020 */ #define DMA_CCR_CIRC DMA_CCR_CIRC_Msk /*!< Circular mode */ #define DMA_CCR_PINC_Pos (6U) #define DMA_CCR_PINC_Msk (0x1UL << DMA_CCR_PINC_Pos) /*!< 0x00000040 */ #define DMA_CCR_PINC DMA_CCR_PINC_Msk /*!< Peripheral increment mode */ #define DMA_CCR_MINC_Pos (7U) #define DMA_CCR_MINC_Msk (0x1UL << DMA_CCR_MINC_Pos) /*!< 0x00000080 */ #define DMA_CCR_MINC DMA_CCR_MINC_Msk /*!< Memory increment mode */ #define DMA_CCR_PSIZE_Pos (8U) #define DMA_CCR_PSIZE_Msk (0x3UL << DMA_CCR_PSIZE_Pos) /*!< 0x00000300 */ #define DMA_CCR_PSIZE DMA_CCR_PSIZE_Msk /*!< PSIZE[1:0] bits (Peripheral size) */ #define DMA_CCR_PSIZE_0 (0x1UL << DMA_CCR_PSIZE_Pos) /*!< 0x00000100 */ #define DMA_CCR_PSIZE_1 (0x2UL << DMA_CCR_PSIZE_Pos) /*!< 0x00000200 */ #define DMA_CCR_MSIZE_Pos (10U) #define DMA_CCR_MSIZE_Msk (0x3UL << DMA_CCR_MSIZE_Pos) /*!< 0x00000C00 */ #define DMA_CCR_MSIZE DMA_CCR_MSIZE_Msk /*!< MSIZE[1:0] bits (Memory size) */ #define DMA_CCR_MSIZE_0 (0x1UL << DMA_CCR_MSIZE_Pos) /*!< 0x00000400 */ #define DMA_CCR_MSIZE_1 (0x2UL << DMA_CCR_MSIZE_Pos) /*!< 0x00000800 */ #define DMA_CCR_PL_Pos (12U) #define DMA_CCR_PL_Msk (0x3UL << DMA_CCR_PL_Pos) /*!< 0x00003000 */ #define DMA_CCR_PL DMA_CCR_PL_Msk /*!< PL[1:0] bits(Channel Priority level) */ #define DMA_CCR_PL_0 (0x1UL << DMA_CCR_PL_Pos) /*!< 0x00001000 */ #define DMA_CCR_PL_1 (0x2UL << DMA_CCR_PL_Pos) /*!< 0x00002000 */ #define DMA_CCR_MEM2MEM_Pos (14U) #define DMA_CCR_MEM2MEM_Msk (0x1UL << DMA_CCR_MEM2MEM_Pos) /*!< 0x00004000 */ #define DMA_CCR_MEM2MEM DMA_CCR_MEM2MEM_Msk /*!< Memory to memory mode */ /****************** Bit definition for DMA_CNDTR register ******************/ #define DMA_CNDTR_NDT_Pos (0U) #define DMA_CNDTR_NDT_Msk (0xFFFFUL << DMA_CNDTR_NDT_Pos) /*!< 0x0000FFFF */ #define DMA_CNDTR_NDT DMA_CNDTR_NDT_Msk /*!< Number of data to Transfer */ /****************** Bit definition for DMA_CPAR register *******************/ #define DMA_CPAR_PA_Pos (0U) #define DMA_CPAR_PA_Msk (0xFFFFFFFFUL << DMA_CPAR_PA_Pos) /*!< 0xFFFFFFFF */ #define DMA_CPAR_PA DMA_CPAR_PA_Msk /*!< Peripheral Address */ /****************** Bit definition for DMA_CMAR register *******************/ #define DMA_CMAR_MA_Pos (0U) #define DMA_CMAR_MA_Msk (0xFFFFFFFFUL << DMA_CMAR_MA_Pos) /*!< 0xFFFFFFFF */ #define DMA_CMAR_MA DMA_CMAR_MA_Msk /*!< Memory Address */ /******************************************************************************/ /* */ /* Analog to Digital Converter (ADC) */ /* */ /******************************************************************************/ /* * @brief Specific device feature definitions (not present on all devices in the STM32F1 family) */ #define ADC_MULTIMODE_SUPPORT /*!< ADC feature available only on specific devices: multimode available on devices with several ADC instances */ /******************** Bit definition for ADC_SR register ********************/ #define ADC_SR_AWD_Pos (0U) #define ADC_SR_AWD_Msk (0x1UL << ADC_SR_AWD_Pos) /*!< 0x00000001 */ #define ADC_SR_AWD ADC_SR_AWD_Msk /*!< ADC analog watchdog 1 flag */ #define ADC_SR_EOS_Pos (1U) #define ADC_SR_EOS_Msk (0x1UL << ADC_SR_EOS_Pos) /*!< 0x00000002 */ #define ADC_SR_EOS ADC_SR_EOS_Msk /*!< ADC group regular end of sequence conversions flag */ #define ADC_SR_JEOS_Pos (2U) #define ADC_SR_JEOS_Msk (0x1UL << ADC_SR_JEOS_Pos) /*!< 0x00000004 */ #define ADC_SR_JEOS ADC_SR_JEOS_Msk /*!< ADC group injected end of sequence conversions flag */ #define ADC_SR_JSTRT_Pos (3U) #define ADC_SR_JSTRT_Msk (0x1UL << ADC_SR_JSTRT_Pos) /*!< 0x00000008 */ #define ADC_SR_JSTRT ADC_SR_JSTRT_Msk /*!< ADC group injected conversion start flag */ #define ADC_SR_STRT_Pos (4U) #define ADC_SR_STRT_Msk (0x1UL << ADC_SR_STRT_Pos) /*!< 0x00000010 */ #define ADC_SR_STRT ADC_SR_STRT_Msk /*!< ADC group regular conversion start flag */ /* Legacy defines */ #define ADC_SR_EOC (ADC_SR_EOS) #define ADC_SR_JEOC (ADC_SR_JEOS) /******************* Bit definition for ADC_CR1 register ********************/ #define ADC_CR1_AWDCH_Pos (0U) #define ADC_CR1_AWDCH_Msk (0x1FUL << ADC_CR1_AWDCH_Pos) /*!< 0x0000001F */ #define ADC_CR1_AWDCH ADC_CR1_AWDCH_Msk /*!< ADC analog watchdog 1 monitored channel selection */ #define ADC_CR1_AWDCH_0 (0x01UL << ADC_CR1_AWDCH_Pos) /*!< 0x00000001 */ #define ADC_CR1_AWDCH_1 (0x02UL << ADC_CR1_AWDCH_Pos) /*!< 0x00000002 */ #define ADC_CR1_AWDCH_2 (0x04UL << ADC_CR1_AWDCH_Pos) /*!< 0x00000004 */ #define ADC_CR1_AWDCH_3 (0x08UL << ADC_CR1_AWDCH_Pos) /*!< 0x00000008 */ #define ADC_CR1_AWDCH_4 (0x10UL << ADC_CR1_AWDCH_Pos) /*!< 0x00000010 */ #define ADC_CR1_EOSIE_Pos (5U) #define ADC_CR1_EOSIE_Msk (0x1UL << ADC_CR1_EOSIE_Pos) /*!< 0x00000020 */ #define ADC_CR1_EOSIE ADC_CR1_EOSIE_Msk /*!< ADC group regular end of sequence conversions interrupt */ #define ADC_CR1_AWDIE_Pos (6U) #define ADC_CR1_AWDIE_Msk (0x1UL << ADC_CR1_AWDIE_Pos) /*!< 0x00000040 */ #define ADC_CR1_AWDIE ADC_CR1_AWDIE_Msk /*!< ADC analog watchdog 1 interrupt */ #define ADC_CR1_JEOSIE_Pos (7U) #define ADC_CR1_JEOSIE_Msk (0x1UL << ADC_CR1_JEOSIE_Pos) /*!< 0x00000080 */ #define ADC_CR1_JEOSIE ADC_CR1_JEOSIE_Msk /*!< ADC group injected end of sequence conversions interrupt */ #define ADC_CR1_SCAN_Pos (8U) #define ADC_CR1_SCAN_Msk (0x1UL << ADC_CR1_SCAN_Pos) /*!< 0x00000100 */ #define ADC_CR1_SCAN ADC_CR1_SCAN_Msk /*!< ADC scan mode */ #define ADC_CR1_AWDSGL_Pos (9U) #define ADC_CR1_AWDSGL_Msk (0x1UL << ADC_CR1_AWDSGL_Pos) /*!< 0x00000200 */ #define ADC_CR1_AWDSGL ADC_CR1_AWDSGL_Msk /*!< ADC analog watchdog 1 monitoring a single channel or all channels */ #define ADC_CR1_JAUTO_Pos (10U) #define ADC_CR1_JAUTO_Msk (0x1UL << ADC_CR1_JAUTO_Pos) /*!< 0x00000400 */ #define ADC_CR1_JAUTO ADC_CR1_JAUTO_Msk /*!< ADC group injected automatic trigger mode */ #define ADC_CR1_DISCEN_Pos (11U) #define ADC_CR1_DISCEN_Msk (0x1UL << ADC_CR1_DISCEN_Pos) /*!< 0x00000800 */ #define ADC_CR1_DISCEN ADC_CR1_DISCEN_Msk /*!< ADC group regular sequencer discontinuous mode */ #define ADC_CR1_JDISCEN_Pos (12U) #define ADC_CR1_JDISCEN_Msk (0x1UL << ADC_CR1_JDISCEN_Pos) /*!< 0x00001000 */ #define ADC_CR1_JDISCEN ADC_CR1_JDISCEN_Msk /*!< ADC group injected sequencer discontinuous mode */ #define ADC_CR1_DISCNUM_Pos (13U) #define ADC_CR1_DISCNUM_Msk (0x7UL << ADC_CR1_DISCNUM_Pos) /*!< 0x0000E000 */ #define ADC_CR1_DISCNUM ADC_CR1_DISCNUM_Msk /*!< ADC group regular sequencer discontinuous number of ranks */ #define ADC_CR1_DISCNUM_0 (0x1UL << ADC_CR1_DISCNUM_Pos) /*!< 0x00002000 */ #define ADC_CR1_DISCNUM_1 (0x2UL << ADC_CR1_DISCNUM_Pos) /*!< 0x00004000 */ #define ADC_CR1_DISCNUM_2 (0x4UL << ADC_CR1_DISCNUM_Pos) /*!< 0x00008000 */ #define ADC_CR1_DUALMOD_Pos (16U) #define ADC_CR1_DUALMOD_Msk (0xFUL << ADC_CR1_DUALMOD_Pos) /*!< 0x000F0000 */ #define ADC_CR1_DUALMOD ADC_CR1_DUALMOD_Msk /*!< ADC multimode mode selection */ #define ADC_CR1_DUALMOD_0 (0x1UL << ADC_CR1_DUALMOD_Pos) /*!< 0x00010000 */ #define ADC_CR1_DUALMOD_1 (0x2UL << ADC_CR1_DUALMOD_Pos) /*!< 0x00020000 */ #define ADC_CR1_DUALMOD_2 (0x4UL << ADC_CR1_DUALMOD_Pos) /*!< 0x00040000 */ #define ADC_CR1_DUALMOD_3 (0x8UL << ADC_CR1_DUALMOD_Pos) /*!< 0x00080000 */ #define ADC_CR1_JAWDEN_Pos (22U) #define ADC_CR1_JAWDEN_Msk (0x1UL << ADC_CR1_JAWDEN_Pos) /*!< 0x00400000 */ #define ADC_CR1_JAWDEN ADC_CR1_JAWDEN_Msk /*!< ADC analog watchdog 1 enable on scope ADC group injected */ #define ADC_CR1_AWDEN_Pos (23U) #define ADC_CR1_AWDEN_Msk (0x1UL << ADC_CR1_AWDEN_Pos) /*!< 0x00800000 */ #define ADC_CR1_AWDEN ADC_CR1_AWDEN_Msk /*!< ADC analog watchdog 1 enable on scope ADC group regular */ /* Legacy defines */ #define ADC_CR1_EOCIE (ADC_CR1_EOSIE) #define ADC_CR1_JEOCIE (ADC_CR1_JEOSIE) /******************* Bit definition for ADC_CR2 register ********************/ #define ADC_CR2_ADON_Pos (0U) #define ADC_CR2_ADON_Msk (0x1UL << ADC_CR2_ADON_Pos) /*!< 0x00000001 */ #define ADC_CR2_ADON ADC_CR2_ADON_Msk /*!< ADC enable */ #define ADC_CR2_CONT_Pos (1U) #define ADC_CR2_CONT_Msk (0x1UL << ADC_CR2_CONT_Pos) /*!< 0x00000002 */ #define ADC_CR2_CONT ADC_CR2_CONT_Msk /*!< ADC group regular continuous conversion mode */ #define ADC_CR2_CAL_Pos (2U) #define ADC_CR2_CAL_Msk (0x1UL << ADC_CR2_CAL_Pos) /*!< 0x00000004 */ #define ADC_CR2_CAL ADC_CR2_CAL_Msk /*!< ADC calibration start */ #define ADC_CR2_RSTCAL_Pos (3U) #define ADC_CR2_RSTCAL_Msk (0x1UL << ADC_CR2_RSTCAL_Pos) /*!< 0x00000008 */ #define ADC_CR2_RSTCAL ADC_CR2_RSTCAL_Msk /*!< ADC calibration reset */ #define ADC_CR2_DMA_Pos (8U) #define ADC_CR2_DMA_Msk (0x1UL << ADC_CR2_DMA_Pos) /*!< 0x00000100 */ #define ADC_CR2_DMA ADC_CR2_DMA_Msk /*!< ADC DMA transfer enable */ #define ADC_CR2_ALIGN_Pos (11U) #define ADC_CR2_ALIGN_Msk (0x1UL << ADC_CR2_ALIGN_Pos) /*!< 0x00000800 */ #define ADC_CR2_ALIGN ADC_CR2_ALIGN_Msk /*!< ADC data alignement */ #define ADC_CR2_JEXTSEL_Pos (12U) #define ADC_CR2_JEXTSEL_Msk (0x7UL << ADC_CR2_JEXTSEL_Pos) /*!< 0x00007000 */ #define ADC_CR2_JEXTSEL ADC_CR2_JEXTSEL_Msk /*!< ADC group injected external trigger source */ #define ADC_CR2_JEXTSEL_0 (0x1UL << ADC_CR2_JEXTSEL_Pos) /*!< 0x00001000 */ #define ADC_CR2_JEXTSEL_1 (0x2UL << ADC_CR2_JEXTSEL_Pos) /*!< 0x00002000 */ #define ADC_CR2_JEXTSEL_2 (0x4UL << ADC_CR2_JEXTSEL_Pos) /*!< 0x00004000 */ #define ADC_CR2_JEXTTRIG_Pos (15U) #define ADC_CR2_JEXTTRIG_Msk (0x1UL << ADC_CR2_JEXTTRIG_Pos) /*!< 0x00008000 */ #define ADC_CR2_JEXTTRIG ADC_CR2_JEXTTRIG_Msk /*!< ADC group injected external trigger enable */ #define ADC_CR2_EXTSEL_Pos (17U) #define ADC_CR2_EXTSEL_Msk (0x7UL << ADC_CR2_EXTSEL_Pos) /*!< 0x000E0000 */ #define ADC_CR2_EXTSEL ADC_CR2_EXTSEL_Msk /*!< ADC group regular external trigger source */ #define ADC_CR2_EXTSEL_0 (0x1UL << ADC_CR2_EXTSEL_Pos) /*!< 0x00020000 */ #define ADC_CR2_EXTSEL_1 (0x2UL << ADC_CR2_EXTSEL_Pos) /*!< 0x00040000 */ #define ADC_CR2_EXTSEL_2 (0x4UL << ADC_CR2_EXTSEL_Pos) /*!< 0x00080000 */ #define ADC_CR2_EXTTRIG_Pos (20U) #define ADC_CR2_EXTTRIG_Msk (0x1UL << ADC_CR2_EXTTRIG_Pos) /*!< 0x00100000 */ #define ADC_CR2_EXTTRIG ADC_CR2_EXTTRIG_Msk /*!< ADC group regular external trigger enable */ #define ADC_CR2_JSWSTART_Pos (21U) #define ADC_CR2_JSWSTART_Msk (0x1UL << ADC_CR2_JSWSTART_Pos) /*!< 0x00200000 */ #define ADC_CR2_JSWSTART ADC_CR2_JSWSTART_Msk /*!< ADC group injected conversion start */ #define ADC_CR2_SWSTART_Pos (22U) #define ADC_CR2_SWSTART_Msk (0x1UL << ADC_CR2_SWSTART_Pos) /*!< 0x00400000 */ #define ADC_CR2_SWSTART ADC_CR2_SWSTART_Msk /*!< ADC group regular conversion start */ #define ADC_CR2_TSVREFE_Pos (23U) #define ADC_CR2_TSVREFE_Msk (0x1UL << ADC_CR2_TSVREFE_Pos) /*!< 0x00800000 */ #define ADC_CR2_TSVREFE ADC_CR2_TSVREFE_Msk /*!< ADC internal path to VrefInt and temperature sensor enable */ /****************** Bit definition for ADC_SMPR1 register *******************/ #define ADC_SMPR1_SMP10_Pos (0U) #define ADC_SMPR1_SMP10_Msk (0x7UL << ADC_SMPR1_SMP10_Pos) /*!< 0x00000007 */ #define ADC_SMPR1_SMP10 ADC_SMPR1_SMP10_Msk /*!< ADC channel 10 sampling time selection */ #define ADC_SMPR1_SMP10_0 (0x1UL << ADC_SMPR1_SMP10_Pos) /*!< 0x00000001 */ #define ADC_SMPR1_SMP10_1 (0x2UL << ADC_SMPR1_SMP10_Pos) /*!< 0x00000002 */ #define ADC_SMPR1_SMP10_2 (0x4UL << ADC_SMPR1_SMP10_Pos) /*!< 0x00000004 */ #define ADC_SMPR1_SMP11_Pos (3U) #define ADC_SMPR1_SMP11_Msk (0x7UL << ADC_SMPR1_SMP11_Pos) /*!< 0x00000038 */ #define ADC_SMPR1_SMP11 ADC_SMPR1_SMP11_Msk /*!< ADC channel 11 sampling time selection */ #define ADC_SMPR1_SMP11_0 (0x1UL << ADC_SMPR1_SMP11_Pos) /*!< 0x00000008 */ #define ADC_SMPR1_SMP11_1 (0x2UL << ADC_SMPR1_SMP11_Pos) /*!< 0x00000010 */ #define ADC_SMPR1_SMP11_2 (0x4UL << ADC_SMPR1_SMP11_Pos) /*!< 0x00000020 */ #define ADC_SMPR1_SMP12_Pos (6U) #define ADC_SMPR1_SMP12_Msk (0x7UL << ADC_SMPR1_SMP12_Pos) /*!< 0x000001C0 */ #define ADC_SMPR1_SMP12 ADC_SMPR1_SMP12_Msk /*!< ADC channel 12 sampling time selection */ #define ADC_SMPR1_SMP12_0 (0x1UL << ADC_SMPR1_SMP12_Pos) /*!< 0x00000040 */ #define ADC_SMPR1_SMP12_1 (0x2UL << ADC_SMPR1_SMP12_Pos) /*!< 0x00000080 */ #define ADC_SMPR1_SMP12_2 (0x4UL << ADC_SMPR1_SMP12_Pos) /*!< 0x00000100 */ #define ADC_SMPR1_SMP13_Pos (9U) #define ADC_SMPR1_SMP13_Msk (0x7UL << ADC_SMPR1_SMP13_Pos) /*!< 0x00000E00 */ #define ADC_SMPR1_SMP13 ADC_SMPR1_SMP13_Msk /*!< ADC channel 13 sampling time selection */ #define ADC_SMPR1_SMP13_0 (0x1UL << ADC_SMPR1_SMP13_Pos) /*!< 0x00000200 */ #define ADC_SMPR1_SMP13_1 (0x2UL << ADC_SMPR1_SMP13_Pos) /*!< 0x00000400 */ #define ADC_SMPR1_SMP13_2 (0x4UL << ADC_SMPR1_SMP13_Pos) /*!< 0x00000800 */ #define ADC_SMPR1_SMP14_Pos (12U) #define ADC_SMPR1_SMP14_Msk (0x7UL << ADC_SMPR1_SMP14_Pos) /*!< 0x00007000 */ #define ADC_SMPR1_SMP14 ADC_SMPR1_SMP14_Msk /*!< ADC channel 14 sampling time selection */ #define ADC_SMPR1_SMP14_0 (0x1UL << ADC_SMPR1_SMP14_Pos) /*!< 0x00001000 */ #define ADC_SMPR1_SMP14_1 (0x2UL << ADC_SMPR1_SMP14_Pos) /*!< 0x00002000 */ #define ADC_SMPR1_SMP14_2 (0x4UL << ADC_SMPR1_SMP14_Pos) /*!< 0x00004000 */ #define ADC_SMPR1_SMP15_Pos (15U) #define ADC_SMPR1_SMP15_Msk (0x7UL << ADC_SMPR1_SMP15_Pos) /*!< 0x00038000 */ #define ADC_SMPR1_SMP15 ADC_SMPR1_SMP15_Msk /*!< ADC channel 15 sampling time selection */ #define ADC_SMPR1_SMP15_0 (0x1UL << ADC_SMPR1_SMP15_Pos) /*!< 0x00008000 */ #define ADC_SMPR1_SMP15_1 (0x2UL << ADC_SMPR1_SMP15_Pos) /*!< 0x00010000 */ #define ADC_SMPR1_SMP15_2 (0x4UL << ADC_SMPR1_SMP15_Pos) /*!< 0x00020000 */ #define ADC_SMPR1_SMP16_Pos (18U) #define ADC_SMPR1_SMP16_Msk (0x7UL << ADC_SMPR1_SMP16_Pos) /*!< 0x001C0000 */ #define ADC_SMPR1_SMP16 ADC_SMPR1_SMP16_Msk /*!< ADC channel 16 sampling time selection */ #define ADC_SMPR1_SMP16_0 (0x1UL << ADC_SMPR1_SMP16_Pos) /*!< 0x00040000 */ #define ADC_SMPR1_SMP16_1 (0x2UL << ADC_SMPR1_SMP16_Pos) /*!< 0x00080000 */ #define ADC_SMPR1_SMP16_2 (0x4UL << ADC_SMPR1_SMP16_Pos) /*!< 0x00100000 */ #define ADC_SMPR1_SMP17_Pos (21U) #define ADC_SMPR1_SMP17_Msk (0x7UL << ADC_SMPR1_SMP17_Pos) /*!< 0x00E00000 */ #define ADC_SMPR1_SMP17 ADC_SMPR1_SMP17_Msk /*!< ADC channel 17 sampling time selection */ #define ADC_SMPR1_SMP17_0 (0x1UL << ADC_SMPR1_SMP17_Pos) /*!< 0x00200000 */ #define ADC_SMPR1_SMP17_1 (0x2UL << ADC_SMPR1_SMP17_Pos) /*!< 0x00400000 */ #define ADC_SMPR1_SMP17_2 (0x4UL << ADC_SMPR1_SMP17_Pos) /*!< 0x00800000 */ /****************** Bit definition for ADC_SMPR2 register *******************/ #define ADC_SMPR2_SMP0_Pos (0U) #define ADC_SMPR2_SMP0_Msk (0x7UL << ADC_SMPR2_SMP0_Pos) /*!< 0x00000007 */ #define ADC_SMPR2_SMP0 ADC_SMPR2_SMP0_Msk /*!< ADC channel 0 sampling time selection */ #define ADC_SMPR2_SMP0_0 (0x1UL << ADC_SMPR2_SMP0_Pos) /*!< 0x00000001 */ #define ADC_SMPR2_SMP0_1 (0x2UL << ADC_SMPR2_SMP0_Pos) /*!< 0x00000002 */ #define ADC_SMPR2_SMP0_2 (0x4UL << ADC_SMPR2_SMP0_Pos) /*!< 0x00000004 */ #define ADC_SMPR2_SMP1_Pos (3U) #define ADC_SMPR2_SMP1_Msk (0x7UL << ADC_SMPR2_SMP1_Pos) /*!< 0x00000038 */ #define ADC_SMPR2_SMP1 ADC_SMPR2_SMP1_Msk /*!< ADC channel 1 sampling time selection */ #define ADC_SMPR2_SMP1_0 (0x1UL << ADC_SMPR2_SMP1_Pos) /*!< 0x00000008 */ #define ADC_SMPR2_SMP1_1 (0x2UL << ADC_SMPR2_SMP1_Pos) /*!< 0x00000010 */ #define ADC_SMPR2_SMP1_2 (0x4UL << ADC_SMPR2_SMP1_Pos) /*!< 0x00000020 */ #define ADC_SMPR2_SMP2_Pos (6U) #define ADC_SMPR2_SMP2_Msk (0x7UL << ADC_SMPR2_SMP2_Pos) /*!< 0x000001C0 */ #define ADC_SMPR2_SMP2 ADC_SMPR2_SMP2_Msk /*!< ADC channel 2 sampling time selection */ #define ADC_SMPR2_SMP2_0 (0x1UL << ADC_SMPR2_SMP2_Pos) /*!< 0x00000040 */ #define ADC_SMPR2_SMP2_1 (0x2UL << ADC_SMPR2_SMP2_Pos) /*!< 0x00000080 */ #define ADC_SMPR2_SMP2_2 (0x4UL << ADC_SMPR2_SMP2_Pos) /*!< 0x00000100 */ #define ADC_SMPR2_SMP3_Pos (9U) #define ADC_SMPR2_SMP3_Msk (0x7UL << ADC_SMPR2_SMP3_Pos) /*!< 0x00000E00 */ #define ADC_SMPR2_SMP3 ADC_SMPR2_SMP3_Msk /*!< ADC channel 3 sampling time selection */ #define ADC_SMPR2_SMP3_0 (0x1UL << ADC_SMPR2_SMP3_Pos) /*!< 0x00000200 */ #define ADC_SMPR2_SMP3_1 (0x2UL << ADC_SMPR2_SMP3_Pos) /*!< 0x00000400 */ #define ADC_SMPR2_SMP3_2 (0x4UL << ADC_SMPR2_SMP3_Pos) /*!< 0x00000800 */ #define ADC_SMPR2_SMP4_Pos (12U) #define ADC_SMPR2_SMP4_Msk (0x7UL << ADC_SMPR2_SMP4_Pos) /*!< 0x00007000 */ #define ADC_SMPR2_SMP4 ADC_SMPR2_SMP4_Msk /*!< ADC channel 4 sampling time selection */ #define ADC_SMPR2_SMP4_0 (0x1UL << ADC_SMPR2_SMP4_Pos) /*!< 0x00001000 */ #define ADC_SMPR2_SMP4_1 (0x2UL << ADC_SMPR2_SMP4_Pos) /*!< 0x00002000 */ #define ADC_SMPR2_SMP4_2 (0x4UL << ADC_SMPR2_SMP4_Pos) /*!< 0x00004000 */ #define ADC_SMPR2_SMP5_Pos (15U) #define ADC_SMPR2_SMP5_Msk (0x7UL << ADC_SMPR2_SMP5_Pos) /*!< 0x00038000 */ #define ADC_SMPR2_SMP5 ADC_SMPR2_SMP5_Msk /*!< ADC channel 5 sampling time selection */ #define ADC_SMPR2_SMP5_0 (0x1UL << ADC_SMPR2_SMP5_Pos) /*!< 0x00008000 */ #define ADC_SMPR2_SMP5_1 (0x2UL << ADC_SMPR2_SMP5_Pos) /*!< 0x00010000 */ #define ADC_SMPR2_SMP5_2 (0x4UL << ADC_SMPR2_SMP5_Pos) /*!< 0x00020000 */ #define ADC_SMPR2_SMP6_Pos (18U) #define ADC_SMPR2_SMP6_Msk (0x7UL << ADC_SMPR2_SMP6_Pos) /*!< 0x001C0000 */ #define ADC_SMPR2_SMP6 ADC_SMPR2_SMP6_Msk /*!< ADC channel 6 sampling time selection */ #define ADC_SMPR2_SMP6_0 (0x1UL << ADC_SMPR2_SMP6_Pos) /*!< 0x00040000 */ #define ADC_SMPR2_SMP6_1 (0x2UL << ADC_SMPR2_SMP6_Pos) /*!< 0x00080000 */ #define ADC_SMPR2_SMP6_2 (0x4UL << ADC_SMPR2_SMP6_Pos) /*!< 0x00100000 */ #define ADC_SMPR2_SMP7_Pos (21U) #define ADC_SMPR2_SMP7_Msk (0x7UL << ADC_SMPR2_SMP7_Pos) /*!< 0x00E00000 */ #define ADC_SMPR2_SMP7 ADC_SMPR2_SMP7_Msk /*!< ADC channel 7 sampling time selection */ #define ADC_SMPR2_SMP7_0 (0x1UL << ADC_SMPR2_SMP7_Pos) /*!< 0x00200000 */ #define ADC_SMPR2_SMP7_1 (0x2UL << ADC_SMPR2_SMP7_Pos) /*!< 0x00400000 */ #define ADC_SMPR2_SMP7_2 (0x4UL << ADC_SMPR2_SMP7_Pos) /*!< 0x00800000 */ #define ADC_SMPR2_SMP8_Pos (24U) #define ADC_SMPR2_SMP8_Msk (0x7UL << ADC_SMPR2_SMP8_Pos) /*!< 0x07000000 */ #define ADC_SMPR2_SMP8 ADC_SMPR2_SMP8_Msk /*!< ADC channel 8 sampling time selection */ #define ADC_SMPR2_SMP8_0 (0x1UL << ADC_SMPR2_SMP8_Pos) /*!< 0x01000000 */ #define ADC_SMPR2_SMP8_1 (0x2UL << ADC_SMPR2_SMP8_Pos) /*!< 0x02000000 */ #define ADC_SMPR2_SMP8_2 (0x4UL << ADC_SMPR2_SMP8_Pos) /*!< 0x04000000 */ #define ADC_SMPR2_SMP9_Pos (27U) #define ADC_SMPR2_SMP9_Msk (0x7UL << ADC_SMPR2_SMP9_Pos) /*!< 0x38000000 */ #define ADC_SMPR2_SMP9 ADC_SMPR2_SMP9_Msk /*!< ADC channel 9 sampling time selection */ #define ADC_SMPR2_SMP9_0 (0x1UL << ADC_SMPR2_SMP9_Pos) /*!< 0x08000000 */ #define ADC_SMPR2_SMP9_1 (0x2UL << ADC_SMPR2_SMP9_Pos) /*!< 0x10000000 */ #define ADC_SMPR2_SMP9_2 (0x4UL << ADC_SMPR2_SMP9_Pos) /*!< 0x20000000 */ /****************** Bit definition for ADC_JOFR1 register *******************/ #define ADC_JOFR1_JOFFSET1_Pos (0U) #define ADC_JOFR1_JOFFSET1_Msk (0xFFFUL << ADC_JOFR1_JOFFSET1_Pos) /*!< 0x00000FFF */ #define ADC_JOFR1_JOFFSET1 ADC_JOFR1_JOFFSET1_Msk /*!< ADC group injected sequencer rank 1 offset value */ /****************** Bit definition for ADC_JOFR2 register *******************/ #define ADC_JOFR2_JOFFSET2_Pos (0U) #define ADC_JOFR2_JOFFSET2_Msk (0xFFFUL << ADC_JOFR2_JOFFSET2_Pos) /*!< 0x00000FFF */ #define ADC_JOFR2_JOFFSET2 ADC_JOFR2_JOFFSET2_Msk /*!< ADC group injected sequencer rank 2 offset value */ /****************** Bit definition for ADC_JOFR3 register *******************/ #define ADC_JOFR3_JOFFSET3_Pos (0U) #define ADC_JOFR3_JOFFSET3_Msk (0xFFFUL << ADC_JOFR3_JOFFSET3_Pos) /*!< 0x00000FFF */ #define ADC_JOFR3_JOFFSET3 ADC_JOFR3_JOFFSET3_Msk /*!< ADC group injected sequencer rank 3 offset value */ /****************** Bit definition for ADC_JOFR4 register *******************/ #define ADC_JOFR4_JOFFSET4_Pos (0U) #define ADC_JOFR4_JOFFSET4_Msk (0xFFFUL << ADC_JOFR4_JOFFSET4_Pos) /*!< 0x00000FFF */ #define ADC_JOFR4_JOFFSET4 ADC_JOFR4_JOFFSET4_Msk /*!< ADC group injected sequencer rank 4 offset value */ /******************* Bit definition for ADC_HTR register ********************/ #define ADC_HTR_HT_Pos (0U) #define ADC_HTR_HT_Msk (0xFFFUL << ADC_HTR_HT_Pos) /*!< 0x00000FFF */ #define ADC_HTR_HT ADC_HTR_HT_Msk /*!< ADC analog watchdog 1 threshold high */ /******************* Bit definition for ADC_LTR register ********************/ #define ADC_LTR_LT_Pos (0U) #define ADC_LTR_LT_Msk (0xFFFUL << ADC_LTR_LT_Pos) /*!< 0x00000FFF */ #define ADC_LTR_LT ADC_LTR_LT_Msk /*!< ADC analog watchdog 1 threshold low */ /******************* Bit definition for ADC_SQR1 register *******************/ #define ADC_SQR1_SQ13_Pos (0U) #define ADC_SQR1_SQ13_Msk (0x1FUL << ADC_SQR1_SQ13_Pos) /*!< 0x0000001F */ #define ADC_SQR1_SQ13 ADC_SQR1_SQ13_Msk /*!< ADC group regular sequencer rank 13 */ #define ADC_SQR1_SQ13_0 (0x01UL << ADC_SQR1_SQ13_Pos) /*!< 0x00000001 */ #define ADC_SQR1_SQ13_1 (0x02UL << ADC_SQR1_SQ13_Pos) /*!< 0x00000002 */ #define ADC_SQR1_SQ13_2 (0x04UL << ADC_SQR1_SQ13_Pos) /*!< 0x00000004 */ #define ADC_SQR1_SQ13_3 (0x08UL << ADC_SQR1_SQ13_Pos) /*!< 0x00000008 */ #define ADC_SQR1_SQ13_4 (0x10UL << ADC_SQR1_SQ13_Pos) /*!< 0x00000010 */ #define ADC_SQR1_SQ14_Pos (5U) #define ADC_SQR1_SQ14_Msk (0x1FUL << ADC_SQR1_SQ14_Pos) /*!< 0x000003E0 */ #define ADC_SQR1_SQ14 ADC_SQR1_SQ14_Msk /*!< ADC group regular sequencer rank 14 */ #define ADC_SQR1_SQ14_0 (0x01UL << ADC_SQR1_SQ14_Pos) /*!< 0x00000020 */ #define ADC_SQR1_SQ14_1 (0x02UL << ADC_SQR1_SQ14_Pos) /*!< 0x00000040 */ #define ADC_SQR1_SQ14_2 (0x04UL << ADC_SQR1_SQ14_Pos) /*!< 0x00000080 */ #define ADC_SQR1_SQ14_3 (0x08UL << ADC_SQR1_SQ14_Pos) /*!< 0x00000100 */ #define ADC_SQR1_SQ14_4 (0x10UL << ADC_SQR1_SQ14_Pos) /*!< 0x00000200 */ #define ADC_SQR1_SQ15_Pos (10U) #define ADC_SQR1_SQ15_Msk (0x1FUL << ADC_SQR1_SQ15_Pos) /*!< 0x00007C00 */ #define ADC_SQR1_SQ15 ADC_SQR1_SQ15_Msk /*!< ADC group regular sequencer rank 15 */ #define ADC_SQR1_SQ15_0 (0x01UL << ADC_SQR1_SQ15_Pos) /*!< 0x00000400 */ #define ADC_SQR1_SQ15_1 (0x02UL << ADC_SQR1_SQ15_Pos) /*!< 0x00000800 */ #define ADC_SQR1_SQ15_2 (0x04UL << ADC_SQR1_SQ15_Pos) /*!< 0x00001000 */ #define ADC_SQR1_SQ15_3 (0x08UL << ADC_SQR1_SQ15_Pos) /*!< 0x00002000 */ #define ADC_SQR1_SQ15_4 (0x10UL << ADC_SQR1_SQ15_Pos) /*!< 0x00004000 */ #define ADC_SQR1_SQ16_Pos (15U) #define ADC_SQR1_SQ16_Msk (0x1FUL << ADC_SQR1_SQ16_Pos) /*!< 0x000F8000 */ #define ADC_SQR1_SQ16 ADC_SQR1_SQ16_Msk /*!< ADC group regular sequencer rank 16 */ #define ADC_SQR1_SQ16_0 (0x01UL << ADC_SQR1_SQ16_Pos) /*!< 0x00008000 */ #define ADC_SQR1_SQ16_1 (0x02UL << ADC_SQR1_SQ16_Pos) /*!< 0x00010000 */ #define ADC_SQR1_SQ16_2 (0x04UL << ADC_SQR1_SQ16_Pos) /*!< 0x00020000 */ #define ADC_SQR1_SQ16_3 (0x08UL << ADC_SQR1_SQ16_Pos) /*!< 0x00040000 */ #define ADC_SQR1_SQ16_4 (0x10UL << ADC_SQR1_SQ16_Pos) /*!< 0x00080000 */ #define ADC_SQR1_L_Pos (20U) #define ADC_SQR1_L_Msk (0xFUL << ADC_SQR1_L_Pos) /*!< 0x00F00000 */ #define ADC_SQR1_L ADC_SQR1_L_Msk /*!< ADC group regular sequencer scan length */ #define ADC_SQR1_L_0 (0x1UL << ADC_SQR1_L_Pos) /*!< 0x00100000 */ #define ADC_SQR1_L_1 (0x2UL << ADC_SQR1_L_Pos) /*!< 0x00200000 */ #define ADC_SQR1_L_2 (0x4UL << ADC_SQR1_L_Pos) /*!< 0x00400000 */ #define ADC_SQR1_L_3 (0x8UL << ADC_SQR1_L_Pos) /*!< 0x00800000 */ /******************* Bit definition for ADC_SQR2 register *******************/ #define ADC_SQR2_SQ7_Pos (0U) #define ADC_SQR2_SQ7_Msk (0x1FUL << ADC_SQR2_SQ7_Pos) /*!< 0x0000001F */ #define ADC_SQR2_SQ7 ADC_SQR2_SQ7_Msk /*!< ADC group regular sequencer rank 7 */ #define ADC_SQR2_SQ7_0 (0x01UL << ADC_SQR2_SQ7_Pos) /*!< 0x00000001 */ #define ADC_SQR2_SQ7_1 (0x02UL << ADC_SQR2_SQ7_Pos) /*!< 0x00000002 */ #define ADC_SQR2_SQ7_2 (0x04UL << ADC_SQR2_SQ7_Pos) /*!< 0x00000004 */ #define ADC_SQR2_SQ7_3 (0x08UL << ADC_SQR2_SQ7_Pos) /*!< 0x00000008 */ #define ADC_SQR2_SQ7_4 (0x10UL << ADC_SQR2_SQ7_Pos) /*!< 0x00000010 */ #define ADC_SQR2_SQ8_Pos (5U) #define ADC_SQR2_SQ8_Msk (0x1FUL << ADC_SQR2_SQ8_Pos) /*!< 0x000003E0 */ #define ADC_SQR2_SQ8 ADC_SQR2_SQ8_Msk /*!< ADC group regular sequencer rank 8 */ #define ADC_SQR2_SQ8_0 (0x01UL << ADC_SQR2_SQ8_Pos) /*!< 0x00000020 */ #define ADC_SQR2_SQ8_1 (0x02UL << ADC_SQR2_SQ8_Pos) /*!< 0x00000040 */ #define ADC_SQR2_SQ8_2 (0x04UL << ADC_SQR2_SQ8_Pos) /*!< 0x00000080 */ #define ADC_SQR2_SQ8_3 (0x08UL << ADC_SQR2_SQ8_Pos) /*!< 0x00000100 */ #define ADC_SQR2_SQ8_4 (0x10UL << ADC_SQR2_SQ8_Pos) /*!< 0x00000200 */ #define ADC_SQR2_SQ9_Pos (10U) #define ADC_SQR2_SQ9_Msk (0x1FUL << ADC_SQR2_SQ9_Pos) /*!< 0x00007C00 */ #define ADC_SQR2_SQ9 ADC_SQR2_SQ9_Msk /*!< ADC group regular sequencer rank 9 */ #define ADC_SQR2_SQ9_0 (0x01UL << ADC_SQR2_SQ9_Pos) /*!< 0x00000400 */ #define ADC_SQR2_SQ9_1 (0x02UL << ADC_SQR2_SQ9_Pos) /*!< 0x00000800 */ #define ADC_SQR2_SQ9_2 (0x04UL << ADC_SQR2_SQ9_Pos) /*!< 0x00001000 */ #define ADC_SQR2_SQ9_3 (0x08UL << ADC_SQR2_SQ9_Pos) /*!< 0x00002000 */ #define ADC_SQR2_SQ9_4 (0x10UL << ADC_SQR2_SQ9_Pos) /*!< 0x00004000 */ #define ADC_SQR2_SQ10_Pos (15U) #define ADC_SQR2_SQ10_Msk (0x1FUL << ADC_SQR2_SQ10_Pos) /*!< 0x000F8000 */ #define ADC_SQR2_SQ10 ADC_SQR2_SQ10_Msk /*!< ADC group regular sequencer rank 10 */ #define ADC_SQR2_SQ10_0 (0x01UL << ADC_SQR2_SQ10_Pos) /*!< 0x00008000 */ #define ADC_SQR2_SQ10_1 (0x02UL << ADC_SQR2_SQ10_Pos) /*!< 0x00010000 */ #define ADC_SQR2_SQ10_2 (0x04UL << ADC_SQR2_SQ10_Pos) /*!< 0x00020000 */ #define ADC_SQR2_SQ10_3 (0x08UL << ADC_SQR2_SQ10_Pos) /*!< 0x00040000 */ #define ADC_SQR2_SQ10_4 (0x10UL << ADC_SQR2_SQ10_Pos) /*!< 0x00080000 */ #define ADC_SQR2_SQ11_Pos (20U) #define ADC_SQR2_SQ11_Msk (0x1FUL << ADC_SQR2_SQ11_Pos) /*!< 0x01F00000 */ #define ADC_SQR2_SQ11 ADC_SQR2_SQ11_Msk /*!< ADC group regular sequencer rank 1 */ #define ADC_SQR2_SQ11_0 (0x01UL << ADC_SQR2_SQ11_Pos) /*!< 0x00100000 */ #define ADC_SQR2_SQ11_1 (0x02UL << ADC_SQR2_SQ11_Pos) /*!< 0x00200000 */ #define ADC_SQR2_SQ11_2 (0x04UL << ADC_SQR2_SQ11_Pos) /*!< 0x00400000 */ #define ADC_SQR2_SQ11_3 (0x08UL << ADC_SQR2_SQ11_Pos) /*!< 0x00800000 */ #define ADC_SQR2_SQ11_4 (0x10UL << ADC_SQR2_SQ11_Pos) /*!< 0x01000000 */ #define ADC_SQR2_SQ12_Pos (25U) #define ADC_SQR2_SQ12_Msk (0x1FUL << ADC_SQR2_SQ12_Pos) /*!< 0x3E000000 */ #define ADC_SQR2_SQ12 ADC_SQR2_SQ12_Msk /*!< ADC group regular sequencer rank 12 */ #define ADC_SQR2_SQ12_0 (0x01UL << ADC_SQR2_SQ12_Pos) /*!< 0x02000000 */ #define ADC_SQR2_SQ12_1 (0x02UL << ADC_SQR2_SQ12_Pos) /*!< 0x04000000 */ #define ADC_SQR2_SQ12_2 (0x04UL << ADC_SQR2_SQ12_Pos) /*!< 0x08000000 */ #define ADC_SQR2_SQ12_3 (0x08UL << ADC_SQR2_SQ12_Pos) /*!< 0x10000000 */ #define ADC_SQR2_SQ12_4 (0x10UL << ADC_SQR2_SQ12_Pos) /*!< 0x20000000 */ /******************* Bit definition for ADC_SQR3 register *******************/ #define ADC_SQR3_SQ1_Pos (0U) #define ADC_SQR3_SQ1_Msk (0x1FUL << ADC_SQR3_SQ1_Pos) /*!< 0x0000001F */ #define ADC_SQR3_SQ1 ADC_SQR3_SQ1_Msk /*!< ADC group regular sequencer rank 1 */ #define ADC_SQR3_SQ1_0 (0x01UL << ADC_SQR3_SQ1_Pos) /*!< 0x00000001 */ #define ADC_SQR3_SQ1_1 (0x02UL << ADC_SQR3_SQ1_Pos) /*!< 0x00000002 */ #define ADC_SQR3_SQ1_2 (0x04UL << ADC_SQR3_SQ1_Pos) /*!< 0x00000004 */ #define ADC_SQR3_SQ1_3 (0x08UL << ADC_SQR3_SQ1_Pos) /*!< 0x00000008 */ #define ADC_SQR3_SQ1_4 (0x10UL << ADC_SQR3_SQ1_Pos) /*!< 0x00000010 */ #define ADC_SQR3_SQ2_Pos (5U) #define ADC_SQR3_SQ2_Msk (0x1FUL << ADC_SQR3_SQ2_Pos) /*!< 0x000003E0 */ #define ADC_SQR3_SQ2 ADC_SQR3_SQ2_Msk /*!< ADC group regular sequencer rank 2 */ #define ADC_SQR3_SQ2_0 (0x01UL << ADC_SQR3_SQ2_Pos) /*!< 0x00000020 */ #define ADC_SQR3_SQ2_1 (0x02UL << ADC_SQR3_SQ2_Pos) /*!< 0x00000040 */ #define ADC_SQR3_SQ2_2 (0x04UL << ADC_SQR3_SQ2_Pos) /*!< 0x00000080 */ #define ADC_SQR3_SQ2_3 (0x08UL << ADC_SQR3_SQ2_Pos) /*!< 0x00000100 */ #define ADC_SQR3_SQ2_4 (0x10UL << ADC_SQR3_SQ2_Pos) /*!< 0x00000200 */ #define ADC_SQR3_SQ3_Pos (10U) #define ADC_SQR3_SQ3_Msk (0x1FUL << ADC_SQR3_SQ3_Pos) /*!< 0x00007C00 */ #define ADC_SQR3_SQ3 ADC_SQR3_SQ3_Msk /*!< ADC group regular sequencer rank 3 */ #define ADC_SQR3_SQ3_0 (0x01UL << ADC_SQR3_SQ3_Pos) /*!< 0x00000400 */ #define ADC_SQR3_SQ3_1 (0x02UL << ADC_SQR3_SQ3_Pos) /*!< 0x00000800 */ #define ADC_SQR3_SQ3_2 (0x04UL << ADC_SQR3_SQ3_Pos) /*!< 0x00001000 */ #define ADC_SQR3_SQ3_3 (0x08UL << ADC_SQR3_SQ3_Pos) /*!< 0x00002000 */ #define ADC_SQR3_SQ3_4 (0x10UL << ADC_SQR3_SQ3_Pos) /*!< 0x00004000 */ #define ADC_SQR3_SQ4_Pos (15U) #define ADC_SQR3_SQ4_Msk (0x1FUL << ADC_SQR3_SQ4_Pos) /*!< 0x000F8000 */ #define ADC_SQR3_SQ4 ADC_SQR3_SQ4_Msk /*!< ADC group regular sequencer rank 4 */ #define ADC_SQR3_SQ4_0 (0x01UL << ADC_SQR3_SQ4_Pos) /*!< 0x00008000 */ #define ADC_SQR3_SQ4_1 (0x02UL << ADC_SQR3_SQ4_Pos) /*!< 0x00010000 */ #define ADC_SQR3_SQ4_2 (0x04UL << ADC_SQR3_SQ4_Pos) /*!< 0x00020000 */ #define ADC_SQR3_SQ4_3 (0x08UL << ADC_SQR3_SQ4_Pos) /*!< 0x00040000 */ #define ADC_SQR3_SQ4_4 (0x10UL << ADC_SQR3_SQ4_Pos) /*!< 0x00080000 */ #define ADC_SQR3_SQ5_Pos (20U) #define ADC_SQR3_SQ5_Msk (0x1FUL << ADC_SQR3_SQ5_Pos) /*!< 0x01F00000 */ #define ADC_SQR3_SQ5 ADC_SQR3_SQ5_Msk /*!< ADC group regular sequencer rank 5 */ #define ADC_SQR3_SQ5_0 (0x01UL << ADC_SQR3_SQ5_Pos) /*!< 0x00100000 */ #define ADC_SQR3_SQ5_1 (0x02UL << ADC_SQR3_SQ5_Pos) /*!< 0x00200000 */ #define ADC_SQR3_SQ5_2 (0x04UL << ADC_SQR3_SQ5_Pos) /*!< 0x00400000 */ #define ADC_SQR3_SQ5_3 (0x08UL << ADC_SQR3_SQ5_Pos) /*!< 0x00800000 */ #define ADC_SQR3_SQ5_4 (0x10UL << ADC_SQR3_SQ5_Pos) /*!< 0x01000000 */ #define ADC_SQR3_SQ6_Pos (25U) #define ADC_SQR3_SQ6_Msk (0x1FUL << ADC_SQR3_SQ6_Pos) /*!< 0x3E000000 */ #define ADC_SQR3_SQ6 ADC_SQR3_SQ6_Msk /*!< ADC group regular sequencer rank 6 */ #define ADC_SQR3_SQ6_0 (0x01UL << ADC_SQR3_SQ6_Pos) /*!< 0x02000000 */ #define ADC_SQR3_SQ6_1 (0x02UL << ADC_SQR3_SQ6_Pos) /*!< 0x04000000 */ #define ADC_SQR3_SQ6_2 (0x04UL << ADC_SQR3_SQ6_Pos) /*!< 0x08000000 */ #define ADC_SQR3_SQ6_3 (0x08UL << ADC_SQR3_SQ6_Pos) /*!< 0x10000000 */ #define ADC_SQR3_SQ6_4 (0x10UL << ADC_SQR3_SQ6_Pos) /*!< 0x20000000 */ /******************* Bit definition for ADC_JSQR register *******************/ #define ADC_JSQR_JSQ1_Pos (0U) #define ADC_JSQR_JSQ1_Msk (0x1FUL << ADC_JSQR_JSQ1_Pos) /*!< 0x0000001F */ #define ADC_JSQR_JSQ1 ADC_JSQR_JSQ1_Msk /*!< ADC group injected sequencer rank 1 */ #define ADC_JSQR_JSQ1_0 (0x01UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000001 */ #define ADC_JSQR_JSQ1_1 (0x02UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000002 */ #define ADC_JSQR_JSQ1_2 (0x04UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000004 */ #define ADC_JSQR_JSQ1_3 (0x08UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000008 */ #define ADC_JSQR_JSQ1_4 (0x10UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000010 */ #define ADC_JSQR_JSQ2_Pos (5U) #define ADC_JSQR_JSQ2_Msk (0x1FUL << ADC_JSQR_JSQ2_Pos) /*!< 0x000003E0 */ #define ADC_JSQR_JSQ2 ADC_JSQR_JSQ2_Msk /*!< ADC group injected sequencer rank 2 */ #define ADC_JSQR_JSQ2_0 (0x01UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00000020 */ #define ADC_JSQR_JSQ2_1 (0x02UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00000040 */ #define ADC_JSQR_JSQ2_2 (0x04UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00000080 */ #define ADC_JSQR_JSQ2_3 (0x08UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00000100 */ #define ADC_JSQR_JSQ2_4 (0x10UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00000200 */ #define ADC_JSQR_JSQ3_Pos (10U) #define ADC_JSQR_JSQ3_Msk (0x1FUL << ADC_JSQR_JSQ3_Pos) /*!< 0x00007C00 */ #define ADC_JSQR_JSQ3 ADC_JSQR_JSQ3_Msk /*!< ADC group injected sequencer rank 3 */ #define ADC_JSQR_JSQ3_0 (0x01UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00000400 */ #define ADC_JSQR_JSQ3_1 (0x02UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00000800 */ #define ADC_JSQR_JSQ3_2 (0x04UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00001000 */ #define ADC_JSQR_JSQ3_3 (0x08UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00002000 */ #define ADC_JSQR_JSQ3_4 (0x10UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00004000 */ #define ADC_JSQR_JSQ4_Pos (15U) #define ADC_JSQR_JSQ4_Msk (0x1FUL << ADC_JSQR_JSQ4_Pos) /*!< 0x000F8000 */ #define ADC_JSQR_JSQ4 ADC_JSQR_JSQ4_Msk /*!< ADC group injected sequencer rank 4 */ #define ADC_JSQR_JSQ4_0 (0x01UL << ADC_JSQR_JSQ4_Pos) /*!< 0x00008000 */ #define ADC_JSQR_JSQ4_1 (0x02UL << ADC_JSQR_JSQ4_Pos) /*!< 0x00010000 */ #define ADC_JSQR_JSQ4_2 (0x04UL << ADC_JSQR_JSQ4_Pos) /*!< 0x00020000 */ #define ADC_JSQR_JSQ4_3 (0x08UL << ADC_JSQR_JSQ4_Pos) /*!< 0x00040000 */ #define ADC_JSQR_JSQ4_4 (0x10UL << ADC_JSQR_JSQ4_Pos) /*!< 0x00080000 */ #define ADC_JSQR_JL_Pos (20U) #define ADC_JSQR_JL_Msk (0x3UL << ADC_JSQR_JL_Pos) /*!< 0x00300000 */ #define ADC_JSQR_JL ADC_JSQR_JL_Msk /*!< ADC group injected sequencer scan length */ #define ADC_JSQR_JL_0 (0x1UL << ADC_JSQR_JL_Pos) /*!< 0x00100000 */ #define ADC_JSQR_JL_1 (0x2UL << ADC_JSQR_JL_Pos) /*!< 0x00200000 */ /******************* Bit definition for ADC_JDR1 register *******************/ #define ADC_JDR1_JDATA_Pos (0U) #define ADC_JDR1_JDATA_Msk (0xFFFFUL << ADC_JDR1_JDATA_Pos) /*!< 0x0000FFFF */ #define ADC_JDR1_JDATA ADC_JDR1_JDATA_Msk /*!< ADC group injected sequencer rank 1 conversion data */ /******************* Bit definition for ADC_JDR2 register *******************/ #define ADC_JDR2_JDATA_Pos (0U) #define ADC_JDR2_JDATA_Msk (0xFFFFUL << ADC_JDR2_JDATA_Pos) /*!< 0x0000FFFF */ #define ADC_JDR2_JDATA ADC_JDR2_JDATA_Msk /*!< ADC group injected sequencer rank 2 conversion data */ /******************* Bit definition for ADC_JDR3 register *******************/ #define ADC_JDR3_JDATA_Pos (0U) #define ADC_JDR3_JDATA_Msk (0xFFFFUL << ADC_JDR3_JDATA_Pos) /*!< 0x0000FFFF */ #define ADC_JDR3_JDATA ADC_JDR3_JDATA_Msk /*!< ADC group injected sequencer rank 3 conversion data */ /******************* Bit definition for ADC_JDR4 register *******************/ #define ADC_JDR4_JDATA_Pos (0U) #define ADC_JDR4_JDATA_Msk (0xFFFFUL << ADC_JDR4_JDATA_Pos) /*!< 0x0000FFFF */ #define ADC_JDR4_JDATA ADC_JDR4_JDATA_Msk /*!< ADC group injected sequencer rank 4 conversion data */ /******************** Bit definition for ADC_DR register ********************/ #define ADC_DR_DATA_Pos (0U) #define ADC_DR_DATA_Msk (0xFFFFUL << ADC_DR_DATA_Pos) /*!< 0x0000FFFF */ #define ADC_DR_DATA ADC_DR_DATA_Msk /*!< ADC group regular conversion data */ #define ADC_DR_ADC2DATA_Pos (16U) #define ADC_DR_ADC2DATA_Msk (0xFFFFUL << ADC_DR_ADC2DATA_Pos) /*!< 0xFFFF0000 */ #define ADC_DR_ADC2DATA ADC_DR_ADC2DATA_Msk /*!< ADC group regular conversion data for ADC slave, in multimode */ /******************************************************************************/ /* */ /* Digital to Analog Converter */ /* */ /******************************************************************************/ /******************** Bit definition for DAC_CR register ********************/ #define DAC_CR_EN1_Pos (0U) #define DAC_CR_EN1_Msk (0x1UL << DAC_CR_EN1_Pos) /*!< 0x00000001 */ #define DAC_CR_EN1 DAC_CR_EN1_Msk /*!< DAC channel1 enable */ #define DAC_CR_BOFF1_Pos (1U) #define DAC_CR_BOFF1_Msk (0x1UL << DAC_CR_BOFF1_Pos) /*!< 0x00000002 */ #define DAC_CR_BOFF1 DAC_CR_BOFF1_Msk /*!< DAC channel1 output buffer disable */ #define DAC_CR_TEN1_Pos (2U) #define DAC_CR_TEN1_Msk (0x1UL << DAC_CR_TEN1_Pos) /*!< 0x00000004 */ #define DAC_CR_TEN1 DAC_CR_TEN1_Msk /*!< DAC channel1 Trigger enable */ #define DAC_CR_TSEL1_Pos (3U) #define DAC_CR_TSEL1_Msk (0x7UL << DAC_CR_TSEL1_Pos) /*!< 0x00000038 */ #define DAC_CR_TSEL1 DAC_CR_TSEL1_Msk /*!< TSEL1[2:0] (DAC channel1 Trigger selection) */ #define DAC_CR_TSEL1_0 (0x1UL << DAC_CR_TSEL1_Pos) /*!< 0x00000008 */ #define DAC_CR_TSEL1_1 (0x2UL << DAC_CR_TSEL1_Pos) /*!< 0x00000010 */ #define DAC_CR_TSEL1_2 (0x4UL << DAC_CR_TSEL1_Pos) /*!< 0x00000020 */ #define DAC_CR_WAVE1_Pos (6U) #define DAC_CR_WAVE1_Msk (0x3UL << DAC_CR_WAVE1_Pos) /*!< 0x000000C0 */ #define DAC_CR_WAVE1 DAC_CR_WAVE1_Msk /*!< WAVE1[1:0] (DAC channel1 noise/triangle wave generation enable) */ #define DAC_CR_WAVE1_0 (0x1UL << DAC_CR_WAVE1_Pos) /*!< 0x00000040 */ #define DAC_CR_WAVE1_1 (0x2UL << DAC_CR_WAVE1_Pos) /*!< 0x00000080 */ #define DAC_CR_MAMP1_Pos (8U) #define DAC_CR_MAMP1_Msk (0xFUL << DAC_CR_MAMP1_Pos) /*!< 0x00000F00 */ #define DAC_CR_MAMP1 DAC_CR_MAMP1_Msk /*!< MAMP1[3:0] (DAC channel1 Mask/Amplitude selector) */ #define DAC_CR_MAMP1_0 (0x1UL << DAC_CR_MAMP1_Pos) /*!< 0x00000100 */ #define DAC_CR_MAMP1_1 (0x2UL << DAC_CR_MAMP1_Pos) /*!< 0x00000200 */ #define DAC_CR_MAMP1_2 (0x4UL << DAC_CR_MAMP1_Pos) /*!< 0x00000400 */ #define DAC_CR_MAMP1_3 (0x8UL << DAC_CR_MAMP1_Pos) /*!< 0x00000800 */ #define DAC_CR_DMAEN1_Pos (12U) #define DAC_CR_DMAEN1_Msk (0x1UL << DAC_CR_DMAEN1_Pos) /*!< 0x00001000 */ #define DAC_CR_DMAEN1 DAC_CR_DMAEN1_Msk /*!< DAC channel1 DMA enable */ #define DAC_CR_EN2_Pos (16U) #define DAC_CR_EN2_Msk (0x1UL << DAC_CR_EN2_Pos) /*!< 0x00010000 */ #define DAC_CR_EN2 DAC_CR_EN2_Msk /*!< DAC channel2 enable */ #define DAC_CR_BOFF2_Pos (17U) #define DAC_CR_BOFF2_Msk (0x1UL << DAC_CR_BOFF2_Pos) /*!< 0x00020000 */ #define DAC_CR_BOFF2 DAC_CR_BOFF2_Msk /*!< DAC channel2 output buffer disable */ #define DAC_CR_TEN2_Pos (18U) #define DAC_CR_TEN2_Msk (0x1UL << DAC_CR_TEN2_Pos) /*!< 0x00040000 */ #define DAC_CR_TEN2 DAC_CR_TEN2_Msk /*!< DAC channel2 Trigger enable */ #define DAC_CR_TSEL2_Pos (19U) #define DAC_CR_TSEL2_Msk (0x7UL << DAC_CR_TSEL2_Pos) /*!< 0x00380000 */ #define DAC_CR_TSEL2 DAC_CR_TSEL2_Msk /*!< TSEL2[2:0] (DAC channel2 Trigger selection) */ #define DAC_CR_TSEL2_0 (0x1UL << DAC_CR_TSEL2_Pos) /*!< 0x00080000 */ #define DAC_CR_TSEL2_1 (0x2UL << DAC_CR_TSEL2_Pos) /*!< 0x00100000 */ #define DAC_CR_TSEL2_2 (0x4UL << DAC_CR_TSEL2_Pos) /*!< 0x00200000 */ #define DAC_CR_WAVE2_Pos (22U) #define DAC_CR_WAVE2_Msk (0x3UL << DAC_CR_WAVE2_Pos) /*!< 0x00C00000 */ #define DAC_CR_WAVE2 DAC_CR_WAVE2_Msk /*!< WAVE2[1:0] (DAC channel2 noise/triangle wave generation enable) */ #define DAC_CR_WAVE2_0 (0x1UL << DAC_CR_WAVE2_Pos) /*!< 0x00400000 */ #define DAC_CR_WAVE2_1 (0x2UL << DAC_CR_WAVE2_Pos) /*!< 0x00800000 */ #define DAC_CR_MAMP2_Pos (24U) #define DAC_CR_MAMP2_Msk (0xFUL << DAC_CR_MAMP2_Pos) /*!< 0x0F000000 */ #define DAC_CR_MAMP2 DAC_CR_MAMP2_Msk /*!< MAMP2[3:0] (DAC channel2 Mask/Amplitude selector) */ #define DAC_CR_MAMP2_0 (0x1UL << DAC_CR_MAMP2_Pos) /*!< 0x01000000 */ #define DAC_CR_MAMP2_1 (0x2UL << DAC_CR_MAMP2_Pos) /*!< 0x02000000 */ #define DAC_CR_MAMP2_2 (0x4UL << DAC_CR_MAMP2_Pos) /*!< 0x04000000 */ #define DAC_CR_MAMP2_3 (0x8UL << DAC_CR_MAMP2_Pos) /*!< 0x08000000 */ #define DAC_CR_DMAEN2_Pos (28U) #define DAC_CR_DMAEN2_Msk (0x1UL << DAC_CR_DMAEN2_Pos) /*!< 0x10000000 */ #define DAC_CR_DMAEN2 DAC_CR_DMAEN2_Msk /*!< DAC channel2 DMA enabled */ /***************** Bit definition for DAC_SWTRIGR register ******************/ #define DAC_SWTRIGR_SWTRIG1_Pos (0U) #define DAC_SWTRIGR_SWTRIG1_Msk (0x1UL << DAC_SWTRIGR_SWTRIG1_Pos) /*!< 0x00000001 */ #define DAC_SWTRIGR_SWTRIG1 DAC_SWTRIGR_SWTRIG1_Msk /*!< DAC channel1 software trigger */ #define DAC_SWTRIGR_SWTRIG2_Pos (1U) #define DAC_SWTRIGR_SWTRIG2_Msk (0x1UL << DAC_SWTRIGR_SWTRIG2_Pos) /*!< 0x00000002 */ #define DAC_SWTRIGR_SWTRIG2 DAC_SWTRIGR_SWTRIG2_Msk /*!< DAC channel2 software trigger */ /***************** Bit definition for DAC_DHR12R1 register ******************/ #define DAC_DHR12R1_DACC1DHR_Pos (0U) #define DAC_DHR12R1_DACC1DHR_Msk (0xFFFUL << DAC_DHR12R1_DACC1DHR_Pos) /*!< 0x00000FFF */ #define DAC_DHR12R1_DACC1DHR DAC_DHR12R1_DACC1DHR_Msk /*!< DAC channel1 12-bit Right aligned data */ /***************** Bit definition for DAC_DHR12L1 register ******************/ #define DAC_DHR12L1_DACC1DHR_Pos (4U) #define DAC_DHR12L1_DACC1DHR_Msk (0xFFFUL << DAC_DHR12L1_DACC1DHR_Pos) /*!< 0x0000FFF0 */ #define DAC_DHR12L1_DACC1DHR DAC_DHR12L1_DACC1DHR_Msk /*!< DAC channel1 12-bit Left aligned data */ /****************** Bit definition for DAC_DHR8R1 register ******************/ #define DAC_DHR8R1_DACC1DHR_Pos (0U) #define DAC_DHR8R1_DACC1DHR_Msk (0xFFUL << DAC_DHR8R1_DACC1DHR_Pos) /*!< 0x000000FF */ #define DAC_DHR8R1_DACC1DHR DAC_DHR8R1_DACC1DHR_Msk /*!< DAC channel1 8-bit Right aligned data */ /***************** Bit definition for DAC_DHR12R2 register ******************/ #define DAC_DHR12R2_DACC2DHR_Pos (0U) #define DAC_DHR12R2_DACC2DHR_Msk (0xFFFUL << DAC_DHR12R2_DACC2DHR_Pos) /*!< 0x00000FFF */ #define DAC_DHR12R2_DACC2DHR DAC_DHR12R2_DACC2DHR_Msk /*!< DAC channel2 12-bit Right aligned data */ /***************** Bit definition for DAC_DHR12L2 register ******************/ #define DAC_DHR12L2_DACC2DHR_Pos (4U) #define DAC_DHR12L2_DACC2DHR_Msk (0xFFFUL << DAC_DHR12L2_DACC2DHR_Pos) /*!< 0x0000FFF0 */ #define DAC_DHR12L2_DACC2DHR DAC_DHR12L2_DACC2DHR_Msk /*!< DAC channel2 12-bit Left aligned data */ /****************** Bit definition for DAC_DHR8R2 register ******************/ #define DAC_DHR8R2_DACC2DHR_Pos (0U) #define DAC_DHR8R2_DACC2DHR_Msk (0xFFUL << DAC_DHR8R2_DACC2DHR_Pos) /*!< 0x000000FF */ #define DAC_DHR8R2_DACC2DHR DAC_DHR8R2_DACC2DHR_Msk /*!< DAC channel2 8-bit Right aligned data */ /***************** Bit definition for DAC_DHR12RD register ******************/ #define DAC_DHR12RD_DACC1DHR_Pos (0U) #define DAC_DHR12RD_DACC1DHR_Msk (0xFFFUL << DAC_DHR12RD_DACC1DHR_Pos) /*!< 0x00000FFF */ #define DAC_DHR12RD_DACC1DHR DAC_DHR12RD_DACC1DHR_Msk /*!< DAC channel1 12-bit Right aligned data */ #define DAC_DHR12RD_DACC2DHR_Pos (16U) #define DAC_DHR12RD_DACC2DHR_Msk (0xFFFUL << DAC_DHR12RD_DACC2DHR_Pos) /*!< 0x0FFF0000 */ #define DAC_DHR12RD_DACC2DHR DAC_DHR12RD_DACC2DHR_Msk /*!< DAC channel2 12-bit Right aligned data */ /***************** Bit definition for DAC_DHR12LD register ******************/ #define DAC_DHR12LD_DACC1DHR_Pos (4U) #define DAC_DHR12LD_DACC1DHR_Msk (0xFFFUL << DAC_DHR12LD_DACC1DHR_Pos) /*!< 0x0000FFF0 */ #define DAC_DHR12LD_DACC1DHR DAC_DHR12LD_DACC1DHR_Msk /*!< DAC channel1 12-bit Left aligned data */ #define DAC_DHR12LD_DACC2DHR_Pos (20U) #define DAC_DHR12LD_DACC2DHR_Msk (0xFFFUL << DAC_DHR12LD_DACC2DHR_Pos) /*!< 0xFFF00000 */ #define DAC_DHR12LD_DACC2DHR DAC_DHR12LD_DACC2DHR_Msk /*!< DAC channel2 12-bit Left aligned data */ /****************** Bit definition for DAC_DHR8RD register ******************/ #define DAC_DHR8RD_DACC1DHR_Pos (0U) #define DAC_DHR8RD_DACC1DHR_Msk (0xFFUL << DAC_DHR8RD_DACC1DHR_Pos) /*!< 0x000000FF */ #define DAC_DHR8RD_DACC1DHR DAC_DHR8RD_DACC1DHR_Msk /*!< DAC channel1 8-bit Right aligned data */ #define DAC_DHR8RD_DACC2DHR_Pos (8U) #define DAC_DHR8RD_DACC2DHR_Msk (0xFFUL << DAC_DHR8RD_DACC2DHR_Pos) /*!< 0x0000FF00 */ #define DAC_DHR8RD_DACC2DHR DAC_DHR8RD_DACC2DHR_Msk /*!< DAC channel2 8-bit Right aligned data */ /******************* Bit definition for DAC_DOR1 register *******************/ #define DAC_DOR1_DACC1DOR_Pos (0U) #define DAC_DOR1_DACC1DOR_Msk (0xFFFUL << DAC_DOR1_DACC1DOR_Pos) /*!< 0x00000FFF */ #define DAC_DOR1_DACC1DOR DAC_DOR1_DACC1DOR_Msk /*!< DAC channel1 data output */ /******************* Bit definition for DAC_DOR2 register *******************/ #define DAC_DOR2_DACC2DOR_Pos (0U) #define DAC_DOR2_DACC2DOR_Msk (0xFFFUL << DAC_DOR2_DACC2DOR_Pos) /*!< 0x00000FFF */ #define DAC_DOR2_DACC2DOR DAC_DOR2_DACC2DOR_Msk /*!< DAC channel2 data output */ /*****************************************************************************/ /* */ /* Timers (TIM) */ /* */ /*****************************************************************************/ /******************* Bit definition for TIM_CR1 register *******************/ #define TIM_CR1_CEN_Pos (0U) #define TIM_CR1_CEN_Msk (0x1UL << TIM_CR1_CEN_Pos) /*!< 0x00000001 */ #define TIM_CR1_CEN TIM_CR1_CEN_Msk /*!
© COPYRIGHT(c) 2017 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx * @{ */ #ifndef __STM32F1XX_H #define __STM32F1XX_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Library_configuration_section * @{ */ /** * @brief STM32 Family */ #if !defined (STM32F1) #define STM32F1 #endif /* STM32F1 */ /* Uncomment the line below according to the target STM32L device used in your application */ #if !defined (STM32F100xB) && !defined (STM32F100xE) && !defined (STM32F101x6) && \ !defined (STM32F101xB) && !defined (STM32F101xE) && !defined (STM32F101xG) && !defined (STM32F102x6) && !defined (STM32F102xB) && !defined (STM32F103x6) && \ !defined (STM32F103xB) && !defined (STM32F103xE) && !defined (STM32F103xG) && !defined (STM32F105xC) && !defined (STM32F107xC) /* #define STM32F100xB */ /*!< STM32F100C4, STM32F100R4, STM32F100C6, STM32F100R6, STM32F100C8, STM32F100R8, STM32F100V8, STM32F100CB, STM32F100RB and STM32F100VB */ /* #define STM32F100xE */ /*!< STM32F100RC, STM32F100VC, STM32F100ZC, STM32F100RD, STM32F100VD, STM32F100ZD, STM32F100RE, STM32F100VE and STM32F100ZE */ /* #define STM32F101x6 */ /*!< STM32F101C4, STM32F101R4, STM32F101T4, STM32F101C6, STM32F101R6 and STM32F101T6 Devices */ /* #define STM32F101xB */ /*!< STM32F101C8, STM32F101R8, STM32F101T8, STM32F101V8, STM32F101CB, STM32F101RB, STM32F101TB and STM32F101VB */ /* #define STM32F101xE */ /*!< STM32F101RC, STM32F101VC, STM32F101ZC, STM32F101RD, STM32F101VD, STM32F101ZD, STM32F101RE, STM32F101VE and STM32F101ZE */ /* #define STM32F101xG */ /*!< STM32F101RF, STM32F101VF, STM32F101ZF, STM32F101RG, STM32F101VG and STM32F101ZG */ /* #define STM32F102x6 */ /*!< STM32F102C4, STM32F102R4, STM32F102C6 and STM32F102R6 */ /* #define STM32F102xB */ /*!< STM32F102C8, STM32F102R8, STM32F102CB and STM32F102RB */ /* #define STM32F103x6 */ /*!< STM32F103C4, STM32F103R4, STM32F103T4, STM32F103C6, STM32F103R6 and STM32F103T6 */ /* #define STM32F103xB */ /*!< STM32F103C8, STM32F103R8, STM32F103T8, STM32F103V8, STM32F103CB, STM32F103RB, STM32F103TB and STM32F103VB */ #define STM32F103xE /*!< STM32F103RC, STM32F103VC, STM32F103ZC, STM32F103RD, STM32F103VD, STM32F103ZD, STM32F103RE, STM32F103VE and STM32F103ZE */ /* #define STM32F103xG */ /*!< STM32F103RF, STM32F103VF, STM32F103ZF, STM32F103RG, STM32F103VG and STM32F103ZG */ /* #define STM32F105xC */ /*!< STM32F105R8, STM32F105V8, STM32F105RB, STM32F105VB, STM32F105RC and STM32F105VC */ /* #define STM32F107xC */ /*!< STM32F107RB, STM32F107VB, STM32F107RC and STM32F107VC */ #endif /* Tip: To avoid modifying this file each time you need to switch between these devices, you can define the device in your toolchain compiler preprocessor. */ #if !defined (USE_HAL_DRIVER) /** * @brief Comment the line below if you will not use the peripherals drivers. In this case, these drivers will not be included and the application code will be based on direct access to peripherals registers */ #define USE_HAL_DRIVER #endif /* USE_HAL_DRIVER */ /** * @brief CMSIS Device version number V4.2.0 */ #define __STM32F1_CMSIS_VERSION_MAIN (0x04) /*!< [31:24] main version */ #define __STM32F1_CMSIS_VERSION_SUB1 (0x02) /*!< [23:16] sub1 version */ #define __STM32F1_CMSIS_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ #define __STM32F1_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */ #define __STM32F1_CMSIS_VERSION ((__STM32F1_CMSIS_VERSION_MAIN << 24)\ |(__STM32F1_CMSIS_VERSION_SUB1 << 16)\ |(__STM32F1_CMSIS_VERSION_SUB2 << 8 )\ |(__STM32F1_CMSIS_VERSION_RC)) /** * @} */ /** @addtogroup Device_Included * @{ */ #if defined(STM32F100xB) #include "stm32f100xb.h" #elif defined(STM32F100xE) #include "stm32f100xe.h" #elif defined(STM32F101x6) #include "stm32f101x6.h" #elif defined(STM32F101xB) #include "stm32f101xb.h" #elif defined(STM32F101xE) #include "stm32f101xe.h" #elif defined(STM32F101xG) #include "stm32f101xg.h" #elif defined(STM32F102x6) #include "stm32f102x6.h" #elif defined(STM32F102xB) #include "stm32f102xb.h" #elif defined(STM32F103x6) #include "stm32f103x6.h" #elif defined(STM32F103xB) #include "stm32f103xb.h" #elif defined(STM32F103xE) #include "stm32f103xe.h" #elif defined(STM32F103xG) #include "stm32f103xg.h" #elif defined(STM32F105xC) #include "stm32f105xc.h" #elif defined(STM32F107xC) #include "stm32f107xc.h" #else #error "Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)" #endif /** * @} */ /** @addtogroup Exported_types * @{ */ typedef enum { RESET = 0, SET = !RESET } FlagStatus, ITStatus; typedef enum { DISABLE = 0, ENABLE = !DISABLE } FunctionalState; #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) typedef enum { ERROR = 0, SUCCESS = !ERROR } ErrorStatus; /** * @} */ /** @addtogroup Exported_macros * @{ */ #define SET_BIT(REG, BIT) ((REG) |= (BIT)) #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) #define READ_BIT(REG, BIT) ((REG) & (BIT)) #define CLEAR_REG(REG) ((REG) = (0x0)) #define WRITE_REG(REG, VAL) ((REG) = (VAL)) #define READ_REG(REG) ((REG)) #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) /** * @} */ #if defined (USE_HAL_DRIVER) #include "stm32f1xx_hal.h" #endif /* USE_HAL_DRIVER */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __STM32F1xx_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F103xC/device/system_stm32f1xx.h ================================================ /** ****************************************************************************** * @file system_stm32f10x.h * @author MCD Application Team * @version V4.2.0 * @date 31-March-2017 * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f10x_system * @{ */ /** * @brief Define to prevent recursive inclusion */ #ifndef __SYSTEM_STM32F10X_H #define __SYSTEM_STM32F10X_H #ifdef __cplusplus extern "C" { #endif /** @addtogroup STM32F10x_System_Includes * @{ */ /** * @} */ /** @addtogroup STM32F10x_System_Exported_types * @{ */ extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ extern const uint8_t AHBPrescTable[16U]; /*!< AHB prescalers table values */ extern const uint8_t APBPrescTable[8U]; /*!< APB prescalers table values */ /** * @} */ /** @addtogroup STM32F10x_System_Exported_Constants * @{ */ /** * @} */ /** @addtogroup STM32F10x_System_Exported_Macros * @{ */ /** * @} */ /** @addtogroup STM32F10x_System_Exported_Functions * @{ */ extern void SystemInit(void); extern void SystemCoreClockUpdate(void); extern void SetSysClock(void); /** * @} */ #ifdef __cplusplus } #endif #endif /*__SYSTEM_STM32F10X_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F103xC/device/us_ticker_data.h ================================================ /* mbed Microcontroller Library * Copyright (c) 2006-2018 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __US_TICKER_DATA_H #define __US_TICKER_DATA_H #ifdef __cplusplus extern "C" { #endif #include "stm32f1xx.h" #include "stm32f1xx_ll_tim.h" #include "cmsis_nvic.h" #define TIM_MST TIM4 #define TIM_MST_IRQ TIM4_IRQn #define TIM_MST_RCC __HAL_RCC_TIM4_CLK_ENABLE() #define TIM_MST_DBGMCU_FREEZE __HAL_DBGMCU_FREEZE_TIM4() #define TIM_MST_RESET_ON __HAL_RCC_TIM4_FORCE_RESET() #define TIM_MST_RESET_OFF __HAL_RCC_TIM4_RELEASE_RESET() #define TIM_MST_BIT_WIDTH 16 // 16 or 32 #define TIM_MST_PCLK 1 // Select the peripheral clock number (1 or 2) #ifdef __cplusplus } #endif #endif // __US_TICKER_DATA_H ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F103xC/objects.h ================================================ /* mbed Microcontroller Library ******************************************************************************* * Copyright (c) 2016, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* */ #ifndef MBED_OBJECTS_H #define MBED_OBJECTS_H #include "cmsis.h" #include "PortNames.h" #include "PeripheralNames.h" #include "PinNames.h" #ifdef __cplusplus extern "C" { #endif struct gpio_irq_s { IRQn_Type irq_n; uint32_t irq_index; uint32_t event; PinName pin; }; struct port_s { PortName port; uint32_t mask; PinDirection direction; __IO uint32_t *reg_in; __IO uint32_t *reg_out; }; #include "common_objects.h" #ifdef __cplusplus } #endif #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/drivers/SDIO/SDIOBlockDevice.cpp ================================================ /* mbed Microcontroller Library * Copyright (c) 2017 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include "platform/mbed_debug.h" #include "platform/mbed_wait_api.h" #include "SDIOBlockDevice.h" namespace mbed { /* * defines */ #define SD_DBG 0 /*!< 1 - Enable debugging */ #define SD_CMD_TRACE 0 /*!< 1 - Enable SD command tracing */ #define SD_BLOCK_DEVICE_ERROR_WOULD_BLOCK -5001 /*!< operation would block */ #define SD_BLOCK_DEVICE_ERROR_UNSUPPORTED -5002 /*!< unsupported operation */ #define SD_BLOCK_DEVICE_ERROR_PARAMETER -5003 /*!< invalid parameter */ #define SD_BLOCK_DEVICE_ERROR_NO_INIT -5004 /*!< uninitialized */ #define SD_BLOCK_DEVICE_ERROR_NO_DEVICE -5005 /*!< device is missing or not connected */ #define SD_BLOCK_DEVICE_ERROR_WRITE_PROTECTED -5006 /*!< write protected */ #define SD_BLOCK_DEVICE_ERROR_UNUSABLE -5007 /*!< unusable card */ #define SD_BLOCK_DEVICE_ERROR_NO_RESPONSE -5008 /*!< No response from device */ #define SD_BLOCK_DEVICE_ERROR_CRC -5009 /*!< CRC error */ #define SD_BLOCK_DEVICE_ERROR_ERASE -5010 /*!< Erase error: reset/sequence */ #define SD_BLOCK_DEVICE_ERROR_WRITE -5011 /*!< SPI Write error: !SPI_DATA_ACCEPTED */ #define SD_BLOCK_DEVICE_ERROR_UNSUPPORTED_BLOCKSIZE -5012 /*!< unsupported blocksize, only 512 byte supported */ #define SD_BLOCK_DEVICE_ERROR_READBLOCKS -5013 /*!< read data blocks from SD failed */ #define SD_BLOCK_DEVICE_ERROR_WRITEBLOCKS -5014 /*!< write data blocks to SD failed */ #define SD_BLOCK_DEVICE_ERROR_ERASEBLOCKS -5015 /*!< erase data blocks to SD failed */ #define BLOCK_SIZE_HC 512 /*!< Block size supported for SD card is 512 bytes */ // Types #define SDCARD_NONE 0 /**< No card is present */ #define SDCARD_V1 1 /**< v1.x Standard Capacity */ #define SDCARD_V2 2 /**< v2.x Standard capacity SD card */ #define SDCARD_V2HC 3 /**< v2.x High capacity SD card */ #define CARD_UNKNOWN 4 /**< Unknown or unsupported card */ #ifndef MBED_CONF_SD_TIMEOUT #define MBED_CONF_SD_TIMEOUT (30 * 1000) /* ms */ #endif SDIOBlockDevice::SDIOBlockDevice(PinName cardDetect) : _cardDetect(cardDetect), _is_initialized(0), _sectors(0), _init_ref_count(0) { _card_type = SDCARD_NONE; // Only HC block size is supported. _block_size = BLOCK_SIZE_HC; _erase_size = BLOCK_SIZE_HC; } SDIOBlockDevice::~SDIOBlockDevice() { if (_is_initialized) { deinit(); } } int SDIOBlockDevice::init() { debug_if(SD_DBG, "init Card...\r\n"); lock(); if (!_is_initialized) { _init_ref_count = 0; } _init_ref_count++; if (_init_ref_count != 1) { unlock(); return BD_ERROR_OK; } if (isPresent() == false) { unlock(); return SD_BLOCK_DEVICE_ERROR_NO_DEVICE; } int status = SD_Init(); if (BD_ERROR_OK != status) { unlock(); return BD_ERROR_DEVICE_ERROR; } SD_GetCardInfo(&_cardInfo); _is_initialized = true; debug_if(SD_DBG, "SD initialized: type: %ld version: %ld class: %ld\n", _cardInfo.CardType, _cardInfo.CardVersion, _cardInfo.Class); debug_if(SD_DBG, "SD size: %ld MB\n", _cardInfo.LogBlockNbr / 2 / 1024); // get sectors count from cardinfo _sectors = _cardInfo.LogBlockNbr; if (BLOCK_SIZE_HC != _cardInfo.BlockSize) { unlock(); return SD_BLOCK_DEVICE_ERROR_UNSUPPORTED_BLOCKSIZE; } unlock(); return status; } int SDIOBlockDevice::deinit() { debug_if(SD_DBG, "deinit Card...\r\n"); lock(); if (!_is_initialized) { _init_ref_count = 0; unlock(); return BD_ERROR_OK; } _init_ref_count--; if (_init_ref_count) { unlock(); return BD_ERROR_OK; } int status = SD_DeInit(); _is_initialized = false; _sectors = 0; unlock(); return status; } int SDIOBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size) { lock(); if (isPresent() == false) { unlock(); return SD_BLOCK_DEVICE_ERROR_NO_DEVICE; } if (!is_valid_read(addr, size)) { unlock(); return SD_BLOCK_DEVICE_ERROR_PARAMETER; } if (!_is_initialized) { unlock(); return SD_BLOCK_DEVICE_ERROR_NO_INIT; } uint32_t *_buffer = static_cast(buffer); // ReadBlocks uses byte unit address // SDHC and SDXC Cards different addressing is handled in ReadBlocks() bd_addr_t blockCnt = size / _block_size; addr = addr / _block_size; // make sure card is ready { uint32_t tickstart = HAL_GetTick(); while (SD_GetCardState() != SD_TRANSFER_OK) { // wait until SD ready if ((HAL_GetTick() - tickstart) >= MBED_CONF_SD_TIMEOUT) { unlock(); return SD_BLOCK_DEVICE_ERROR_READBLOCKS; } } } // receive the data : one block/ multiple blocks is handled in ReadBlocks() int status = SD_ReadBlocks_DMA(_buffer, addr, blockCnt); debug_if(SD_DBG, "ReadBlocks dbgtest addr: %lld blockCnt: %lld \n", addr, blockCnt); if (status == MSD_OK) { // wait until DMA finished uint32_t tickstart = HAL_GetTick(); while (SD_DMA_ReadPending() != SD_TRANSFER_OK) { if ((HAL_GetTick() - tickstart) >= MBED_CONF_SD_TIMEOUT) { unlock(); return SD_BLOCK_DEVICE_ERROR_READBLOCKS; } } // make sure card is ready tickstart = HAL_GetTick(); while (SD_GetCardState() != SD_TRANSFER_OK) { // wait until SD ready if ((HAL_GetTick() - tickstart) >= MBED_CONF_SD_TIMEOUT) { unlock(); return SD_BLOCK_DEVICE_ERROR_READBLOCKS; } } } else { debug_if(SD_DBG, "ReadBlocks failed! addr: %lld blockCnt: %lld \n", addr, blockCnt); unlock(); return SD_BLOCK_DEVICE_ERROR_READBLOCKS; } unlock(); return status; } int SDIOBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size) { lock(); if (isPresent() == false) { unlock(); return SD_BLOCK_DEVICE_ERROR_NO_DEVICE; } if (!is_valid_program(addr, size)) { unlock(); return SD_BLOCK_DEVICE_ERROR_PARAMETER; } if (!_is_initialized) { unlock(); return SD_BLOCK_DEVICE_ERROR_NO_INIT; } // HAL layer uses uint32_t for addr/size uint32_t *_buffer = (uint32_t *)(buffer); // Get block count bd_size_t blockCnt = size / _block_size; addr = addr / _block_size; // make sure card is ready { uint32_t tickstart = HAL_GetTick(); while (SD_GetCardState() != SD_TRANSFER_OK) { // wait until SD ready if ((HAL_GetTick() - tickstart) >= MBED_CONF_SD_TIMEOUT) { unlock(); return SD_BLOCK_DEVICE_ERROR_WRITEBLOCKS; } } } int status = SD_WriteBlocks_DMA(_buffer, addr, blockCnt); debug_if(SD_DBG, "WriteBlocks dbgtest addr: %lld blockCnt: %lld \n", addr, blockCnt); if (status == MSD_OK) { // wait until DMA finished uint32_t tickstart = HAL_GetTick(); while (SD_DMA_WritePending() != SD_TRANSFER_OK) { if ((HAL_GetTick() - tickstart) >= MBED_CONF_SD_TIMEOUT) { unlock(); return SD_BLOCK_DEVICE_ERROR_WRITEBLOCKS; } } // make sure card is ready tickstart = HAL_GetTick(); while (SD_GetCardState() != SD_TRANSFER_OK) { // wait until SD ready if ((HAL_GetTick() - tickstart) >= MBED_CONF_SD_TIMEOUT) { unlock(); return SD_BLOCK_DEVICE_ERROR_WRITEBLOCKS; } } } else { debug_if(SD_DBG, "WriteBlocks failed! addr: %lld blockCnt: %lld \n", addr, blockCnt); unlock(); return SD_BLOCK_DEVICE_ERROR_WRITEBLOCKS; } unlock(); return status; } int SDIOBlockDevice::trim(bd_addr_t addr, bd_size_t size) { debug_if(SD_DBG, "trim Card...\r\n"); lock(); if (isPresent() == false) { unlock(); return SD_BLOCK_DEVICE_ERROR_NO_DEVICE; } if (!_is_valid_trim(addr, size)) { unlock(); return SD_BLOCK_DEVICE_ERROR_PARAMETER; } if (!_is_initialized) { unlock(); return SD_BLOCK_DEVICE_ERROR_NO_INIT; } bd_size_t blockCnt = size / _block_size; addr = addr / _block_size; int status = SD_Erase(addr, blockCnt); if (status != 0) { debug_if(SD_DBG, "Erase blocks failed! addr: %lld blockCnt: %lld \n", addr, blockCnt); unlock(); return SD_BLOCK_DEVICE_ERROR_ERASEBLOCKS; } else { uint32_t tickstart = HAL_GetTick(); while (SD_GetCardState() != SD_TRANSFER_OK) { // wait until SD ready if ((HAL_GetTick() - tickstart) >= MBED_CONF_SD_TIMEOUT) { unlock(); return SD_BLOCK_DEVICE_ERROR_ERASEBLOCKS; } } } unlock(); return status; } bd_size_t SDIOBlockDevice::get_read_size() const { return _block_size; } bd_size_t SDIOBlockDevice::get_program_size() const { return _block_size; } bd_size_t SDIOBlockDevice::size() const { return _block_size * _sectors; } void SDIOBlockDevice::debug(bool dbg) { } bool SDIOBlockDevice::_is_valid_trim(bd_addr_t addr, bd_size_t size) { return ( addr % _erase_size == 0 && size % _erase_size == 0 && addr + size <= this->size()); } bool SDIOBlockDevice::isPresent(void) { if (_cardDetect.is_connected()) { return (_cardDetect.read() == 0); } else { return true; } } const char *SDIOBlockDevice::get_type() const { return "SDIO"; } } // namespace mbed ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/drivers/SDIO/SDIOBlockDevice.h ================================================ /* mbed Microcontroller Library * Copyright (c) 2017 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MBED_OS_FEATURES_STORAGE_BLOCKDEVICE_SDIOBLOCKDEVICE_H_ #define MBED_OS_FEATURES_STORAGE_BLOCKDEVICE_SDIOBLOCKDEVICE_H_ #include "BlockDevice.h" #include "DigitalIn.h" #include "PlatformMutex.h" #include "sdio_device.h" namespace mbed { class SDIOBlockDevice : public BlockDevice { public: SDIOBlockDevice(PinName cardDetect = NC); virtual ~SDIOBlockDevice(); /** Initialize a block device * * @return 0 on success or a negative error code on failure */ virtual int init(); /** Deinitialize a block device * * @return 0 on success or a negative error code on failure */ virtual int deinit(); /** Read blocks from a block device * * @param buffer Buffer to write blocks to * @param addr Address of block to begin reading from * @param size Size to read in bytes, must be a multiple of read block size * @return 0 on success, negative error code on failure */ virtual int read(void *buffer, bd_addr_t addr, bd_size_t size); /** Program blocks to a block device * * The blocks must have been erased prior to being programmed * * @param buffer Buffer of data to write to blocks * @param addr Address of block to begin writing to * @param size Size to write in bytes, must be a multiple of program block size * @return 0 on success, negative error code on failure */ virtual int program(const void *buffer, bd_addr_t addr, bd_size_t size); /** Mark blocks as no longer in use * * This function provides a hint to the underlying block device that a region of blocks * is no longer in use and may be erased without side effects. Erase must still be called * before programming, but trimming allows flash-translation-layers to schedule erases when * the device is not busy. * * @param addr Address of block to mark as unused * @param size Size to mark as unused in bytes, must be a multiple of erase block size * @return 0 on success, negative error code on failure */ virtual int trim(bd_addr_t addr, bd_size_t size); /** Get the size of a readable block * * @return Size of a readable block in bytes */ virtual bd_size_t get_read_size() const; /** Get the size of a programable block * * @return Size of a programable block in bytes * @note Must be a multiple of the read size */ virtual bd_size_t get_program_size() const; /** Get the total size of the underlying device * * @return Size of the underlying device in bytes */ virtual bd_size_t size() const; /** Enable or disable debugging * * @param dbg State of debugging */ virtual void debug(bool dbg); /** Set the transfer frequency * * @param freq Transfer frequency * @note Max frequency supported is 25MHZ */ virtual int frequency(uint64_t freq) { return BD_ERROR_OK; }; /** check if SD is present * * @note check physical present switch. Maybe not support by hardware, then function will always return true. */ virtual bool isPresent(void); /** Get the BlockDevice class type. * * @return A string representation of the BlockDevice class type. */ virtual const char *get_type() const; private: DigitalIn _cardDetect; bool _is_initialized; bd_size_t _block_size; bd_size_t _erase_size; bd_size_t _sectors; uint32_t _init_ref_count; SD_Cardinfo_t _cardInfo; uint32_t _card_type; PlatformMutex _mutex; virtual void lock() { _mutex.lock(); } virtual void unlock() { _mutex.unlock(); } bool _is_valid_trim(bd_addr_t addr, bd_size_t size); }; } // namespace mbed #endif /* MBED_OS_FEATURES_STORAGE_BLOCKDEVICE_SDIOBLOCKDEVICE_H_ */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/drivers/SDIO/sdio_device.c ================================================ /* mbed Microcontroller Library * Copyright (c) 2017 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "sdio_device.h" #include "platform/mbed_error.h" /* Extern variables ---------------------------------------------------------*/ SD_HandleTypeDef hsd; DMA_HandleTypeDef hdma_sdio_rx; DMA_HandleTypeDef hdma_sdio_tx; // simple flags for DMA pending signaling volatile uint8_t SD_DMA_ReadPendingState = SD_TRANSFER_OK; volatile uint8_t SD_DMA_WritePendingState = SD_TRANSFER_OK; /* DMA Handlers are global, there is only one SDIO interface */ /** * @brief This function handles SDIO global interrupt. */ void _SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); } /** * @brief This function handles DMAx stream_n global interrupt. DMA Rx */ void _DMA_Stream_Rx_IRQHandler(void) { HAL_DMA_IRQHandler(hsd.hdmarx); } /** * @brief This function handles DMAx stream_n global interrupt. DMA Tx */ void _DMA_Stream_Tx_IRQHandler(void) { HAL_DMA_IRQHandler(hsd.hdmatx); } /** * * @param hsd: Handle for SD handle Structure definition */ void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { IRQn_Type IRQn; GPIO_InitTypeDef GPIO_InitStruct; if (hsd->Instance == SDIO) { /* Peripheral clock enable */ __HAL_RCC_SDIO_CLK_ENABLE(); __HAL_RCC_DMA2_CLK_ENABLE(); /* Enable GPIOs clock */ __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); /**SDIO GPIO Configuration PC12 ------> SDIO_CK PC11 ------> SDIO_D3 PC10 ------> SDIO_D2 PD2 ------> SDIO_CMD PC9 ------> SDIO_D1 PC8 ------> SDIO_D0 */ GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_11 | GPIO_PIN_10 | GPIO_PIN_9 | GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_2; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); /* NVIC configuration for SDIO interrupts */ IRQn = SDIO_IRQn; HAL_NVIC_SetPriority(IRQn, 0x0E, 0); NVIC_SetVector(IRQn, (uint32_t)&_SDIO_IRQHandler); HAL_NVIC_EnableIRQ(IRQn); /* SDIO DMA Init */ /* SDIO_RX Init */ hdma_sdio_rx.Instance = DMA2_Stream3; hdma_sdio_rx.Init.Channel = DMA_CHANNEL_4; hdma_sdio_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma_sdio_rx.Init.PeriphInc = DMA_PINC_DISABLE; hdma_sdio_rx.Init.MemInc = DMA_MINC_ENABLE; hdma_sdio_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; hdma_sdio_rx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; hdma_sdio_rx.Init.Mode = DMA_PFCTRL; hdma_sdio_rx.Init.Priority = DMA_PRIORITY_LOW; hdma_sdio_rx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; hdma_sdio_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; hdma_sdio_rx.Init.MemBurst = DMA_MBURST_INC4; hdma_sdio_rx.Init.PeriphBurst = DMA_PBURST_INC4; if (HAL_DMA_Init(&hdma_sdio_rx) != HAL_OK) { error("SDIO DMA Init error at %d in %s", __LINE__, __FILE__); } __HAL_LINKDMA(hsd, hdmarx, hdma_sdio_rx); /* Deinitialize the stream for new transfer */ HAL_DMA_DeInit(&hdma_sdio_rx); /* Configure the DMA stream */ HAL_DMA_Init(&hdma_sdio_rx); /* SDIO_TX Init */ hdma_sdio_tx.Instance = DMA2_Stream6; hdma_sdio_tx.Init.Channel = DMA_CHANNEL_4; hdma_sdio_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; hdma_sdio_tx.Init.PeriphInc = DMA_PINC_DISABLE; hdma_sdio_tx.Init.MemInc = DMA_MINC_ENABLE; hdma_sdio_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; hdma_sdio_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; hdma_sdio_tx.Init.Mode = DMA_PFCTRL; hdma_sdio_tx.Init.Priority = DMA_PRIORITY_LOW; hdma_sdio_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; hdma_sdio_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; hdma_sdio_tx.Init.MemBurst = DMA_MBURST_INC4; hdma_sdio_tx.Init.PeriphBurst = DMA_PBURST_INC4; if (HAL_DMA_Init(&hdma_sdio_tx) != HAL_OK) { error("SDIO DMA Init error at %d in %s", __LINE__, __FILE__); } __HAL_LINKDMA(hsd, hdmatx, hdma_sdio_tx); /* Deinitialize the stream for new transfer */ HAL_DMA_DeInit(&hdma_sdio_tx); /* Configure the DMA stream */ HAL_DMA_Init(&hdma_sdio_tx); /* Enable NVIC for DMA transfer complete interrupts */ IRQn = DMA2_Stream3_IRQn; NVIC_SetVector(IRQn, (uint32_t)&_DMA_Stream_Rx_IRQHandler); HAL_NVIC_SetPriority(IRQn, 0x0F, 0); HAL_NVIC_EnableIRQ(IRQn); IRQn = DMA2_Stream6_IRQn; NVIC_SetVector(IRQn, (uint32_t)&_DMA_Stream_Tx_IRQHandler); HAL_NVIC_SetPriority(IRQn, 0x0F, 0); HAL_NVIC_EnableIRQ(IRQn); } } /** * * @param hsd: Handle for SD handle Structure definition */ void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) { if (hsd->Instance == SDIO) { /* Peripheral clock disable */ __HAL_RCC_SDIO_CLK_DISABLE(); /**SDIO GPIO Configuration PC12 ------> SDIO_CK PC11 ------> SDIO_D3 PC10 ------> SDIO_D2 PD2 ------> SDIO_CMD PC9 ------> SDIO_D1 PC8 ------> SDIO_D0 */ HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12 | GPIO_PIN_11 | GPIO_PIN_10 | GPIO_PIN_9 | GPIO_PIN_8); HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2); /* SDIO DMA DeInit */ HAL_DMA_DeInit(hsd->hdmarx); HAL_DMA_DeInit(hsd->hdmatx); } } /** * @brief DeInitializes the SD MSP. * @param hsd: SD handle * @param Params : pointer on additional configuration parameters, can be NULL. */ __weak void SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params) { static DMA_HandleTypeDef dma_rx_handle; static DMA_HandleTypeDef dma_tx_handle; /* Disable NVIC for DMA transfer complete interrupts */ HAL_NVIC_DisableIRQ(DMA2_Stream3_IRQn); HAL_NVIC_DisableIRQ(DMA2_Stream6_IRQn); /* Deinitialize the stream for new transfer */ dma_rx_handle.Instance = DMA2_Stream3; HAL_DMA_DeInit(&dma_rx_handle); /* Deinitialize the stream for new transfer */ dma_tx_handle.Instance = DMA2_Stream6; HAL_DMA_DeInit(&dma_tx_handle); /* Disable NVIC for SDIO interrupts */ HAL_NVIC_DisableIRQ(SDIO_IRQn); /* Disable SDIO clock */ __HAL_RCC_SDIO_CLK_DISABLE(); } /** * @brief Enables the SDIO wide bus mode. * @param hsd pointer to SD handle * @retval error state */ static uint32_t SD_WideBus_Enable(SD_HandleTypeDef *hsd) { uint32_t errorstate = HAL_SD_ERROR_NONE; if ((SDIO_GetResponse(hsd->Instance, SDIO_RESP1) & SDMMC_CARD_LOCKED) == SDMMC_CARD_LOCKED) { return HAL_SD_ERROR_LOCK_UNLOCK_FAILED; } /* Send CMD55 APP_CMD with argument as card's RCA.*/ errorstate = SDMMC_CmdAppCommand(hsd->Instance, (uint32_t)(hsd->SdCard.RelCardAdd << 16U)); if (errorstate != HAL_OK) { return errorstate; } /* Send ACMD6 APP_CMD with argument as 2 for wide bus mode */ errorstate = SDMMC_CmdBusWidth(hsd->Instance, 2U); if (errorstate != HAL_OK) { return errorstate; } hsd->Init.BusWide = SDIO_BUS_WIDE_4B; SDIO_Init(hsd->Instance, hsd->Init); return HAL_SD_ERROR_NONE; } /** * @brief Initializes the SD card device. * @retval SD status */ uint8_t SD_Init(void) { uint8_t sd_state = MSD_OK; hsd.Instance = SDIO; hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; hsd.Init.BusWide = SDIO_BUS_WIDE_1B; hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; hsd.Init.ClockDiv = 0; /* HAL SD initialization */ sd_state = HAL_SD_Init(&hsd); /* Configure SD Bus width (4 bits mode selected) */ if (sd_state == MSD_OK) { /* Enable wide operation */ if (SD_WideBus_Enable(&hsd) != HAL_OK) { sd_state = MSD_ERROR; } } return sd_state; } /** * @brief DeInitializes the SD card device. * @retval SD status */ uint8_t SD_DeInit(void) { uint8_t sd_state = MSD_OK; hsd.Instance = SDIO; /* HAL SD deinitialization */ if (HAL_SD_DeInit(&hsd) != HAL_OK) { sd_state = MSD_ERROR; } /* Msp SD deinitialization */ hsd.Instance = SDIO; SD_MspDeInit(&hsd, NULL); return sd_state; } /** * @brief Reads block(s) from a specified address in an SD card, in polling mode. * @param pData: Pointer to the buffer that will contain the data to transmit * @param ReadAddr: Address from where data is to be read * @param NumOfBlocks: Number of SD blocks to read * @param Timeout: Timeout for read operation * @retval SD status */ uint8_t SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout) { uint8_t sd_state = MSD_OK; if (HAL_SD_ReadBlocks(&hsd, (uint8_t *)pData, ReadAddr, NumOfBlocks, Timeout) != HAL_OK) { sd_state = MSD_ERROR; } return sd_state; } /** * @brief Writes block(s) to a specified address in an SD card, in polling mode. * @param pData: Pointer to the buffer that will contain the data to transmit * @param WriteAddr: Address from where data is to be written * @param NumOfBlocks: Number of SD blocks to write * @param Timeout: Timeout for write operation * @retval SD status */ uint8_t SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout) { uint8_t sd_state = MSD_OK; if (HAL_SD_WriteBlocks(&hsd, (uint8_t *)pData, WriteAddr, NumOfBlocks, Timeout) != HAL_OK) { sd_state = MSD_ERROR; } return sd_state; } /** * @brief Reads block(s) from a specified address in an SD card, in DMA mode. * @param pData: Pointer to the buffer that will contain the data to transmit * @param ReadAddr: Address from where data is to be read * @param NumOfBlocks: Number of SD blocks to read * @retval SD status */ uint8_t SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks) { uint8_t sd_state = MSD_OK; SD_DMA_ReadPendingState = SD_TRANSFER_BUSY; /* Read block(s) in DMA transfer mode */ if (HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)pData, ReadAddr, NumOfBlocks) != HAL_OK) { sd_state = MSD_ERROR; SD_DMA_ReadPendingState = SD_TRANSFER_OK; } return sd_state; } /** * @brief Writes block(s) to a specified address in an SD card, in DMA mode. * @param pData: Pointer to the buffer that will contain the data to transmit * @param WriteAddr: Address from where data is to be written * @param NumOfBlocks: Number of SD blocks to write * @retval SD status */ uint8_t SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks) { uint8_t sd_state = MSD_OK; SD_DMA_WritePendingState = SD_TRANSFER_BUSY; /* Write block(s) in DMA transfer mode */ if (HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)pData, WriteAddr, NumOfBlocks) != HAL_OK) { sd_state = MSD_ERROR; SD_DMA_WritePendingState = SD_TRANSFER_OK; } return sd_state; } /** * @brief Erases the specified memory area of the given SD card. * @param StartAddr: Start byte address * @param EndAddr: End byte address * @retval SD status */ uint8_t SD_Erase(uint32_t StartAddr, uint32_t EndAddr) { uint8_t sd_state = MSD_OK; if (HAL_SD_Erase(&hsd, StartAddr, EndAddr) != HAL_OK) { sd_state = MSD_ERROR; } return sd_state; } /** * @brief Gets the current SD card data status. * @param None * @retval Data transfer state. * This value can be one of the following values: * @arg SD_TRANSFER_OK: No data transfer is acting * @arg SD_TRANSFER_BUSY: Data transfer is acting */ uint8_t SD_GetCardState(void) { return ((HAL_SD_GetCardState(&hsd) == HAL_SD_CARD_TRANSFER) ? SD_TRANSFER_OK : SD_TRANSFER_BUSY); } /** * @brief Get SD information about specific SD card. * @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure * @retval None */ void SD_GetCardInfo(SD_Cardinfo_t *CardInfo) { /* Get SD card Information, copy structure for portability */ HAL_SD_CardInfoTypeDef HAL_CardInfo; HAL_SD_GetCardInfo(&hsd, &HAL_CardInfo); if (CardInfo) { CardInfo->CardType = HAL_CardInfo.CardType; CardInfo->CardVersion = HAL_CardInfo.CardVersion; CardInfo->Class = HAL_CardInfo.Class; CardInfo->RelCardAdd = HAL_CardInfo.RelCardAdd; CardInfo->BlockNbr = HAL_CardInfo.BlockNbr; CardInfo->BlockSize = HAL_CardInfo.BlockSize; CardInfo->LogBlockNbr = HAL_CardInfo.LogBlockNbr; CardInfo->LogBlockSize = HAL_CardInfo.LogBlockSize; } } /** * @brief Check if a DMA operation is pending * @retval DMA operation is pending * This value can be one of the following values: * @arg SD_TRANSFER_OK: No data transfer is acting * @arg SD_TRANSFER_BUSY: Data transfer is acting */ uint8_t SD_DMA_ReadPending(void) { return SD_DMA_ReadPendingState; } /** * @brief Check if a DMA operation is pending * @retval DMA operation is pending * This value can be one of the following values: * @arg SD_TRANSFER_OK: No data transfer is acting * @arg SD_TRANSFER_BUSY: Data transfer is acting */ uint8_t SD_DMA_WritePending(void) { return SD_DMA_WritePendingState; } /** * @brief Rx Transfer completed callbacks * @param hsd Pointer SD handle * @retval None */ void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd) { SD_DMA_ReadPendingState = SD_TRANSFER_OK; } /** * @brief Tx Transfer completed callbacks * @param hsd Pointer to SD handle * @retval None */ void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd) { SD_DMA_WritePendingState = SD_TRANSFER_OK; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/drivers/SDIO/sdio_device.h ================================================ /* mbed Microcontroller Library * Copyright (c) 2017 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __SDIO_DEVICE_H #define __SDIO_DEVICE_H #ifdef __cplusplus extern "C" { #endif #include "stm32f4xx_hal.h" /* Typedefs */ typedef struct { uint32_t CardType; /* Specifies the card Type */ uint32_t CardVersion; /* Specifies the card version */ uint32_t Class; /* Specifies the class of the card class */ uint32_t RelCardAdd; /* Specifies the Relative Card Address */ uint32_t BlockNbr; /* Specifies the Card Capacity in blocks */ uint32_t BlockSize; /* Specifies one block size in bytes */ uint32_t LogBlockNbr; /* Specifies the Card logical Capacity in blocks */ uint32_t LogBlockSize; /* Specifies logical block size in bytes */ } SD_Cardinfo_t; /* External Global var */ extern SD_HandleTypeDef hsd; /* Exported types */ /** * @brief SD Card information structure */ #define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef /* Exported constants */ /** * @brief SD status structure definition */ #define MSD_OK ((uint8_t)0x00) #define MSD_ERROR ((uint8_t)0x01) /** * @brief SD transfer state definition */ #define SD_TRANSFER_OK ((uint8_t)0x00) #define SD_TRANSFER_BUSY ((uint8_t)0x01) /* Exported functions */ uint8_t SD_Init(void); uint8_t SD_DeInit(void); uint8_t SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout); uint8_t SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout); uint8_t SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks); uint8_t SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks); uint8_t SD_DMA_ReadPending(void); uint8_t SD_DMA_WritePending(void); uint8_t SD_Erase(uint32_t StartAddr, uint32_t EndAddr); uint8_t SD_GetCardState(void); void SD_GetCardInfo(SD_Cardinfo_t *CardInfo); /* callback function for DMA Rx/Tx completete, called by HAL SDIO interrupt handler */ void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd); void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd); #ifdef __cplusplus } #endif #endif /* __SDIO_DEVICE_H */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/drivers/comms/RemoraComms.cpp ================================================ #include "mbed.h" #include "RemoraComms.h" #include "stm32f4xx_hal.h" RemoraComms::RemoraComms(volatile rxData_t* ptrRxData, volatile txData_t* ptrTxData, SPI_TypeDef* spiType, PinName interruptPin) : ptrRxData(ptrRxData), ptrTxData(ptrTxData), spiType(spiType), interruptPin(interruptPin), slaveSelect(interruptPin) { this->spiHandle.Instance = this->spiType; if (this->interruptPin == PA_4) { // interrupt pin is the NSS pin sharedSPI = false; HAL_NVIC_SetPriority(EXTI4_IRQn, 5, 0); } else if (this->interruptPin == PC_6) { // interrupt pin is not the NSS pin, ie the board shares the SPI bus with the SD card // configure the SPI in software NSS mode and always on sharedSPI = true; HAL_NVIC_SetPriority(EXTI9_5_IRQn , 5, 0); } slaveSelect.rise(callback(this, &RemoraComms::processPacket)); } void RemoraComms::init() { if(this->spiHandle.Instance == SPI1) { printf("Initialising SPI1 slave\n"); GPIO_InitTypeDef GPIO_InitStruct; /**SPI1 GPIO Configuration PA4 ------> SPI1_NSS PA5 ------> SPI1_SCK PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI */ GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); __HAL_RCC_SPI1_CLK_ENABLE(); this->spiHandle.Init.Mode = SPI_MODE_SLAVE; this->spiHandle.Init.Direction = SPI_DIRECTION_2LINES; this->spiHandle.Init.DataSize = SPI_DATASIZE_8BIT; this->spiHandle.Init.CLKPolarity = SPI_POLARITY_LOW; this->spiHandle.Init.CLKPhase = SPI_PHASE_1EDGE; if (sharedSPI) { this->spiHandle.Init.NSS = SPI_NSS_SOFT; printf("SPI is shared with SD card\n"); } else { this->spiHandle.Init.NSS = SPI_NSS_HARD_INPUT; } this->spiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB; this->spiHandle.Init.TIMode = SPI_TIMODE_DISABLE; this->spiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; this->spiHandle.Init.CRCPolynomial = 10; HAL_SPI_Init(&this->spiHandle); if (sharedSPI) { // set SSI (Slave Select Internal) low, ie same as NSS going low CLEAR_BIT(this->spiHandle.Instance->CR1, SPI_CR1_SSI); } printf("Initialising DMA for SPI\n"); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_DMA2_CLK_ENABLE(); this->hdma_spi_tx.Instance = DMA2_Stream3; this->hdma_spi_tx.Init.Channel = DMA_CHANNEL_3; this->hdma_spi_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; this->hdma_spi_tx.Init.PeriphInc = DMA_PINC_DISABLE; this->hdma_spi_tx.Init.MemInc = DMA_MINC_ENABLE; this->hdma_spi_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; this->hdma_spi_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; this->hdma_spi_tx.Init.Mode = DMA_CIRCULAR; //this->hdma_spi_tx.Init.Mode = DMA_NORMAL; this->hdma_spi_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH; this->hdma_spi_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; HAL_DMA_Init(&this->hdma_spi_tx); __HAL_LINKDMA(&this->spiHandle, hdmatx, this->hdma_spi_tx); //HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 0, 0); ///NVIC_SetVector(DMA2_Stream3_IRQn, (uint32_t)&DMA2_Stream3_IRQHandler); //HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); this->hdma_spi_rx.Instance = DMA2_Stream0; this->hdma_spi_rx.Init.Channel = DMA_CHANNEL_3; this->hdma_spi_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; this->hdma_spi_rx.Init.PeriphInc = DMA_PINC_DISABLE; this->hdma_spi_rx.Init.MemInc = DMA_MINC_ENABLE; this->hdma_spi_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; this->hdma_spi_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; this->hdma_spi_rx.Init.Mode = DMA_CIRCULAR; //this->hdma_spi_rx.Init.Mode = DMA_NORMAL; this->hdma_spi_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH; this->hdma_spi_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; HAL_DMA_Init(&this->hdma_spi_rx); __HAL_LINKDMA(&this->spiHandle,hdmarx,this->hdma_spi_rx); //HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0); //NVIC_SetVector(DMA2_Stream0_IRQn, (uint32_t)&DMA2_Stream0_IRQHandler); //HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); this->hdma_memtomem_dma2_stream1.Instance = DMA2_Stream1; this->hdma_memtomem_dma2_stream1.Init.Channel = DMA_CHANNEL_0; this->hdma_memtomem_dma2_stream1.Init.Direction = DMA_MEMORY_TO_MEMORY; this->hdma_memtomem_dma2_stream1.Init.PeriphInc = DMA_PINC_ENABLE; this->hdma_memtomem_dma2_stream1.Init.MemInc = DMA_MINC_ENABLE; this->hdma_memtomem_dma2_stream1.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; this->hdma_memtomem_dma2_stream1.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; this->hdma_memtomem_dma2_stream1.Init.Mode = DMA_NORMAL; this->hdma_memtomem_dma2_stream1.Init.Priority = DMA_PRIORITY_LOW; this->hdma_memtomem_dma2_stream1.Init.FIFOMode = DMA_FIFOMODE_ENABLE; this->hdma_memtomem_dma2_stream1.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; this->hdma_memtomem_dma2_stream1.Init.MemBurst = DMA_MBURST_SINGLE; this->hdma_memtomem_dma2_stream1.Init.PeriphBurst = DMA_PBURST_SINGLE; HAL_DMA_Init(&this->hdma_memtomem_dma2_stream1); } } void RemoraComms::start() { this->ptrTxData->header = PRU_DATA; HAL_SPI_TransmitReceive_DMA(&this->spiHandle, (uint8_t *)this->ptrTxData->txBuffer, (uint8_t *)this->spiRxBuffer.rxBuffer, SPI_BUFF_SIZE); } void RemoraComms::processPacket() { switch (this->spiRxBuffer.header) { case PRU_READ: this->SPIdata = true; this->rejectCnt = 0; // READ so do nothing with the received data break; case PRU_WRITE: this->SPIdata = true; this->rejectCnt = 0; // we've got a good WRITE header, move the data to rxData // **** would like to use DMA for this but cannot when the stream is in CIRCULAR mode for the SPI transfer **** // TODO: figure out how to use NORMAL mode for SPI... //this->status = HAL_DMA_Start(&hdma_memtomem_dma2_stream1, (uint32_t)&this->spiRxBuffer.rxBuffer, (uint32_t)this->rxData->rxBuffer, SPI_BUFF_SIZE); //if (this->status != HAL_OK) printf("F\n"); // Do it the slower way. This does not seem to impact performance but not great to stay in ISR context for longer.. :-( // ensure an atomic access to the rxBuffer // disable thread interrupts __disable_irq(); for (int i = 0; i < SPI_BUFF_SIZE; i++) { this->ptrRxData->rxBuffer[i] = this->spiRxBuffer.rxBuffer[i]; } // re-enable thread interrupts __enable_irq(); break; default: this->rejectCnt++; if (this->rejectCnt > 5) { this->SPIdataError = true; } // reset SPI somehow } HAL_SPI_TransmitReceive_DMA(&this->spiHandle, (uint8_t *)this->ptrTxData->txBuffer, (uint8_t *)this->spiRxBuffer.rxBuffer, SPI_BUFF_SIZE); } bool RemoraComms::getStatus(void) { return this->SPIdata; } void RemoraComms::setStatus(bool status) { this->SPIdata = status; } bool RemoraComms::getError(void) { return this->SPIdataError; } void RemoraComms::setError(bool error) { this->SPIdataError = error; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/drivers/comms/RemoraComms.h ================================================ #ifndef REMORASPI_H #define REMORASPI_H #include "mbed.h" #include "configuration.h" #include "remora.h" #include "stm32f4xx_hal.h" class RemoraComms { private: SPI_TypeDef* spiType; SPI_HandleTypeDef spiHandle; DMA_HandleTypeDef hdma_spi_tx; DMA_HandleTypeDef hdma_spi_rx; DMA_HandleTypeDef hdma_memtomem_dma2_stream1; HAL_StatusTypeDef status; volatile rxData_t* ptrRxData; volatile txData_t* ptrTxData; rxData_t spiRxBuffer; uint8_t rejectCnt; bool SPIdata; bool SPIdataError; PinName interruptPin; InterruptIn slaveSelect; bool sharedSPI; void processPacket(void); public: RemoraComms(volatile rxData_t*, volatile txData_t*, SPI_TypeDef*, PinName); void init(void); void start(void); bool getStatus(void); void setStatus(bool); bool getError(void); void setError(bool); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/drivers/pin/pin.cpp ================================================ #include "mbed.h" #include "pin.h" #include #include #include #include "stm32f4xx_hal.h" Pin::Pin(std::string portAndPin, int dir) : portAndPin(portAndPin), dir(dir) { // Set direction if (this->dir == INPUT) { this->mode = GPIO_MODE_INPUT; this->pull = GPIO_NOPULL; } else { this->mode = GPIO_MODE_OUTPUT_PP; this->pull = GPIO_NOPULL; } this->configPin(); } Pin::Pin(std::string portAndPin, int dir, int modifier) : portAndPin(portAndPin), dir(dir), modifier(modifier) { // Set direction if (this->dir == INPUT) { this->mode = GPIO_MODE_INPUT; // Set pin modifier switch(this->modifier) { case PULLUP: printf(" Setting pin as Pull Up\n"); this->pull = GPIO_PULLUP; break; case PULLDOWN: printf(" Setting pin as Pull Down\n"); this->pull = GPIO_PULLDOWN; break; case NONE: case PULLNONE: printf(" Setting pin as No Pull\n"); this->pull = GPIO_NOPULL; break; } } else { this->mode = GPIO_MODE_OUTPUT_PP; this->pull = GPIO_NOPULL; } this->configPin(); } void Pin::configPin() { printf("Creating Pin @\n"); //x can be (A..H) to select the GPIO peripheral for STM32F40XX and STM32F427X devices. GPIO_TypeDef* gpios[8] ={GPIOA,GPIOB,GPIOC,GPIOD,GPIOE,GPIOF,GPIOG,GPIOH}; if (this->portAndPin[0] == 'P') // PXXX e.g.PA2 PC15 { this->portIndex = this->portAndPin[1] - 'A'; this->pinNumber = this->portAndPin[3] - '0'; uint16_t pin2 = this->portAndPin[4] - '0'; if (pin2 <= 8) { this->pinNumber = this->pinNumber * 10 + pin2; } this->pin = 1 << this->pinNumber; // this is equivalent to GPIO_PIN_x definition } else { printf(" Invalid port and pin definition\n"); return; } printf(" port = GPIO%c\n", char('A' + this->portIndex)); printf(" pin = %d\n", this->pinNumber); // translate port index into something useful this->GPIOx = gpios[this->portIndex]; // enable the peripheral clock switch (portIndex){ case 0: __HAL_RCC_GPIOA_CLK_ENABLE(); break; case 1: __HAL_RCC_GPIOB_CLK_ENABLE(); break; case 2: __HAL_RCC_GPIOC_CLK_ENABLE(); break; case 3: __HAL_RCC_GPIOD_CLK_ENABLE(); break; case 4: __HAL_RCC_GPIOE_CLK_ENABLE(); break; case 5: __HAL_RCC_GPIOF_CLK_ENABLE(); break; case 6: __HAL_RCC_GPIOG_CLK_ENABLE(); break; case 7: __HAL_RCC_GPIOH_CLK_ENABLE(); break; } this->initPin(); } void Pin::initPin() { // Configure GPIO pin Output Level HAL_GPIO_WritePin(this->GPIOx, this->pin, GPIO_PIN_RESET); // Configure the GPIO pin this->GPIO_InitStruct.Pin = this->pin; this->GPIO_InitStruct.Mode = this->mode; this->GPIO_InitStruct.Pull = this->pull; this->GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(this->GPIOx, &this->GPIO_InitStruct); } void Pin::setAsOutput() { this->mode = GPIO_MODE_OUTPUT_PP; this->pull = GPIO_NOPULL; this->initPin(); } void Pin::setAsInput() { this->mode = GPIO_MODE_INPUT; this->pull = GPIO_NOPULL; this->initPin(); } void Pin::pull_none() { this->pull = GPIO_NOPULL; this->initPin(); } void Pin::pull_up() { this->pull = GPIO_PULLUP; this->initPin(); } void Pin::pull_down() { this->pull = GPIO_PULLDOWN; this->initPin(); } PinName Pin::pinToPinName() { printf("PinName = 0x%x\n", (this->portIndex << 4) | this->pinNumber); return static_cast((this->portIndex << 4) | this->pinNumber); } // If available on this pin, return mbed hardware pwm class for this pin PwmOut* Pin::hardware_pwm() { if (this->portIndex == 0) { if (this->pinNumber == 0) { return new mbed::PwmOut(PA_0); } if (this->pinNumber == 1) { return new mbed::PwmOut(PA_1); } if (this->pinNumber == 2) { return new mbed::PwmOut(PA_2); } if (this->pinNumber == 3) { return new mbed::PwmOut(PA_3); } if (this->pinNumber == 5) { return new mbed::PwmOut(PA_5); } if (this->pinNumber == 6) { return new mbed::PwmOut(PA_6); } if (this->pinNumber == 7) { return new mbed::PwmOut(PA_7); } if (this->pinNumber == 8) { return new mbed::PwmOut(PA_8); } if (this->pinNumber == 9) { return new mbed::PwmOut(PA_9); } if (this->pinNumber == 10) { return new mbed::PwmOut(PA_10); } if (this->pinNumber == 11) { return new mbed::PwmOut(PA_11); } if (this->pinNumber == 15) { return new mbed::PwmOut(PA_15); } } else if (this->portIndex == 1) { if (this->pinNumber == 0) { return new mbed::PwmOut(PB_0); } if (this->pinNumber == 1) { return new mbed::PwmOut(PB_1); } if (this->pinNumber == 3) { return new mbed::PwmOut(PB_3); } if (this->pinNumber == 4) { return new mbed::PwmOut(PB_4); } if (this->pinNumber == 5) { return new mbed::PwmOut(PB_5); } if (this->pinNumber == 6) { return new mbed::PwmOut(PB_6); } if (this->pinNumber == 7) { return new mbed::PwmOut(PB_7); } if (this->pinNumber == 8) { return new mbed::PwmOut(PB_8); } if (this->pinNumber == 9) { return new mbed::PwmOut(PB_9); } if (this->pinNumber == 10) { return new mbed::PwmOut(PB_10); } if (this->pinNumber == 11) { return new mbed::PwmOut(PB_11); } if (this->pinNumber == 13) { return new mbed::PwmOut(PB_13); } if (this->pinNumber == 14) { return new mbed::PwmOut(PB_14); } if (this->pinNumber == 15) { return new mbed::PwmOut(PB_15); } } else if (this->portIndex == 2) { if (this->pinNumber == 6) { return new mbed::PwmOut(PC_6); } if (this->pinNumber == 7) { return new mbed::PwmOut(PC_7); } if (this->pinNumber == 8) { return new mbed::PwmOut(PC_8); } if (this->pinNumber == 9) { return new mbed::PwmOut(PC_9); } } else if (this->portIndex == 3) { if (this->pinNumber == 12) { return new mbed::PwmOut(PD_12); } if (this->pinNumber == 13) { return new mbed::PwmOut(PD_13); } if (this->pinNumber == 14) { return new mbed::PwmOut(PD_14); } if (this->pinNumber == 15) { return new mbed::PwmOut(PD_15); } } else if (this->portIndex == 4) { if (this->pinNumber == 5) { return new mbed::PwmOut(PE_5); } if (this->pinNumber == 6) { return new mbed::PwmOut(PE_6); } if (this->pinNumber == 8) { return new mbed::PwmOut(PE_8); } if (this->pinNumber == 9) { return new mbed::PwmOut(PE_9); } if (this->pinNumber == 10) { return new mbed::PwmOut(PE_10); } if (this->pinNumber == 11) { return new mbed::PwmOut(PE_11); } if (this->pinNumber == 12) { return new mbed::PwmOut(PE_12); } if (this->pinNumber == 13) { return new mbed::PwmOut(PE_13); } if (this->pinNumber == 14) { return new mbed::PwmOut(PE_14); } } return nullptr; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/drivers/pin/pin.h ================================================ #ifndef PIN_H #define PIN_H #include "mbed.h" #include #include #include #include #include "stm32f4xx_hal.h" #define INPUT 0x0 #define OUTPUT 0x1 #define NONE 0b000 #define OPENDRAIN 0b001 #define PULLUP 0b010 #define PULLDOWN 0b011 #define PULLNONE 0b100 class Pin { private: std::string portAndPin; uint8_t dir; uint8_t modifier; uint8_t portIndex; uint16_t pinNumber; uint16_t pin; uint32_t mode; uint32_t pull; uint32_t speed; GPIO_TypeDef* GPIOx; GPIO_InitTypeDef GPIO_InitStruct = {0}; public: Pin(std::string, int); Pin(std::string, int, int); PwmOut* hardware_pwm(); void configPin(); void initPin(); void setAsOutput(); void setAsInput(); void pull_none(); void pull_up(); void pull_down(); PinName pinToPinName(); inline bool get() { return HAL_GPIO_ReadPin(this->GPIOx, this->pin); } inline void set(bool value) { if (value) { HAL_GPIO_WritePin(this->GPIOx, this->pin, GPIO_PIN_SET); } else { HAL_GPIO_WritePin(this->GPIOx, this->pin, GPIO_PIN_RESET); } } }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/drivers/qei/qeiDriver.cpp ================================================ #include "mbed.h" #include "qeiDriver.h" QEIdriver::QEIdriver() : qeiIndex(NC) { this->hasIndex = false; this->init(); } QEIdriver::QEIdriver(bool hasIndex) : hasIndex(hasIndex), qeiIndex(PE_13) { this->hasIndex = true; this->irq = EXTI15_10_IRQn; this->init(); qeiIndex.rise(callback(this, &QEIdriver::interruptHandler)); //NVIC_EnableIRQ(this->irq); HAL_NVIC_SetPriority(this->irq, 0, 0); } void QEIdriver::interruptHandler() { this->indexDetected = true; this->indexCount = this->get(); } uint32_t QEIdriver::get() { return __HAL_TIM_GET_COUNTER(&htim); } // reference https://os.mbed.com/users/gregeric/code/Nucleo_Hello_Encoder/ void QEIdriver::init() { printf(" Initialising hardware QEI module\n"); this->htim.Instance = TIM1; this->htim.Init.Prescaler = 0; this->htim.Init.CounterMode = TIM_COUNTERMODE_UP; //this->htim.Init.Period = 0xffffffff; // 32-bit count for TIM2 this->htim.Init.Period = 65535; this->htim.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; this->htim.Init.RepetitionCounter = 0; this->sConfig.EncoderMode = TIM_ENCODERMODE_TI12; this->sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; this->sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; this->sConfig.IC1Prescaler = TIM_ICPSC_DIV1; this->sConfig.IC1Filter = 0; this->sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; this->sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; this->sConfig.IC2Prescaler = TIM_ICPSC_DIV1; this->sConfig.IC2Filter = 0; if (HAL_TIM_Encoder_Init(&this->htim, &this->sConfig) != HAL_OK) { printf("Couldn't Init Encoder\r\n"); } this->sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; this->sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; HAL_TIMEx_MasterConfigSynchronization(&this->htim, &this->sMasterConfig); if (HAL_TIM_Encoder_Start(&this->htim, TIM_CHANNEL_2)!=HAL_OK) { printf("Couldn't Start Encoder\r\n"); } } void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if(htim_encoder->Instance==TIM1) { __HAL_RCC_TIM1_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE(); /**TIM1 GPIO Configuration PE9 ------> TIM1_CH1 PE11 ------> TIM1_CH2 */ GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); } } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/drivers/qei/qeiDriver.h ================================================ #ifndef QEIDRIVER_H #define QEIDRIVER_H #include "mbed.h" #include #include #include #include #include "stm32f4xx_hal.h" class QEIdriver { private: TIM_HandleTypeDef htim; TIM_Encoder_InitTypeDef sConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; InterruptIn qeiIndex; IRQn_Type irq; void interruptHandler(); public: bool hasIndex; bool indexDetected; int32_t indexCount; QEIdriver(); // for channel A & B QEIdriver(bool); // For channels A & B, and index void init(void); uint32_t get(void); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/thread/createThreads.h ================================================ #include "extern.h" void createThreads(void) { // Create the thread objects and set the interrupt vectors to RAM. This is needed // as we are using the SD bootloader that requires a different code starting // address. Also set interrupt priority with NVIC_SetPriority. baseThread = new pruThread(TIM9, TIM1_BRK_TIM9_IRQn, base_freq); NVIC_SetVector(TIM1_BRK_TIM9_IRQn, (uint32_t)TIM9_IRQHandler); NVIC_SetPriority(TIM1_BRK_TIM9_IRQn, 2); servoThread = new pruThread(TIM10, TIM1_UP_TIM10_IRQn, servo_freq); NVIC_SetVector(TIM1_UP_TIM10_IRQn, (uint32_t)TIM10_IRQHandler); NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 3); commsThread = new pruThread(TIM11, TIM1_TRG_COM_TIM11_IRQn, PRU_COMMSFREQ); NVIC_SetVector(TIM1_TRG_COM_TIM11_IRQn, (uint32_t)TIM11_IRQHandler); NVIC_SetPriority(TIM1_TRG_COM_TIM11_IRQn, 4); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/thread/interrupt.cpp ================================================ #include "interrupt.h" #include "stm32f4xx_hal.h" #include // Define the vector table, it is only declared in the class declaration Interrupt* Interrupt::ISRVectorTable[] = {0}; // Constructor Interrupt::Interrupt(void){} // Methods void Interrupt::Register(int interruptNumber, Interrupt* intThisPtr) { printf("Registering interrupt for interrupt number = %d\n", interruptNumber); ISRVectorTable[interruptNumber] = intThisPtr; } //void Interrupt::TIM3_Wrapper(void) //{ // ISRVectorTable[TIM3_IRQn]->ISR_Handler(); //} void Interrupt::TIM9_Wrapper(void) { ISRVectorTable[TIM1_BRK_TIM9_IRQn]->ISR_Handler(); } void Interrupt::TIM10_Wrapper(void) { ISRVectorTable[TIM1_UP_TIM10_IRQn]->ISR_Handler(); } void Interrupt::TIM11_Wrapper(void) { ISRVectorTable[TIM1_TRG_COM_TIM11_IRQn]->ISR_Handler(); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/thread/interrupt.h ================================================ #ifndef INTERRUPT_H #define INTERRUPT_H // Base class for all interrupt derived classes #define PERIPH_COUNT_IRQn 82 // Total number of device interrupt sources class Interrupt { protected: static Interrupt* ISRVectorTable[PERIPH_COUNT_IRQn]; public: Interrupt(void); //static Interrupt* ISRVectorTable[PERIPH_COUNT_IRQn]; static void Register(int interruptNumber, Interrupt* intThisPtr); // wrapper functions to ISR_Handler() //static void TIM3_Wrapper(); static void TIM9_Wrapper(); static void TIM10_Wrapper(); static void TIM11_Wrapper(); virtual void ISR_Handler(void) = 0; }; #endif /****** STM32 specific Interrupt Numbers ********************************************************************* WWDG_IRQn = 0, !SR & TIM_SR_UIF) // if UIF flag is set // { // TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag // Interrupt::TIM3_Wrapper(); // } //} void TIM9_IRQHandler() { if(TIM9->SR & TIM_SR_UIF) // if UIF flag is set { TIM9->SR &= ~TIM_SR_UIF; // clear UIF flag Interrupt::TIM9_Wrapper(); } } void TIM10_IRQHandler() { if(TIM10->SR & TIM_SR_UIF) // if UIF flag is set { TIM10->SR &= ~TIM_SR_UIF; // clear UIF flag Interrupt::TIM10_Wrapper(); } } void TIM11_IRQHandler() { if(TIM11->SR & TIM_SR_UIF) // if UIF flag is set { TIM11->SR &= ~TIM_SR_UIF; // clear UIF flag Interrupt::TIM11_Wrapper(); } } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/thread/pruThread.cpp ================================================ #include "pruThread.h" #include "modules/module.h" using namespace std; // Thread constructor pruThread::pruThread(TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency) : timer(timer), irq(irq), frequency(frequency) { printf("Creating thread %d\n", this->frequency); } void pruThread::startThread(void) { TimerPtr = new pruTimer(this->timer, this->irq, this->frequency, this); } void pruThread::stopThread(void) { this->TimerPtr->stopTimer(); } void pruThread::registerModule(Module* module) { this->vThread.push_back(module); } void pruThread::unregisterModule(Module* module) { iter = std::remove(vThread.begin(),vThread.end(), module); vThread.erase(iter, vThread.end()); } void pruThread::run(void) { // iterate over the Thread pointer vector to run all instances of Module::runModule() for (iter = vThread.begin(); iter != vThread.end(); ++iter) (*iter)->runModule(); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/thread/pruThread.h ================================================ #ifndef PRUTHREAD_H #define PRUTHREAD_H #include "stm32f4xx_hal.h" #include "timer.h" // Standard Template Library (STL) includes #include #include using namespace std; class Module; class pruThread { private: pruTimer* TimerPtr; TIM_TypeDef* timer; IRQn_Type irq; uint32_t frequency; vector vThread; // vector containing pointers to Thread modules vector::iterator iter; public: pruThread(TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency); void registerModule(Module *module); void unregisterModule(Module *module); void startThread(void); void stopThread(void); void run(void); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/thread/timer.cpp ================================================ #include "mbed.h" #include "stm32f4xx_hal.h" #include #include #include "interrupt.h" #include "timerInterrupt.h" #include "timer.h" #include "pruThread.h" // Timer constructor pruTimer::pruTimer(TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency, pruThread* ownerPtr): timer(timer), irq(irq), frequency(frequency), timerOwnerPtr(ownerPtr) { interruptPtr = new TimerInterrupt(this->irq, this); // Instantiate a new Timer Interrupt object and pass "this" pointer this->startTimer(); } void pruTimer::timerTick(void) { //Do something here this->timerOwnerPtr->run(); } void pruTimer::startTimer(void) { uint32_t TIM_CLK; if (this->timer == TIM3) { printf(" power on Timer 3\n\r"); __TIM3_CLK_ENABLE(); TIM_CLK = APB2CLK; } else if (this->timer == TIM9) { printf(" power on Timer 9\n\r"); __TIM9_CLK_ENABLE(); TIM_CLK = APB1CLK; } else if (this->timer == TIM10) { printf(" power on Timer 10\n\r"); __TIM10_CLK_ENABLE(); TIM_CLK = APB1CLK; } else if (this->timer == TIM11) { printf(" power on Timer 11\n\r"); __TIM11_CLK_ENABLE(); TIM_CLK = APB1CLK; } //timer uptade frequency = TIM_CLK/(TIM_PSC+1)/(TIM_ARR + 1) this->timer->CR2 &= 0; // UG used as trigg output this->timer->PSC = TIM_PSC-1; // prescaler this->timer->ARR = ((TIM_CLK / TIM_PSC / this->frequency) - 1); // period this->timer->EGR = TIM_EGR_UG; // reinit the counter this->timer->DIER = TIM_DIER_UIE; // enable update interrupts this->timer->CR1 |= TIM_CR1_CEN; // enable timer NVIC_EnableIRQ(this->irq); } void pruTimer::stopTimer() { NVIC_DisableIRQ(this->irq); printf(" timer stop\n\r"); this->timer->CR1 &= (~(TIM_CR1_CEN)); // disable timer } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TARGET_STM32F4/thread/timer.h ================================================ #ifndef TIMER_H #define TIMER_H #include "mbed.h" #include #define TIM_PSC 4 #define APB1CLK SystemCoreClock #define APB2CLK SystemCoreClock/2 class TimerInterrupt; // forward declatation class pruThread; // forward declatation class pruTimer { friend class TimerInterrupt; private: TimerInterrupt* interruptPtr; TIM_TypeDef* timer; IRQn_Type irq; uint32_t frequency; pruThread* timerOwnerPtr; void startTimer(void); void timerTick(); // Private timer tiggered method public: pruTimer(TIM_TypeDef* timer, IRQn_Type irq, uint32_t frequency, pruThread* ownerPtr); void stopTimer(void); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/.hg/branch ================================================ default ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/.hg/cache/branch2-base ================================================ 5ba0c258c4ed90a7b2d84a782374f254077a2acc 1 5ba0c258c4ed90a7b2d84a782374f254077a2acc o default ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/.hg/cache/rbc-names-v1 ================================================ default ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/.hg/cache/tags2-visible ================================================ 1 5ba0c258c4ed90a7b2d84a782374f254077a2acc ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/.hg/hgrc ================================================ # example repository config (see 'hg help config' for more info) [paths] mbed-studio-cache = c:\Users\tanya\AppData\Local\Mbed Studio\library-cache\os.mbed.com\users\charly\code\TMCStepper default = https://os.mbed.com/users/charly/code/TMCStepper/ # path aliases to other clones of this repo in URLs or filesystem paths # (see 'hg help config.paths' for more info) # # default:pushurl = ssh://jdoe@example.net/hg/jdoes-fork # my-fork = ssh://jdoe@example.net/hg/jdoes-fork # my-clone = /home/jdoe/jdoes-clone [ui] # name and email (local to this repository, optional), e.g. # username = Jane Doe ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/.hg/requires ================================================ dotencode fncache generaldelta revlogv1 sparserevlog store ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/.hg/store/fncache ================================================ data/DRV_STATUS.cpp.i data/TMC_MACROS.h.i data/TMCStepper.cpp.i data/TMC2208Stepper.cpp.i data/GCONF.cpp.i data/IHOLD_IRUN.cpp.i data/TMC2209_bitfields.h.i data/TMCStepper.h.i data/TMC2208_bitfields.h.i data/CHOPCONF.cpp.i data/TMC2209Stepper.cpp.i data/PWMCONF.cpp.i ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/.hg/thgstatus ================================================ m ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/CHOPCONF.cpp ================================================ #include "TMCStepper.h" #include "TMC_MACROS.h" #define SET_REG(SETTING) CHOPCONF_register.SETTING = B; write(CHOPCONF_register.address, CHOPCONF_register.sr) // CHOPCONF /* uint32_t TMC2130Stepper::CHOPCONF() { return read(CHOPCONF_register.address); } void TMC2130Stepper::CHOPCONF(uint32_t input) { CHOPCONF_register.sr = input; write(CHOPCONF_register.address, CHOPCONF_register.sr); } void TMC2130Stepper::toff( uint8_t B ) { SET_REG(toff); } void TMC2130Stepper::hstrt( uint8_t B ) { SET_REG(hstrt); } void TMC2130Stepper::hend( uint8_t B ) { SET_REG(hend); } //void TMC2130Stepper::fd( uint8_t B ) { SET_REG(fd); } void TMC2130Stepper::disfdcc( bool B ) { SET_REG(disfdcc); } void TMC2130Stepper::rndtf( bool B ) { SET_REG(rndtf); } void TMC2130Stepper::chm( bool B ) { SET_REG(chm); } void TMC2130Stepper::tbl( uint8_t B ) { SET_REG(tbl); } void TMC2130Stepper::vsense( bool B ) { SET_REG(vsense); } void TMC2130Stepper::vhighfs( bool B ) { SET_REG(vhighfs); } void TMC2130Stepper::vhighchm( bool B ) { SET_REG(vhighchm);} void TMC2130Stepper::sync( uint8_t B ) { SET_REG(sync); } void TMC2130Stepper::mres( uint8_t B ) { SET_REG(mres); } void TMC2130Stepper::intpol( bool B ) { SET_REG(intpol); } void TMC2130Stepper::dedge( bool B ) { SET_REG(dedge); } void TMC2130Stepper::diss2g( bool B ) { SET_REG(diss2g); } uint8_t TMC2130Stepper::toff() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.toff; } uint8_t TMC2130Stepper::hstrt() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.hstrt; } uint8_t TMC2130Stepper::hend() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.hend; } //uint8_t TMC2130Stepper::fd() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.fd; } bool TMC2130Stepper::disfdcc() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.disfdcc; } bool TMC2130Stepper::rndtf() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.rndtf; } bool TMC2130Stepper::chm() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.chm; } uint8_t TMC2130Stepper::tbl() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.tbl; } bool TMC2130Stepper::vsense() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.vsense; } bool TMC2130Stepper::vhighfs() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.vhighfs; } bool TMC2130Stepper::vhighchm() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.vhighchm;} uint8_t TMC2130Stepper::sync() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.sync; } uint8_t TMC2130Stepper::mres() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.mres; } bool TMC2130Stepper::intpol() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.intpol; } bool TMC2130Stepper::dedge() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.dedge; } bool TMC2130Stepper::diss2g() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.diss2g; } void TMC5160Stepper::diss2vs(bool B){ SET_REG(diss2vs); } void TMC5160Stepper::tpfd(uint8_t B){ SET_REG(tpfd); } bool TMC5160Stepper::diss2vs() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.diss2vs; } uint8_t TMC5160Stepper::tpfd() { CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.tpfd; } */ void TMC2208Stepper::CHOPCONF(uint32_t input) { CHOPCONF_register.sr = input; write(CHOPCONF_register.address, CHOPCONF_register.sr); } uint32_t TMC2208Stepper::CHOPCONF() { return read(CHOPCONF_register.address); } void TMC2208Stepper::toff ( uint8_t B ) { SET_REG(toff); } void TMC2208Stepper::hstrt ( uint8_t B ) { SET_REG(hstrt); } void TMC2208Stepper::hend ( uint8_t B ) { SET_REG(hend); } void TMC2208Stepper::tbl ( uint8_t B ) { SET_REG(tbl); } void TMC2208Stepper::vsense ( bool B ) { SET_REG(vsense); } void TMC2208Stepper::mres ( uint8_t B ) { SET_REG(mres); } void TMC2208Stepper::intpol ( bool B ) { SET_REG(intpol); } void TMC2208Stepper::dedge ( bool B ) { SET_REG(dedge); } void TMC2208Stepper::diss2g ( bool B ) { SET_REG(diss2g); } void TMC2208Stepper::diss2vs( bool B ) { SET_REG(diss2vs); } uint8_t TMC2208Stepper::toff() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.toff; } uint8_t TMC2208Stepper::hstrt() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.hstrt; } uint8_t TMC2208Stepper::hend() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.hend; } uint8_t TMC2208Stepper::tbl() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.tbl; } bool TMC2208Stepper::vsense() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.vsense; } uint8_t TMC2208Stepper::mres() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.mres; } bool TMC2208Stepper::intpol() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.intpol; } bool TMC2208Stepper::dedge() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.dedge; } bool TMC2208Stepper::diss2g() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.diss2g; } bool TMC2208Stepper::diss2vs() { TMC2208_n::CHOPCONF_t r{0}; r.sr = CHOPCONF(); return r.diss2vs; } /* #define GET_REG_2660(SETTING) return CHOPCONF_register.SETTING; uint32_t TMC2660Stepper::CHOPCONF() { return CHOPCONF_register.sr; } void TMC2660Stepper::CHOPCONF(uint32_t data) { CHOPCONF_register.sr = data; write(CHOPCONF_register.address, CHOPCONF_register.sr); } void TMC2660Stepper::toff(uint8_t B) { SET_REG(toff); if (B>0) _savedToff = B; } void TMC2660Stepper::hstrt(uint8_t B) { SET_REG(hstrt); } void TMC2660Stepper::hend(uint8_t B) { SET_REG(hend); } void TMC2660Stepper::hdec(uint8_t B) { SET_REG(hdec); } void TMC2660Stepper::rndtf(bool B) { SET_REG(rndtf); } void TMC2660Stepper::chm(bool B) { SET_REG(chm); } void TMC2660Stepper::tbl(uint8_t B) { SET_REG(tbl); } uint8_t TMC2660Stepper::toff() { GET_REG_2660(toff); } uint8_t TMC2660Stepper::hstrt() { GET_REG_2660(hstrt); } uint8_t TMC2660Stepper::hend() { GET_REG_2660(hend); } uint8_t TMC2660Stepper::hdec() { GET_REG_2660(hdec); } bool TMC2660Stepper::rndtf() { GET_REG_2660(rndtf); } bool TMC2660Stepper::chm() { GET_REG_2660(chm); } uint8_t TMC2660Stepper::tbl() { GET_REG_2660(tbl); } */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/COOLCONF.cpp ================================================ #include "TMCStepper.h" #include "TMC_MACROS.h" #define SET_REG(SETTING) COOLCONF_register.SETTING = B; write(COOLCONF_register.address, COOLCONF_register.sr); #define GET_REG(SETTING) return COOLCONF_register.SETTING; // COOLCONF uint16_t TMC2209Stepper::COOLCONF() { return COOLCONF_register.sr; } void TMC2209Stepper::COOLCONF(uint16_t input) { COOLCONF_register.sr = input; write(COOLCONF_register.address, COOLCONF_register.sr); } void TMC2209Stepper::semin( uint8_t B ) { SET_REG(semin); } void TMC2209Stepper::seup( uint8_t B ) { SET_REG(seup); } void TMC2209Stepper::semax( uint8_t B ) { SET_REG(semax); } void TMC2209Stepper::sedn( uint8_t B ) { SET_REG(sedn); } void TMC2209Stepper::seimin(bool B ) { SET_REG(seimin); } uint8_t TMC2209Stepper::semin() { GET_REG(semin); } uint8_t TMC2209Stepper::seup() { GET_REG(seup); } uint8_t TMC2209Stepper::semax() { GET_REG(semax); } uint8_t TMC2209Stepper::sedn() { GET_REG(sedn); } bool TMC2209Stepper::seimin(){ GET_REG(seimin); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/DRV_STATUS.cpp ================================================ #include "TMCStepper.h" #include "TMC_MACROS.h" #define GET_REG(NS, SETTING) NS::DRV_STATUS_t r{0}; r.sr = DRV_STATUS(); return r.SETTING /* uint32_t TMC2130Stepper::DRV_STATUS() { return read(DRV_STATUS_t::address); } uint16_t TMC2130Stepper::sg_result(){ GET_REG(TMC2130_n, sg_result); } bool TMC2130Stepper::fsactive() { GET_REG(TMC2130_n, fsactive); } uint8_t TMC2130Stepper::cs_actual() { GET_REG(TMC2130_n, cs_actual); } bool TMC2130Stepper::stallguard() { GET_REG(TMC2130_n, stallGuard); } bool TMC2130Stepper::ot() { GET_REG(TMC2130_n, ot); } bool TMC2130Stepper::otpw() { GET_REG(TMC2130_n, otpw); } bool TMC2130Stepper::s2ga() { GET_REG(TMC2130_n, s2ga); } bool TMC2130Stepper::s2gb() { GET_REG(TMC2130_n, s2gb); } bool TMC2130Stepper::ola() { GET_REG(TMC2130_n, ola); } bool TMC2130Stepper::olb() { GET_REG(TMC2130_n, olb); } bool TMC2130Stepper::stst() { GET_REG(TMC2130_n, stst); } */ uint32_t TMC2208Stepper::DRV_STATUS() { return read(TMC2208_n::DRV_STATUS_t::address); } bool TMC2208Stepper::otpw() { GET_REG(TMC2208_n, otpw); } bool TMC2208Stepper::ot() { GET_REG(TMC2208_n, ot); } bool TMC2208Stepper::s2ga() { GET_REG(TMC2208_n, s2ga); } bool TMC2208Stepper::s2gb() { GET_REG(TMC2208_n, s2gb); } bool TMC2208Stepper::s2vsa() { GET_REG(TMC2208_n, s2vsa); } bool TMC2208Stepper::s2vsb() { GET_REG(TMC2208_n, s2vsb); } bool TMC2208Stepper::ola() { GET_REG(TMC2208_n, ola); } bool TMC2208Stepper::olb() { GET_REG(TMC2208_n, olb); } bool TMC2208Stepper::t120() { GET_REG(TMC2208_n, t120); } bool TMC2208Stepper::t143() { GET_REG(TMC2208_n, t143); } bool TMC2208Stepper::t150() { GET_REG(TMC2208_n, t150); } bool TMC2208Stepper::t157() { GET_REG(TMC2208_n, t157); } uint16_t TMC2208Stepper::cs_actual() { GET_REG(TMC2208_n, cs_actual); } bool TMC2208Stepper::stealth() { GET_REG(TMC2208_n, stealth); } bool TMC2208Stepper::stst() { GET_REG(TMC2208_n, stst); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/GCONF.cpp ================================================ #include "TMCStepper.h" #include "TMC_MACROS.h" #define SET_REG(SETTING) GCONF_register.SETTING = B; write(GCONF_register.address, GCONF_register.sr) // GCONF /* uint32_t TMC2130Stepper::GCONF() { return read(GCONF_register.address); } void TMC2130Stepper::GCONF(uint32_t input) { GCONF_register.sr = input; write(GCONF_register.address, GCONF_register.sr); } void TMC2130Stepper::I_scale_analog(bool B) { SET_REG(i_scale_analog); } void TMC2130Stepper::internal_Rsense(bool B) { SET_REG(internal_rsense); } void TMC2130Stepper::en_pwm_mode(bool B) { SET_REG(en_pwm_mode); } void TMC2130Stepper::enc_commutation(bool B) { SET_REG(enc_commutation); } void TMC2130Stepper::shaft(bool B) { SET_REG(shaft); } void TMC2130Stepper::diag0_error(bool B) { SET_REG(diag0_error); } void TMC2130Stepper::diag0_otpw(bool B) { SET_REG(diag0_otpw); } void TMC2130Stepper::diag0_stall(bool B) { SET_REG(diag0_stall); } void TMC2130Stepper::diag1_stall(bool B) { SET_REG(diag1_stall); } void TMC2130Stepper::diag1_index(bool B) { SET_REG(diag1_index); } void TMC2130Stepper::diag1_onstate(bool B) { SET_REG(diag1_onstate); } void TMC2130Stepper::diag1_steps_skipped(bool B) { SET_REG(diag1_steps_skipped); } void TMC2130Stepper::diag0_int_pushpull(bool B) { SET_REG(diag0_int_pushpull); } void TMC2130Stepper::diag1_pushpull(bool B) { SET_REG(diag1_poscomp_pushpull); } void TMC2130Stepper::small_hysteresis(bool B) { SET_REG(small_hysteresis); } void TMC2130Stepper::stop_enable(bool B) { SET_REG(stop_enable); } void TMC2130Stepper::direct_mode(bool B) { SET_REG(direct_mode); } bool TMC2130Stepper::I_scale_analog() { GCONF_t r{0}; r.sr = GCONF(); return r.i_scale_analog; } bool TMC2130Stepper::internal_Rsense() { GCONF_t r{0}; r.sr = GCONF(); return r.internal_rsense; } bool TMC2130Stepper::en_pwm_mode() { GCONF_t r{0}; r.sr = GCONF(); return r.en_pwm_mode; } bool TMC2130Stepper::enc_commutation() { GCONF_t r{0}; r.sr = GCONF(); return r.enc_commutation; } bool TMC2130Stepper::shaft() { GCONF_t r{0}; r.sr = GCONF(); return r.shaft; } bool TMC2130Stepper::diag0_error() { GCONF_t r{0}; r.sr = GCONF(); return r.diag0_error; } bool TMC2130Stepper::diag0_otpw() { GCONF_t r{0}; r.sr = GCONF(); return r.diag0_otpw; } bool TMC2130Stepper::diag0_stall() { GCONF_t r{0}; r.sr = GCONF(); return r.diag0_stall; } bool TMC2130Stepper::diag1_stall() { GCONF_t r{0}; r.sr = GCONF(); return r.diag1_stall; } bool TMC2130Stepper::diag1_index() { GCONF_t r{0}; r.sr = GCONF(); return r.diag1_index; } bool TMC2130Stepper::diag1_onstate() { GCONF_t r{0}; r.sr = GCONF(); return r.diag1_onstate; } bool TMC2130Stepper::diag1_steps_skipped() { GCONF_t r{0}; r.sr = GCONF(); return r.diag1_steps_skipped; } bool TMC2130Stepper::diag0_int_pushpull() { GCONF_t r{0}; r.sr = GCONF(); return r.diag0_int_pushpull; } bool TMC2130Stepper::diag1_pushpull() { GCONF_t r{0}; r.sr = GCONF(); return r.diag1_poscomp_pushpull;} bool TMC2130Stepper::small_hysteresis() { GCONF_t r{0}; r.sr = GCONF(); return r.small_hysteresis; } bool TMC2130Stepper::stop_enable() { GCONF_t r{0}; r.sr = GCONF(); return r.stop_enable; } bool TMC2130Stepper::direct_mode() { GCONF_t r{0}; r.sr = GCONF(); return r.direct_mode; } */ /* bit 18 not implemented: test_mode 0: Normal operation 1: Enable analog test output on pin DCO. IHOLD[1..0] selects the function of DCO: 0…2: T120, DAC, VDDH Attention: Not for user, set to 0 for normal operation! */ /* void TMC5160Stepper::recalibrate(bool B) { SET_REG(recalibrate); } void TMC5160Stepper::faststandstill(bool B) { SET_REG(faststandstill); } void TMC5160Stepper::multistep_filt(bool B) { SET_REG(multistep_filt); } bool TMC5160Stepper::recalibrate() { GCONF_t r{0}; r.sr = GCONF(); return r.recalibrate; } bool TMC5160Stepper::faststandstill() { GCONF_t r{0}; r.sr = GCONF(); return r.faststandstill; } bool TMC5160Stepper::multistep_filt() { GCONF_t r{0}; r.sr = GCONF(); return r.multistep_filt; } */ uint32_t TMC2208Stepper::GCONF() { return read(GCONF_register.address); } void TMC2208Stepper::GCONF(uint32_t input) { GCONF_register.sr = input; write(GCONF_register.address, GCONF_register.sr); } void TMC2208Stepper::I_scale_analog(bool B) { SET_REG(i_scale_analog); } void TMC2208Stepper::internal_Rsense(bool B) { SET_REG(internal_rsense); } void TMC2208Stepper::en_spreadCycle(bool B) { SET_REG(en_spreadcycle); } void TMC2208Stepper::shaft(bool B) { SET_REG(shaft); } void TMC2208Stepper::index_otpw(bool B) { SET_REG(index_otpw); } void TMC2208Stepper::index_step(bool B) { SET_REG(index_step); } void TMC2208Stepper::pdn_disable(bool B) { SET_REG(pdn_disable); } void TMC2208Stepper::mstep_reg_select(bool B) { SET_REG(mstep_reg_select);} void TMC2208Stepper::multistep_filt(bool B) { SET_REG(multistep_filt); } bool TMC2208Stepper::I_scale_analog() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.i_scale_analog; } bool TMC2208Stepper::internal_Rsense() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.internal_rsense; } bool TMC2208Stepper::en_spreadCycle() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.en_spreadcycle; } bool TMC2208Stepper::shaft() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.shaft; } bool TMC2208Stepper::index_otpw() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.index_otpw; } bool TMC2208Stepper::index_step() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.index_step; } bool TMC2208Stepper::pdn_disable() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.pdn_disable; } bool TMC2208Stepper::mstep_reg_select() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.mstep_reg_select; } bool TMC2208Stepper::multistep_filt() { TMC2208_n::GCONF_t r{0}; r.sr = GCONF(); return r.multistep_filt; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/IHOLD_IRUN.cpp ================================================ #include "TMCStepper.h" #include "TMC_MACROS.h" #define SET_REG(SETTING) IHOLD_IRUN_register.SETTING = B; write(IHOLD_IRUN_register.address, IHOLD_IRUN_register.sr); #define GET_REG(SETTING) return IHOLD_IRUN_register.SETTING; // IHOLD_IRUN uint32_t TMCStepper::IHOLD_IRUN() { return IHOLD_IRUN_register.sr; } void TMCStepper::IHOLD_IRUN(uint32_t input) { IHOLD_IRUN_register.sr = input; write(IHOLD_IRUN_register.address, IHOLD_IRUN_register.sr); } void TMCStepper::ihold(uint8_t B) { SET_REG(ihold); } void TMCStepper::irun(uint8_t B) { SET_REG(irun); } void TMCStepper::iholddelay(uint8_t B) { SET_REG(iholddelay); } uint8_t TMCStepper::ihold() { GET_REG(ihold); } uint8_t TMCStepper::irun() { GET_REG(irun); } uint8_t TMCStepper::iholddelay() { GET_REG(iholddelay); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/PWMCONF.cpp ================================================ #include "TMCStepper.h" #include "TMC_MACROS.h" #define SET_REG(SETTING) PWMCONF_register.SETTING = B; write(PWMCONF_register.address, PWMCONF_register.sr) #define GET_REG(SETTING) return PWMCONF_register.SETTING // PWMCONF /* uint32_t TMC2130Stepper::PWMCONF() { return PWMCONF_register.sr; } void TMC2130Stepper::PWMCONF(uint32_t input) { PWMCONF_register.sr = input; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2130Stepper::pwm_ampl( uint8_t B ) { SET_REG(pwm_ampl); } void TMC2130Stepper::pwm_grad( uint8_t B ) { SET_REG(pwm_grad); } void TMC2130Stepper::pwm_freq( uint8_t B ) { SET_REG(pwm_freq); } void TMC2130Stepper::pwm_autoscale( bool B ) { SET_REG(pwm_autoscale); } void TMC2130Stepper::pwm_symmetric( bool B ) { SET_REG(pwm_symmetric); } void TMC2130Stepper::freewheel( uint8_t B ) { SET_REG(freewheel); } uint8_t TMC2130Stepper::pwm_ampl() { GET_REG(pwm_ampl); } uint8_t TMC2130Stepper::pwm_grad() { GET_REG(pwm_grad); } uint8_t TMC2130Stepper::pwm_freq() { GET_REG(pwm_freq); } bool TMC2130Stepper::pwm_autoscale() { GET_REG(pwm_autoscale); } bool TMC2130Stepper::pwm_symmetric() { GET_REG(pwm_symmetric); } uint8_t TMC2130Stepper::freewheel() { GET_REG(freewheel); } uint32_t TMC2160Stepper::PWMCONF() { return PWMCONF_register.sr; } void TMC2160Stepper::PWMCONF(uint32_t input) { PWMCONF_register.sr = input; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2160Stepper::pwm_ofs ( uint8_t B ) { PWMCONF_register.pwm_ofs = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2160Stepper::pwm_grad ( uint8_t B ) { PWMCONF_register.pwm_grad = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2160Stepper::pwm_freq ( uint8_t B ) { PWMCONF_register.pwm_freq = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2160Stepper::pwm_autoscale ( bool B ) { PWMCONF_register.pwm_autoscale = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2160Stepper::pwm_autograd ( bool B ) { PWMCONF_register.pwm_autograd = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2160Stepper::freewheel ( uint8_t B ) { PWMCONF_register.freewheel = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2160Stepper::pwm_reg ( uint8_t B ) { PWMCONF_register.pwm_reg = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2160Stepper::pwm_lim ( uint8_t B ) { PWMCONF_register.pwm_lim = B; write(PWMCONF_register.address, PWMCONF_register.sr); } uint8_t TMC2160Stepper::pwm_ofs() { return PWMCONF_register.pwm_ofs; } uint8_t TMC2160Stepper::pwm_grad() { return PWMCONF_register.pwm_grad; } uint8_t TMC2160Stepper::pwm_freq() { return PWMCONF_register.pwm_freq; } bool TMC2160Stepper::pwm_autoscale() { return PWMCONF_register.pwm_autoscale;} bool TMC2160Stepper::pwm_autograd() { return PWMCONF_register.pwm_autograd; } uint8_t TMC2160Stepper::freewheel() { return PWMCONF_register.freewheel; } uint8_t TMC2160Stepper::pwm_reg() { return PWMCONF_register.pwm_reg; } uint8_t TMC2160Stepper::pwm_lim() { return PWMCONF_register.pwm_lim; } */ uint32_t TMC2208Stepper::PWMCONF() { return read(PWMCONF_register.address); } void TMC2208Stepper::PWMCONF(uint32_t input) { PWMCONF_register.sr = input; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2208Stepper::pwm_ofs ( uint8_t B ) { PWMCONF_register.pwm_ofs = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2208Stepper::pwm_grad ( uint8_t B ) { PWMCONF_register.pwm_grad = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2208Stepper::pwm_freq ( uint8_t B ) { PWMCONF_register.pwm_freq = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2208Stepper::pwm_autoscale ( bool B ) { PWMCONF_register.pwm_autoscale = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2208Stepper::pwm_autograd ( bool B ) { PWMCONF_register.pwm_autograd = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2208Stepper::freewheel ( uint8_t B ) { PWMCONF_register.freewheel = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2208Stepper::pwm_reg ( uint8_t B ) { PWMCONF_register.pwm_reg = B; write(PWMCONF_register.address, PWMCONF_register.sr); } void TMC2208Stepper::pwm_lim ( uint8_t B ) { PWMCONF_register.pwm_lim = B; write(PWMCONF_register.address, PWMCONF_register.sr); } uint8_t TMC2208Stepper::pwm_ofs() { TMC2208_n::PWMCONF_t r{0}; r.sr = PWMCONF(); return r.pwm_ofs; } uint8_t TMC2208Stepper::pwm_grad() { TMC2208_n::PWMCONF_t r{0}; r.sr = PWMCONF(); return r.pwm_grad; } uint8_t TMC2208Stepper::pwm_freq() { TMC2208_n::PWMCONF_t r{0}; r.sr = PWMCONF(); return r.pwm_freq; } bool TMC2208Stepper::pwm_autoscale() { TMC2208_n::PWMCONF_t r{0}; r.sr = PWMCONF(); return r.pwm_autoscale; } bool TMC2208Stepper::pwm_autograd() { TMC2208_n::PWMCONF_t r{0}; r.sr = PWMCONF(); return r.pwm_autograd; } uint8_t TMC2208Stepper::freewheel() { TMC2208_n::PWMCONF_t r{0}; r.sr = PWMCONF(); return r.freewheel; } uint8_t TMC2208Stepper::pwm_reg() { TMC2208_n::PWMCONF_t r{0}; r.sr = PWMCONF(); return r.pwm_reg; } uint8_t TMC2208Stepper::pwm_lim() { TMC2208_n::PWMCONF_t r{0}; r.sr = PWMCONF(); return r.pwm_lim; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/TMC2208Stepper.cpp ================================================ #include "TMCStepper.h" #include "TMC_MACROS.h" // Protected // addr needed for TMC2209 TMC2208Stepper::TMC2208Stepper(std::string SWRXpin, std::string SWTXpin, float RS, uint8_t addr) : SWRXpin(SWRXpin), SWTXpin(SWRXpin), TMCStepper(RS), //RXTX_pin(SW_RX_pin == SW_TX_pin ? SW_RX_pin : 0), slave_address(addr) { SoftwareSerial *SWSerialObj = new SoftwareSerial(SWRXpin, SWTXpin); SWSerial = SWSerialObj; defaults(); #if defined TARGET_LPC176X //this->debug1 = new DigitalOut(P1_30); //this->debug2 = new DigitalOut(P0_28); #elif defined TARGET_STM32F4 //this->debug1 = new DigitalOut(PE_5); //this->debug2 = new DigitalOut(PE_4); #endif } void TMC2208Stepper::beginSerial(uint32_t baudrate) { SWSerial->begin(baudrate); } void TMC2208Stepper::begin() { beginSerial(19600); pdn_disable(true); mstep_reg_select(true); //Wait to initialize wait_ms(replyDelay); } void TMC2208Stepper::defaults() { GCONF_register.i_scale_analog = 1; GCONF_register.internal_rsense = 0; // OTP GCONF_register.en_spreadcycle = 0; // OTP GCONF_register.multistep_filt = 1; // OTP IHOLD_IRUN_register.iholddelay = 1; // OTP TPOWERDOWN_register.sr = 20; CHOPCONF_register.sr = 0x10000053; PWMCONF_register.sr = 0xC10D0024; //MSLUT0_register.sr = ???; //MSLUT1_register.sr = ???; //MSLUT2_register.sr = ???; //MSLUT3_register.sr = ???; //MSLUT4_register.sr = ???; //MSLUT5_register.sr = ???; //MSLUT6_register.sr = ???; //MSLUT7_register.sr = ???; //MSLUTSTART_register.start_sin90 = 247; } void TMC2208Stepper::push() { GCONF(GCONF_register.sr); IHOLD_IRUN(IHOLD_IRUN_register.sr); SLAVECONF(SLAVECONF_register.sr); TPOWERDOWN(TPOWERDOWN_register.sr); TPWMTHRS(TPWMTHRS_register.sr); VACTUAL(VACTUAL_register.sr); CHOPCONF(CHOPCONF_register.sr); PWMCONF(PWMCONF_register.sr); } bool TMC2208Stepper::isEnabled() { return !enn() && toff(); } uint8_t TMC2208Stepper::calcCRC(uint8_t datagram[], uint8_t len) { uint8_t crc = 0; for (uint8_t i = 0; i < len; i++) { uint8_t currentByte = datagram[i]; for (uint8_t j = 0; j < 8; j++) { if ((crc >> 7) ^ (currentByte & 0x01)) { crc = (crc << 1) ^ 0x07; } else { crc = (crc << 1); } crc &= 0xff; currentByte = currentByte >> 1; } } return crc; } __attribute__((weak)) int TMC2208Stepper::available() { int out = 0; out = SWSerial->available(); return out; } __attribute__((weak)) void TMC2208Stepper::preWriteCommunication() { //this->debug1->write(1); } __attribute__((weak)) void TMC2208Stepper::preReadCommunication() { SWSerial->listen(); //this->debug2->write(1); } __attribute__((weak)) void TMC2208Stepper::postWriteCommunication() { //this->debug1->write(0); } __attribute__((weak)) void TMC2208Stepper::postReadCommunication() { //this->debug2->write(0); } __attribute__((weak)) int16_t TMC2208Stepper::serial_read() { int16_t out = 0; out = SWSerial->read(); return out; } __attribute__((weak)) uint8_t TMC2208Stepper::serial_write(const uint8_t data) { int out = 0; SWSerial->write(data); return out; } void TMC2208Stepper::write(uint8_t addr, uint32_t regVal) { uint8_t len = 7; addr |= TMC_WRITE; uint8_t datagram[] = {TMC2208_SYNC, slave_address, addr, (uint8_t)(regVal>>24), (uint8_t)(regVal>>16), (uint8_t)(regVal>>8), (uint8_t)(regVal>>0), 0x00}; datagram[len] = calcCRC(datagram, len); //printf("write datagram = %x, %x, %x, %x, %x, %x, %x, %x\n", datagram[0], datagram[1], datagram[2], datagram[3], datagram[4], datagram[5], datagram[6], datagram[7]); preWriteCommunication(); for(uint8_t i=0; i<=len; i++) { bytesWritten += serial_write(datagram[i]); } postWriteCommunication(); //delay(replyDelay); //ThisThread::sleep_for(150); wait_ms(5); } uint64_t TMC2208Stepper::_sendDatagram(uint8_t datagram[], const uint8_t len, uint16_t timeout) { while (available() > 0) serial_read(); // Flush tmcTimer.reset(); tmcTimer.start(); preWriteCommunication(); for(int i=0; i<=len; i++) { serial_write(datagram[i]); } //delay(replyDelay); //ThisThread::sleep_for(replyDelay); postWriteCommunication(); // scan for the rx frame and read it uint32_t ms = tmcTimer.read_ms(); uint32_t sync_target = (static_cast(datagram[0])<<16) | 0xFF00 | datagram[2]; uint32_t sync = 0; do { uint32_t ms2 = tmcTimer.read_ms(); if (ms2 != ms) { // 1ms tick ms = ms2; timeout--; } if (!timeout) return 0; int16_t res = serial_read(); if (res < 0) continue; sync <<= 8; sync |= res & 0xFF; sync &= 0xFFFFFF; } while (sync != sync_target); uint64_t out = sync; ms = tmcTimer.read_ms(); timeout = this->abort_window; for(uint8_t i=0; i<5;) { uint32_t ms2 = tmcTimer.read_ms(); if (ms2 != ms) { // 1ms tick ms = ms2; timeout--; } if (!timeout) return 0; int16_t res = serial_read(); if (res < 0) continue; out <<= 8; out |= res & 0xFF; i++; } tmcTimer.stop(); while (available() > 0) serial_read(); // Flush return out; } uint32_t TMC2208Stepper::read(uint8_t addr) { constexpr uint8_t len = 3; addr |= TMC_READ; uint8_t datagram[] = {TMC2208_SYNC, slave_address, addr, 0x00}; datagram[len] = calcCRC(datagram, len); uint64_t out = 0x00000000UL; for (uint8_t i = 0; i < max_retries; i++) { preReadCommunication(); out = _sendDatagram(datagram, len, abort_window); postReadCommunication(); // delay(replyDelay); //ThisThread::sleep_for(replyDelay); wait_ms(5); CRCerror = false; uint8_t out_datagram[] = { static_cast(out>>56), static_cast(out>>48), static_cast(out>>40), static_cast(out>>32), static_cast(out>>24), static_cast(out>>16), static_cast(out>> 8), static_cast(out>> 0) }; //printf("read datagram = %x, %x, %x, %x, %x, %x, %x, %x\n", out_datagram[0], out_datagram[1], out_datagram[2], out_datagram[3], out_datagram[4], out_datagram[5], out_datagram[6], out_datagram[7]); uint8_t crc = calcCRC(out_datagram, 7); if ((crc != static_cast(out)) || crc == 0 ) { CRCerror = true; out = 0; } else { break; } } return out>>8; } uint8_t TMC2208Stepper::IFCNT() { return read(IFCNT_t::address); } void TMC2208Stepper::SLAVECONF(uint16_t input) { SLAVECONF_register.sr = input&0xF00; write(SLAVECONF_register.address, SLAVECONF_register.sr); } uint16_t TMC2208Stepper::SLAVECONF() { return SLAVECONF_register.sr; } void TMC2208Stepper::senddelay(uint8_t B) { SLAVECONF_register.senddelay = B; write(SLAVECONF_register.address, SLAVECONF_register.sr); } uint8_t TMC2208Stepper::senddelay() { return SLAVECONF_register.senddelay; } void TMC2208Stepper::OTP_PROG(uint16_t input) { write(OTP_PROG_t::address, input); } uint32_t TMC2208Stepper::OTP_READ() { return read(OTP_READ_t::address); } uint32_t TMC2208Stepper::IOIN() { return read(TMC2208_n::IOIN_t::address); } bool TMC2208Stepper::enn() { TMC2208_n::IOIN_t r{0}; r.sr = IOIN(); return r.enn; } bool TMC2208Stepper::ms1() { TMC2208_n::IOIN_t r{0}; r.sr = IOIN(); return r.ms1; } bool TMC2208Stepper::ms2() { TMC2208_n::IOIN_t r{0}; r.sr = IOIN(); return r.ms2; } bool TMC2208Stepper::diag() { TMC2208_n::IOIN_t r{0}; r.sr = IOIN(); return r.diag; } bool TMC2208Stepper::pdn_uart() { TMC2208_n::IOIN_t r{0}; r.sr = IOIN(); return r.pdn_uart; } bool TMC2208Stepper::step() { TMC2208_n::IOIN_t r{0}; r.sr = IOIN(); return r.step; } bool TMC2208Stepper::sel_a() { TMC2208_n::IOIN_t r{0}; r.sr = IOIN(); return r.sel_a; } bool TMC2208Stepper::dir() { TMC2208_n::IOIN_t r{0}; r.sr = IOIN(); return r.dir; } uint8_t TMC2208Stepper::version() { TMC2208_n::IOIN_t r{0}; r.sr = IOIN(); return r.version; } /* uint32_t TMC2224Stepper::IOIN() { return read(TMC2224_n::IOIN_t::address); } bool TMC2224Stepper::enn() { TMC2224_n::IOIN_t r{0}; r.sr = IOIN(); return r.enn; } bool TMC2224Stepper::ms1() { TMC2224_n::IOIN_t r{0}; r.sr = IOIN(); return r.ms1; } bool TMC2224Stepper::ms2() { TMC2224_n::IOIN_t r{0}; r.sr = IOIN(); return r.ms2; } bool TMC2224Stepper::pdn_uart() { TMC2224_n::IOIN_t r{0}; r.sr = IOIN(); return r.pdn_uart; } bool TMC2224Stepper::spread() { TMC2224_n::IOIN_t r{0}; r.sr = IOIN(); return r.spread; } bool TMC2224Stepper::step() { TMC2224_n::IOIN_t r{0}; r.sr = IOIN(); return r.step; } bool TMC2224Stepper::sel_a() { TMC2224_n::IOIN_t r{0}; r.sr = IOIN(); return r.sel_a; } bool TMC2224Stepper::dir() { TMC2224_n::IOIN_t r{0}; r.sr = IOIN(); return r.dir; } uint8_t TMC2224Stepper::version() { TMC2224_n::IOIN_t r{0}; r.sr = IOIN(); return r.version; } */ uint16_t TMC2208Stepper::FACTORY_CONF() { return read(FACTORY_CONF_register.address); } void TMC2208Stepper::FACTORY_CONF(uint16_t input) { FACTORY_CONF_register.sr = input; write(FACTORY_CONF_register.address, FACTORY_CONF_register.sr); } void TMC2208Stepper::fclktrim(uint8_t B){ FACTORY_CONF_register.fclktrim = B; write(FACTORY_CONF_register.address, FACTORY_CONF_register.sr); } void TMC2208Stepper::ottrim(uint8_t B) { FACTORY_CONF_register.ottrim = B; write(FACTORY_CONF_register.address, FACTORY_CONF_register.sr); } uint8_t TMC2208Stepper::fclktrim() { FACTORY_CONF_t r{0}; r.sr = FACTORY_CONF(); return r.fclktrim; } uint8_t TMC2208Stepper::ottrim() { FACTORY_CONF_t r{0}; r.sr = FACTORY_CONF(); return r.ottrim; } void TMC2208Stepper::VACTUAL(uint32_t input) { VACTUAL_register.sr = input; write(VACTUAL_register.address, VACTUAL_register.sr); } uint32_t TMC2208Stepper::VACTUAL() { return VACTUAL_register.sr; } uint32_t TMC2208Stepper::PWM_SCALE() { return read(TMC2208_n::PWM_SCALE_t::address); } uint8_t TMC2208Stepper::pwm_scale_sum() { TMC2208_n::PWM_SCALE_t r{0}; r.sr = PWM_SCALE(); return r.pwm_scale_sum; } int16_t TMC2208Stepper::pwm_scale_auto() { TMC2208_n::PWM_SCALE_t r{0}; r.sr = PWM_SCALE(); return r.pwm_scale_auto; // Not two's complement? 9nth bit determines sign /* uint32_t d = PWM_SCALE(); int16_t response = (d>>PWM_SCALE_AUTO_bp)&0xFF; if (((d&PWM_SCALE_AUTO_bm) >> 24) & 0x1) return -response; else return response; */ } // R: PWM_AUTO uint32_t TMC2208Stepper::PWM_AUTO() { return read(PWM_AUTO_t::address); } uint8_t TMC2208Stepper::pwm_ofs_auto() { PWM_AUTO_t r{0}; r.sr = PWM_AUTO(); return r.pwm_ofs_auto; } uint8_t TMC2208Stepper::pwm_grad_auto() { PWM_AUTO_t r{0}; r.sr = PWM_AUTO(); return r.pwm_grad_auto; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/TMC2208_bitfields.h ================================================ #pragma once #pragma pack(push, 1) namespace TMC2208_n { struct GCONF_t { constexpr static uint8_t address = 0x00; union { uint16_t sr : 10; struct { bool i_scale_analog : 1, internal_rsense : 1, en_spreadcycle : 1, shaft : 1, index_otpw : 1, index_step : 1, pdn_disable : 1, mstep_reg_select : 1, multistep_filt : 1, test_mode : 1; }; }; }; } namespace TMC2208_n { struct IOIN_t { constexpr static uint8_t address = 0x06; union { uint32_t sr; struct { bool enn : 1, : 1, ms1 : 1, ms2 : 1, diag : 1, : 1, pdn_uart : 1, step : 1, sel_a : 1, dir : 1; uint16_t : 14; uint8_t version : 8; }; }; }; } namespace TMC2224_n { struct IOIN_t { constexpr static uint8_t address = 0x06; union { uint32_t sr; struct { bool : 1, pdn_uart : 1, spread : 1, dir : 1, enn : 1, step : 1, ms1 : 1, ms2 : 1, sel_a : 1; uint16_t : 15; uint8_t version : 8; }; }; }; } struct FACTORY_CONF_t { constexpr static uint8_t address = 0x07; union { uint16_t sr; struct { uint8_t fclktrim : 5, : 3, ottrim : 2; }; }; }; namespace TMC2208_n { struct VACTUAL_t { constexpr static uint8_t address = 0x22; uint32_t sr; }; } struct MSCURACT_t { constexpr static uint8_t address = 0x6B; union { uint32_t sr : 25; struct { int16_t cur_a : 9, : 7, cur_b : 9; }; }; }; namespace TMC2208_n { struct CHOPCONF_t { constexpr static uint8_t address = 0x6C; union { uint32_t sr; struct { uint8_t toff : 4, hstrt : 3, hend : 4, : 4, tbl : 2; bool vsense : 1; uint8_t : 6, mres : 4; bool intpol : 1, dedge : 1, diss2g : 1, diss2vs : 1; }; }; }; struct PWMCONF_t { constexpr static uint8_t address = 0x70; union { uint32_t sr; struct { uint8_t pwm_ofs : 8, pwm_grad : 8, pwm_freq : 2; bool pwm_autoscale : 1, pwm_autograd : 1; uint8_t freewheel : 2, : 2, pwm_reg : 4, pwm_lim : 4; }; }; }; struct DRV_STATUS_t { constexpr static uint8_t address = 0x6F; union { uint32_t sr; struct { bool otpw : 1, ot : 1, s2ga : 1, s2gb : 1, s2vsa : 1, s2vsb : 1, ola : 1, olb : 1, t120 : 1, t143 : 1, t150 : 1, t157 : 1; uint8_t : 4, cs_actual : 5, : 3, : 6; bool stealth : 1, stst : 1; }; }; }; struct PWM_SCALE_t { constexpr static uint8_t address = 0x71; union { uint32_t sr; struct { uint8_t pwm_scale_sum : 8, : 8; int16_t pwm_scale_auto : 9; }; }; }; } #pragma pack(pop) ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/TMC2209Stepper.cpp ================================================ #include "TMCStepper.h" uint32_t TMC2209Stepper::IOIN() { return read(TMC2209_n::IOIN_t::address); } bool TMC2209Stepper::enn() { TMC2209_n::IOIN_t r{0}; r.sr = IOIN(); return r.enn; } bool TMC2209Stepper::ms1() { TMC2209_n::IOIN_t r{0}; r.sr = IOIN(); return r.ms1; } bool TMC2209Stepper::ms2() { TMC2209_n::IOIN_t r{0}; r.sr = IOIN(); return r.ms2; } bool TMC2209Stepper::diag() { TMC2209_n::IOIN_t r{0}; r.sr = IOIN(); return r.diag; } bool TMC2209Stepper::pdn_uart() { TMC2209_n::IOIN_t r{0}; r.sr = IOIN(); return r.pdn_uart; } bool TMC2209Stepper::step() { TMC2209_n::IOIN_t r{0}; r.sr = IOIN(); return r.step; } bool TMC2209Stepper::spread_en() { TMC2209_n::IOIN_t r{0}; r.sr = IOIN(); return r.spread_en;} bool TMC2209Stepper::dir() { TMC2209_n::IOIN_t r{0}; r.sr = IOIN(); return r.dir; } uint8_t TMC2209Stepper::version() { TMC2209_n::IOIN_t r{0}; r.sr = IOIN(); return r.version; } void TMC2209Stepper::push() { IHOLD_IRUN(IHOLD_IRUN_register.sr); TPOWERDOWN(TPOWERDOWN_register.sr); TPWMTHRS(TPWMTHRS_register.sr); GCONF(GCONF_register.sr); SLAVECONF(SLAVECONF_register.sr); VACTUAL(VACTUAL_register.sr); CHOPCONF(CHOPCONF_register.sr); PWMCONF(PWMCONF_register.sr); TCOOLTHRS(TCOOLTHRS_register.sr); } void TMC2209Stepper::SGTHRS(uint8_t input) { SGTHRS_register.sr = input; write(SGTHRS_register.address, SGTHRS_register.sr); } uint8_t TMC2209Stepper::SGTHRS() { return SGTHRS_register.sr; } // W: TCOOLTHRS uint32_t TMC2209Stepper::TCOOLTHRS() { return TCOOLTHRS_register.sr; } void TMC2209Stepper::TCOOLTHRS(uint32_t input) { TCOOLTHRS_register.sr = input; write(TCOOLTHRS_register.address, TCOOLTHRS_register.sr); } uint16_t TMC2209Stepper::SG_RESULT() { return read(TMC2209_n::SG_RESULT_t::address); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/TMC2209_bitfields.h ================================================ #pragma once #pragma pack(push, 1) namespace TMC2209_n { struct IOIN_t { constexpr static uint8_t address = 0x06; union { uint32_t sr; struct { bool enn : 1, : 1, ms1 : 1, ms2 : 1, diag : 1, : 1, pdn_uart : 1, step : 1, spread_en : 1, dir : 1; uint16_t : 14; uint8_t version : 8; }; }; }; struct SGTHRS_t { constexpr static uint8_t address = 0x40; uint8_t sr : 8; }; struct SG_RESULT_t { constexpr static uint8_t address = 0x41; uint16_t sr : 10; }; struct COOLCONF_t { constexpr static uint8_t address = 0x42; union { uint16_t sr; struct { uint8_t semin : 4, : 1, seup : 2, : 1, semax : 4, : 1, sedn : 2; bool seimin : 1; }; }; }; } //namespace ////////////////////////////////////////////////////// struct SLAVECONF_t { constexpr static uint8_t address = 0x03; union { uint16_t sr : 12; struct { uint8_t slaveaddr : 8; uint8_t senddelay : 4; }; }; }; struct PWM_AUTO_t { constexpr static uint8_t address = 0x72; union { uint32_t sr : 24; struct { uint8_t pwm_ofs_auto : 8, : 8, pwm_grad_auto : 8; }; }; }; struct GCONF_t { constexpr static uint8_t address = 0x00; union { uint32_t sr : 18; struct { bool i_scale_analog : 1, // 2130, 5130 internal_rsense : 1, // 2130, 5130 en_pwm_mode : 1, enc_commutation : 1, // 2130, 5130 shaft : 1, diag0_error : 1, diag0_otpw : 1, diag0_stall : 1, diag1_stall : 1, diag1_index : 1, diag1_onstate : 1, diag1_steps_skipped : 1, diag0_int_pushpull : 1, diag1_pushpull : 1, small_hysteresis : 1, stop_enable : 1, direct_mode : 1; }; struct { // TMC5160 bool recalibrate : 1, faststandstill : 1, : 1, multistep_filt : 1, : 3, diag0_step : 1, diag1_dir : 1, : 4, diag1_poscomp_pushpull : 1; }; }; }; struct IHOLD_IRUN_t { constexpr static uint8_t address = 0x10; union { uint32_t sr : 20; struct { uint8_t ihold : 5, : 3, irun : 5, : 3, iholddelay : 4; }; }; }; struct GSTAT_t { constexpr static uint8_t address = 0x01; union { uint8_t sr : 3; struct { bool reset : 1, drv_err : 1, uv_cp : 1; }; }; }; struct TPOWERDOWN_t { constexpr static uint8_t address = 0x11; uint8_t sr : 8; }; struct TPWMTHRS_t { constexpr static uint8_t address = 0x13; uint32_t sr : 20; }; struct TCOOLTHRS_t { constexpr static uint8_t address = 0x14; uint32_t sr : 20; }; struct THIGH_t { constexpr static uint8_t address = 0x15; uint32_t sr : 20; }; struct XDIRECT_t { constexpr static uint8_t address = 0x2D; union { uint32_t sr : 25; struct { int16_t coil_A : 9; int8_t : 7; int16_t coil_B : 9; }; }; }; struct VDCMIN_t { constexpr static uint8_t address = 0x33; uint32_t sr : 23; }; struct CHOPCONF_t { constexpr static uint8_t address = 0x6C; union { uint32_t sr : 32; struct { uint8_t toff : 4, hstrt : 3, hend : 4, : 1; bool disfdcc : 1, rndtf : 1, chm : 1; uint8_t tbl : 2; bool vsense : 1, vhighfs : 1, vhighchm : 1; uint8_t sync : 4, // 2130, 5130 mres : 4; bool intpol : 1, dedge : 1, diss2g : 1; }; struct { // TMC5160 uint32_t : 20; uint8_t tpfd : 4; // 5160 uint16_t : 7; bool diss2vs : 1; // TMC5160 only }; }; }; struct DCCTRL_t { constexpr static uint8_t address = 0x6E; union { uint32_t sr : 24; struct { uint16_t dc_time : 10, : 6; uint8_t dc_sg : 8; }; }; }; struct PWMCONF_t { constexpr static uint8_t address = 0x70; union { uint32_t sr : 22; struct { uint8_t pwm_ampl : 8, pwm_grad : 8, pwm_freq : 2; bool pwm_autoscale : 1, pwm_symmetric : 1; uint8_t freewheel : 2; }; }; }; struct ENCM_CTRL_t { constexpr static uint8_t address = 0x72; union { uint8_t sr : 2; struct { bool inv : 1, maxspeed : 1; }; }; }; #pragma pack(pop) ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/TMCStepper.cpp ================================================ #include "TMCStepper.h" /* Requested current = mA = I_rms/1000 Equation for current: I_rms = (CS+1)/32 * V_fs/(R_sense+0.02ohm) * 1/sqrt(2) Solve for CS -> CS = 32*sqrt(2)*I_rms*(R_sense+0.02)/V_fs - 1 Example: vsense = 0b0 -> V_fs = 0.325V mA = 1640mA = I_rms/1000 = 1.64A R_sense = 0.10 Ohm -> CS = 32*sqrt(2)*1.64*(0.10+0.02)/0.325 - 1 = 26.4 CS = 26 */ uint16_t TMCStepper::cs2rms(uint8_t CS) { return (float)(CS+1)/32.0 * (vsense() ? 0.180 : 0.325)/(Rsense+0.02) / 1.41421 * 1000; } void TMCStepper::rms_current(uint16_t mA) { uint8_t CS = 32.0*1.41421*mA/1000.0*(Rsense+0.02)/0.325 - 1; // If Current Scale is too low, turn on high sensitivity R_sense and calculate again if (CS < 16) { vsense(true); CS = 32.0*1.41421*mA/1000.0*(Rsense+0.02)/0.180 - 1; } else { // If CS >= 16, turn off high_sense_r vsense(false); } if (CS > 31) CS = 31; irun(CS); ihold(CS*holdMultiplier); //val_mA = mA; } void TMCStepper::rms_current(uint16_t mA, float mult) { holdMultiplier = mult; rms_current(mA); } uint16_t TMCStepper::rms_current() { return cs2rms(irun()); } uint8_t TMCStepper::test_connection() { uint32_t drv_status = DRV_STATUS(); switch (drv_status) { case 0xFFFFFFFF: return 1; case 0: return 2; default: return 0; } } void TMCStepper::hysteresis_end(int8_t value) { hend(value+3); } int8_t TMCStepper::hysteresis_end() { return hend()-3; }; void TMCStepper::hysteresis_start(uint8_t value) { hstrt(value-1); } uint8_t TMCStepper::hysteresis_start() { return hstrt()+1; } void TMCStepper::microsteps(uint16_t ms) { switch(ms) { case 256: mres(0); break; case 128: mres(1); break; case 64: mres(2); break; case 32: mres(3); break; case 16: mres(4); break; case 8: mres(5); break; case 4: mres(6); break; case 2: mres(7); break; case 1: mres(8); break; default: break; } } uint16_t TMCStepper::microsteps() { switch(mres()) { case 0: return 256; case 1: return 128; case 2: return 64; case 3: return 32; case 4: return 16; case 5: return 8; case 6: return 4; case 7: return 2; case 8: return 1; } return 1; } void TMCStepper::blank_time(uint8_t value) { switch (value) { case 16: tbl(0b00); break; case 24: tbl(0b01); break; case 36: tbl(0b10); break; case 54: tbl(0b11); break; } } uint8_t TMCStepper::blank_time() { switch (tbl()) { case 0b00: return 16; case 0b01: return 24; case 0b10: return 36; case 0b11: return 54; } return 0; } /////////////////////////////////////////////////////////////////////////////////////// // R+C: GSTAT uint8_t TMCStepper::GSTAT() { return read(GSTAT_t::address); } void TMCStepper::GSTAT(uint8_t){ write(GSTAT_t::address, 0b111); } bool TMCStepper::reset() { GSTAT_t r; r.sr = GSTAT(); return r.reset; } bool TMCStepper::drv_err() { GSTAT_t r; r.sr = GSTAT(); return r.drv_err; } bool TMCStepper::uv_cp() { GSTAT_t r; r.sr = GSTAT(); return r.uv_cp; } /////////////////////////////////////////////////////////////////////////////////////// // W: TPOWERDOWN uint8_t TMCStepper::TPOWERDOWN() { return TPOWERDOWN_register.sr; } void TMCStepper::TPOWERDOWN(uint8_t input) { TPOWERDOWN_register.sr = input; write(TPOWERDOWN_register.address, TPOWERDOWN_register.sr); } /////////////////////////////////////////////////////////////////////////////////////// // R: TSTEP uint32_t TMCStepper::TSTEP() { return read(TSTEP_t::address); } /////////////////////////////////////////////////////////////////////////////////////// // W: TPWMTHRS uint32_t TMCStepper::TPWMTHRS() { return TPWMTHRS_register.sr; } void TMCStepper::TPWMTHRS(uint32_t input) { TPWMTHRS_register.sr = input; write(TPWMTHRS_register.address, TPWMTHRS_register.sr); } uint16_t TMCStepper::MSCNT() { return read(MSCNT_t::address); } uint32_t TMCStepper::MSCURACT() { return read(MSCURACT_t::address); } int16_t TMCStepper::cur_a() { MSCURACT_t r{0}; r.sr = MSCURACT(); int16_t value = r.cur_a; if (value > 255) value -= 512; return value; } int16_t TMCStepper::cur_b() { MSCURACT_t r{0}; r.sr = MSCURACT(); int16_t value = r.cur_b; if (value > 255) value -= 512; return value; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/TMCStepper.h ================================================ #include "mbed.h" #include #include "../SoftwareSerial/SoftwareSerial.h" #include "../pin/pin.h" //#include "TMC2130_bitfields.h" //#include "TMC2160_bitfields.h" //#include "TMC5130_bitfields.h" //#include "TMC5160_bitfields.h" #include "TMC2208_bitfields.h" #include "TMC2209_bitfields.h" //#include "TMC2660_bitfields.h" #define INIT_REGISTER(REG) REG##_t REG##_register = REG##_t #define INIT2208_REGISTER(REG) TMC2208_n::REG##_t REG##_register = TMC2208_n::REG##_t #define SET_ALIAS(TYPE, DRIVER, NEW, ARG, OLD) TYPE (DRIVER::*NEW)(ARG) = &DRIVER::OLD #define TMCSTEPPER_VERSION 0x000701 // v0.7.1 class TMCStepper { public: uint16_t cs2rms(uint8_t CS); void rms_current(uint16_t mA); void rms_current(uint16_t mA, float mult); uint16_t rms_current(); void hold_multiplier(float val) { holdMultiplier = val; } float hold_multiplier() { return holdMultiplier; } uint8_t test_connection(); // Helper functions void microsteps(uint16_t ms); uint16_t microsteps(); void blank_time(uint8_t value); uint8_t blank_time(); void hysteresis_end(int8_t value); int8_t hysteresis_end(); void hysteresis_start(uint8_t value); uint8_t hysteresis_start(); // R+WC: GSTAT void GSTAT( uint8_t input); uint8_t GSTAT(); bool reset(); bool drv_err(); bool uv_cp(); // W: IHOLD_IRUN void IHOLD_IRUN( uint32_t input); uint32_t IHOLD_IRUN(); void ihold( uint8_t B); void irun( uint8_t B); void iholddelay( uint8_t B); uint8_t ihold(); uint8_t irun(); uint8_t iholddelay(); // W: TPOWERDOWN uint8_t TPOWERDOWN(); void TPOWERDOWN( uint8_t input); // R: TSTEP uint32_t TSTEP(); // W: TPWMTHRS uint32_t TPWMTHRS(); void TPWMTHRS( uint32_t input); // R: MSCNT uint16_t MSCNT(); // R: MSCURACT uint32_t MSCURACT(); int16_t cur_a(); int16_t cur_b(); Timer tmcTimer; protected: TMCStepper(float RS) : Rsense(RS) {}; INIT_REGISTER(IHOLD_IRUN){{.sr=0}}; // 32b INIT_REGISTER(TPOWERDOWN){.sr=0}; // 8b INIT_REGISTER(TPWMTHRS){.sr=0}; // 32b static constexpr uint8_t TMC_READ = 0x00, TMC_WRITE = 0x80; struct TSTEP_t { constexpr static uint8_t address = 0x12; }; struct MSCNT_t { constexpr static uint8_t address = 0x6A; }; virtual void write(uint8_t, uint32_t) = 0; virtual uint32_t read(uint8_t) = 0; virtual void vsense(bool) = 0; virtual bool vsense(void) = 0; virtual uint32_t DRV_STATUS() = 0; virtual void hend(uint8_t) = 0; virtual uint8_t hend() = 0; virtual void hstrt(uint8_t) = 0; virtual uint8_t hstrt() = 0; virtual void mres(uint8_t) = 0; virtual uint8_t mres() = 0; virtual void tbl(uint8_t) = 0; virtual uint8_t tbl() = 0; const float Rsense; float holdMultiplier = 0.5; }; class TMC2208Stepper : public TMCStepper { public: TMC2208Stepper(std::string SWRXpin, std::string SWTXpin, float RS) : TMC2208Stepper(SWRXpin, SWTXpin, RS, TMC2208_SLAVE_ADDR) {} SoftwareSerial * SWSerial = nullptr; void defaults(); void push(); void begin(); void beginSerial(uint32_t baudrate) __attribute__((weak)); bool isEnabled(); // RW: GCONF void GCONF(uint32_t input); void I_scale_analog(bool B); void internal_Rsense(bool B); void en_spreadCycle(bool B); void shaft(bool B); void index_otpw(bool B); void index_step(bool B); void pdn_disable(bool B); void mstep_reg_select(bool B); void multistep_filt(bool B); uint32_t GCONF(); bool I_scale_analog(); bool internal_Rsense(); bool en_spreadCycle(); bool shaft(); bool index_otpw(); bool index_step(); bool pdn_disable(); bool mstep_reg_select(); bool multistep_filt(); // R: IFCNT uint8_t IFCNT(); // W: SLAVECONF void SLAVECONF(uint16_t input); uint16_t SLAVECONF(); void senddelay(uint8_t B); uint8_t senddelay(); // W: OTP_PROG void OTP_PROG(uint16_t input); // R: OTP_READ uint32_t OTP_READ(); // R: IOIN uint32_t IOIN(); bool enn(); bool ms1(); bool ms2(); bool diag(); bool pdn_uart(); bool step(); bool sel_a(); bool dir(); uint8_t version(); // RW: FACTORY_CONF void FACTORY_CONF(uint16_t input); uint16_t FACTORY_CONF(); void fclktrim(uint8_t B); void ottrim(uint8_t B); uint8_t fclktrim(); uint8_t ottrim(); // W: VACTUAL void VACTUAL(uint32_t input); uint32_t VACTUAL(); // RW: CHOPCONF void CHOPCONF(uint32_t input); void toff(uint8_t B); void hstrt(uint8_t B); void hend(uint8_t B); void tbl(uint8_t B); void vsense(bool B); void mres(uint8_t B); void intpol(bool B); void dedge(bool B); void diss2g(bool B); void diss2vs(bool B); uint32_t CHOPCONF(); uint8_t toff(); uint8_t hstrt(); uint8_t hend(); uint8_t tbl(); bool vsense(); uint8_t mres(); bool intpol(); bool dedge(); bool diss2g(); bool diss2vs(); // R: DRV_STATUS uint32_t DRV_STATUS(); bool otpw(); bool ot(); bool s2ga(); bool s2gb(); bool s2vsa(); bool s2vsb(); bool ola(); bool olb(); bool t120(); bool t143(); bool t150(); bool t157(); uint16_t cs_actual(); bool stealth(); bool stst(); // RW: PWMCONF void PWMCONF(uint32_t input); void pwm_ofs(uint8_t B); void pwm_grad(uint8_t B); void pwm_freq(uint8_t B); void pwm_autoscale(bool B); void pwm_autograd(bool B); void freewheel(uint8_t B); void pwm_reg(uint8_t B); void pwm_lim(uint8_t B); uint32_t PWMCONF(); uint8_t pwm_ofs(); uint8_t pwm_grad(); uint8_t pwm_freq(); bool pwm_autoscale(); bool pwm_autograd(); uint8_t freewheel(); uint8_t pwm_reg(); uint8_t pwm_lim(); // R: PWM_SCALE uint32_t PWM_SCALE(); uint8_t pwm_scale_sum(); int16_t pwm_scale_auto(); // R: PWM_AUTO (0x72) uint32_t PWM_AUTO(); uint8_t pwm_ofs_auto(); uint8_t pwm_grad_auto(); uint16_t bytesWritten = 0; float Rsense = 0.11; bool CRCerror = false; protected: INIT2208_REGISTER(GCONF) {{.sr=0}}; INIT_REGISTER(SLAVECONF) {{.sr=0}}; INIT_REGISTER(FACTORY_CONF) {{.sr=0}}; INIT2208_REGISTER(VACTUAL) {.sr=0}; INIT2208_REGISTER(CHOPCONF) {{.sr=0}}; INIT2208_REGISTER(PWMCONF) {{.sr=0}}; struct IFCNT_t { constexpr static uint8_t address = 0x02; }; struct OTP_PROG_t { constexpr static uint8_t address = 0x04; }; struct OTP_READ_t { constexpr static uint8_t address = 0x05; }; //SoftwareSerial * SWSerial = nullptr; TMC2208Stepper(std::string SWRXpin, std::string SWTXpin, float RS, uint8_t addr); std::string SWTXpin; std::string SWRXpin; DigitalOut* debug1; DigitalOut* debug2; int available(); void preWriteCommunication(); void preReadCommunication(); int16_t serial_read(); uint8_t serial_write(const uint8_t data); void postWriteCommunication(); void postReadCommunication(); void write(uint8_t, uint32_t); uint32_t read(uint8_t); const uint8_t slave_address; uint8_t calcCRC(uint8_t datagram[], uint8_t len); static constexpr uint8_t TMC2208_SYNC = 0x05, TMC2208_SLAVE_ADDR = 0x00; static constexpr uint8_t replyDelay = 2; //ms static constexpr uint8_t abort_window = 5; static constexpr uint8_t max_retries = 2; uint64_t _sendDatagram(uint8_t [], const uint8_t, uint16_t); }; class TMC2209Stepper : public TMC2208Stepper { public: TMC2209Stepper(std::string SWRXpin, std::string SWTXpin, float RS, uint8_t addr) : TMC2208Stepper(SWRXpin, SWTXpin, RS, addr) {} void push(); // R: IOIN uint32_t IOIN(); bool enn(); bool ms1(); bool ms2(); bool diag(); bool pdn_uart(); bool step(); bool spread_en(); bool dir(); uint8_t version(); // W: TCOOLTHRS uint32_t TCOOLTHRS(); void TCOOLTHRS(uint32_t input); // W: SGTHRS void SGTHRS(uint8_t B); uint8_t SGTHRS(); // R: SG_RESULT uint16_t SG_RESULT(); // W: COOLCONF void COOLCONF(uint16_t B); uint16_t COOLCONF(); void semin(uint8_t B); void seup(uint8_t B); void semax(uint8_t B); void sedn(uint8_t B); void seimin(bool B); uint8_t semin(); uint8_t seup(); uint8_t semax(); uint8_t sedn(); bool seimin(); protected: INIT_REGISTER(TCOOLTHRS){.sr=0}; TMC2209_n::SGTHRS_t SGTHRS_register{.sr=0}; TMC2209_n::COOLCONF_t COOLCONF_register{{.sr=0}}; }; ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/TMCStepper/TMC_MACROS.h ================================================ #pragma once #define DEBUG_PRINT(CFG, VAL) Serial.print(CFG); Serial.print('('); Serial.print(VAL, HEX); Serial.println(')') //#define WRITE_REG(R) write(R##_register.address, R##_register.sr) //#define READ_REG(R) read(R##_register.address) ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/.hg/branch ================================================ default ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/.hg/cache/branch2-base ================================================ d4c8fe4d9b29d4e5614620b0820a49d31087b512 0 d4c8fe4d9b29d4e5614620b0820a49d31087b512 o default ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/.hg/cache/rbc-names-v1 ================================================ default ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/.hg/cache/tags2-visible ================================================ 0 d4c8fe4d9b29d4e5614620b0820a49d31087b512 ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/.hg/hgrc ================================================ # example repository config (see 'hg help config' for more info) [paths] mbed-studio-cache = c:\Users\tanya\AppData\Local\Mbed Studio\library-cache\os.mbed.com\teams\WIZnet\code\WIZnetInterface-OS5 default = http://os.mbed.com/teams/WIZnet/code/WIZnetInterface-OS5/ # path aliases to other clones of this repo in URLs or filesystem paths # (see 'hg help config.paths' for more info) # # default:pushurl = ssh://jdoe@example.net/hg/jdoes-fork # my-fork = ssh://jdoe@example.net/hg/jdoes-fork # my-clone = /home/jdoe/jdoes-clone [ui] # name and email (local to this repository, optional), e.g. # username = Jane Doe ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/.hg/requires ================================================ dotencode fncache generaldelta revlogv1 sparserevlog store ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/.hg/store/fncache ================================================ data/Socket/DNSClient.h.i data/arch/int/W7500x_toe.cpp.i data/Socket/TCPSocketServer.h.i data/Socket/TCPSocketConnection.cpp.i data/arch/ext/W5500.cpp.i data/arch/ext/W5500.h.i data/Socket/DHCPClient.h.i data/Socket/TCPSocketServer.cpp.i data/Socket/WIZnet_UDPSocket.cpp.i data/Socket/TCPSocketConnection.h.i data/WIZnetInterface.h.i data/arch/int/W7500x_toe.h.i data/Socket/WIZnet_Socket.h.i data/Socket/WIZnet_Socket.cpp.i data/Socket/Endpoint.h.i data/Socket/DNSClient.cpp.i data/WIZnetInterface.cpp.i data/Socket/Endpoint.cpp.i data/eth_arch.h.i data/Socket/DHCPClient.cpp.i data/Socket/WIZnet_UDPSocket.h.i data/Socket/dnsname.h.i data/Socket/pico_string.h.i ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/DHCPClient.cpp ================================================ // DHCPClient.cpp 2013/4/10 #include "mbed.h" #include "mbed_debug.h" #include "WIZnet_UDPSocket.h" #include "DHCPClient.h" #define DBG_DHCP 0 #if DBG_DHCP #define DBG(...) do{debug("[%s:%d]", __PRETTY_FUNCTION__,__LINE__);debug(__VA_ARGS__);} while(0); #define DBG_HEX(A,B) do{debug("[%s:%d]\r\n", __PRETTY_FUNCTION__,__LINE__);debug_hex(A,B);} while(0); #else #define DBG(...) while(0); #define DBG_HEX(A,B) while(0); #endif int DHCPClient::discover() { m_pos = 0; const uint8_t header[] = {0x01,0x01,0x06,0x00}; add_buf((uint8_t*)header, sizeof(header)); uint32_t x = time(NULL) + rand(); xid[0] = x>>24; xid[1] = x>>16; xid[2] = x>>8; xid[3] = x; add_buf(xid, 4); fill_buf(20, 0x00); add_buf(chaddr, 6); fill_buf(10+192, 0x00); const uint8_t options[] = {0x63,0x82,0x53,0x63, // magic cookie 53,1,DHCPDISCOVER, // DHCP option 53: DHCP Discover 55,4,1,3,15,6, 255}; add_buf((uint8_t*)options, sizeof(options)); return m_pos; } int DHCPClient::request() { m_pos = 0; const uint8_t header[] = {0x01,0x01,0x06,0x00}; add_buf((uint8_t*)header, sizeof(header)); add_buf(xid, 4); fill_buf(12, 0x00); add_buf(siaddr, 4); fill_buf(4, 0x00); // giaddr add_buf(chaddr, 6); fill_buf(10+192, 0x00); const uint8_t options[] = {0x63,0x82,0x53,0x63, // magic cookie 53,1,DHCPREQUEST, // DHCP option 53: DHCP Request 55,4,1,3,15,6, // DHCP option 55: }; add_buf((uint8_t*)options, sizeof(options)); add_option(50, yiaddr, 4); add_option(54, siaddr, 4); add_option(255); return m_pos; } int DHCPClient::offer(uint8_t buf[], int size) { memcpy(yiaddr, buf+DHCP_OFFSET_YIADDR, 4); memcpy(siaddr, buf+DHCP_OFFSET_SIADDR, 4); uint8_t *p; int msg_type = -1; p = buf + DHCP_OFFSET_OPTIONS; while(*p != 255 && p < (buf+size)) { uint8_t code = *p++; if (code == 0) { // Pad Option continue; } int len = *p++; DBG("DHCP option: %d\r\n", code); DBG_HEX(p, len); switch(code) { case 53: msg_type = *p; break; case 1: memcpy(netmask, p, 4); // Subnet mask address break; case 3: memcpy(gateway, p, 4); // Gateway IP address break; case 6: // DNS server memcpy(dnsaddr, p, 4); break; case 51: // IP lease time break; case 54: // DHCP server memcpy(siaddr, p, 4); break; } p += len; } return msg_type; } bool DHCPClient::verify(uint8_t buf[], int len) { if (len < DHCP_OFFSET_OPTIONS) { return false; } if (buf[DHCP_OFFSET_OP] != 0x02) { return false; } if (memcmp(buf+DHCP_OFFSET_XID, xid, 4) != 0) { return false; } return true; } void DHCPClient::callback() { Endpoint host; int recv_len = m_udp->receiveFrom(host, (char*)m_buf, sizeof(m_buf)); if (recv_len < 0) { return; } if (!verify(m_buf, recv_len)) { return; } int r = offer(m_buf, recv_len); if (r == DHCPOFFER) { int send_size = request(); m_udp->sendTo(m_server, (char*)m_buf, send_size); } else if (r == DHCPACK) { exit_flag = true; } } void DHCPClient::add_buf(uint8_t c) { m_buf[m_pos++] = c; } void DHCPClient::add_buf(uint8_t* buf, int len) { for(int i = 0; i < len; i++) { add_buf(buf[i]); } } void DHCPClient::fill_buf(int len, uint8_t data) { while(len-- > 0) { add_buf(data); } } void DHCPClient::add_option(uint8_t code, uint8_t* buf, int len) { add_buf(code); if (len > 0) { add_buf((uint8_t)len); add_buf(buf, len); } } int DHCPClient::setup(int timeout_ms) { eth = WIZnet_Chip::getInstance(); if (eth == NULL) { return -1; } eth->reg_rd_mac(SHAR, chaddr); int interval_ms = 5*1000; // 5000msec if (timeout_ms < interval_ms) { interval_ms = timeout_ms; } m_udp = new WIZnet_UDPSocket; m_udp->init(); m_udp->set_blocking(false); eth->reg_wr(SIPR, 0x00000000); // local ip "0.0.0.0" m_udp->bind(68); // local port m_server.set_address("255.255.255.255", 67); // DHCP broadcast exit_flag = false; int err = 0; int seq = 0; int send_size; while(!exit_flag) { switch(seq) { case 0: m_retry = 0; seq++; break; case 1: send_size = discover(); m_udp->sendTo(m_server, (char*)m_buf, send_size); m_interval.reset(); m_interval.start(); seq++; break; case 2: callback(); if (m_interval.read_ms() > interval_ms) { DBG("m_retry: %d\n", m_retry); if (++m_retry >= (timeout_ms/interval_ms)) { err = -1; exit_flag = true; } seq--; } break; } } DBG("m_retry: %d, m_interval: %d\n", m_retry, m_interval.read_ms()); delete m_udp; return err; } DHCPClient::DHCPClient() { } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/DHCPClient.h ================================================ // DHCPClient.h 2013/4/10 #ifndef DHCPCLIENT_H #define DHCPCLIENT_H #include "eth_arch.h" #include "WIZnet_UDPSocket.h" #define DHCP_OFFSET_OP 0 #define DHCP_OFFSET_XID 4 #define DHCP_OFFSET_YIADDR 16 #define DHCP_OFFSET_SIADDR 20 #define DHCP_OFFSET_OPTIONS 240 #define DHCP_MAX_PACKET_SIZE 600 // DHCP Message Type #define DHCPDISCOVER 1 #define DHCPOFFER 2 #define DHCPREQUEST 3 #define DHCPDECLINE 4 #define DHCPACK 5 #define DHCPNAK 6 #define DHCPRELEASE 7 #define DHCPINFORM 8 class DHCPClient { public: DHCPClient(); int setup(int timeout_ms = 15*1000); uint8_t chaddr[6]; // MAC uint8_t yiaddr[4]; // IP uint8_t dnsaddr[4]; // DNS uint8_t gateway[4]; uint8_t netmask[4]; uint8_t siaddr[4]; private: int discover(); int request(); int offer(uint8_t buf[], int size); void add_buf(uint8_t* buf, int len); void fill_buf(int len, uint8_t data = 0x00); void add_buf(uint8_t c); void add_option(uint8_t code, uint8_t* buf = NULL, int len = 0); bool verify(uint8_t buf[], int len); void callback(); WIZnet_UDPSocket* m_udp; Endpoint m_server; uint8_t xid[4]; bool exit_flag; Timer m_interval; int m_retry; uint8_t m_buf[DHCP_MAX_PACKET_SIZE]; int m_pos; WIZnet_Chip* eth; }; #endif //DHCPCLIENT_H ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/DNSClient.cpp ================================================ // DNSClient.cpp 2013/8/27 #include "mbed.h" #include "mbed_debug.h" #include "DNSClient.h" #include "WIZnet_UDPSocket.h" #include "dnsname.h" #include "eth_arch.h" #define DBG_DNS 0 #if DBG_DNS #define DBG2(...) do{debug("[DNS]%p %d %s ", this,__LINE__,__PRETTY_FUNCTION__); debug(__VA_ARGS__); } while(0); #else #define DBG2(...) while(0); #endif DNSClient::DNSClient(const char* hostname) : m_state(MYNETDNS_START), m_udp(NULL) { m_hostname = hostname; } DNSClient::DNSClient(Endpoint* pHost) : m_state(MYNETDNS_START), m_udp(NULL) { } DNSClient::~DNSClient() { if (m_udp) { delete m_udp; } } void DNSClient::callback() { uint8_t buf[512]; Endpoint host; int len = m_udp->receiveFrom(host, (char*)buf, sizeof(buf)); if (len < 0) { return; } if (memcmp(buf+0, m_id, 2) != 0) { //verify return; } int rcode = response(buf, len); if (rcode == 0) { m_state = MYNETDNS_OK; } else { m_state = MYNETDNS_NOTFOUND; } } int DNSClient::response(uint8_t buf[], int size) { int rcode = buf[3] & 0x0f; if (rcode != 0) { return rcode; } int qdcount = buf[4]<<8|buf[5]; int ancount = buf[6]<<8|buf[7]; int pos = 12; while(qdcount-- > 0) { dnsname qname(buf); pos = qname.decode(pos); // qname pos += 4; // qtype qclass } while(ancount-- > 0) { dnsname name(buf); pos = name.decode(pos); // name int type = buf[pos]<<8|buf[pos+1]; pos += 8; // type class TTL int rdlength = buf[pos]<<8|buf[pos+1]; pos += 2; int rdata_pos = pos; pos += rdlength; if (type == 1) { // A record ip = (buf[rdata_pos]<<24) | (buf[rdata_pos+1]<<16) | (buf[rdata_pos+2]<<8) | buf[rdata_pos+3]; } #if DBG_DNS printf("%s", name.str.c_str()); if (type == 1) { printf(" A %d.%d.%d.%d\n", buf[rdata_pos],buf[rdata_pos+1],buf[rdata_pos+2],buf[rdata_pos+3]); } else if (type == 5) { dnsname rdname(buf); rdname.decode(rdata_pos); printf(" CNAME %s\n", rdname.str.c_str()); } else { printf(" TYPE:%d", type); printfBytes(" RDATA:", &buf[rdata_pos], rdlength); } #endif } return rcode; } int DNSClient::query(uint8_t buf[], int size, const char* hostname) { const uint8_t header[] = { 0x00,0x00,0x01,0x00, // id=0x0000 QR=0 rd=1 opcode=0 rcode=0 0x00,0x01,0x00,0x00, // qdcount=1 ancount=0 0x00,0x00,0x00,0x00};// nscount=0 arcount=0 const uint8_t tail[] = {0x00,0x01,0x00,0x01}; // qtype=A qclass=IN memcpy(buf, header, sizeof(header)); int t = rand(); m_id[0] = t>>8; m_id[1] = t; memcpy(buf, m_id, 2); dnsname qname(buf); int pos = qname.encode(sizeof(header), (char*)hostname); memcpy(buf+pos, tail, sizeof(tail)); pos += sizeof(tail); return pos; } void DNSClient::resolve(const char* hostname) { if (m_udp == NULL) { m_udp = new WIZnet_UDPSocket; } m_udp->init(); m_udp->set_blocking(false); Endpoint server; server.set_address("8.8.8.8", 53); // DNS m_udp->bind(rand()&0x7fff); uint8_t buf[256]; int size = query(buf, sizeof(buf), hostname); #if DBG_DNS printf("hostname:[%s]\n", hostname); printHex(buf, size); #endif m_udp->sendTo(server, (char*)buf, size); m_interval.reset(); m_interval.start(); } void DNSClient::poll() { #if DBG_DNS printf("%p m_state: %d, m_udp: %p\n", this, m_state, m_udp); wait_ms(400); #endif switch(m_state) { case MYNETDNS_START: m_retry = 0; resolve(m_hostname); m_state = MYNETDNS_PROCESSING; break; case MYNETDNS_PROCESSING: break; case MYNETDNS_NOTFOUND: break; case MYNETDNS_ERROR: break; case MYNETDNS_OK: DBG2("m_retry=%d, m_interval=%d\n", m_retry, m_interval.read_ms()); break; } if (m_interval.read_ms() > 1000) { m_interval.stop(); DBG2("timeout m_retry=%d\n", m_retry); if (++m_retry >= 2) { m_state = MYNETDNS_ERROR; } else { resolve(m_hostname); m_state = MYNETDNS_PROCESSING; } } } bool DNSClient::lookup(const char* hostname) { m_hostname = hostname; m_state = MYNETDNS_START; while(1) { poll(); callback(); if (m_state != MYNETDNS_PROCESSING) { break; } } return m_state == MYNETDNS_OK; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/DNSClient.h ================================================ // DNSClient.h 2013/4/5 #pragma once #include "WIZnet_UDPSocket.h" class DNSClient { public: DNSClient(const char* hostname = NULL); DNSClient(Endpoint* pHost); virtual ~DNSClient(); bool lookup(const char* hostname = NULL); uint32_t ip; protected: void poll(); void callback(); int response(uint8_t buf[], int size); int query(uint8_t buf[], int size, const char* hostname); void resolve(const char* hostname); uint8_t m_id[2]; Timer m_interval; int m_retry; const char* m_hostname; private: enum MyNetDnsState { MYNETDNS_START, MYNETDNS_PROCESSING, //Req has not completed MYNETDNS_NOTFOUND, MYNETDNS_ERROR, MYNETDNS_OK }; MyNetDnsState m_state; WIZnet_UDPSocket *m_udp; }; ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/Endpoint.cpp ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "WIZnet_Socket.h" #include "Endpoint.h" Endpoint::Endpoint() { //printf("reset_address\r\n"); reset_address(); } Endpoint::~Endpoint() {} void Endpoint::reset_address(void) { _ipAddress[0] = '\0'; _port = 0; } int Endpoint::set_address(const char* host, const int port) { //Resolve DNS address or populate hard-coded IP address WIZnet_Chip* eth = WIZnet_Chip::getInstance(); if (eth == NULL) { error("Endpoint constructor error: no WIZnet chip instance available!\r\n"); return -1; } uint32_t addr; if (!eth->gethostbyname(host, &addr)) { error("DNS error : Cannot get url from DNS server\r\n"); return -1; } snprintf(_ipAddress, sizeof(_ipAddress), "%d.%d.%d.%d", (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, addr&0xff); _port = port; return 0; } char* Endpoint::get_address() { return _ipAddress; } int Endpoint::get_port() { return _port; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/Endpoint.h ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef ENDPOINT_H #define ENDPOINT_H #include "eth_arch.h" class WIZnet_UDPSocket; /** IP Endpoint (address, port) */ class Endpoint { friend class WIZnet_UDPSocket; public: /** IP Endpoint (address, port) */ Endpoint(void); ~Endpoint(void); /** Reset the address of this endpoint */ void reset_address(void); /** Set the address of this endpoint \param host The endpoint address (it can either be an IP Address or a hostname that will be resolved with DNS). \param port The endpoint port \return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS). */ int set_address(const char* host, const int port); /** Get the IP address of this endpoint \return The IP address of this endpoint. */ char* get_address(void); /** Get the port of this endpoint \return The port of this endpoint */ int get_port(void); protected: char _ipAddress[16]; int _port; }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/TCPSocketConnection.cpp ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "TCPSocketConnection.h" #include using std::memset; using std::memcpy; // not a big code. // refer from EthernetInterface by mbed official driver TCPSocketConnection::TCPSocketConnection() : _is_connected(false) { } int TCPSocketConnection::connect(const char* host, const int port) { if (_sock_fd < 0) { _sock_fd = eth->new_socket(); if (_sock_fd < 0) { return -1; } } if (set_address(host, port) != 0) { return -1; } if (!eth->connect(_sock_fd, get_address(), port)) { return -1; } set_blocking(false); // add code refer from EthernetInterface. _is_connected = true; return 0; } bool TCPSocketConnection::is_connected(void) { // force update recent state. _is_connected = eth->is_connected(_sock_fd); return _is_connected; } int TCPSocketConnection::send(char* data, int length) { if((_sock_fd<0) || !(eth->is_connected(_sock_fd))) return -1; int size = eth->wait_writeable(_sock_fd, _blocking ? -1 : _timeout); if (size < 0) return -1; if (size > length) size = length; return eth->send(_sock_fd, data, size); } // -1 if unsuccessful, else number of bytes written int TCPSocketConnection::send_all(char* data, int length) { int writtenLen = 0; if(_sock_fd<0) return -1; while (writtenLen < length) { if(!(eth->is_connected(_sock_fd))) return -1; int size = eth->wait_writeable(_sock_fd, _blocking ? -1 : _timeout); if (size < 0) { return -1; } if (size > (length-writtenLen)) { size = (length-writtenLen); } int ret = eth->send(_sock_fd, data + writtenLen, size); if (ret < 0) { return -1; } writtenLen += ret; } return writtenLen; } // -1 if unsuccessful, else number of bytes received int TCPSocketConnection::receive(char* data, int length) { if((_sock_fd<0) || !(eth->is_connected(_sock_fd))) return -1; int size = eth->wait_readable(_sock_fd, _blocking ? -1 : _timeout); if (size < 0) { return -1; } if (size > length) { size = length; } return eth->recv(_sock_fd, data, size); } // -1 if unsuccessful, else number of bytes received int TCPSocketConnection::receive_all(char* data, int length) { if(_sock_fd<0) return -1; int readLen = 0; while (readLen < length) { if(!(eth->is_connected(_sock_fd))) return -1; int size = eth->wait_readable(_sock_fd, _blocking ? -1 :_timeout); if (size <= 0) { break; } if (size > (length - readLen)) { size = length - readLen; } int ret = eth->recv(_sock_fd, data + readLen, size); if (ret < 0) { return -1; } readLen += ret; } return readLen; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/TCPSocketConnection.h ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef TCPSOCKETCONNECTION_H #define TCPSOCKETCONNECTION_H #include "WIZnet_Socket.h" #include "Endpoint.h" /** TCP socket connection */ class TCPSocketConnection: public WIZnet_Socket, public Endpoint { friend class TCPSocketServer; public: /** TCP socket connection */ TCPSocketConnection(); /** Connects this TCP socket to the server \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS. \param port The host's port to connect to. \return 0 on success, -1 on failure. */ int connect(const char* host, const int port); /** Check if the socket is connected \return true if connected, false otherwise. */ bool is_connected(void); /** Send data to the remote host. \param data The buffer to send to the host. \param length The length of the buffer to send. \return the number of written bytes on success (>=0) or -1 on failure */ int send(char* data, int length); /** Send all the data to the remote host. \param data The buffer to send to the host. \param length The length of the buffer to send. \return the number of written bytes on success (>=0) or -1 on failure */ int send_all(char* data, int length); /** Receive data from the remote host. \param data The buffer in which to store the data received from the host. \param length The maximum length of the buffer. \return the number of received bytes on success (>=0) or -1 on failure */ int receive(char* data, int length); /** Receive all the data from the remote host. \param data The buffer in which to store the data received from the host. \param length The maximum length of the buffer. \return the number of received bytes on success (>=0) or -1 on failure */ int receive_all(char* data, int length); private: bool _is_connected; }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/TCPSocketServer.cpp ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "TCPSocketServer.h" TCPSocketServer::TCPSocketServer() {} // Server initialization int TCPSocketServer::bind(int port) { // set the listen_port for next connection. listen_port = port; if (_sock_fd < 0) { _sock_fd = eth->new_socket(); if (_sock_fd < 0) { return -1; } } // set TCP protocol eth->setProtocol(_sock_fd, WIZnet_Chip::TCP); // set local port eth->sreg(_sock_fd, Sn_PORT, port); // connect the network eth->scmd(_sock_fd, WIZnet_Chip::OPEN); return 0; } int TCPSocketServer::listen(int backlog) { if (_sock_fd < 0) { return -1; } if (backlog != 1) { return -1; } eth->scmd(_sock_fd, WIZnet_Chip::LISTEN); return 0; } int TCPSocketServer::accept(TCPSocketConnection& connection) { if (_sock_fd < 0) { return -1; } Timer t; t.reset(); t.start(); while(1) { if (t.read_ms() > _timeout && _blocking == false) { return -1; } if (eth->sreg(_sock_fd, Sn_SR) == WIZnet_Chip::SOCK_ESTABLISHED) { break; } } uint32_t ip = eth->sreg(_sock_fd, Sn_DIPR); char host[16]; snprintf(host, sizeof(host), "%d.%d.%d.%d", (ip>>24)&0xff, (ip>>16)&0xff, (ip>>8)&0xff, ip&0xff); uint16_t port = eth->sreg(_sock_fd, Sn_DPORT); // change this server socket to connection socket. connection._sock_fd = _sock_fd; connection._is_connected = true; connection.set_address(host, port); // and then, for the next connection, server socket should be assigned new one. _sock_fd = -1; // want to assign new available _sock_fd. if(bind(listen_port) < 0) { // modified by Patrick Pollet error("No more socket for listening, bind error"); return -1; } else { //return -1; if(listen(1) < 0) { // modified by Patrick Pollet error("No more socket for listening, listen error"); return -1; } } return 0; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/TCPSocketServer.h ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef TCPSOCKETSERVER_H #define TCPSOCKETSERVER_H #include "WIZnet_Socket.h" #include "TCPSocketConnection.h" /** TCP Server. */ class TCPSocketServer : public WIZnet_Socket { public: /** Instantiate a TCP Server. */ TCPSocketServer(); /** Bind a socket to a specific port. \param port The port to listen for incoming connections on. \return 0 on success, -1 on failure. */ int bind(int port); /** Start listening for incoming connections. \param backlog number of pending connections that can be queued up at any one time [Default: 1]. \return 0 on success, -1 on failure. */ int listen(int backlog=1); /** Accept a new connection. \param connection A TCPSocketConnection instance that will handle the incoming connection. \return 0 on success, -1 on failure. */ int accept(TCPSocketConnection& connection); private : int listen_port; }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/WIZnet_Socket.cpp ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "WIZnet_Socket.h" WIZnet_Socket::WIZnet_Socket() : _sock_fd(-1),_blocking(true), _timeout(1500) { eth = WIZnet_Chip::getInstance(); if (eth == NULL) { error("Socket constructor error: no W7500 instance available!\r\n"); } } void WIZnet_Socket::set_blocking(bool blocking, unsigned int timeout) { _blocking = blocking; _timeout = timeout; } int WIZnet_Socket::close() { // add this code refer from EthernetInterface. // update by Patrick Pollet int res; res = eth->close(_sock_fd); _sock_fd = -1; return (res)? 0: -1; } WIZnet_Socket::~WIZnet_Socket() { close(); //Don't want to leak } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/WIZnet_Socket.h ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef WIZnet_SOCKET_H_ #define WIZnet_SOCKET_H_ #include "eth_arch.h" #define htons(x) __REV16(x) #define ntohs(x) __REV16(x) #define htonl(x) __REV(x) #define ntohl(x) __REV(x) /** Socket file descriptor and select wrapper */ class WIZnet_Socket { public: /** Socket */ WIZnet_Socket(); /** Set blocking or non-blocking mode of the socket and a timeout on blocking socket operations \param blocking true for blocking mode, false for non-blocking mode. \param timeout timeout in ms [Default: (1500)ms]. */ //void set_blocking(bool blocking, unsigned int timeout=1500); void set_blocking(bool blocking, unsigned int timeout=1); /** Close the socket file descriptor */ int close(); ~WIZnet_Socket(); protected: int _sock_fd; bool _blocking; int _timeout; WIZnet_Chip* eth; }; #endif /* SOCKET_H_ */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/WIZnet_UDPSocket.cpp ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "WIZnet_UDPSocket.h" static int udp_local_port; WIZnet_UDPSocket::WIZnet_UDPSocket() { } // After init function, bind() should be called. int WIZnet_UDPSocket::init(void) { if (_sock_fd < 0) { _sock_fd = eth->new_socket(); } if (eth->setProtocol(_sock_fd, WIZnet_Chip::UDP) == false) return -1; return 0; } // Server initialization int WIZnet_UDPSocket::bind(int port) { if (_sock_fd < 0) { _sock_fd = eth->new_socket(); if (_sock_fd < 0) { return -1; } } // set local port if (port != 0) { eth->sreg(_sock_fd, Sn_PORT, port); } else { udp_local_port++; eth->sreg(_sock_fd, Sn_PORT, udp_local_port); } // set udp protocol eth->setProtocol(_sock_fd, WIZnet_Chip::UDP); eth->scmd(_sock_fd, WIZnet_Chip::OPEN); return 0; } // -1 if unsuccessful, else number of bytes written int WIZnet_UDPSocket::sendTo(Endpoint &remote, char *packet, int length) { int size = eth->wait_writeable(_sock_fd, _blocking ? -1 : _timeout, length-1); if (size < 0) { return -1; } confEndpoint(remote); int ret = eth->send(_sock_fd, packet, length); return ret; } // -1 if unsuccessful, else number of bytes received int WIZnet_UDPSocket::receiveFrom(Endpoint &remote, char *buffer, int length) { uint8_t info[8]; int size = eth->wait_readable(_sock_fd, _blocking ? -1 : _timeout, sizeof(info)); if (size < 0) { return -1; } eth->recv(_sock_fd, (char*)info, sizeof(info)); readEndpoint(remote, info); int udp_size = info[6]<<8|info[7]; //TEST_ASSERT(udp_size <= (size-sizeof(info))); if (udp_size > (size-sizeof(info))) { return -1; } /* Perform Length check here to prevent buffer overrun */ /* fixed by Sean Newton (https://developer.mbed.org/users/SeanNewton/) */ if (udp_size > length) { //printf("udp_size: %d\n",udp_size); return -1; } return eth->recv(_sock_fd, buffer, udp_size); } void WIZnet_UDPSocket::confEndpoint(Endpoint & ep) { char * host = ep.get_address(); // set remote host eth->sreg_ip(_sock_fd, Sn_DIPR, host); // set remote port eth->sreg(_sock_fd, Sn_DPORT, ep.get_port()); } void WIZnet_UDPSocket::readEndpoint(Endpoint & ep, uint8_t info[]) { char addr[17]; snprintf(addr, sizeof(addr), "%d.%d.%d.%d", info[0], info[1], info[2], info[3]); uint16_t port = info[4]<<8|info[5]; ep.set_address(addr, port); } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/WIZnet_UDPSocket.h ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef WIZnet_UDPSOCKET_H #define WIZnet_UDPSOCKET_H #include "Endpoint.h" #include "WIZnet_Socket.h" /** UDP Socket */ class WIZnet_UDPSocket: public WIZnet_Socket { public: /** Instantiate an UDP Socket. */ WIZnet_UDPSocket(); /** Init the UDP Client Socket without binding it to any specific port \return 0 on success, -1 on failure. */ int init(void); /** Bind a UDP Server Socket to a specific port \param port The port to listen for incoming connections on \return 0 on success, -1 on failure. */ int bind(int port = -1); /** Send a packet to a remote endpoint \param remote The remote endpoint \param packet The packet to be sent \param length The length of the packet to be sent \return the number of written bytes on success (>=0) or -1 on failure */ int sendTo(Endpoint &remote, char *packet, int length); /** Receive a packet from a remote endpoint \param remote The remote endpoint \param buffer The buffer for storing the incoming packet data. If a packet is too long to fit in the supplied buffer, excess bytes are discarded \param length The length of the buffer \return the number of received bytes on success (>=0) or -1 on failure */ int receiveFrom(Endpoint &remote, char *buffer, int length); private: void confEndpoint(Endpoint & ep); void readEndpoint(Endpoint & ep, uint8_t info[]); }; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/dnsname.h ================================================ // dnsname.h 2013/8/27 #pragma once //#include #include "pico_string.h" class dnsname { public: uint8_t *buf; pico_string str; dnsname(uint8_t *s) { buf = s; } int decode(int pos) { while(1) { int len = buf[pos++]; if (len == 0x00) { break; } if ((len&0xc0) == 0xc0) { //compress int offset = (len&0x3f)<<8|buf[pos]; decode(offset); return pos+1; } if (!str.empty()) { str.append("."); } str.append((const char*)(buf+pos), len); pos += len; } return pos; } int encode(int pos, char* s) { while(*s) { char *f = strchr(s, '.'); if (f == NULL) { int len = strlen(s); buf[pos++] = len; memcpy(buf+pos, s, len); pos += len; break; } int len = f - s; buf[pos++] = len; memcpy(buf+pos, s, len); s = f+1; pos += len; } buf[pos++] = 0x00; return pos; } }; ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/Socket/pico_string.h ================================================ // pico_string.h 2013/8/27 #pragma once class pico_string { public: pico_string(){ _len = 0; _buf = (char*)malloc(1); if (_buf) { _buf[0] = '\0'; } } ~pico_string() { if (_buf) { free(_buf); } } bool empty() { return _len == 0; } void append(const char* s, int len) { if (_buf == NULL) { return; } char* p = (char*)malloc(_len+len+1); if (p == NULL) { return; } memcpy(p, _buf, _len); memcpy(p+_len, s, len); p[_len+len] = '\0'; free(_buf); _buf = p; } void append(const char* s) { append(s, strlen(s)); } char* c_str() { if (_buf) { return _buf; } return ""; } private: char* _buf; int _len; }; ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/WIZnetInterface.cpp ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "WIZnetInterface.h" #include "DHCPClient.h" #if (not defined TARGET_WIZwiki_W7500) && (not defined TARGET_WIZwiki_W7500P) && (not defined TARGET_WIZwiki_W7500ECO) WIZnetInterface::WIZnetInterface(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset) : WIZnet_Chip(mosi, miso, sclk, cs, reset) { ip_set = false; } WIZnetInterface::WIZnetInterface(SPI* spi, PinName cs, PinName reset) : WIZnet_Chip(spi, cs, reset) { ip_set = false; } #endif int WIZnetInterface::init() { dhcp = true; reset(); return 0; } int WIZnetInterface::init(uint8_t * mac) { dhcp = true; // for (int i =0; i < 6; i++) this->mac[i] = mac[i]; // reset(); return 0; } int WIZnetInterface::init(uint8_t * mac, const char* ip, const char* mask, const char* gateway) { dhcp = false; // for (int i =0; i < 6; i++) this->mac[i] = mac[i]; // this->ip = str_to_ip(ip); strcpy(ip_string, ip); ip_set = true; this->netmask = str_to_ip(mask); this->gateway = str_to_ip(gateway); reset(); // @Jul. 8. 2014 add code. should be called to write chip. setmac(); setip(); return 0; } // Connect Bring the interface up, start DHCP if needed. int WIZnetInterface::connect() { if (dhcp) { int r = IPrenew(); if (r < 0) { return r; } } if (WIZnet_Chip::setip() == false) return -1; return 0; } // Disconnect Bring the interface down. int WIZnetInterface::disconnect() { //if (WIZnet_Chip::disconnect() == false) return -1; return 0; } char* WIZnetInterface::getIPAddress() { uint32_t ip = reg_rd(SIPR); snprintf(ip_string, sizeof(ip_string), "%d.%d.%d.%d", (uint8_t)((ip>>24)&0xff), (uint8_t)((ip>>16)&0xff), (uint8_t)((ip>>8)&0xff), (uint8_t)(ip&0xff)); return ip_string; } char* WIZnetInterface::getNetworkMask() { uint32_t ip = reg_rd(SUBR); snprintf(mask_string, sizeof(mask_string), "%d.%d.%d.%d", (uint8_t)((ip>>24)&0xff), (uint8_t)((ip>>16)&0xff), (uint8_t)((ip>>8)&0xff), (uint8_t)(ip&0xff)); return mask_string; } char* WIZnetInterface::getGateway() { uint32_t ip = reg_rd(GAR); snprintf(gw_string, sizeof(gw_string), "%d.%d.%d.%d", (uint8_t)((ip>>24)&0xff), (uint8_t)((ip>>16)&0xff), (uint8_t)((ip>>8)&0xff), (uint8_t)(ip&0xff)); return gw_string; } char* WIZnetInterface::getMACAddress() { uint8_t mac[6]; reg_rd_mac(SHAR, mac); snprintf(mac_string, sizeof(mac_string), "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); //ethernet_address(mac_string); return mac_string; } int WIZnetInterface::IPrenew(int timeout_ms) { DHCPClient dhcp; int err = dhcp.setup(timeout_ms); if (err == (-1)) { return -1; } // printf("Connected, IP: %d.%d.%d.%d\n", dhcp.yiaddr[0], dhcp.yiaddr[1], dhcp.yiaddr[2], dhcp.yiaddr[3]); ip = (dhcp.yiaddr[0] <<24) | (dhcp.yiaddr[1] <<16) | (dhcp.yiaddr[2] <<8) | dhcp.yiaddr[3]; gateway = (dhcp.gateway[0]<<24) | (dhcp.gateway[1]<<16) | (dhcp.gateway[2]<<8) | dhcp.gateway[3]; netmask = (dhcp.netmask[0]<<24) | (dhcp.netmask[1]<<16) | (dhcp.netmask[2]<<8) | dhcp.netmask[3]; dnsaddr = (dhcp.dnsaddr[0]<<24) | (dhcp.dnsaddr[1]<<16) | (dhcp.dnsaddr[2]<<8) | dhcp.dnsaddr[3]; return 0; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/WIZnetInterface.h ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once #include "eth_arch.h" /** Interface using Wiznet chip to connect to an IP-based network * */ class WIZnetInterface: public WIZnet_Chip { public: #if (not defined TARGET_WIZwiki_W7500) && (not defined TARGET_WIZwiki_W7500P) && (not defined TARGET_WIZwiki_W7500ECO) /** * Constructor * * \param mosi mbed pin to use for SPI * \param miso mbed pin to use for SPI * \param sclk mbed pin to use for SPI * \param cs chip select of the WIZnet_Chip * \param reset reset pin of the WIZnet_Chip */ WIZnetInterface(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset); WIZnetInterface(SPI* spi, PinName cs, PinName reset); #endif /** Initialize the interface with DHCP. * Initialize the interface and configure it to use DHCP (no connection at this point). * \return 0 on success, a negative number on failure */ int init(); //With DHCP int init(uint8_t * mac); //With DHCP /** Initialize the interface with a static IP address. * Initialize the interface and configure it with the following static configuration (no connection at this point). * \param ip the IP address to use * \param mask the IP address mask * \param gateway the gateway to use * \return 0 on success, a negative number on failure */ int init(uint8_t * mac, const char* ip, const char* mask, const char* gateway); /** Connect * Bring the interface up, start DHCP if needed. * \return 0 on success, a negative number on failure */ int connect(); /** Disconnect * Bring the interface down * \return 0 on success, a negative number on failure */ int disconnect(); /** Get IP address & MAC address * * @ returns ip address */ char* getIPAddress(); char* getNetworkMask(); char* getGateway(); char* getMACAddress(); int IPrenew(int timeout_ms = 15*1000); private: char ip_string[20]; char mask_string[20]; char gw_string[20]; char mac_string[20]; bool ip_set; }; #include "TCPSocketConnection.h" #include "TCPSocketServer.h" #include "WIZnet_UDPSocket.h" ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/arch/ext/W5500.cpp ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "eth_arch.h" #if (not defined TARGET_WIZwiki_W7500) && (not defined TARGET_WIZwiki_W7500P) && (not defined TARGET_WIZwiki_W7500ECO) #include "mbed.h" #include "mbed_debug.h" #include "DNSClient.h" //Debug is disabled by default #if 0 #define DBG(...) do{debug("%p %d %s ", this,__LINE__,__PRETTY_FUNCTION__); debug(__VA_ARGS__); } while(0); //#define DBG(x, ...) debug("[W5500:DBG]"x"\r\n", ##__VA_ARGS__); #define WARN(x, ...) debug("[W5500:WARN]"x"\r\n", ##__VA_ARGS__); #define ERR(x, ...) debug("[W5500:ERR]"x"\r\n", ##__VA_ARGS__); #else #define DBG(x, ...) #define WARN(x, ...) #define ERR(x, ...) #endif #if 1 #define INFO(x, ...) debug("[W5500:INFO]"x"\r\n", ##__VA_ARGS__); #else #define INFO(x, ...) #endif #define DBG_SPI 0 WIZnet_Chip* WIZnet_Chip::inst; WIZnet_Chip::WIZnet_Chip(PinName mosi, PinName miso, PinName sclk, PinName _cs, PinName _reset): cs(_cs), reset_pin(_reset) { spi = new SPI(mosi, miso, sclk); cs = 1; reset_pin = 1; inst = this; sock_any_port = SOCK_ANY_PORT_NUM; } WIZnet_Chip::WIZnet_Chip(SPI* spi, PinName _cs, PinName _reset): cs(_cs), reset_pin(_reset) { this->spi = spi; cs = 1; reset_pin = 1; inst = this; sock_any_port = SOCK_ANY_PORT_NUM; } bool WIZnet_Chip::setmac() { for (int i =0; i < 6; i++) reg_wr(SHAR+i, mac[i]); return true; } // Set the IP bool WIZnet_Chip::setip() { reg_wr(SIPR, ip); reg_wr(GAR, gateway); reg_wr(SUBR, netmask); return true; } bool WIZnet_Chip::setProtocol(int socket, Protocol p) { if (socket < 0) { return false; } sreg(socket, Sn_MR, p); return true; } bool WIZnet_Chip::connect(int socket, const char * host, int port, int timeout_ms) { if (socket < 0) { return false; } sreg(socket, Sn_MR, TCP); scmd(socket, OPEN); sreg_ip(socket, Sn_DIPR, host); sreg(socket, Sn_DPORT, port); sreg(socket, Sn_PORT, new_port()); scmd(socket, CONNECT); Timer t; t.reset(); t.start(); while(!is_connected(socket)) { if (t.read_ms() > timeout_ms) { return false; } } return true; } bool WIZnet_Chip::gethostbyname(const char* host, uint32_t* ip) { uint32_t addr = str_to_ip(host); char buf[17]; snprintf(buf, sizeof(buf), "%d.%d.%d.%d", (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, addr&0xff); if (strcmp(buf, host) == 0) { *ip = addr; return true; } DNSClient client; if(client.lookup(host)) { *ip = client.ip; return true; } return false; } bool WIZnet_Chip::disconnect() { return true; } bool WIZnet_Chip::is_connected(int socket) { /* if (sreg(socket, Sn_SR) == SOCK_ESTABLISHED) { return true; } */ uint8_t tmpSn_SR; tmpSn_SR = sreg(socket, Sn_SR); // packet sending is possible, when state is SOCK_CLOSE_WAIT. if ((tmpSn_SR == SOCK_ESTABLISHED) || (tmpSn_SR == SOCK_CLOSE_WAIT)) { return true; } return false; } // Reset the chip & set the buffer void WIZnet_Chip::reset() { #if defined(USE_WIZ550IO_MAC) //read the MAC address inside the module reg_rd_mac(SHAR, mac); #endif // hw reset reset_pin = 1; reset_pin = 0; wait_us(500); // 500us (w5500) reset_pin = 1; wait_ms(400); // 400ms (w5500) #if defined(USE_WIZ550IO_MAC) // write MAC address inside the WZTOE MAC address register reg_wr_mac(SHAR, mac); #endif // set RX and TX buffer size #if 0 for (int socket = 0; socket < MAX_SOCK_NUM; socket++) { sreg(socket, Sn_RXBUF_SIZE, 2); sreg(socket, Sn_TXBUF_SIZE, 2); } #endif } bool WIZnet_Chip::close(int socket) { if (socket < 0) { return false; } // if not connected, return if (sreg(socket, Sn_SR) == SOCK_CLOSED) { return true; } if (sreg(socket, Sn_MR) == TCP) { scmd(socket, DISCON); } scmd(socket, CLOSE); sreg(socket, Sn_IR, 0xff); return true; } int WIZnet_Chip::wait_readable(int socket, int wait_time_ms, int req_size) { if (socket < 0) { return -1; } Timer t; t.reset(); t.start(); while(1) { //int size = sreg(socket, Sn_RX_RSR); // during the reading Sn_RX_RXR, it has the possible change of this register. // so read twice and get same value then use size information. int size, size2; do { size = sreg(socket, Sn_RX_RSR); size2 = sreg(socket, Sn_RX_RSR); } while (size != size2); if (size > req_size) { return size; } break; //if (wait_time_ms != (-1) && t.read_ms() > wait_time_ms) { // break; //} } return -1; } int WIZnet_Chip::wait_writeable(int socket, int wait_time_ms, int req_size) { if (socket < 0) { return -1; } Timer t; t.reset(); t.start(); while(1) { //int size = sreg(socket, Sn_TX_FSR); // during the reading Sn_TX_FSR, it has the possible change of this register. // so read twice and get same value then use size information. int size, size2; do { size = sreg(socket, Sn_TX_FSR); size2 = sreg(socket, Sn_TX_FSR); } while (size != size2); if (size > req_size) { return size; } break; //if (wait_time_ms != (-1) && t.read_ms() > wait_time_ms) { // break; //} } return -1; } int WIZnet_Chip::send(int socket, const char * str, int len) { if (socket < 0) { return -1; } uint16_t ptr = sreg(socket, Sn_TX_WR); uint8_t cntl_byte = (0x14 + (socket << 5)); spi_write(ptr, cntl_byte, (uint8_t*)str, len); sreg(socket, Sn_TX_WR, ptr + len); scmd(socket, SEND); uint8_t tmp_Sn_IR; while (( (tmp_Sn_IR = sreg(socket, Sn_IR)) & INT_SEND_OK) != INT_SEND_OK) { // @Jul.10, 2014 fix contant name, and udp sendto function. switch (sreg(socket, Sn_SR)) { case SOCK_CLOSED : close(socket); return 0; //break; case SOCK_UDP : // ARP timeout is possible. if ((tmp_Sn_IR & INT_TIMEOUT) == INT_TIMEOUT) { sreg(socket, Sn_IR, INT_TIMEOUT); return 0; } break; default : break; } } /* while ((sreg(socket, Sn_IR) & INT_SEND_OK) != INT_SEND_OK) { if (sreg(socket, Sn_SR) == CLOSED) { close(socket); return 0; } } */ sreg(socket, Sn_IR, INT_SEND_OK); return len; } int WIZnet_Chip::recv(int socket, char* buf, int len) { if (socket < 0) { return -1; } uint16_t ptr = sreg(socket, Sn_RX_RD); uint8_t cntl_byte = (0x18 + (socket << 5)); spi_read(ptr, cntl_byte, (uint8_t*)buf, len); sreg(socket, Sn_RX_RD, ptr + len); scmd(socket, RECV); return len; } int WIZnet_Chip::new_socket() { for(int s = 0; s < MAX_SOCK_NUM; s++) { if (sreg(s, Sn_SR) == SOCK_CLOSED) { return s; } } return -1; } uint16_t WIZnet_Chip::new_port() { uint16_t port = rand(); port |= 49152; return port; } bool WIZnet_Chip::link(int wait_time_ms) { Timer t; t.reset(); t.start(); while(1) { int is_link = ethernet_link(); if (is_link) { return true; } if (wait_time_ms != (-1) && t.read_ms() > wait_time_ms) { break; } } return 0; } void WIZnet_Chip::set_link(PHYMode phymode) { int speed = -1; int duplex = 0; switch(phymode) { case AutoNegotiate : speed = -1; duplex = 0; break; case HalfDuplex10 : speed = 0; duplex = 0; break; case FullDuplex10 : speed = 0; duplex = 1; break; case HalfDuplex100 : speed = 1; duplex = 0; break; case FullDuplex100 : speed = 1; duplex = 1; break; } ethernet_set_link(speed, duplex); } void WIZnet_Chip::scmd(int socket, Command cmd) { sreg(socket, Sn_CR, cmd); while(sreg(socket, Sn_CR)); } void WIZnet_Chip::spi_write(uint16_t addr, uint8_t cb, const uint8_t *buf, uint16_t len) { cs = 0; spi->write(addr >> 8); spi->write(addr & 0xff); spi->write(cb); for(int i = 0; i < len; i++) { spi->write(buf[i]); } cs = 1; #if DBG_SPI debug("[SPI]W %04x(%02x %d)", addr, cb, len); for(int i = 0; i < len; i++) { debug(" %02x", buf[i]); if (i > 16) { debug(" ..."); break; } } debug("\r\n"); #endif } void WIZnet_Chip::spi_read(uint16_t addr, uint8_t cb, uint8_t *buf, uint16_t len) { cs = 0; spi->write(addr >> 8); spi->write(addr & 0xff); spi->write(cb); for(int i = 0; i < len; i++) { buf[i] = spi->write(0); } cs = 1; #if DBG_SPI debug("[SPI]R %04x(%02x %d)", addr, cb, len); for(int i = 0; i < len; i++) { debug(" %02x", buf[i]); if (i > 16) { debug(" ..."); break; } } debug("\r\n"); if ((addr&0xf0ff)==0x4026 || (addr&0xf0ff)==0x4003) { wait_ms(200); } #endif } uint32_t str_to_ip(const char* str) { uint32_t ip = 0; char* p = (char*)str; for(int i = 0; i < 4; i++) { ip |= atoi(p); p = strchr(p, '.'); if (p == NULL) { break; } ip <<= 8; p++; } return ip; } void printfBytes(char* str, uint8_t* buf, int len) { printf("%s %d:", str, len); for(int i = 0; i < len; i++) { printf(" %02x", buf[i]); } printf("\n"); } void printHex(uint8_t* buf, int len) { for(int i = 0; i < len; i++) { if ((i%16) == 0) { printf("%p", buf+i); } printf(" %02x", buf[i]); if ((i%16) == 15) { printf("\n"); } } printf("\n"); } void debug_hex(uint8_t* buf, int len) { for(int i = 0; i < len; i++) { if ((i%16) == 0) { debug("%p", buf+i); } debug(" %02x", buf[i]); if ((i%16) == 15) { debug("\n"); } } debug("\n"); } int WIZnet_Chip::ethernet_link(void) { int val = getPHYCFGR(); return (val&0x01); } void WIZnet_Chip::ethernet_set_link(int speed, int duplex) { uint32_t val=0; if((speed < 0) || (speed > 1)) { val = (PHYCFGR_OPMDC_ALLA)<<3; } else { val = (((speed&0x01)<<1)+ (duplex&0x01))<<3; } setPHYCFGR((uint8_t)(PHYCFGR_RST&(PHYCFGR_OPMD|val))); wait(0.2); setPHYCFGR((uint8_t)((~PHYCFGR_RST)|(PHYCFGR_OPMD|val))); wait(0.2); } void WIZnet_Chip::reg_rd_mac(uint16_t addr, uint8_t* data) { spi_read(addr, 0x00, data, 6); } void WIZnet_Chip::reg_wr_ip(uint16_t addr, uint8_t cb, const char* ip) { uint8_t buf[4]; char* p = (char*)ip; for(int i = 0; i < 4; i++) { buf[i] = atoi(p); p = strchr(p, '.'); if (p == NULL) { break; } p++; } spi_write(addr, cb, buf, sizeof(buf)); } void WIZnet_Chip::sreg_ip(int socket, uint16_t addr, const char* ip) { reg_wr_ip(addr, (0x0C + (socket << 5)), ip); } void WIZnet_Chip::reg_rd_ip_byte(uint16_t addr, uint8_t* data) { spi_read(addr, 0x00, data, 4); } void WIZnet_Chip::reg_wr_ip_byte(uint16_t addr, uint8_t* data) { spi_write(addr, 0x04, data, 4); } #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/arch/ext/W5500.h ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #pragma once #include "mbed.h" #include "mbed_debug.h" #define TEST_ASSERT(A) while(!(A)){debug("\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);}; #define DEFAULT_WAIT_RESP_TIMEOUT 500 #define SOCK_ERROR 0 #define SOCKERR_SOCKNUM (SOCK_ERROR - 1) ///< Invalid socket number #define SOCKERR_SOCKOPT (SOCK_ERROR - 2) ///< Invalid socket option #define SOCKERR_SOCKINIT (SOCK_ERROR - 3) ///< Socket is not initialized #define SOCKERR_SOCKCLOSED (SOCK_ERROR - 4) ///< Socket unexpectedly closed. #define SOCKERR_SOCKMODE (SOCK_ERROR - 5) ///< Invalid socket mode for socket operation. #define SOCKERR_SOCKFLAG (SOCK_ERROR - 6) ///< Invalid socket flag #define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///< Invalid socket status for socket operation. #define SOCKERR_ARG (SOCK_ERROR - 10) ///< Invalid argrument. #define SOCKERR_PORTZERO (SOCK_ERROR - 11) ///< Port number is zero #define SOCKERR_IPINVALID (SOCK_ERROR - 12) ///< Invalid IP address #define SOCKERR_TIMEOUT (SOCK_ERROR - 13) ///< Timeout occurred #define SOCKERR_DATALEN (SOCK_ERROR - 14) ///< Data length is zero or greater than buffer max size. #define SOCKERR_BUFFER (SOCK_ERROR - 15) ///< Socket buffer is not enough for data communication. #define SOCK_ANY_PORT_NUM 0xC000; #define MAX_SOCK_NUM 8 #define MR 0x0000 #define GAR 0x0001 #define SUBR 0x0005 #define SHAR 0x0009 #define SIPR 0x000f #define IR 0x0015 #define IMR 0x0016 #define SIR 0x0017 #define SIMR 0x0018 #define RTR 0x0019 #define RCR 0x001b #define UIPR 0x0028 #define UPORTR 0x002c #define PHYCFGR 0x002e // W5500 socket register #define Sn_MR 0x0000 #define Sn_CR 0x0001 #define Sn_IR 0x0002 #define Sn_SR 0x0003 #define Sn_PORT 0x0004 #define Sn_DHAR 0x0006 #define Sn_DIPR 0x000c #define Sn_DPORT 0x0010 #define Sn_RXBUF_SIZE 0x001e #define Sn_TXBUF_SIZE 0x001f #define Sn_TX_FSR 0x0020 #define Sn_TX_RD 0x0022 #define Sn_TX_WR 0x0024 #define Sn_RX_RSR 0x0026 #define Sn_RX_RD 0x0028 #define Sn_RX_WR 0x002a #define Sn_IMR 0x002c //Define for Socket Command register option value #define Sn_CR_OPEN 0x01 #define Sn_CR_LISTEN 0x02 #define Sn_CR_CONNECT 0x04 #define Sn_CR_DISCON 0x08 #define Sn_CR_CLOSE 0x10 #define Sn_CR_SEND 0x20 #define Sn_CR_SEND_MAC 0x21 #define Sn_CR_SEND_KEEP 0x22 #define Sn_CR_RECV 0x40 //Define for Socket Mode register option value #define Sn_MR_CLOSE 0x00 #define Sn_MR_TCP 0x01 #define Sn_MR_UDP 0x02 #define Sn_MR_MACRAW 0x04 #define Sn_MR_UCASTB 0x10 #define Sn_MR_ND 0x20 #define Sn_MR_BCASTB 0x40 #define Sn_MR_MULTI 0x80 #define Sn_IR_SENDOK 0x10 //Sn_IR values #define Sn_IR_TIMEOUT 0x08 #define Sn_IR_RECV 0x04 #define Sn_IR_DISCON 0x02 #define Sn_IR_CON 0x01 /* PHYCFGR register value */ #define PHYCFGR_RST ~(1<<7) //< For PHY reset, must operate AND mask. #define PHYCFGR_OPMD (1<<6) // Configre PHY with OPMDC value #define PHYCFGR_OPMDC_ALLA (7<<3) #define PHYCFGR_OPMDC_PDOWN (6<<3) #define PHYCFGR_OPMDC_NA (5<<3) #define PHYCFGR_OPMDC_100FA (4<<3) #define PHYCFGR_OPMDC_100F (3<<3) #define PHYCFGR_OPMDC_100H (2<<3) #define PHYCFGR_OPMDC_10F (1<<3) #define PHYCFGR_OPMDC_10H (0<<3) #define PHYCFGR_DPX_FULL (1<<2) #define PHYCFGR_DPX_HALF (0<<2) #define PHYCFGR_SPD_100 (1<<1) #define PHYCFGR_SPD_10 (0<<1) #define PHYCFGR_LNK_ON (1<<0) #define PHYCFGR_LNK_OFF (0<<0) //PHY status define #define PHY_CONFBY_HW 0 ///< Configured PHY operation mode by HW pin #define PHY_CONFBY_SW 1 ///< Configured PHY operation mode by SW register #define PHY_MODE_MANUAL 0 ///< Configured PHY operation mode with user setting. #define PHY_MODE_AUTONEGO 1 ///< Configured PHY operation mode with auto-negotiation #define PHY_SPEED_10 0 ///< Link Speed 10 #define PHY_SPEED_100 1 ///< Link Speed 100 #define PHY_DUPLEX_HALF 0 ///< Link Half-Duplex #define PHY_DUPLEX_FULL 1 ///< Link Full-Duplex #define PHY_LINK_OFF 0 ///< Link Off #define PHY_LINK_ON 1 ///< Link On #define PHY_POWER_NORM 0 ///< PHY power normal mode #define PHY_POWER_DOWN 1 ///< PHY power down mode enum PHYMode { AutoNegotiate = 0, HalfDuplex10 = 1, FullDuplex10 = 2, HalfDuplex100 = 3, FullDuplex100 = 4, }; class WIZnet_Chip { public: enum Protocol { CLOSED = 0, TCP = 1, UDP = 2, }; enum Command { OPEN = 0x01, LISTEN = 0x02, CONNECT = 0x04, DISCON = 0x08, CLOSE = 0x10, SEND = 0x20, SEND_MAC = 0x21, SEND_KEEP = 0x22, RECV = 0x40, }; enum Interrupt { INT_CON = 0x01, INT_DISCON = 0x02, INT_RECV = 0x04, INT_TIMEOUT = 0x08, INT_SEND_OK = 0x10, }; enum Status { SOCK_CLOSED = 0x00, SOCK_INIT = 0x13, SOCK_LISTEN = 0x14, SOCK_SYNSENT = 0x15, SOCK_ESTABLISHED = 0x17, SOCK_CLOSE_WAIT = 0x1c, SOCK_UDP = 0x22, }; uint16_t sock_any_port; /* * Constructor * * @param spi spi class * @param cs cs of the W5500 * @param reset reset pin of the W5500 */ WIZnet_Chip(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset); WIZnet_Chip(SPI* spi, PinName cs, PinName reset); /* * Set MAC Address to W5500 * * @return true if connected, false otherwise */ bool setmac(); /* * Set Network Informations (SrcIP, Netmask, Gataway) * * @return true if connected, false otherwise */ bool setip(); /* * Disconnect the connection * * @ returns true */ bool disconnect(); /* * Open a tcp connection with the specified host on the specified port * * @param host host (can be either an ip address or a name. If a name is provided, a dns request will be established) * @param port port * @ returns true if successful */ bool connect(int socket, const char * host, int port, int timeout_ms = 10*1000); /* * Set the protocol (UDP or TCP) * * @param p protocol * @ returns true if successful */ bool setProtocol(int socket, Protocol p); /* * Reset the W5500 */ void reset(); int wait_readable(int socket, int wait_time_ms, int req_size = 0); int wait_writeable(int socket, int wait_time_ms, int req_size = 0); /* * Check if an ethernet link is pressent or not. * * @returns true if successful */ bool link(int wait_time_ms= 3*1000); /* * Sets the speed and duplex parameters of an ethernet link. * * @returns true if successful */ void set_link(PHYMode phymode); /* * Check if a tcp link is active * * @returns true if successful */ bool is_connected(int socket); /* * Close a tcp connection * * @ returns true if successful */ bool close(int socket); /* * @param str string to be sent * @param len string length */ int send(int socket, const char * str, int len); int recv(int socket, char* buf, int len); /* * Return true if the module is using dhcp * * @returns true if the module is using dhcp */ bool isDHCP() { return dhcp; } bool gethostbyname(const char* host, uint32_t* ip); static WIZnet_Chip * getInstance() { return inst; }; int new_socket(); uint16_t new_port(); void scmd(int socket, Command cmd); template void sreg(int socket, uint16_t addr, T data) { reg_wr(addr, (0x0C + (socket << 5)), data); } template T sreg(int socket, uint16_t addr) { return reg_rd(addr, (0x08 + (socket << 5))); } template void reg_wr(uint16_t addr, T data) { return reg_wr(addr, 0x04, data); } template void reg_wr(uint16_t addr, uint8_t cb, T data) { uint8_t buf[sizeof(T)]; *reinterpret_cast(buf) = data; for(int i = 0; i < sizeof(buf)/2; i++) { // Little Endian to Big Endian uint8_t t = buf[i]; buf[i] = buf[sizeof(buf)-1-i]; buf[sizeof(buf)-1-i] = t; } spi_write(addr, cb, buf, sizeof(buf)); } template T reg_rd(uint16_t addr) { return reg_rd(addr, 0x00); } template T reg_rd(uint16_t addr, uint8_t cb) { uint8_t buf[sizeof(T)]; spi_read(addr, cb, buf, sizeof(buf)); for(int i = 0; i < sizeof(buf)/2; i++) { // Big Endian to Little Endian uint8_t t = buf[i]; buf[i] = buf[sizeof(buf)-1-i]; buf[sizeof(buf)-1-i] = t; } return *reinterpret_cast(buf); } void reg_rd_mac(uint16_t addr, uint8_t* data); /* { spi_read(addr, 0x00, data, 6); }*/ void reg_wr_ip(uint16_t addr, uint8_t cb, const char* ip); /* { uint8_t buf[4]; char* p = (char*)ip; for(int i = 0; i < 4; i++) { buf[i] = atoi(p); p = strchr(p, '.'); if (p == NULL) { break; } p++; } spi_write(addr, cb, buf, sizeof(buf)); } */ void sreg_ip(int socket, uint16_t addr, const char* ip); /* { reg_wr_ip(addr, (0x0C + (socket << 5)), ip); }*/ void reg_rd_ip_byte(uint16_t addr, uint8_t* data); /* { spi_read(addr, 0x00, data, 4); }*/ void reg_wr_ip_byte(uint16_t addr, uint8_t* data); /* { spi_write(addr, 0x04, data, 4); }*/ ///////////////////////////////// // Common Register I/O function // ///////////////////////////////// /** * @ingroup Common_register_access_function * @brief Set Mode Register * @param (uint8_t)mr The value to be set. * @sa getMR() */ void setMR(uint8_t mr) { reg_wr(MR,mr); } /** * @ingroup Common_register_access_function * @brief Get Mode Register * @return uint8_t. The value of Mode register. * @sa setMR() */ uint8_t getMR() { return reg_rd(MR); } /** * @ingroup Common_register_access_function * @brief Set gateway IP address * @param (uint8_t*)gar Pointer variable to set gateway IP address. It should be allocated 4 bytes. * @sa getGAR() */ void setGAR(uint8_t * gar) { reg_wr_ip_byte(GAR,gar); } /** * @ingroup Common_register_access_function * @brief Get gateway IP address * @param (uint8_t*)gar Pointer variable to get gateway IP address. It should be allocated 4 bytes. * @sa setGAR() */ void getGAR(uint8_t * gar) { reg_rd_ip_byte(GAR,gar); } /** * @ingroup Common_register_access_function * @brief Set subnet mask address * @param (uint8_t*)subr Pointer variable to set subnet mask address. It should be allocated 4 bytes. * @sa getSUBR() */ void setSUBR(uint8_t * subr) { reg_wr_ip_byte(SUBR, subr); } /** * @ingroup Common_register_access_function * @brief Get subnet mask address * @param (uint8_t*)subr Pointer variable to get subnet mask address. It should be allocated 4 bytes. * @sa setSUBR() */ void getSUBR(uint8_t * subr) { reg_rd_ip_byte(SUBR, subr); } /** * @ingroup Common_register_access_function * @brief Set local MAC address * @param (uint8_t*)shar Pointer variable to set local MAC address. It should be allocated 6 bytes. * @sa getSHAR() */ void setSHAR(uint8_t * shar) { reg_wr_mac(SHAR, shar); } /** * @ingroup Common_register_access_function * @brief Get local MAC address * @param (uint8_t*)shar Pointer variable to get local MAC address. It should be allocated 6 bytes. * @sa setSHAR() */ void getSHAR(uint8_t * shar) { reg_rd_mac(SHAR, shar); } /** * @ingroup Common_register_access_function * @brief Set local IP address * @param (uint8_t*)sipr Pointer variable to set local IP address. It should be allocated 4 bytes. * @sa getSIPR() */ void setSIPR(uint8_t * sipr) { reg_wr_ip_byte(SIPR, sipr); } /** * @ingroup Common_register_access_function * @brief Get local IP address * @param (uint8_t*)sipr Pointer variable to get local IP address. It should be allocated 4 bytes. * @sa setSIPR() */ void getSIPR(uint8_t * sipr) { reg_rd_ip_byte(SIPR, sipr); } /** * @ingroup Common_register_access_function * @brief Set @ref IR register * @param (uint8_t)ir Value to set @ref IR register. * @sa getIR() */ void setIR(uint8_t ir) { reg_wr(IR, (ir & 0xF0)); } /** * @ingroup Common_register_access_function * @brief Get @ref IR register * @return uint8_t. Value of @ref IR register. * @sa setIR() */ uint8_t getIR() { return reg_rd(IR & 0xF0); } /** * @ingroup Common_register_access_function * @brief Set @ref IMR register * @param (uint8_t)imr Value to set @ref IMR register. * @sa getIMR() */ void setIMR(uint8_t imr) { reg_wr(IMR, imr); } /** * @ingroup Common_register_access_function * @brief Get @ref IMR register * @return uint8_t. Value of @ref IMR register. * @sa setIMR() */ uint8_t getIMR() { return reg_rd(IMR); } /** * @ingroup Common_register_access_function * @brief Set @ref SIR register * @param (uint8_t)sir Value to set @ref SIR register. * @sa getSIR() */ void setSIR(uint8_t sir) { reg_wr(SIR, sir); } /** * @ingroup Common_register_access_function * @brief Get @ref SIR register * @return uint8_t. Value of @ref SIR register. * @sa setSIR() */ uint8_t getSIR() { return reg_rd(SIR); } /** * @ingroup Common_register_access_function * @brief Set @ref SIMR register * @param (uint8_t)simr Value to set @ref SIMR register. * @sa getSIMR() */ void setSIMR(uint8_t simr) { reg_wr(SIMR, simr); } /** * @ingroup Common_register_access_function * @brief Get @ref SIMR register * @return uint8_t. Value of @ref SIMR register. * @sa setSIMR() */ uint8_t getSIMR() { return reg_rd(SIMR); } /** * @ingroup Common_register_access_function * @brief Set @ref RTR register * @param (uint16_t)rtr Value to set @ref RTR register. * @sa getRTR() */ void setRTR(uint16_t rtr) { reg_wr(RTR, rtr); } /** * @ingroup Common_register_access_function * @brief Get @ref RTR register * @return uint16_t. Value of @ref RTR register. * @sa setRTR() */ uint16_t getRTR() { return reg_rd(RTR); } /** * @ingroup Common_register_access_function * @brief Set @ref RCR register * @param (uint8_t)rcr Value to set @ref RCR register. * @sa getRCR() */ void setRCR(uint8_t rcr) { reg_wr(RCR, rcr); } /** * @ingroup Common_register_access_function * @brief Get @ref RCR register * @return uint8_t. Value of @ref RCR register. * @sa setRCR() */ uint8_t getRCR() { return reg_rd(RCR); } //================================================== test done =========================================================== /** * @ingroup Common_register_access_function * @brief Set @ref PHYCFGR register * @param (uint8_t)phycfgr Value to set @ref PHYCFGR register. * @sa setPHYCFGR() */ void setPHYCFGR(uint8_t phycfgr) { reg_wr(PHYCFGR, phycfgr); } /** * @ingroup Common_register_access_function * @brief Get @ref PHYCFGR register * @return uint8_t. Value of @ref PHYCFGR register. * @sa getPHYCFGR() */ uint8_t getPHYCFGR() { return reg_rd(PHYCFGR); } ///////////////////////////////////// /////////////////////////////////// // Socket N register I/O function // /////////////////////////////////// /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_MR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint8_t)mr Value to set @ref Sn_MR * @sa getSn_MR() */ void setSn_MR(uint8_t sn, uint8_t mr) { sreg(sn, MR, mr); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_MR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint8_t. Value of @ref Sn_MR. * @sa setSn_MR() */ uint8_t getSn_MR(uint8_t sn) { return sreg(sn, Sn_MR); } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_CR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint8_t)cr Value to set @ref Sn_CR * @sa getSn_CR() */ void setSn_CR(uint8_t sn, uint8_t cr) { sreg(sn, Sn_CR, cr); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_CR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint8_t. Value of @ref Sn_CR. * @sa setSn_CR() */ uint8_t getSn_CR(uint8_t sn) { return sreg(sn, Sn_CR); } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_IR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint8_t)ir Value to set @ref Sn_IR * @sa getSn_IR() */ void setSn_IR(uint8_t sn, uint8_t ir) { sreg(sn, Sn_IR, (ir & 0x1F)); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_IR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint8_t. Value of @ref Sn_IR. * @sa setSn_IR() */ uint8_t getSn_IR(uint8_t sn) { return (sreg(sn, Sn_IR)) & 0x1F; } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_IMR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint8_t)imr Value to set @ref Sn_IMR * @sa getSn_IMR() */ void setSn_IMR(uint8_t sn, uint8_t imr) { sreg(sn, Sn_IMR, (imr & 0x1F)); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_IMR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint8_t. Value of @ref Sn_IMR. * @sa setSn_IMR() */ uint8_t getSn_IMR(uint8_t sn) { return (sreg(sn, Sn_IMR)) & 0x1F; } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_SR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint8_t. Value of @ref Sn_SR. */ uint8_t getSn_SR(uint8_t sn) { return sreg(sn, Sn_SR); } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_PORT register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint16_t)port Value to set @ref Sn_PORT. * @sa getSn_PORT() */ void setSn_PORT(uint8_t sn, uint16_t port) { sreg(sn, Sn_PORT, port ); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_PORT register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint16_t. Value of @ref Sn_PORT. * @sa setSn_PORT() */ uint16_t getSn_PORT(uint8_t sn) { return sreg(sn, Sn_PORT); } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_DHAR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint8_t*)dhar Pointer variable to set socket n destination hardware address. It should be allocated 6 bytes. * @sa getSn_DHAR() */ void setSn_DHAR(uint8_t sn, uint8_t * dhar) { spi_write(Sn_DHAR, (0x0C + (sn << 5)), dhar, 6); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_MR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint8_t*)dhar Pointer variable to get socket n destination hardware address. It should be allocated 6 bytes. * @sa setSn_DHAR() */ void getSn_DHAR(uint8_t sn, uint8_t * dhar) { spi_read(Sn_DHAR, (0x08 + (sn << 5)), dhar, 6); } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_DIPR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint8_t*)dipr Pointer variable to set socket n destination IP address. It should be allocated 4 bytes. * @sa getSn_DIPR() */ void setSn_DIPR(uint8_t sn, uint8_t * dipr) { spi_write(Sn_DIPR, (0x0C + (sn << 5)), dipr, 4); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_DIPR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint8_t*)dipr Pointer variable to get socket n destination IP address. It should be allocated 4 bytes. * @sa SetSn_DIPR() */ void getSn_DIPR(uint8_t sn, uint8_t * dipr) { spi_read(Sn_DIPR, (0x08 + (sn << 5)), dipr, 4); } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_DPORT register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint16_t)dport Value to set @ref Sn_DPORT * @sa getSn_DPORT() */ void setSn_DPORT(uint8_t sn, uint16_t dport) { sreg(sn, Sn_DPORT, dport); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_DPORT register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint16_t. Value of @ref Sn_DPORT. * @sa setSn_DPORT() */ uint16_t getSn_DPORT(uint8_t sn) { return sreg(sn, Sn_DPORT); } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_RXBUF_SIZE register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint8_t)rxbufsize Value to set @ref Sn_RXBUF_SIZE * @sa getSn_RXBUF_SIZE() */ void setSn_RXBUF_SIZE(uint8_t sn, uint8_t rxbufsize) { sreg(sn, Sn_RXBUF_SIZE ,rxbufsize); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_RXBUF_SIZE register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint8_t. Value of @ref Sn_RXBUF_SIZE. * @sa setSn_RXBUF_SIZE() */ uint8_t getSn_RXBUF_SIZE(uint8_t sn) { return sreg(sn, Sn_RXBUF_SIZE); } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_TXBUF_SIZE register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint8_t)txbufsize Value to set @ref Sn_TXBUF_SIZE * @sa getSn_TXBUF_SIZE() */ void setSn_TXBUF_SIZE(uint8_t sn, uint8_t txbufsize) { sreg(sn, Sn_TXBUF_SIZE, txbufsize); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_TXBUF_SIZE register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint8_t. Value of @ref Sn_TXBUF_SIZE. * @sa setSn_TXBUF_SIZE() */ uint8_t getSn_TXBUF_SIZE(uint8_t sn) { return sreg(sn, Sn_TXBUF_SIZE); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_TX_FSR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint16_t. Value of @ref Sn_TX_FSR. */ uint16_t getSn_TX_FSR(uint8_t sn) { return sreg(sn, Sn_TX_FSR); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_TX_RD register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint16_t. Value of @ref Sn_TX_RD. */ uint16_t getSn_TX_RD(uint8_t sn) { return sreg(sn, Sn_TX_RD); } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_TX_WR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint16_t)txwr Value to set @ref Sn_TX_WR * @sa GetSn_TX_WR() */ void setSn_TX_WR(uint8_t sn, uint16_t txwr) { sreg(sn, Sn_TX_WR, txwr); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_TX_WR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint16_t. Value of @ref Sn_TX_WR. * @sa setSn_TX_WR() */ uint16_t getSn_TX_WR(uint8_t sn) { return sreg(sn, Sn_TX_WR); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_RX_RSR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint16_t. Value of @ref Sn_RX_RSR. */ uint16_t getSn_RX_RSR(uint8_t sn) { return sreg(sn, Sn_RX_RSR); } /** * @ingroup Socket_register_access_function * @brief Set @ref Sn_RX_RD register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @param (uint16_t)rxrd Value to set @ref Sn_RX_RD * @sa getSn_RX_RD() */ void setSn_RX_RD(uint8_t sn, uint16_t rxrd) { sreg(sn, Sn_RX_RD, rxrd); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_RX_RD register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @regurn uint16_t. Value of @ref Sn_RX_RD. * @sa setSn_RX_RD() */ uint16_t getSn_RX_RD(uint8_t sn) { return sreg(sn, Sn_RX_RD); } /** * @ingroup Socket_register_access_function * @brief Get @ref Sn_RX_WR register * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint16_t. Value of @ref Sn_RX_WR. */ uint16_t getSn_RX_WR(uint8_t sn) { return sreg(sn, Sn_RX_WR); } ////////////////////////////////////// ///////////////////////////////////// // Sn_TXBUF & Sn_RXBUF IO function // ///////////////////////////////////// /** * @brief Gets the max buffer size of socket sn passed as parameter. * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint16_t. Value of Socket n RX max buffer size. */ uint16_t getSn_RxMAX(uint8_t sn) { return (getSn_RXBUF_SIZE(sn) << 10); } /** * @brief Gets the max buffer size of socket sn passed as parameters. * @param (uint8_t)sn Socket number. It should be 0 ~ 7. * @return uint16_t. Value of Socket n TX max buffer size. */ //uint16_t getSn_TxMAX(uint8_t sn); uint16_t getSn_TxMAX(uint8_t sn) { return (getSn_TXBUF_SIZE(sn) << 10); } int ethernet_link(void); void ethernet_set_link(int speed, int duplex); protected: uint8_t mac[6]; uint32_t ip; uint32_t netmask; uint32_t gateway; uint32_t dnsaddr; bool dhcp; void spi_write(uint16_t addr, uint8_t cb, const uint8_t *buf, uint16_t len); void spi_read(uint16_t addr, uint8_t cb, uint8_t *buf, uint16_t len); SPI* spi; DigitalOut cs; DigitalOut reset_pin; static WIZnet_Chip* inst; void reg_wr_mac(uint16_t addr, uint8_t* data) { spi_write(addr, 0x04, data, 6); } }; extern uint32_t str_to_ip(const char* str); extern void printfBytes(char* str, uint8_t* buf, int len); extern void printHex(uint8_t* buf, int len); extern void debug_hex(uint8_t* buf, int len); ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/arch/int/W7500x_toe.cpp ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "eth_arch.h" #if defined(TARGET_WIZwiki_W7500) || defined(TARGET_WIZwiki_W7500P) || defined(TARGET_WIZwiki_W7500ECO) #include "mbed.h" #include "mbed_debug.h" #include "DNSClient.h" /* * MDIO via GPIO * mdio via gpio is supported and related functions as follows. * - mdio_init(),mdio_read(),mdio_write() * - input_MDIO(),output_MDIO(),turnaroud_MDIO(),idle_MDIO() * called by ethernet_link() and ethernet_set_link() */ #if defined (TARGET_WIZwiki_W7500) || defined(TARGET_WIZwiki_W7500ECO) #define MDIO GPIO_Pin_14 #define MDC GPIO_Pin_15 #define GPIO_MDC GPIOB #define PHY_ADDR_IP101G 0x07 #define PHY_ADDR PHY_ADDR_IP101G #define SVAL 0x2 //right shift val = 2 #define PHYREG_CONTROL 0x0 //Control Register address (Contorl basic register) #define PHYREG_STATUS 0x1 //Status Register address (Status basic register) #define CNTL_DUPLEX (0x01ul<< 7) #define CNTL_AUTONEGO (0x01ul<<11) #define CNTL_SPEED (0x01ul<<12) #define MDC_WAIT (1) #elif defined (TARGET_WIZwiki_W7500P) #define MDIO GPIO_Pin_15 #define MDC GPIO_Pin_14 #define GPIO_MDC GPIOB #define PHY_ADDR_IP101G 0x01 #define PHY_ADDR PHY_ADDR_IP101G #define SVAL 0x2 //right shift val = 2 #define PHYREG_CONTROL 0x0 //Control Register address (Contorl basic register) #define PHYREG_STATUS 0x1 //Status Register address (Status basic register) #define CNTL_DUPLEX (0x01ul<< 8) #define CNTL_AUTONEGO (0x01ul<<12) #define CNTL_SPEED (0x01ul<<13) #define MDC_WAIT (1) #endif void mdio_init(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin_MDC, uint16_t GPIO_Pin_MDIO); void mdio_write(GPIO_TypeDef* GPIOx, uint32_t PhyRegAddr, uint32_t val); uint32_t mdio_read(GPIO_TypeDef* GPIOx, uint32_t PhyRegAddr); WIZnet_Chip* WIZnet_Chip::inst; WIZnet_Chip::WIZnet_Chip() { inst = this; } bool WIZnet_Chip::setmac() { reg_wr_mac(SHAR, mac); return true; } // Set the IP bool WIZnet_Chip::setip() { reg_wr(SIPR, ip); reg_wr(GAR, gateway); reg_wr(SUBR, netmask); return true; } bool WIZnet_Chip::setProtocol(int socket, Protocol p) { if (socket < 0) { return false; } sreg(socket, Sn_MR, p); return true; } bool WIZnet_Chip::connect(int socket, const char * host, int port, int timeout_ms) { if (socket < 0) { return false; } sreg(socket, Sn_MR, TCP); scmd(socket, OPEN); sreg_ip(socket, Sn_DIPR, host); sreg(socket, Sn_DPORT, port); sreg(socket, Sn_PORT, new_port()); scmd(socket, CONNECT); Timer t; t.reset(); t.start(); while(!is_connected(socket)) { if (t.read_ms() > timeout_ms) { return false; } } return true; } bool WIZnet_Chip::gethostbyname(const char* host, uint32_t* ip) { uint32_t addr = str_to_ip(host); char buf[17]; snprintf(buf, sizeof(buf), "%d.%d.%d.%d", (uint8_t)((addr>>24)&0xff), (uint8_t)((addr>>16)&0xff), (uint8_t)((addr>>8)&0xff), (uint8_t)(addr&0xff)); if (strcmp(buf, host) == 0) { *ip = addr; return true; } DNSClient client; if(client.lookup(host)) { *ip = client.ip; return true; } return false; } bool WIZnet_Chip::is_connected(int socket) { /* if (sreg(socket, Sn_SR) == SOCK_ESTABLISHED) { return true; } */ uint8_t tmpSn_SR; tmpSn_SR = sreg(socket, Sn_SR); // packet sending is possible, when state is SOCK_CLOSE_WAIT. if ((tmpSn_SR == SOCK_ESTABLISHED) || (tmpSn_SR == SOCK_CLOSE_WAIT)) { return true; } return false; } // Reset the chip & set the buffer void WIZnet_Chip::reset() { /* S/W Reset PHY */ mdio_write(GPIO_MDC, PHYREG_CONTROL, 0x8000); wait_ms(10);//for S/W reset wait_ms(10);//for MDC I/F RDY mdio_init(GPIO_MDC, MDC, MDIO); /* S/W Reset WZTOE */ reg_wr(MR, MR_RST); // set PAD strengh and pull-up for TXD[3:0] and TXE #ifdef __DEF_USED_IC101AG__ //For using IC+101AG #if defined(TARGET_WIZwiki_W7500) || defined(TARGET_WIZwiki_W7500ECO) *(volatile uint32_t *)(0x41003068) = 0x64; //TXD0 *(volatile uint32_t *)(0x4100306C) = 0x64; //TXD1 *(volatile uint32_t *)(0x41003070) = 0x64; //TXD2 *(volatile uint32_t *)(0x41003074) = 0x64; //TXD3 *(volatile uint32_t *)(0x41003050) = 0x64; //TXE #endif #endif // set ticker counter reg_wr(TIC100US, (SystemCoreClock/10000)); // write MAC address inside the WZTOE MAC address register reg_wr_mac(SHAR, mac); /* * set RX and TX buffer size * for (int socket = 0; socket < MAX_SOCK_NUM; socket++) { * sreg(socket, Sn_RXBUF_SIZE, 2); * sreg(socket, Sn_TXBUF_SIZE, 2); * } */ } bool WIZnet_Chip::close(int socket) { if (socket < 0) { return false; } // if SOCK_CLOSED, return if (sreg(socket, Sn_SR) == SOCK_CLOSED) { return true; } // if SOCK_ESTABLISHED, send FIN-Packet to peer if (sreg(socket, Sn_MR) == TCP) { scmd(socket, DISCON); } // close socket scmd(socket, CLOSE); // clear Socket Interrupt Register sreg(socket, Sn_ICR, 0xff); return true; } int WIZnet_Chip::wait_readable(int socket, int wait_time_ms, int req_size) { if (socket < 0) { return -1; } Timer t; t.reset(); t.start(); while(1) { int size = sreg(socket, Sn_RX_RSR); if (size > req_size) { return size; } if (wait_time_ms != (-1) && t.read_ms() > wait_time_ms) { break; } } return -1; } int WIZnet_Chip::wait_writeable(int socket, int wait_time_ms, int req_size) { if (socket < 0) { return -1; } Timer t; t.reset(); t.start(); while(1) { int size = sreg(socket, Sn_TX_FSR); if (size > req_size) { return size; } if (wait_time_ms != (-1) && t.read_ms() > wait_time_ms) { break; } } return -1; } int WIZnet_Chip::send(int socket, const char * str, int len) { if (socket < 0) { return -1; } uint16_t ptr = sreg(socket, Sn_TX_WR); uint32_t sn_tx_base = W7500x_TXMEM_BASE + (uint32_t)(socket<<18); for(int i=0; i(socket, Sn_TX_WR, ptr + len); scmd(socket, SEND); uint8_t tmp_Sn_IR; while (( (tmp_Sn_IR = sreg(socket, Sn_IR)) & INT_SEND_OK) != INT_SEND_OK) { // @Jul.10, 2014 fix contant name, and udp sendto function. switch (sreg(socket, Sn_SR)) { case SOCK_CLOSED : close(socket); return 0; //break; case SOCK_UDP : // ARP timeout is possible. if ((tmp_Sn_IR & INT_TIMEOUT) == INT_TIMEOUT) { sreg(socket, Sn_ICR, INT_TIMEOUT); return 0; } break; default : break; } } sreg(socket, Sn_ICR, INT_SEND_OK); return len; } int WIZnet_Chip::recv(int socket, char* buf, int len) { if (socket < 0) { return -1; } uint16_t ptr = sreg(socket, Sn_RX_RD); uint32_t sn_rx_base = W7500x_RXMEM_BASE + (uint32_t)(socket<<18); for(int i=0; i(socket, Sn_RX_RD, ptr + len); scmd(socket, RECV); return len; } int WIZnet_Chip::new_socket() { for(int s = 0; s < MAX_SOCK_NUM; s++) { if (sreg(s, Sn_SR) == SOCK_CLOSED) { return s; } } return -1; } uint16_t WIZnet_Chip::new_port() { uint16_t port = rand(); port |= 49152; return port; } bool WIZnet_Chip::link(int wait_time_ms) { Timer t; t.reset(); t.start(); while(1) { int is_link = ethernet_link(); if (is_link) { return true; } if (wait_time_ms != (-1) && t.read_ms() > wait_time_ms) { break; } } return 0; } void WIZnet_Chip::set_link(PHYMode phymode) { int speed = -1; int duplex = 0; switch(phymode) { case AutoNegotiate : speed = -1; duplex = 0; break; case HalfDuplex10 : speed = 0; duplex = 0; break; case FullDuplex10 : speed = 0; duplex = 1; break; case HalfDuplex100 : speed = 1; duplex = 0; break; case FullDuplex100 : speed = 1; duplex = 1; break; } ethernet_set_link(speed, duplex); } uint32_t str_to_ip(const char* str) { uint32_t ip = 0; char* p = (char*)str; for(int i = 0; i < 4; i++) { ip |= atoi(p); p = strchr(p, '.'); if (p == NULL) { break; } ip <<= 8; p++; } return ip; } void printfBytes(char* str, uint8_t* buf, int len) { printf("%s %d:", str, len); for(int i = 0; i < len; i++) { printf(" %02x", buf[i]); } printf("\n"); } void printHex(uint8_t* buf, int len) { for(int i = 0; i < len; i++) { if ((i%16) == 0) { printf("%p", buf+i); } printf(" %02x", buf[i]); if ((i%16) == 15) { printf("\n"); } } printf("\n"); } void debug_hex(uint8_t* buf, int len) { for(int i = 0; i < len; i++) { if ((i%16) == 0) { debug("%p", buf+i); } debug(" %02x", buf[i]); if ((i%16) == 15) { debug("\n"); } } debug("\n"); } void WIZnet_Chip::scmd(int socket, Command cmd) { sreg(socket, Sn_CR, cmd); while(sreg(socket, Sn_CR)); } void mdio_init(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin_MDC, uint16_t GPIO_Pin_MDIO) { /* Set GPIOs for MDIO and MDC */ GPIO_InitTypeDef MDIO_InitDef; HAL_PAD_AFConfig(PAD_PB, GPIO_Pin_MDIO, PAD_AF1); HAL_PAD_AFConfig(PAD_PB, GPIO_Pin_MDC, PAD_AF1); MDIO_InitDef.GPIO_Pin = GPIO_Pin_MDC | GPIO_Pin_MDIO; MDIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; HAL_GPIO_Init(GPIOx, &MDIO_InitDef); } void output_MDIO(GPIO_TypeDef* GPIOx, uint32_t val, uint32_t n) { for(val <<= (32-n); n; val<<=1, n--) { if(val & 0x80000000) HAL_GPIO_SetBits(GPIOx, MDIO); else HAL_GPIO_ResetBits(GPIOx, MDIO); wait_ms(MDC_WAIT); HAL_GPIO_SetBits(GPIOx, MDC); wait_ms(MDC_WAIT); HAL_GPIO_ResetBits(GPIOx, MDC); } } uint32_t input_MDIO( GPIO_TypeDef* GPIOx ) { uint32_t i, val=0; for(i=0; i<16; i++) { val <<=1; HAL_GPIO_SetBits(GPIOx, MDC); wait_ms(MDC_WAIT); HAL_GPIO_ResetBits(GPIOx, MDC); wait_ms(MDC_WAIT); val |= HAL_GPIO_ReadInputDataBit(GPIOx, MDIO); } return (val); } void turnaround_MDIO( GPIO_TypeDef* GPIOx) { GPIOx->OUTENCLR = MDIO ; HAL_GPIO_SetBits(GPIOx, MDC); wait_ms(MDC_WAIT); HAL_GPIO_ResetBits(GPIOx, MDC); wait_ms(MDC_WAIT); } void idle_MDIO( GPIO_TypeDef* GPIOx ) { GPIOx->OUTENSET = MDIO ; HAL_GPIO_SetBits(GPIOx,MDC); wait_ms(MDC_WAIT); HAL_GPIO_ResetBits(GPIOx, MDC); wait_ms(MDC_WAIT); } uint32_t mdio_read(GPIO_TypeDef* GPIOx, uint32_t PhyRegAddr) { output_MDIO(GPIOx, 0xFFFFFFFF, 32); output_MDIO(GPIOx, 0x06, 4); output_MDIO(GPIOx, PHY_ADDR, 5); output_MDIO(GPIOx, PhyRegAddr, 5); turnaround_MDIO(GPIOx); uint32_t val = input_MDIO(GPIOx ); idle_MDIO(GPIOx); return val; } void mdio_write(GPIO_TypeDef* GPIOx, uint32_t PhyRegAddr, uint32_t val) { output_MDIO(GPIOx, 0xFFFFFFFF, 32); output_MDIO(GPIOx, 0x05, 4); output_MDIO(GPIOx, PHY_ADDR, 5); output_MDIO(GPIOx, PhyRegAddr, 5); output_MDIO(GPIOx, 0x02, 2); output_MDIO(GPIOx, val, 16); idle_MDIO(GPIOx); } int WIZnet_Chip::ethernet_link(void) { return ((mdio_read(GPIO_MDC, PHYREG_STATUS)>>SVAL)&0x01); } void WIZnet_Chip::ethernet_set_link(int speed, int duplex) { uint32_t val=0; if((speed < 0) || (speed > 1)) { val = CNTL_AUTONEGO; } else { val = ((CNTL_SPEED&(speed<<11))|(CNTL_DUPLEX&(duplex<<7))); } mdio_write(GPIO_MDC, PHYREG_CONTROL, val); } void WIZnet_Chip::reg_rd_mac(uint16_t addr, uint8_t* data) { data[0] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+3)); data[1] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+2)); data[2] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+1)); data[3] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+0)); data[4] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+7)); data[5] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+6)); } void WIZnet_Chip::reg_wr_ip(uint16_t addr, uint8_t cb, const char* ip) { uint8_t buf[4]={0,}; uint32_t wr_ip = 0; char* p = (char*)ip; for(int i = 0; i < 4; i++) { wr_ip = (wr_ip<<8); buf[i] = atoi(p); wr_ip |= buf[i]; p = strchr(p, '.'); if (p == NULL) break; p++; } *(volatile uint32_t *)(W7500x_WZTOE_BASE + (uint32_t)((cb<<16)+addr)) = wr_ip; } void WIZnet_Chip::sreg_ip(int socket, uint16_t addr, const char* ip) { reg_wr_ip(addr, (uint8_t)(0x01+(socket<<2)), ip); } #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/arch/int/W7500x_toe.h ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #pragma once #include "mbed.h" #include "mbed_debug.h" #define TEST_ASSERT(A) while(!(A)){debug("\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);}; #define DEFAULT_WAIT_RESP_TIMEOUT 500 #define MAX_SOCK_NUM 8 // Peripheral base address #define W7500x_WZTOE_BASE (0x46000000) #define W7500x_TXMEM_BASE (W7500x_WZTOE_BASE + 0x00020000) #define W7500x_RXMEM_BASE (W7500x_WZTOE_BASE + 0x00030000) // Common register #define MR (0x2300) #define GAR (0x6008) #define SUBR (0x600C) #define SHAR (0x6000) #define SIPR (0x6010) // Added Common register @W7500 #define TIC100US (0x2000) // Socket register #define Sn_MR (0x0000) #define Sn_CR (0x0010) #define Sn_IR (0x0020) //--Sn_ISR #define Sn_SR (0x0030) #define Sn_PORT (0x0114) #define Sn_DIPR (0x0124) #define Sn_DPORT (0x0120) #define Sn_RXBUF_SIZE (0x0200) #define Sn_TXBUF_SIZE (0x0220) #define Sn_TX_FSR (0x0204) #define Sn_TX_WR (0x020C) #define Sn_RX_RSR (0x0224) #define Sn_RX_RD (0x0228) // added Socket register @W7500 #define Sn_ICR (0x0028) enum PHYMode { AutoNegotiate = 0, HalfDuplex10 = 1, FullDuplex10 = 2, HalfDuplex100 = 3, FullDuplex100 = 4, }; //bool plink(int wait_time_ms= 3*1000); class WIZnet_Chip { public: enum Protocol { CLOSED = 0, TCP = 1, UDP = 2, }; enum Command { OPEN = 0x01, LISTEN = 0x02, CONNECT = 0x04, DISCON = 0x08, CLOSE = 0x10, SEND = 0x20, SEND_MAC = 0x21, SEND_KEEP = 0x22, RECV = 0x40, }; enum Interrupt { INT_CON = 0x01, INT_DISCON = 0x02, INT_RECV = 0x04, INT_TIMEOUT = 0x08, INT_SEND_OK = 0x10, }; enum Status { SOCK_CLOSED = 0x00, SOCK_INIT = 0x13, SOCK_LISTEN = 0x14, SOCK_SYNSENT = 0x15, SOCK_ESTABLISHED = 0x17, SOCK_CLOSE_WAIT = 0x1c, SOCK_UDP = 0x22, }; enum Mode { MR_RST = 0x80, MR_WOL = 0x20, MR_PB = 0x10, MR_FARP = 0x02, }; WIZnet_Chip(); /* * Set MAC Address to W7500x_TOE * * @return true if connected, false otherwise */ bool setmac(); /* * Connect the W7500 WZTOE to the ssid contained in the constructor. * * @return true if connected, false otherwise */ bool setip(); /* * Open a tcp connection with the specified host on the specified port * * @param host host (can be either an ip address or a name. If a name is provided, a dns request will be established) * @param port port * @ returns true if successful */ bool connect(int socket, const char * host, int port, int timeout_ms = 10*1000); /* * Set the protocol (UDP or TCP) * * @param p protocol * @ returns true if successful */ bool setProtocol(int socket, Protocol p); /* * Reset the W7500 WZTOE */ void reset(); int wait_readable(int socket, int wait_time_ms, int req_size = 0); int wait_writeable(int socket, int wait_time_ms, int req_size = 0); /* * Check if an ethernet link is pressent or not. * * @returns true if successful */ bool link(int wait_time_ms= 3*1000); /* * Sets the speed and duplex parameters of an ethernet link. * * @returns true if successful */ void set_link(PHYMode phymode); /* * Check if a tcp link is active * * @returns true if successful */ bool is_connected(int socket); /* * Close a tcp connection * * @ returns true if successful */ bool close(int socket); /* * @param str string to be sent * @param len string length */ int send(int socket, const char * str, int len); int recv(int socket, char* buf, int len); /* * Return true if the module is using dhcp * * @returns true if the module is using dhcp */ bool isDHCP() { return dhcp; } bool gethostbyname(const char* host, uint32_t* ip); static WIZnet_Chip * getInstance() { return inst; }; int new_socket(); uint16_t new_port(); void scmd(int socket, Command cmd); template void sreg(int socket, uint16_t addr, T data) { reg_wr(addr, (uint8_t)(0x01+(socket<<2)), data); } template T sreg(int socket, uint16_t addr) { return reg_rd(addr, (uint8_t)(0x01+(socket<<2))); } template void reg_wr(uint16_t addr, T data) { return reg_wr(addr, 0x00, data); } template void reg_wr(uint16_t addr, uint8_t cb, T data) { uint8_t buf[sizeof(T)]; *reinterpret_cast(buf) = data; /* for(int i = 0; i < sizeof(buf)/2; i++) { // Little Endian to Big Endian uint8_t t = buf[i]; buf[i] = buf[sizeof(buf)-1-i]; buf[sizeof(buf)-1-i] = t; } */ for(int i = 0; i < sizeof(buf); i++) { // Little Endian to Big Endian *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)((cb<<16)+addr)+i) = buf[i]; } } template T reg_rd(uint16_t addr) { return reg_rd(addr, (uint8_t)(0x00)); } template T reg_rd(uint16_t addr, uint8_t cb) { uint8_t buf[sizeof(T)] = {0,}; for(int i = 0; i < sizeof(buf); i++) { // Little Endian to Big Endian buf[i] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)((cb<<16)+addr)+i); } /* for(int i = 0; i < sizeof(buf)/2; i++) { // Big Endian to Little Endian uint8_t t = buf[i]; buf[i] = buf[sizeof(buf)-1-i]; buf[sizeof(buf)-1-i] = t; } */ return *reinterpret_cast(buf); } void reg_rd_mac(uint16_t addr, uint8_t* data); void reg_wr_ip(uint16_t addr, uint8_t cb, const char* ip); void sreg_ip(int socket, uint16_t addr, const char* ip); int ethernet_link(void); void ethernet_set_link(int speed, int duplex); protected: uint8_t mac[6]; uint32_t ip; uint32_t netmask; uint32_t gateway; uint32_t dnsaddr; bool dhcp; static WIZnet_Chip* inst; void reg_wr_mac(uint16_t addr, uint8_t* data) { *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+3)) = data[0] ; *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+2)) = data[1] ; *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+1)) = data[2] ; *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+0)) = data[3] ; *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+7)) = data[4] ; *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+6)) = data[5] ; } }; extern uint32_t str_to_ip(const char* str); extern void printfBytes(char* str, uint8_t* buf, int len); extern void printHex(uint8_t* buf, int len); extern void debug_hex(uint8_t* buf, int len); ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5/eth_arch.h ================================================ /* Copyright (C) 2012 mbed.org, MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #pragma once #if defined(TARGET_WIZwiki_W7500) || defined(TARGET_WIZwiki_W7500ECO) #include "W7500x_toe.h" #define __DEF_USED_IC101AG__ //For using IC+101AG@WIZwiki-W7500 #elif defined(TARGET_WIZwiki_W7500P) #include "W7500x_toe.h" #else #include "W5500.h" // W5500 Ethernet Shield //#define USE_WIZ550IO_MAC // WIZ550io; using the MAC address #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/WIZnetInterface-OS5.lib ================================================ http://os.mbed.com/teams/WIZnet/code/WIZnetInterface-OS5/#d4c8fe4d9b29d4e5614620b0820a49d31087b512 ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/configuration.h ================================================ #ifndef CONFIGURATION_H #define CONFIGURATION_H #define PRU_BASEFREQ 40000 //24000 // PRU Base thread ISR update frequency (hz) #define PRU_SERVOFREQ 1000 // PRU Servo thread ISR update freqency (hz) #define OVERSAMPLE 3 #define SWBAUDRATE 19200 // Software serial baud rate #define PRU_COMMSFREQ (SWBAUDRATE * OVERSAMPLE) #define STEPBIT 22 // bit location in DDS accum #define STEP_MASK (1L< #define confine(value, min, max) (((value) < (min))?(min):(((value) > (max))?(max):(value))) #define PID_PWM_MAX 256 // 8 bit resolution using namespace std; SoftPWM::SoftPWM(std::string pin) : pin(pin), pwmMax(PID_PWM_MAX-1), pwmSP(0), SDaccumulator(0), SDdirection(false) { this->pwmPin = new Pin(this->pin, OUTPUT); } void SoftPWM::setMaxPwm(int pwmMax) { this->pwmMax = confine(pwmMax, 0, PID_PWM_MAX-1); } void SoftPWM::setPwmSP(int newPwmSP) { this->pwmSP = newPwmSP; //confine(newPwmSP, 0, pwmMax); } void SoftPWM::update() { // Use the standard Moudle interface if ((this->pwmSP < 0) || this->pwmSP >= PID_PWM_MAX) { return; } else if (this->pwmSP == 0) { this->pwmPin->set(false); return; } else if (this->pwmSP == PID_PWM_MAX-1) { this->pwmPin->set(true); return; } // this line should never actually do anything, it's just a sanity check in case our accumulator gets corrupted somehow. // If we didn't check and the accumulator is corrupted, we could leave a heater on for quite a long time // the accumulator is kept within these limits by the normal operation of the Sigma-Delta algorithm SDaccumulator = confine(SDaccumulator, -PID_PWM_MAX, PID_PWM_MAX << 1); // when SDdirection == false, our output is 0 and our accumulator is increasing by pwmSP if (this->SDdirection == false) { // increment accumulator this->SDaccumulator += this->pwmSP; // if we've reached half of max, flip our direction if (this->SDaccumulator >= (PID_PWM_MAX >> 1)) this->SDdirection = true; } // when SDdirection == true, our output is 1 and our accumulator is decreasing by (maxPwm - pwmSP) else { // decrement accumulator this->SDaccumulator -= (PID_PWM_MAX - this->pwmSP); // if we've reached 0, flip our direction if (this->SDaccumulator <= 0) this->SDdirection = false; } this->pwmPin->set(this->SDdirection); return; } void SoftPWM::slowUpdate() { return; } ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/drivers/softPwm/softPwm.h ================================================ #ifndef SOFTPWM_H #define SOFTPWM_H #include #include "modules/module.h" #include "drivers/pin/pin.h" class SoftPWM : public Module { private: std::string pin; // PWM output pin int pwmMax; // maximum PWM output: 8 bit resolution (ie 0 to 255) int pwmSP; // PWM setpoint as a percentage of maxPwm int SDaccumulator; // Sigma-Delta accumulator bool SDdirection; // direction the SD accumulator is being updated Pin* pwmPin; // pin object public: SoftPWM(std::string); // constructor void setMaxPwm(int pwmMax); void setPwmSP(int newPwmSP); virtual void update(void); // Module default interface virtual void slowUpdate(void); // Module default interface }; #endif /* The following is taken from Smoothieware... * Sigma-Delta PWM algorithm * * This Sigma-Delta implementation works by increasing _sd_accumulator by _pwm until we reach _half_ of max, * then decreasing by (max - target_pwm) until we hit zero * * While we're increasing, the output is 0 and while we're decreasing the output is 1 * * For example, with pwm=128 and a max of 256, we'll see the following pattern: * ACC ADD OUT * 0 128 1 // after the add, we hit 256/2 = 128 so we change direction * 128 -128 0 // after the add, we hit 0 so we change direction again * 0 128 1 * 128 -128 0 * as expected * * with a pwm value of 192 (75%) we'll see this: * ACC ADD OUT * 0 192 0 // after the add, we are beyond max/2 so we change direction * 192 -64 1 // haven't reached 0 yet * 128 -64 1 // haven't reached 0 yet * 64 -64 1 // after this add we reach 0, and change direction * 0 192 0 * 192 -64 1 * 128 -64 1 * 64 -64 1 * 0 192 0 * etcetera * * with a pwm value of 75 (about 29%) we'll see this pattern: * ACC ADD OUT * 0 75 0 * 75 75 0 * 150 -181 1 * -31 75 0 * 44 75 0 * 119 75 0 * 194 -181 1 * 13 -181 1 * -168 75 0 * -93 75 0 * -18 75 0 * 57 75 0 * 132 -181 1 * -49 75 0 * 26 75 0 * 101 75 0 * 176 -181 1 * -5 75 0 * 70 75 0 * 145 -181 1 * -36 75 0 * etcetera. This pattern has 6 '1's over a total of 21 lines which is on 28.57% of the time. If we let it run longer, it would get closer to the target as time went on */ ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/extern.h ================================================ #ifndef EXTERN_H #define EXTERN_H #include "configuration.h" #include "remora.h" #include "ArduinoJson.h" #include "pruThread.h" extern uint32_t base_freq; extern uint32_t servo_freq; extern JsonObject module; extern volatile bool PRUreset; // unions for RX and TX data extern volatile rxData_t rxData; extern volatile txData_t txData; // pointers to objects with global scope extern pruThread* baseThread; extern pruThread* servoThread; extern pruThread* commsThread; // pointers to data extern volatile rxData_t* ptrRxData; extern volatile txData_t* ptrTxData; extern volatile int32_t* ptrTxHeader; extern volatile bool* ptrPRUreset; extern volatile int32_t* ptrJointFreqCmd[JOINTS]; extern volatile int32_t* ptrJointFeedback[JOINTS]; extern volatile uint8_t* ptrJointEnable; extern volatile float* ptrSetPoint[VARIABLES]; extern volatile float* ptrProcessVariable[VARIABLES]; extern volatile uint16_t* ptrInputs; extern volatile uint16_t* ptrOutputs; #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Array/ArrayFunctions.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "../Collection/CollectionData.hpp" namespace ARDUINOJSON_NAMESPACE { inline VariantData *arrayAdd(CollectionData *arr, MemoryPool *pool) { return arr ? arr->add(pool) : 0; } template inline void arrayAccept(const CollectionData *arr, Visitor &visitor) { if (arr) visitor.visitArray(*arr); else visitor.visitNull(); } inline bool arrayEquals(const CollectionData *lhs, const CollectionData *rhs) { if (lhs == rhs) return true; if (!lhs || !rhs) return false; return lhs->equalsArray(*rhs); } } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Array/ArrayImpl.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "../Object/ObjectRef.hpp" #include "ArrayRef.hpp" namespace ARDUINOJSON_NAMESPACE { template inline ArrayRef ArrayShortcuts::createNestedArray() const { return impl()->addElement().template to(); } template inline ObjectRef ArrayShortcuts::createNestedObject() const { return impl()->addElement().template to(); } } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Array/ArrayIterator.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "../Variant/SlotFunctions.hpp" #include "../Variant/VariantRef.hpp" namespace ARDUINOJSON_NAMESPACE { class VariantPtr { public: VariantPtr(MemoryPool *pool, VariantData *data) : _variant(pool, data) {} VariantRef *operator->() { return &_variant; } VariantRef &operator*() { return _variant; } private: VariantRef _variant; }; class ArrayIterator { public: ArrayIterator() : _slot(0) {} explicit ArrayIterator(MemoryPool *pool, VariantSlot *slot) : _pool(pool), _slot(slot) {} VariantRef operator*() const { return VariantRef(_pool, _slot->data()); } VariantPtr operator->() { return VariantPtr(_pool, _slot->data()); } bool operator==(const ArrayIterator &other) const { return _slot == other._slot; } bool operator!=(const ArrayIterator &other) const { return _slot != other._slot; } ArrayIterator &operator++() { _slot = _slot->next(); return *this; } ArrayIterator &operator+=(size_t distance) { _slot = _slot->next(distance); return *this; } VariantSlot *internal() { return _slot; } private: MemoryPool *_pool; VariantSlot *_slot; }; class VariantConstPtr { public: VariantConstPtr(const VariantData *data) : _variant(data) {} VariantConstRef *operator->() { return &_variant; } VariantConstRef &operator*() { return _variant; } private: VariantConstRef _variant; }; class ArrayConstRefIterator { public: ArrayConstRefIterator() : _slot(0) {} explicit ArrayConstRefIterator(const VariantSlot *slot) : _slot(slot) {} VariantConstRef operator*() const { return VariantConstRef(_slot->data()); } VariantConstPtr operator->() { return VariantConstPtr(_slot->data()); } bool operator==(const ArrayConstRefIterator &other) const { return _slot == other._slot; } bool operator!=(const ArrayConstRefIterator &other) const { return _slot != other._slot; } ArrayConstRefIterator &operator++() { _slot = _slot->next(); return *this; } ArrayConstRefIterator &operator+=(size_t distance) { _slot = _slot->next(distance); return *this; } const VariantSlot *internal() { return _slot; } private: const VariantSlot *_slot; }; } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Array/ArrayRef.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "../Variant/VariantData.hpp" #include "ArrayFunctions.hpp" #include "ArrayIterator.hpp" // Returns the size (in bytes) of an array with n elements. // Can be very handy to determine the size of a StaticMemoryPool. #define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \ ((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot)) namespace ARDUINOJSON_NAMESPACE { class ObjectRef; template class ElementProxy; template class ArrayRefBase { public: operator VariantConstRef() const { const void* data = _data; // prevent warning cast-align return VariantConstRef(reinterpret_cast(data)); } template FORCE_INLINE void accept(Visitor& visitor) const { arrayAccept(_data, visitor); } FORCE_INLINE bool isNull() const { return _data == 0; } FORCE_INLINE size_t memoryUsage() const { return _data ? _data->memoryUsage() : 0; } FORCE_INLINE size_t nesting() const { return _data ? _data->nesting() : 0; } FORCE_INLINE size_t size() const { return _data ? _data->size() : 0; } protected: ArrayRefBase(TData* data) : _data(data) {} TData* _data; }; class ArrayConstRef : public ArrayRefBase, public Visitable { friend class ArrayRef; typedef ArrayRefBase base_type; public: typedef ArrayConstRefIterator iterator; FORCE_INLINE iterator begin() const { if (!_data) return iterator(); return iterator(_data->head()); } FORCE_INLINE iterator end() const { return iterator(); } FORCE_INLINE ArrayConstRef() : base_type(0) {} FORCE_INLINE ArrayConstRef(const CollectionData* data) : base_type(data) {} FORCE_INLINE bool operator==(ArrayConstRef rhs) const { return arrayEquals(_data, rhs._data); } FORCE_INLINE VariantConstRef operator[](size_t index) const { return getElement(index); } FORCE_INLINE VariantConstRef getElement(size_t index) const { return VariantConstRef(_data ? _data->get(index) : 0); } }; class ArrayRef : public ArrayRefBase, public ArrayShortcuts, public Visitable { typedef ArrayRefBase base_type; public: typedef ArrayIterator iterator; FORCE_INLINE ArrayRef() : base_type(0), _pool(0) {} FORCE_INLINE ArrayRef(MemoryPool* pool, CollectionData* data) : base_type(data), _pool(pool) {} operator VariantRef() { void* data = _data; // prevent warning cast-align return VariantRef(_pool, reinterpret_cast(data)); } operator ArrayConstRef() const { return ArrayConstRef(_data); } VariantRef addElement() const { return VariantRef(_pool, arrayAdd(_data, _pool)); } FORCE_INLINE iterator begin() const { if (!_data) return iterator(); return iterator(_pool, _data->head()); } FORCE_INLINE iterator end() const { return iterator(); } // Copy a ArrayRef FORCE_INLINE bool set(ArrayConstRef src) const { if (!_data || !src._data) return false; return _data->copyFrom(*src._data, _pool); } FORCE_INLINE bool operator==(ArrayRef rhs) const { return arrayEquals(_data, rhs._data); } // Gets the value at the specified index. FORCE_INLINE VariantRef getElement(size_t index) const { return VariantRef(_pool, _data ? _data->get(index) : 0); } // Removes element at specified position. FORCE_INLINE void remove(iterator it) const { if (!_data) return; _data->remove(it.internal()); } // Removes element at specified index. FORCE_INLINE void remove(size_t index) const { if (!_data) return; _data->remove(index); } private: MemoryPool* _pool; }; } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Array/ArrayShortcuts.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "../Polyfills/attributes.hpp" #include "../Polyfills/type_traits.hpp" namespace ARDUINOJSON_NAMESPACE { // Forward declarations. template class ElementProxy; template class ArrayShortcuts { public: // Returns the element at specified index if the variant is an array. FORCE_INLINE ElementProxy operator[](size_t index) const; FORCE_INLINE ObjectRef createNestedObject() const; FORCE_INLINE ArrayRef createNestedArray() const; // Adds the specified value at the end of the array. // // bool add(TValue); // TValue = bool, long, int, short, float, double, serialized, VariantRef, // std::string, String, ObjectRef template FORCE_INLINE bool add(const T &value) const { return impl()->addElement().set(value); } // // bool add(TValue); // TValue = char*, const char*, const __FlashStringHelper* template FORCE_INLINE bool add(T *value) const { return impl()->addElement().set(value); } private: const TArray *impl() const { return static_cast(this); } }; } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Array/ElementProxy.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "../Configuration.hpp" #include "../Operators/VariantOperators.hpp" #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4522) #endif namespace ARDUINOJSON_NAMESPACE { template class ElementProxy : public VariantOperators >, public Visitable { typedef ElementProxy this_type; public: FORCE_INLINE ElementProxy(TArray array, size_t index) : _array(array), _index(index) {} FORCE_INLINE this_type& operator=(const this_type& src) { getUpstreamElement().set(src.as()); return *this; } // Replaces the value // // operator=(const TValue&) // TValue = bool, long, int, short, float, double, serialized, VariantRef, // std::string, String, ArrayRef, ObjectRef template FORCE_INLINE this_type& operator=(const T& src) { getUpstreamElement().set(src); return *this; } // // operator=(TValue) // TValue = char*, const char*, const __FlashStringHelper* template FORCE_INLINE this_type& operator=(T* src) { getUpstreamElement().set(src); return *this; } FORCE_INLINE void clear() const { getUpstreamElement().clear(); } FORCE_INLINE bool isNull() const { return getUpstreamElement().isNull(); } template FORCE_INLINE typename VariantAs::type as() const { return getUpstreamElement().template as(); } template FORCE_INLINE bool is() const { return getUpstreamElement().template is(); } template FORCE_INLINE typename VariantTo::type to() const { return getUpstreamElement().template to(); } // Replaces the value // // bool set(const TValue&) // TValue = bool, long, int, short, float, double, serialized, VariantRef, // std::string, String, ArrayRef, ObjectRef template FORCE_INLINE bool set(const TValue& value) const { return getUpstreamElement().set(value); } // // bool set(TValue) // TValue = char*, const char*, const __FlashStringHelper* template FORCE_INLINE bool set(TValue* value) const { return getUpstreamElement().set(value); } template void accept(Visitor& visitor) const { return getUpstreamElement().accept(visitor); } FORCE_INLINE size_t size() const { return getUpstreamElement().size(); } template VariantRef getMember(TNestedKey* key) const { return getUpstreamElement().getMember(key); } template VariantRef getMember(const TNestedKey& key) const { return getUpstreamElement().getMember(key); } template VariantRef getOrAddMember(TNestedKey* key) const { return getUpstreamElement().getOrAddMember(key); } template VariantRef getOrAddMember(const TNestedKey& key) const { return getUpstreamElement().getOrAddMember(key); } VariantRef addElement() const { return getUpstreamElement().addElement(); } VariantRef getElement(size_t index) const { return getUpstreamElement().getElement(index); } FORCE_INLINE void remove(size_t index) const { getUpstreamElement().remove(index); } // remove(char*) const // remove(const char*) const // remove(const __FlashStringHelper*) const template FORCE_INLINE typename enable_if::value>::type remove( TChar* key) const { getUpstreamElement().remove(key); } // remove(const std::string&) const // remove(const String&) const template FORCE_INLINE typename enable_if::value>::type remove( const TString& key) const { getUpstreamElement().remove(key); } private: FORCE_INLINE VariantRef getUpstreamElement() const { return _array.getElement(_index); } TArray _array; const size_t _index; }; template inline ElementProxy ArrayShortcuts::operator[]( size_t index) const { return ElementProxy(*impl(), index); } } // namespace ARDUINOJSON_NAMESPACE #ifdef _MSC_VER #pragma warning(pop) #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Array/Utilities.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "ArrayRef.hpp" namespace ARDUINOJSON_NAMESPACE { // Copy a 1D array to a JsonArray template inline bool copyArray(T (&src)[N], ArrayRef dst) { return copyArray(src, N, dst); } // Copy a 1D array to a JsonArray template inline bool copyArray(T* src, size_t len, ArrayRef dst) { bool ok = true; for (size_t i = 0; i < len; i++) { ok &= dst.add(src[i]); } return ok; } // Copy a 2D array to a JsonArray template inline bool copyArray(T (&src)[N1][N2], ArrayRef dst) { bool ok = true; for (size_t i = 0; i < N1; i++) { ArrayRef nestedArray = dst.createNestedArray(); for (size_t j = 0; j < N2; j++) { ok &= nestedArray.add(src[i][j]); } } return ok; } // Copy a JsonArray to a 1D array template inline size_t copyArray(ArrayConstRef src, T (&dst)[N]) { return copyArray(src, dst, N); } // Copy a JsonArray to a 1D array template inline size_t copyArray(ArrayConstRef src, T* dst, size_t len) { size_t i = 0; for (ArrayConstRef::iterator it = src.begin(); it != src.end() && i < len; ++it) dst[i++] = *it; return i; } // Copy a JsonArray to a 2D array template inline void copyArray(ArrayConstRef src, T (&dst)[N1][N2]) { size_t i = 0; for (ArrayConstRef::iterator it = src.begin(); it != src.end() && i < N1; ++it) { copyArray(it->as(), dst[i++]); } } } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Collection/CollectionData.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once namespace ARDUINOJSON_NAMESPACE { class MemoryPool; class VariantData; class VariantSlot; class CollectionData { VariantSlot *_head; VariantSlot *_tail; public: // Must be a POD! // - no constructor // - no destructor // - no virtual // - no inheritance VariantSlot *addSlot(MemoryPool *); VariantData *add(MemoryPool *pool); template VariantData *add(TAdaptedString key, MemoryPool *pool); void clear(); template bool containsKey(const TAdaptedString &key) const; bool copyFrom(const CollectionData &src, MemoryPool *pool); bool equalsArray(const CollectionData &other) const; bool equalsObject(const CollectionData &other) const; VariantData *get(size_t index) const; template VariantData *get(TAdaptedString key) const; VariantSlot *head() const { return _head; } void remove(size_t index); template void remove(TAdaptedString key) { remove(getSlot(key)); } void remove(VariantSlot *slot); size_t memoryUsage() const; size_t nesting() const; size_t size() const; private: VariantSlot *getSlot(size_t index) const; template VariantSlot *getSlot(TAdaptedString key) const; VariantSlot *getPreviousSlot(VariantSlot *) const; }; } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Collection/CollectionImpl.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "../Variant/VariantData.hpp" #include "CollectionData.hpp" namespace ARDUINOJSON_NAMESPACE { inline VariantSlot* CollectionData::addSlot(MemoryPool* pool) { VariantSlot* slot = pool->allocVariant(); if (!slot) return 0; if (_tail) { _tail->setNextNotNull(slot); _tail = slot; } else { _head = slot; _tail = slot; } slot->clear(); return slot; } inline VariantData* CollectionData::add(MemoryPool* pool) { return slotData(addSlot(pool)); } template inline VariantData* CollectionData::add(TAdaptedString key, MemoryPool* pool) { VariantSlot* slot = addSlot(pool); if (!slotSetKey(slot, key, pool)) return 0; return slot->data(); } inline void CollectionData::clear() { _head = 0; _tail = 0; } template inline bool CollectionData::containsKey(const TAdaptedString& key) const { return getSlot(key) != 0; } inline bool CollectionData::copyFrom(const CollectionData& src, MemoryPool* pool) { clear(); for (VariantSlot* s = src._head; s; s = s->next()) { VariantData* var; if (s->key() != 0) { if (s->ownsKey()) var = add(RamStringAdapter(s->key()), pool); else var = add(ConstRamStringAdapter(s->key()), pool); } else { var = add(pool); } if (!var) return false; if (!var->copyFrom(*s->data(), pool)) return false; } return true; } inline bool CollectionData::equalsObject(const CollectionData& other) const { size_t count = 0; for (VariantSlot* slot = _head; slot; slot = slot->next()) { VariantData* v1 = slot->data(); VariantData* v2 = other.get(adaptString(slot->key())); if (!variantEquals(v1, v2)) return false; count++; } return count == other.size(); } inline bool CollectionData::equalsArray(const CollectionData& other) const { VariantSlot* s1 = _head; VariantSlot* s2 = other._head; for (;;) { if (s1 == s2) return true; if (!s1 || !s2) return false; if (!variantEquals(s1->data(), s2->data())) return false; s1 = s1->next(); s2 = s2->next(); } } template inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const { VariantSlot* slot = _head; while (slot) { if (key.equals(slot->key())) break; slot = slot->next(); } return slot; } inline VariantSlot* CollectionData::getSlot(size_t index) const { return _head->next(index); } inline VariantSlot* CollectionData::getPreviousSlot(VariantSlot* target) const { VariantSlot* current = _head; while (current) { VariantSlot* next = current->next(); if (next == target) return current; current = next; } return 0; } template inline VariantData* CollectionData::get(TAdaptedString key) const { VariantSlot* slot = getSlot(key); return slot ? slot->data() : 0; } inline VariantData* CollectionData::get(size_t index) const { VariantSlot* slot = getSlot(index); return slot ? slot->data() : 0; } inline void CollectionData::remove(VariantSlot* slot) { if (!slot) return; VariantSlot* prev = getPreviousSlot(slot); VariantSlot* next = slot->next(); if (prev) prev->setNext(next); else _head = next; if (!next) _tail = prev; } inline void CollectionData::remove(size_t index) { remove(getSlot(index)); } inline size_t CollectionData::memoryUsage() const { size_t total = 0; for (VariantSlot* s = _head; s; s = s->next()) { total += sizeof(VariantSlot) + s->data()->memoryUsage(); if (s->ownsKey()) total += strlen(s->key()) + 1; } return total; } inline size_t CollectionData::nesting() const { size_t maxChildNesting = 0; for (VariantSlot* s = _head; s; s = s->next()) { size_t childNesting = s->data()->nesting(); if (childNesting > maxChildNesting) maxChildNesting = childNesting; } return maxChildNesting + 1; } inline size_t CollectionData::size() const { return slotSize(_head); } } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Configuration.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #if defined(_MSC_VER) #define ARDUINOJSON_HAS_INT64 1 #else #define ARDUINOJSON_HAS_INT64 0 #endif #if __cplusplus >= 201103L #define ARDUINOJSON_HAS_LONG_LONG 1 #else #define ARDUINOJSON_HAS_LONG_LONG 0 #endif // Small or big machine? #ifndef ARDUINOJSON_EMBEDDED_MODE #if defined(ARDUINO) || defined(__IAR_SYSTEMS_ICC__) || defined(__XC) || \ defined(__ARMCC_VERSION) #define ARDUINOJSON_EMBEDDED_MODE 1 #else #define ARDUINOJSON_EMBEDDED_MODE 0 #endif #endif #if ARDUINOJSON_EMBEDDED_MODE // Store floats by default to reduce the memory usage (issue #134) #ifndef ARDUINOJSON_USE_DOUBLE #define ARDUINOJSON_USE_DOUBLE 0 #endif // Store longs by default, because they usually match the size of a float. #ifndef ARDUINOJSON_USE_LONG_LONG #define ARDUINOJSON_USE_LONG_LONG 0 #endif // Embedded systems usually don't have std::string #ifndef ARDUINOJSON_ENABLE_STD_STRING #define ARDUINOJSON_ENABLE_STD_STRING 0 #endif // Embedded systems usually don't have std::stream #ifndef ARDUINOJSON_ENABLE_STD_STREAM #define ARDUINOJSON_ENABLE_STD_STREAM 0 #endif // Limit nesting as the stack is likely to be small #ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT #define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10 #endif #else // ARDUINOJSON_EMBEDDED_MODE // On a computer we have plenty of memory so we can use doubles #ifndef ARDUINOJSON_USE_DOUBLE #define ARDUINOJSON_USE_DOUBLE 1 #endif // Use long long when available #ifndef ARDUINOJSON_USE_LONG_LONG #if ARDUINOJSON_HAS_LONG_LONG || ARDUINOJSON_HAS_INT64 #define ARDUINOJSON_USE_LONG_LONG 1 #else #define ARDUINOJSON_USE_LONG_LONG 0 #endif #endif // On a computer, we can use std::string #ifndef ARDUINOJSON_ENABLE_STD_STRING #define ARDUINOJSON_ENABLE_STD_STRING 1 #endif // On a computer, we can assume std::stream #ifndef ARDUINOJSON_ENABLE_STD_STREAM #define ARDUINOJSON_ENABLE_STD_STREAM 1 #endif // On a computer, the stack is large so we can increase nesting limit #ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT #define ARDUINOJSON_DEFAULT_NESTING_LIMIT 50 #endif #endif // ARDUINOJSON_EMBEDDED_MODE #ifdef ARDUINO // Enable support for Arduino's String class #ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING #define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 #endif // Enable support for Arduino's Stream class #ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM #define ARDUINOJSON_ENABLE_ARDUINO_STREAM 1 #endif // Enable support for Arduino's Print class #ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT #define ARDUINOJSON_ENABLE_ARDUINO_PRINT 1 #endif #else // ARDUINO // Enable support for Arduino's String class #ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING #define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 #endif // Enable support for Arduino's Stream class #ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM #define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0 #endif // Enable support for Arduino's Print class #ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT #define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0 #endif #endif // ARDUINO #ifndef ARDUINOJSON_ENABLE_PROGMEM #ifdef PROGMEM #define ARDUINOJSON_ENABLE_PROGMEM 1 #else #define ARDUINOJSON_ENABLE_PROGMEM 0 #endif #endif // Convert unicode escape sequence (\u0123) to UTF-8 #ifndef ARDUINOJSON_DECODE_UNICODE #define ARDUINOJSON_DECODE_UNICODE 0 #endif // Control the exponentiation threshold for big numbers // CAUTION: cannot be more that 1e9 !!!! #ifndef ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD #define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e7 #endif // Control the exponentiation threshold for small numbers #ifndef ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD #define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5 #endif #ifndef ARDUINOJSON_LITTLE_ENDIAN #if defined(_MSC_VER) || \ (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \ defined(__LITTLE_ENDIAN__) || defined(__i386) || defined(__x86_64) #define ARDUINOJSON_LITTLE_ENDIAN 1 #else #define ARDUINOJSON_LITTLE_ENDIAN 0 #endif #endif #ifndef ARDUINOJSON_TAB #define ARDUINOJSON_TAB " " #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Deserialization/ArduinoStreamReader.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #if ARDUINOJSON_ENABLE_ARDUINO_STREAM #include namespace ARDUINOJSON_NAMESPACE { struct ArduinoStreamReader { Stream& _stream; char _current; bool _ended; public: explicit ArduinoStreamReader(Stream& stream) : _stream(stream), _current(0), _ended(false) {} char read() { // don't use _stream.read() as it ignores the timeout char c = 0; _ended = _stream.readBytes(&c, 1) == 0; return c; } bool ended() const { return _ended; } }; inline ArduinoStreamReader makeReader(Stream& input) { return ArduinoStreamReader(input); } } // namespace ARDUINOJSON_NAMESPACE #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Deserialization/CharPointerReader.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once namespace ARDUINOJSON_NAMESPACE { class UnsafeCharPointerReader { const char* _ptr; public: explicit UnsafeCharPointerReader(const char* ptr) : _ptr(ptr ? ptr : reinterpret_cast("")) {} char read() { return static_cast(*_ptr++); } bool ended() const { // we cannot know, that's why it's unsafe return false; } }; class SafeCharPointerReader { const char* _ptr; const char* _end; public: explicit SafeCharPointerReader(const char* ptr, size_t len) : _ptr(ptr ? ptr : reinterpret_cast("")), _end(_ptr + len) {} char read() { return static_cast(*_ptr++); } bool ended() const { return _ptr == _end; } }; template inline UnsafeCharPointerReader makeReader(TChar* input) { return UnsafeCharPointerReader(reinterpret_cast(input)); } template inline SafeCharPointerReader makeReader(TChar* input, size_t n) { return SafeCharPointerReader(reinterpret_cast(input), n); } #if ARDUINOJSON_ENABLE_ARDUINO_STRING inline SafeCharPointerReader makeReader(const ::String& input) { return SafeCharPointerReader(input.c_str(), input.length()); } #endif } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Deserialization/DeserializationError.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #if ARDUINOJSON_ENABLE_STD_STREAM #include #endif namespace ARDUINOJSON_NAMESPACE { class DeserializationError { // safe bool idiom typedef void (DeserializationError::*bool_type)() const; void safeBoolHelper() const {} public: enum Code { Ok, IncompleteInput, InvalidInput, NoMemory, NotSupported, TooDeep }; DeserializationError() {} DeserializationError(Code c) : _code(c) {} // Compare with DeserializationError friend bool operator==(const DeserializationError& lhs, const DeserializationError& rhs) { return lhs._code == rhs._code; } friend bool operator!=(const DeserializationError& lhs, const DeserializationError& rhs) { return lhs._code != rhs._code; } // Compare with Code friend bool operator==(const DeserializationError& lhs, Code rhs) { return lhs._code == rhs; } friend bool operator==(Code lhs, const DeserializationError& rhs) { return lhs == rhs._code; } friend bool operator!=(const DeserializationError& lhs, Code rhs) { return lhs._code != rhs; } friend bool operator!=(Code lhs, const DeserializationError& rhs) { return lhs != rhs._code; } // Behaves like a bool operator bool_type() const { return _code != Ok ? &DeserializationError::safeBoolHelper : 0; } friend bool operator==(bool value, const DeserializationError& err) { return static_cast(err) == value; } friend bool operator==(const DeserializationError& err, bool value) { return static_cast(err) == value; } friend bool operator!=(bool value, const DeserializationError& err) { return static_cast(err) != value; } friend bool operator!=(const DeserializationError& err, bool value) { return static_cast(err) != value; } // Returns internal enum, useful for switch statement Code code() const { return _code; } const char* c_str() const { switch (_code) { case Ok: return "Ok"; case TooDeep: return "TooDeep"; case NoMemory: return "NoMemory"; case InvalidInput: return "InvalidInput"; case IncompleteInput: return "IncompleteInput"; case NotSupported: return "NotSupported"; default: return "???"; } } private: Code _code; }; #if ARDUINOJSON_ENABLE_STD_STREAM inline std::ostream& operator<<(std::ostream& s, const DeserializationError& e) { s << e.c_str(); return s; } inline std::ostream& operator<<(std::ostream& s, DeserializationError::Code c) { s << DeserializationError(c).c_str(); return s; } #endif } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Deserialization/FlashStringReader.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #if ARDUINOJSON_ENABLE_PROGMEM namespace ARDUINOJSON_NAMESPACE { class UnsafeFlashStringReader { const char* _ptr; public: explicit UnsafeFlashStringReader(const __FlashStringHelper* ptr) : _ptr(reinterpret_cast(ptr)) {} char read() { return pgm_read_byte_near(_ptr++); } bool ended() const { // this reader cannot detect the end return false; } }; class SafeFlashStringReader { const char* _ptr; const char* _end; public: explicit SafeFlashStringReader(const __FlashStringHelper* ptr, size_t size) : _ptr(reinterpret_cast(ptr)), _end(_ptr + size) {} char read() { return pgm_read_byte_near(_ptr++); } bool ended() const { return _ptr == _end; } }; inline UnsafeFlashStringReader makeReader(const __FlashStringHelper* input) { return UnsafeFlashStringReader(input); } inline SafeFlashStringReader makeReader(const __FlashStringHelper* input, size_t size) { return SafeFlashStringReader(input, size); } } // namespace ARDUINOJSON_NAMESPACE #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Deserialization/IteratorReader.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once namespace ARDUINOJSON_NAMESPACE { template class IteratorReader { TIterator _ptr, _end; public: explicit IteratorReader(TIterator begin, TIterator end) : _ptr(begin), _end(end) {} bool ended() const { return _ptr == _end; } char read() { return char(*_ptr++); } }; template inline IteratorReader makeReader( const TInput& input) { return IteratorReader(input.begin(), input.end()); } } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Deserialization/NestingLimit.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "../Configuration.hpp" namespace ARDUINOJSON_NAMESPACE { struct NestingLimit { NestingLimit() : value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {} explicit NestingLimit(uint8_t n) : value(n) {} uint8_t value; }; } // namespace ARDUINOJSON_NAMESPACE ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Deserialization/StdStreamReader.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #if ARDUINOJSON_ENABLE_STD_STREAM #include namespace ARDUINOJSON_NAMESPACE { class StdStreamReader { std::istream& _stream; char _current; public: explicit StdStreamReader(std::istream& stream) : _stream(stream), _current(0) {} bool ended() const { return _stream.eof(); } char read() { return static_cast(_stream.get()); } private: StdStreamReader& operator=(const StdStreamReader&); // Visual Studio C4512 }; inline StdStreamReader makeReader(std::istream& input) { return StdStreamReader(input); } } // namespace ARDUINOJSON_NAMESPACE #endif ================================================ FILE: Firmware/FirmwareSource/Remora-OS5/lib/ArduinoJson6/ArduinoJson/Deserialization/deserialize.hpp ================================================ // ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include "../StringStorage/StringStorage.hpp" #include "ArduinoStreamReader.hpp" #include "CharPointerReader.hpp" #include "DeserializationError.hpp" #include "FlashStringReader.hpp" #include "IteratorReader.hpp" #include "NestingLimit.hpp" #include "StdStreamReader.hpp" namespace ARDUINOJSON_NAMESPACE { template