mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #2211 from pan-/nrf52_nrf51_unified_integration
NRF52 target and unification with NRF51pull/2277/head
commit
90fa585568
|
@ -0,0 +1,344 @@
|
|||
# Change Log
|
||||
|
||||
## [v2.5.3](https://github.com/ARMmbed/ble-nrf51822/tree/v2.5.3) (2016-02-16)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.5.2...v2.5.3)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Fix for compilation errors with S110 softdevice in btle.cpp [\#109](https://github.com/ARMmbed/ble-nrf51822/pull/109) ([ddavidebor](https://github.com/ddavidebor))
|
||||
|
||||
## [v2.5.2](https://github.com/ARMmbed/ble-nrf51822/tree/v2.5.2) (2016-02-16)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.5.1...v2.5.2)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Sync develop against master [\#113](https://github.com/ARMmbed/ble-nrf51822/pull/113) ([pan-](https://github.com/pan-))
|
||||
- Fix incorrect handles of characteristics descriptors. [\#112](https://github.com/ARMmbed/ble-nrf51822/pull/112) ([pan-](https://github.com/pan-))
|
||||
|
||||
## [v2.5.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.5.1) (2016-01-27)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.5.0...v2.5.1)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Remove Gap::state updates from this module [\#108](https://github.com/ARMmbed/ble-nrf51822/pull/108) ([andresag01](https://github.com/andresag01))
|
||||
- merge version [\#106](https://github.com/ARMmbed/ble-nrf51822/pull/106) ([pan-](https://github.com/pan-))
|
||||
|
||||
## [v2.5.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.5.0) (2016-01-12)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.4.1...v2.5.0)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Fix access to enum member [\#105](https://github.com/ARMmbed/ble-nrf51822/pull/105) ([pan-](https://github.com/pan-))
|
||||
- Hotfix dependency [\#104](https://github.com/ARMmbed/ble-nrf51822/pull/104) ([pan-](https://github.com/pan-))
|
||||
- Finish implementation of getAddressesFromBondTable [\#103](https://github.com/ARMmbed/ble-nrf51822/pull/103) ([andresag01](https://github.com/andresag01))
|
||||
|
||||
## [v2.4.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.4.1) (2016-01-11)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.4.0...v2.4.1)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- merge branch develop \(v2.4.0\) [\#100](https://github.com/ARMmbed/ble-nrf51822/pull/100) ([pan-](https://github.com/pan-))
|
||||
|
||||
## [v2.4.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.4.0) (2016-01-10)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.3.1...v2.4.0)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Add implementation of experimental whitelisting API [\#99](https://github.com/ARMmbed/ble-nrf51822/pull/99) ([andresag01](https://github.com/andresag01))
|
||||
|
||||
## [v2.3.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.3.1) (2016-01-07)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.3.0...v2.3.1)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Update yotta module dependencies [\#98](https://github.com/ARMmbed/ble-nrf51822/pull/98) ([pan-](https://github.com/pan-))
|
||||
|
||||
## [v2.3.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.3.0) (2015-12-23)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.10...v2.3.0)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Implementation of Characteristic descriptor discovery [\#74](https://github.com/ARMmbed/ble-nrf51822/pull/74) ([pan-](https://github.com/pan-))
|
||||
|
||||
## [v2.2.10](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.10) (2015-12-23)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.9...v2.2.10)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- nRF5xn::init don't verify if errors have occurred during btle\_init [\#59](https://github.com/ARMmbed/ble-nrf51822/issues/59)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- A call to shutdown does not clear the state of some components of BLE API [\#85](https://github.com/ARMmbed/ble-nrf51822/issues/85)
|
||||
- Memory allocation issue on the NRF51DK board. [\#76](https://github.com/ARMmbed/ble-nrf51822/issues/76)
|
||||
- Terrible handling of initLen / minLen and variable length characteristics. [\#56](https://github.com/ARMmbed/ble-nrf51822/issues/56)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Fix shutdown of Gap instance to avoid NULL refs [\#96](https://github.com/ARMmbed/ble-nrf51822/pull/96) ([andresag01](https://github.com/andresag01))
|
||||
- Add check for return code of ble\_init [\#95](https://github.com/ARMmbed/ble-nrf51822/pull/95) ([andresag01](https://github.com/andresag01))
|
||||
|
||||
## [v2.2.9](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.9) (2015-12-18)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.8...v2.2.9)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- Cannot open source input file "system\_nrf51.h" [\#52](https://github.com/ARMmbed/ble-nrf51822/issues/52)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Remove occurrence of deprecated appearance enum [\#92](https://github.com/ARMmbed/ble-nrf51822/pull/92) ([andresag01](https://github.com/andresag01))
|
||||
|
||||
## [v2.2.8](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.8) (2015-12-16)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.7...v2.2.8)
|
||||
|
||||
## [v2.2.7](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.7) (2015-12-15)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.6...v2.2.7)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Replace deprecated inclusions of mbed.h [\#89](https://github.com/ARMmbed/ble-nrf51822/pull/89) ([andresag01](https://github.com/andresag01))
|
||||
- Improve shutdown to clear BLE API and not just SD [\#87](https://github.com/ARMmbed/ble-nrf51822/pull/87) ([andresag01](https://github.com/andresag01))
|
||||
|
||||
## [v2.2.6](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.6) (2015-12-15)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.5...v2.2.6)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- follow the extraction of address related types from Gap.h into BLEProtocol.h [\#88](https://github.com/ARMmbed/ble-nrf51822/pull/88) ([rgrover](https://github.com/rgrover))
|
||||
|
||||
## [v2.2.5](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.5) (2015-12-11)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.3...v2.2.5)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Added SecurityManager::setLinkSecurity call for elevating security settings on a particular connection. [\#86](https://github.com/ARMmbed/ble-nrf51822/pull/86) ([marcuschangarm](https://github.com/marcuschangarm))
|
||||
|
||||
## [v2.2.3](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.3) (2015-12-10)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.2...v2.2.3)
|
||||
|
||||
## [v2.2.2](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.2) (2015-12-08)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.1...v2.2.2)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Add -Wno-unused-function to supress-warnings.cmake [\#83](https://github.com/ARMmbed/ble-nrf51822/pull/83) ([andresag01](https://github.com/andresag01))
|
||||
|
||||
## [v2.2.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.1) (2015-12-08)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.2.0...v2.2.1)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- WIP: UUID endian change [\#82](https://github.com/ARMmbed/ble-nrf51822/pull/82) ([marcuschangarm](https://github.com/marcuschangarm))
|
||||
|
||||
## [v2.2.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.2.0) (2015-12-02)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.1.4...v2.2.0)
|
||||
|
||||
## [v2.1.4](https://github.com/ARMmbed/ble-nrf51822/tree/v2.1.4) (2015-12-02)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.1.3...v2.1.4)
|
||||
|
||||
## [v2.1.3](https://github.com/ARMmbed/ble-nrf51822/tree/v2.1.3) (2015-12-02)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.1.2...v2.1.3)
|
||||
|
||||
## [v2.1.2](https://github.com/ARMmbed/ble-nrf51822/tree/v2.1.2) (2015-12-02)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.1.1...v2.1.2)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Allow GattAttributes to have variable length [\#81](https://github.com/ARMmbed/ble-nrf51822/pull/81) ([andresag01](https://github.com/andresag01))
|
||||
|
||||
## [v2.1.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.1.1) (2015-12-02)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.1.0...v2.1.1)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Fixed endianness bug in nRF5xServiceDiscovery::processDiscoverUUIDResponse so it is consistent with BLE API. [\#80](https://github.com/ARMmbed/ble-nrf51822/pull/80) ([marcuschangarm](https://github.com/marcuschangarm))
|
||||
- Fixed bug in nRF5xGap.setAddress where random adresses where not set properly. [\#79](https://github.com/ARMmbed/ble-nrf51822/pull/79) ([marcuschangarm](https://github.com/marcuschangarm))
|
||||
- Separate concept of minlen and len for BLE chars [\#78](https://github.com/ARMmbed/ble-nrf51822/pull/78) ([andresag01](https://github.com/andresag01))
|
||||
- Split nordic sdk into its own module [\#75](https://github.com/ARMmbed/ble-nrf51822/pull/75) ([LiyouZhou](https://github.com/LiyouZhou))
|
||||
|
||||
## [v2.1.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.1.0) (2015-11-27)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.8...v2.1.0)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Update to sdk 8.1 [\#77](https://github.com/ARMmbed/ble-nrf51822/pull/77) ([LiyouZhou](https://github.com/LiyouZhou))
|
||||
|
||||
## [v2.0.8](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.8) (2015-11-26)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.7...v2.0.8)
|
||||
|
||||
## [v2.0.7](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.7) (2015-11-26)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.6...v2.0.7)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- test2000 [\#72](https://github.com/ARMmbed/ble-nrf51822/issues/72)
|
||||
- test1000000 [\#71](https://github.com/ARMmbed/ble-nrf51822/issues/71)
|
||||
- test4 [\#70](https://github.com/ARMmbed/ble-nrf51822/issues/70)
|
||||
- test3 [\#69](https://github.com/ARMmbed/ble-nrf51822/issues/69)
|
||||
- test2 [\#68](https://github.com/ARMmbed/ble-nrf51822/issues/68)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- use Extern c around \#include to use nordic sdk headers implemented in C [\#73](https://github.com/ARMmbed/ble-nrf51822/pull/73) ([LiyouZhou](https://github.com/LiyouZhou))
|
||||
|
||||
## [v2.0.6](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.6) (2015-11-17)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.5...v2.0.6)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- test [\#66](https://github.com/ARMmbed/ble-nrf51822/issues/66)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- add Nordic's license agreement. [\#67](https://github.com/ARMmbed/ble-nrf51822/pull/67) ([rgrover](https://github.com/rgrover))
|
||||
|
||||
## [v2.0.5](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.5) (2015-11-16)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.4...v2.0.5)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Post radio notification callback through minar [\#65](https://github.com/ARMmbed/ble-nrf51822/pull/65) ([andresag01](https://github.com/andresag01))
|
||||
|
||||
## [v2.0.4](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.4) (2015-11-13)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.3...v2.0.4)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Fix assembly sequence to start bootloader in GCC [\#64](https://github.com/ARMmbed/ble-nrf51822/pull/64) ([andresag01](https://github.com/andresag01))
|
||||
|
||||
## [v2.0.3](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.3) (2015-11-09)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.2...v2.0.3)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Added watchdog header file from Nordic SDK 8.1 [\#62](https://github.com/ARMmbed/ble-nrf51822/pull/62) ([marcuschangarm](https://github.com/marcuschangarm))
|
||||
|
||||
## [v2.0.2](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.2) (2015-11-03)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/mbedos-release-15-11...v2.0.2)
|
||||
|
||||
## [mbedos-release-15-11](https://github.com/ARMmbed/ble-nrf51822/tree/mbedos-release-15-11) (2015-11-03)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.1...mbedos-release-15-11)
|
||||
|
||||
## [v2.0.1](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.1) (2015-11-02)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v2.0.0...v2.0.1)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Ensure that the initialization flags is set to false if the BLE stack is shutdown properly. [\#58](https://github.com/ARMmbed/ble-nrf51822/pull/58) ([pan-](https://github.com/pan-))
|
||||
|
||||
## [v2.0.0](https://github.com/ARMmbed/ble-nrf51822/tree/v2.0.0) (2015-11-02)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v1.1.0...v2.0.0)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- Nordic SDK and SoftDevice [\#57](https://github.com/ARMmbed/ble-nrf51822/issues/57)
|
||||
- shouldn't eab6631cb be merged into master? [\#54](https://github.com/ARMmbed/ble-nrf51822/issues/54)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Introduced changes for memory savings [\#55](https://github.com/ARMmbed/ble-nrf51822/pull/55) ([andresag01](https://github.com/andresag01))
|
||||
|
||||
## [v1.1.0](https://github.com/ARMmbed/ble-nrf51822/tree/v1.1.0) (2015-10-28)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v1.0.0...v1.1.0)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- target dependencies in module.json [\#50](https://github.com/ARMmbed/ble-nrf51822/issues/50)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- When connecting, if no scanning parameters are passed, use values from Gap parent. [\#53](https://github.com/ARMmbed/ble-nrf51822/pull/53) ([marcuschangarm](https://github.com/marcuschangarm))
|
||||
|
||||
## [v1.0.0](https://github.com/ARMmbed/ble-nrf51822/tree/v1.0.0) (2015-10-19)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/mbedos-techcon-oob2...v1.0.0)
|
||||
|
||||
## [mbedos-techcon-oob2](https://github.com/ARMmbed/ble-nrf51822/tree/mbedos-techcon-oob2) (2015-10-19)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.8...mbedos-techcon-oob2)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- rename the bootloader files with \_fota in the name? [\#51](https://github.com/ARMmbed/ble-nrf51822/issues/51)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Update S110 detection macros, again [\#49](https://github.com/ARMmbed/ble-nrf51822/pull/49) ([jpbrucker](https://github.com/jpbrucker))
|
||||
- Error check number of characteristics [\#48](https://github.com/ARMmbed/ble-nrf51822/pull/48) ([Timmmm](https://github.com/Timmmm))
|
||||
|
||||
## [v0.4.8](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.8) (2015-09-25)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.7...v0.4.8)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- Error real cause loss in nRF5xGattServer.cpp [\#44](https://github.com/ARMmbed/ble-nrf51822/issues/44)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- rgrover patch fixed [\#47](https://github.com/ARMmbed/ble-nrf51822/pull/47) ([fabiencomte](https://github.com/fabiencomte))
|
||||
- Update S110 detection macros [\#43](https://github.com/ARMmbed/ble-nrf51822/pull/43) ([jpbrucker](https://github.com/jpbrucker))
|
||||
- remove some unnecessary include paths [\#42](https://github.com/ARMmbed/ble-nrf51822/pull/42) ([autopulated](https://github.com/autopulated))
|
||||
- Add FOTA bootloader image [\#41](https://github.com/ARMmbed/ble-nrf51822/pull/41) ([jpbrucker](https://github.com/jpbrucker))
|
||||
|
||||
## [v0.4.7](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.7) (2015-08-13)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.6...v0.4.7)
|
||||
|
||||
## [v0.4.6](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.6) (2015-08-11)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.5...v0.4.6)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- remove duplication of global static variable BLE\_EVT\_BUFFER [\#39](https://github.com/ARMmbed/ble-nrf51822/issues/39)
|
||||
- clearScanResponse\(\) [\#30](https://github.com/ARMmbed/ble-nrf51822/issues/30)
|
||||
- Debug builds fail due to missing bsp.h [\#11](https://github.com/ARMmbed/ble-nrf51822/issues/11)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Disable GattClient features when using S110 SoftDevice [\#38](https://github.com/ARMmbed/ble-nrf51822/pull/38) ([jpbrucker](https://github.com/jpbrucker))
|
||||
|
||||
## [v0.4.5](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.5) (2015-08-10)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.4...v0.4.5)
|
||||
|
||||
## [v0.4.4](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.4) (2015-08-07)
|
||||
[Full Changelog](https://github.com/ARMmbed/ble-nrf51822/compare/v0.4.3...v0.4.4)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- nrf51822 hangs after calling sd\_flash\_page\_erase\(\) [\#35](https://github.com/ARMmbed/ble-nrf51822/issues/35)
|
||||
- nRF5xn::getVersion return \(Unknown\) with version 8 soft device [\#29](https://github.com/ARMmbed/ble-nrf51822/issues/29)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Changed Gap:: to GapAdvertisingParams:: because of change in BLE [\#34](https://github.com/ARMmbed/ble-nrf51822/pull/34) ([jslater8](https://github.com/jslater8))
|
||||
- Select the clock source dynamically on SoftDevice initialisation [\#32](https://github.com/ARMmbed/ble-nrf51822/pull/32) ([jpbrucker](https://github.com/jpbrucker))
|
||||
- Add S110 SoftDevice compatibility [\#28](https://github.com/ARMmbed/ble-nrf51822/pull/28) ([jpbrucker](https://github.com/jpbrucker))
|
||||
|
||||
## [v0.4.3](https://github.com/ARMmbed/ble-nrf51822/tree/v0.4.3) (2015-07-22)
|
||||
**Closed issues:**
|
||||
|
||||
- Target polling failed [\#24](https://github.com/ARMmbed/ble-nrf51822/issues/24)
|
||||
- support handling of HVX Events \(notifications and indications\). [\#22](https://github.com/ARMmbed/ble-nrf51822/issues/22)
|
||||
- provide an implementation for GattServer::areUpdatesEnabled\(\) [\#21](https://github.com/ARMmbed/ble-nrf51822/issues/21)
|
||||
- getValueHandle\(\) returns characteristicIndex instead of attribute-handle [\#20](https://github.com/ARMmbed/ble-nrf51822/issues/20)
|
||||
- Clash With Definition And Enum Naming [\#16](https://github.com/ARMmbed/ble-nrf51822/issues/16)
|
||||
- Errors in GCC build [\#14](https://github.com/ARMmbed/ble-nrf51822/issues/14)
|
||||
- bring s110 support back [\#10](https://github.com/ARMmbed/ble-nrf51822/issues/10)
|
||||
- Allow adding a User Description descriptor to a GattCharacteristic. [\#9](https://github.com/ARMmbed/ble-nrf51822/issues/9)
|
||||
- device\_manager\_peripheral.c includes app\_trace.h [\#7](https://github.com/ARMmbed/ble-nrf51822/issues/7)
|
||||
- linking esb\_gcc.a \(nrf51822 enhanced shock burst\) with mbed [\#5](https://github.com/ARMmbed/ble-nrf51822/issues/5)
|
||||
- The app\_timer usage may conflict [\#2](https://github.com/ARMmbed/ble-nrf51822/issues/2)
|
||||
- Nordic License [\#1](https://github.com/ARMmbed/ble-nrf51822/issues/1)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Develop [\#25](https://github.com/ARMmbed/ble-nrf51822/pull/25) ([zoujixing](https://github.com/zoujixing))
|
||||
- Remove unnecessary 'compiler\_abstraction.h' to get rid of duplicate '… [\#23](https://github.com/ARMmbed/ble-nrf51822/pull/23) ([adfernandes](https://github.com/adfernandes))
|
||||
- restructure for minimal yotta compatibility [\#15](https://github.com/ARMmbed/ble-nrf51822/pull/15) ([autopulated](https://github.com/autopulated))
|
||||
- Fix various GCC compilation issues. [\#12](https://github.com/ARMmbed/ble-nrf51822/pull/12) ([adfernandes](https://github.com/adfernandes))
|
||||
- Fix for GCC lost in SDK v8.0 update [\#8](https://github.com/ARMmbed/ble-nrf51822/pull/8) ([rosterloh](https://github.com/rosterloh))
|
||||
- new target DELTA\_DFCM\_NNN40 with nrf51822 chip, config internal RC crystal. [\#6](https://github.com/ARMmbed/ble-nrf51822/pull/6) ([Marcomissyou](https://github.com/Marcomissyou))
|
||||
- Updated return value for nRF51GattServer::updateValue. Will now report w... [\#4](https://github.com/ARMmbed/ble-nrf51822/pull/4) ([marcuschangarm](https://github.com/marcuschangarm))
|
||||
- Added optional data and length fields to the return struct for authorize... [\#3](https://github.com/ARMmbed/ble-nrf51822/pull/3) ([marcuschangarm](https://github.com/marcuschangarm))
|
||||
|
||||
|
||||
|
||||
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
|
@ -0,0 +1,6 @@
|
|||
This module contains softdevice which comes with The Nordic Softdevice License Agreement,
|
||||
a BSD-like licence for binary distributions, offered by Nordic for use in mbed. Some
|
||||
other files come from the mbed SDK, and are licensed under Apache-2.0. Unless
|
||||
specifically indicated otherwise in a file, files are licensed under the
|
||||
Apache 2.0 license, as can be found in: apache-2.0.txt. The Nordic Semiconductor Softdevice
|
||||
License Agreement can be found in softdevice_nrf51822_licence_agreement.txt.
|
|
@ -0,0 +1,13 @@
|
|||
Copyright (c) 2015 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.
|
|
@ -0,0 +1,463 @@
|
|||
:020000040003F7
|
||||
:20C00000983C002005DD030017DD030019DD03000000000000000000000000000000000057
|
||||
:20C0200000000000000000000000000069C1030000000000000000001DDD03001FDD0300D7
|
||||
:20C0400021DD030021DD030021DD030021DD030021DD03000000000021DD030021DD0300D9
|
||||
:20C0600021DD030021DD030021DD030021DD030021DD030021DD030021DD030021DD0300B8
|
||||
:20C0800021DD030057D8030021DD030021DD03006DD8030021DD03004DF4030021DD0300DD
|
||||
:20C0A00021DD030021DD03000000000000000000000000000000000000000000000000007E
|
||||
:20C0C00000F002F800F040F80CA030C8083824182D18A246671EAB4654465D46AC4201D18E
|
||||
:20C0E00000F032F87E460F3E0FCCB6460126334200D0FB1AA246AB463343184710370000C8
|
||||
:20C1000030370000103A02D378C878C1FAD8520701D330C830C101D504680C6070470000D3
|
||||
:20C120000023002400250026103A01D378C1FBD8520700D330C100D50B6070471FB5C04655
|
||||
:20C14000C0461FBD10B510BD03F0E3FA1146FFF7F5FF00F0D3F803F0FBFA03B4FFF7F2FF19
|
||||
:20C1600003BC03F0FFFA00000648704502D1EFF3098101E0EFF30881886902380078024A97
|
||||
:20C1800010470000FDFFFFFF39D50300401E00BF00BF00BF00BF00BF00BF00BF00BF00BF28
|
||||
:20C1A00000BF00BF00BFF1D170470000401E00BF00BF00BF00BF00BF00BF00BF00BF00BFB4
|
||||
:20C1C00000BF00BF00BFF1D170470000401E00BF00BF00BF00BF00BF00BF00BF00BF00BF94
|
||||
:20C1E00000BF00BF00BFF1D170470000056885F3088846680A4AEFF305839A42304602D183
|
||||
:20C20000084CA6463047074C064D0646064FF0B4034C034D024E024FF0B404480047000005
|
||||
:20C2200000000000FFFFFFFF00000021F9FFFFFF70B505460C46164602E00FCC0FC5103EEE
|
||||
:20C24000102EFAD2082E02D303CC03C5083E042E07D301CC01C5361F03E021782970641C63
|
||||
:20C260006D1C761EF9D270BD0A4610B50146664803F064F810BD10B502F078FC10BD10B5C6
|
||||
:20C28000624C86B01ECC03946C460EC4002807D0684618DF002803D00022114603F04EF864
|
||||
:20C2A0000F20800313DF002803D00022114603F045F8574B48225749092003F0A3F80028AB
|
||||
:20C2C00003D00022114603F039F800200490059001206946087404A860DF002803D0002251
|
||||
:20C2E000114603F02BF84C4803F0A8F8002803D00022114603F022F806B010BD08B547485A
|
||||
:20C30000C169B12943D0002445480F2140698903884204D000221146104603F00FF8012068
|
||||
:20C320000007006901218902884204D000221146104603F003F83B4800903B4B05220321A1
|
||||
:20C34000002001F0BAFA002803D00022114602F0F5FF00F067FC00F0AAFC012500281AD09D
|
||||
:20C3600000F0B4FC002803D00022114602F0E6FF20466840FFF783FF00F038F800F0CCFC74
|
||||
:20C3800000280ED00022114602F0D8FF09E001240021C161B8E720466840FFF770FF00F002
|
||||
:20C3A00025F803252D03002C04D1A86800F090FB002807D100F047FC002803D000221146D5
|
||||
:20C3C00002F0BCFFA86800F083FB002806D000F06EFC002802D1A86800F041FCBFF34F8F12
|
||||
:20C3E00013491248C860BFF34F8FFEE7094A10B548321421082002F00BFF002803D00022E2
|
||||
:20C40000114602F09BFF10BDEFBEADDE8CF703006BF30300342B002077C20300000500404D
|
||||
:20C4200000100010EFDC0300F42800200400FA0500ED00E070B5FC4C1E46A06815460229A3
|
||||
:20C4400002D0042916D108E0052813D1A369002B10D03246294604200BE002280AD1F348B0
|
||||
:20C46000406880470320A060A369002B02D0324629469847280003D00022114602F05EFF98
|
||||
:20C4800070BD4CB5E84E0120307005200195009400F058FB4CBD10B5E34C2078002801D057
|
||||
:20C4A000082010BD206901F0F4FA002803D00022114602F043FF0F2100228904206901F01E
|
||||
:20C4C000ABFA040003D00022114602F037FF204610BDD54910B5D448243141610221816012
|
||||
:20C4E000C168243002F059FD002803D00022114602F024FF10BDCC4910B5CB481C31416145
|
||||
:20C50000022181600320000380680F218903081A4108C5481C3002F040FD002803D000223D
|
||||
:20C52000114602F00BFF10BD704700B589B01822BF4902A8FFF77CFE06980799009001917A
|
||||
:20C5400002A80FC800F0FEFA09B000BD00B5B64987B049886A461181032109038968069146
|
||||
:20C56000B249012050394A6803928A680492C9680591069A0091019202A90EC900F0E2FA6E
|
||||
:20C58000002007B000BD30B5A84CA748503C89B02430E16802F001FD002803D00022114679
|
||||
:20C5A00002F0CCFEA048E2681C3041680023083002F0C3FC050012D1182102A802F0E6FFEA
|
||||
:20C5C00000209949029049886A469181E1680691079A0091019203A90EC900F0B3FA284601
|
||||
:20C5E00009B030BD00B5904987B049886A4611818E49032050394A6803928A680492C9683A
|
||||
:20C600000591069A0091019202A90EC900F09AFA0020B6E73EB5864A6B46183207CA07C3A4
|
||||
:20C62000814D00246C7029466C802431684602F068FC002801D0AC603EBD03207A4900038F
|
||||
:20C6400080682431486024390A46526ACA610F218903091A490840187349764A1C31486068
|
||||
:20C6600071480021103001F07BF9002803D00022114602F063FE0F2100228904286901F013
|
||||
:20C68000CBF9002803D00022114602F057FE01206C60A86000203EBD63498861704770B59A
|
||||
:20C6A000426862481468536891685038D26804604360C26081600078440701D5840705D130
|
||||
:20C6C0009C0703D18C0701D1940701D0062070BD5B189A18544D0F239B02EA60994213D81A
|
||||
:20C6E0005549564B514CC60709D08868181A90420AD3534820605348606053480FE08968F6
|
||||
:20C70000591A4908914201D20C2070BD4F4921604F496160800701D54E4800E04E48A0607B
|
||||
:20C72000A868012802D00826304670BDFFF7B3FE0600FAD12168E8688847F5E770B50500F7
|
||||
:20C7400004D0287A800703D0102070BD0E2070BD354CA068032805D0042801D0052803D0CB
|
||||
:20C76000082070BD0520A0606868E168860060688019884204D90020C04360600C2070BD5C
|
||||
:20C78000FFF789FE0028FAD1A96832466368606902F0D3FB0028F2D1616889196160E268EB
|
||||
:20C7A0009142ECD0092070BD10B51F4C08206168002900D010BDA1680429FBD11B4861786F
|
||||
:20C7C000403802F021FC002802D00021617010BD0521A16010BDF8B5134C0746A068032899
|
||||
:20C7E00004D0042804D008252846F8BD0420A0606068002801D00820F8BDFFF74CFE05000E
|
||||
:20C80000FAD17868860060788119402901D90920F8BD064AB968403A1018324602F057FE82
|
||||
:20C82000607880196070DFE7002800201C2D00209CF7030083C403000030000000C003006D
|
||||
:20C84000D3C403002BC503004DC50300F7C4030029C50300E5C5030087C5030010B5894CF1
|
||||
:20C86000A068052813D1E168606888420FD10620A060FFF710FE002808D16069E1684068FF
|
||||
:20C8800002F0FCFB002801D10721A16010BD082010BD10B57B488168072901D0082010BD63
|
||||
:20C8A000006901F0F6F8002803D00022114602F045FD75488068804710BD1CB506200195C2
|
||||
:20C8C000009400F03FF91CBDF8B51C4617460D46064600F0C1F8002817D001200003854215
|
||||
:20C8E00007D92346291B301B1A46FFF7EDFF00280BD13A462946304600F0B9F8002804D117
|
||||
:20C900003A462946304600F0A7F8F8BDF0B589B0684600F015FA049800282AD001210903F7
|
||||
:20C92000079A4018904226D9501A45081046049A0C468718024668001618001908900320DF
|
||||
:20C9400000038068049988420DD261190846042200F08DF800280CD121460422084600F073
|
||||
:20C9600086F8002805D1BA1B2B4630460899FFF7ABFF09B0F0BD049A079800F078F8F8E75C
|
||||
:20C9800000B58DB004A800F0DBF9099800280DD0089800280CD008990B984018019000219D
|
||||
:20C9A0000998009180080290684618DF0DB000BD0320000380680F218903091A4908ECE7FB
|
||||
:20C9C00000B58DB004A800F0BBF909980028EDD00F210898890300280CD0089A0B98019158
|
||||
:20C9E0008018029003220998009280080390684618DFDBE70320000380680A1A5208EEE7D2
|
||||
:20CA000030B591B0684600F09BF90498002814D001210903079A4018904214D9501A43087B
|
||||
:20CA20001046049A5C0082180019611803242403A468049DAC4202D20E2011B030BD121AB5
|
||||
:20CA4000FFF742FFF9E703200CAB07C3049880080F900CA818DFF0E71FB5032301909008B3
|
||||
:20CA6000039000930291684618DF04B010BD1FB5012301909008039000930291684618DF58
|
||||
:20CA8000F3E70000002800201C2D002010B5BB480368012B02D1022900D10160100003D099
|
||||
:20CAA0000022114602F04AFC10BD10B5B34C48DF002803D00022114602F040FC02F0FCFB82
|
||||
:20CAC0002068022803D0032801D00428EFD110BD38B50068401C19D00024684600F058F96F
|
||||
:20CAE00000980168012910D1818800290AD0C168032000038068002202F0CEFA0099898861
|
||||
:20CB0000814201D1012400E00024204638BD10B504469A482021001D02F0B9F9002803D00E
|
||||
:20CB20000022114602F00AFC9448002320222146001D02F01BF9002803D00022114602F053
|
||||
:20CB4000FDFB10BD0FB4F8B5684600F021F96846818B069D0122894CFF238948002D13D090
|
||||
:20CB6000012D17D0032D2BD00021022D37D02A46052D46D0042D4ED0062A01D10420206071
|
||||
:20CB8000F8BC08BC04B0184781800A9983600260C16010E08180099D089949190A9D49195D
|
||||
:20CBA000C160A52183600160089901610999856141610B99C16122607148FFF7A8FFDFE7B9
|
||||
:20CBC00000990B6803608B888380C968C160AA21816008990161099941610A990BE0009D60
|
||||
:20CBE0002E68A52E09D00660AE888680ED68C5600161836041618161DDE781800360C160C5
|
||||
:20CC0000F6E700F085F9002803D00022114602F095FB0320B3E781800360C1600099896807
|
||||
:20CC20008160C9E70EB557480090202001900120029002F001F8002804D150496846091D98
|
||||
:20CC400002F023F80EBD10B5FFF7E4FC002805D100F02FFB0446FFF728FF204610BD70B58A
|
||||
:20CC600011DF002803D00022114602F067FB464900200B68444C012180340A4682401A4206
|
||||
:20CC800004D0C506ED0E0A46AA402260401C2028F3D303242403A06813DF002803D000226F
|
||||
:20CCA000114602F04BFBA06802F0F2F970BD08B5684600F06DF800980168A52904D0806888
|
||||
:20CCC000AA2801D0002008BD012008BD10B5FFF797FE002803D1FFF773FE00281BD064209C
|
||||
:20CCE00001F0F2FDFFF712FE002803D00022114602F024FBFFF784FE002803D000221146DD
|
||||
:20CD000002F01CFBFFF73CFE040003D00022114602F014FB204610BD00B589B018221B49CA
|
||||
:20CD200002A8FFF785FA069807990090019102A80FC8FFF707FFFFF7B8FE002009B000BDB5
|
||||
:20CD400010B50E4988B0044600232022091D684602F04FF80098206068468088A08003983A
|
||||
:20CD6000E0600298A06004982061059860610698A0610798E06108B010BD00002C280020E6
|
||||
:20CD8000282D00208DCA030000E100E0C0F70300014901607047000000FC030008280CD0DC
|
||||
:20CDA00004DC002807D006280FD108E00B280AD00C280AD105E001207047022070470320C9
|
||||
:20CDC000704704207047042901D0062070470520704770B515460A46032823D0042820D1FF
|
||||
:20CDE000FE4C002906D0E088FD49884219D0132176DF10E0284602F0A3F9002803D00022F7
|
||||
:20CE0000114602F09BFAE069A8420AD101220321F44801F003F8002803D00022114602F051
|
||||
:20CE20008DFA70BD01211046FFF7B8FF02460121EEE7F0B5054608790E4685B081070CD07C
|
||||
:20CE400003221146284600F0E9FF002803D00022114602F073FA05B0F0BDE04900901831D9
|
||||
:20CE600002F047F9010011D1DC4CB168009AA06902F02DFB009802F097F9010006D1204647
|
||||
:20CE80006946183002F09CF9010003D0284600F0AFFAE0E704200190009880080290A06902
|
||||
:20CEA000039001A8FFF74AFC07000BD0092F10D0A06902F045F9010002D0284600F098FA04
|
||||
:20CEC0003946E3E73079616940186061A069E061C1E7307961694118616160780028BAD073
|
||||
:20CEE0006089401E0004000C6081B4D1284601F0E9F8002803D00022114602F01FFA20890D
|
||||
:20CF00006081A8E710B50022114602F017FA10BD10B5B24C01202070E088B149884208D01B
|
||||
:20CF2000132176DF002810D00022114602F006FA0BE0A078002808D074DF002803D0002282
|
||||
:20CF4000114602F0FBF90020A07001F034FC002803D00022114602F0F1F9002010BD70B5E1
|
||||
:20CF60000D68044601209D4A2B0002F002FC0A2B3043061320575C466012FFF76FFC0421FD
|
||||
:20CF8000FFF70CFF024604212EE00022114602F0D5F970BDFFF7BCFF002803D0002211468A
|
||||
:20CFA00002F0CCF9FFF775FC002808D170BDFFF7AFFF002803D00022114602F0BFF9FFF76D
|
||||
:20CFC0007CFC70BD106188680078107170BD02201061886800780128F8D1FFF7E5FB02213F
|
||||
:20CFE000FFF7DCFE02460221204600F017FF0028CBD170BD0320106170BD12692046012ACC
|
||||
:20D0000006D0022A07D0032AF6D1FFF712FF70BD00F001FA70BD00F03BFA70BD50708888D5
|
||||
:20D020001081508170BD00205070108170BD2046516901F010F8DAE710B5044669488EB0EB
|
||||
:20D0400081796846817068490180342101A802F09DFA022001900021684641728472012131
|
||||
:20D0600001820590002101A801F03FFA002803D00022114602F062F90EB010BDF0B5574C10
|
||||
:20D080008BB0A07800283AD156481821183802F07DFA2046534CC078183C00250126002875
|
||||
:20D0A00037D02746483700950195029510226946F81D039502F0DEF9002822D0F81D08909D
|
||||
:20D0C00009976846067509A804906846067708A806900420FFF7B0FF25700220207204A813
|
||||
:20D0E000E060282020823F486582183873DF002803D00022114602F021F9384886700BB045
|
||||
:20D10000F0BD0520FFF798FF2670676025722582E9E70620FFF790FF257065602572E0E7E2
|
||||
:20D1200070B52E4C01880022E588A6B017290AD01EDC11293FD008DC022977D0102902D123
|
||||
:20D140008088E080A27026B070BD264C303426461836132951D01429F5D1C289638D002106
|
||||
:20D160009A4200D1314600238088E21D82DF1BE0512970D00EDC18296CD01929E3D18079F5
|
||||
:20D180000028E0D1A270E068401EE0604FD0FFF775FFD8E7522976D05529D4D18079002871
|
||||
:20D1A000D1D11321284676DF0028CCD00022114602F0C4F8C7E78020694688803220E06054
|
||||
:20D1C000012301AA06A92846AADF002803D00022114602F0B3F82078002807E038280020A2
|
||||
:20D1E000FFFF0000602D00203015000001D1FFF745FF0020C043E080A5E70722C14910A839
|
||||
:20D2000002F065F91022E11D0CA802F060F91C22314612A802F05BF90CA80A9012A8099039
|
||||
:20D2200006ABB94A852128467FDFBDE70DE01822B64906A8FEF7FCFF0A980B9900900191F8
|
||||
:20D2400006A80FC8FFF77EFC7DE70021284667DFAAE700E017E0817900299AD0807A042885
|
||||
:20D2600003D0062801D0052893D1022909D0012069460872FF208330888102A92846A8DF82
|
||||
:20D2800092E70220F4E700F08DF88DE710B5044601F0C2FA9B482146303800F09AFE2046D3
|
||||
:20D2A000FFF73EFF10BD10B50022114602F046F810BD30B5944D87B00024203D2C7094483D
|
||||
:20D2C0002C6102F0B3F800286AD19248FFF7E4F901F000FF002863D18A4800F059F900288C
|
||||
:20D2E00001D10120E87011206946087207228AA102A87CDF002803D00022114602F01EF8B4
|
||||
:20D3000000940C2168460194018018214180FF2184809131C1807ADF002803D0002211469A
|
||||
:20D3200002F00CF804206946009408807C4801907C4802907348303800F00BFE002803D046
|
||||
:20D340000022114601F0FAFF1C21684602F01EF9754801900120800302900094032168468C
|
||||
:20D360000173C4810474714806900594684601F0FEF9002803D00022114601F0DFFF624910
|
||||
:20D38000E12208784008400010400C30DF22104008700720487010208870FFF76FFE0020A3
|
||||
:20D3A00007B030BD70B5584C614D203CE088A84201D1082070BDE178002914D05149012359
|
||||
:20D3C00008223431A9DF0028F4D12A460C21E088A7DF5849884204D0082802D0891C88420E
|
||||
:20D3E000E8D1002070BD00231A461946A9DF70BD10B50A46044603211046FFF7CFFC0246AE
|
||||
:20D400000321204600F00AFD002803D00022114601F094FF10BD30B5054687B000200090AF
|
||||
:20D4200001900290039038486A46203800791070364A0C3A1068926804906846069205900E
|
||||
:20D4400008790C2806D003221BE00022114601F075FFA5E78C68204600F049F80190201D5E
|
||||
:20D4600000F045F802902046083000F040F8039004A8FFF714F9002892D00121FFF78EFCB9
|
||||
:20D4800002460121284600F0C9FC0028DDD187E7FEB50446087982070ED08207920F042385
|
||||
:20D4A0009B1A0022154604E08E683554401CC0B2521C9A42F8D30871012000908868029048
|
||||
:20D4C0000879800801906846FFF785F900280DD00221FFF763FC02460221204600F09EFCB8
|
||||
:20D4E000002803D00022114601F028FFFEBD10B5044602F04DF80002E178000A09060843E0
|
||||
:20D5000010BD0000902D002058280020E4F703008DD20300D3CD0300446675546172670031
|
||||
:20D520005FCF0300A7D20300CD0C000005CF0300FFFF00000230000010B50C46002802D04D
|
||||
:20D540000120086010BD2168002911D01C48421A814212D03C2A0DD23C303C3101220B78B9
|
||||
:20D5600003701346491E401E521C3C2BF7D904E00E200BE03C2201F0AAFF00223C211048A9
|
||||
:20D5800001F08AFD0E49891E08800020206010BD70B5054600223C21094801F07DFD084C21
|
||||
:20D5A000A41E2188884201D00B2070BD3C220449284601F08CFF2088401C2080002070BD87
|
||||
:20D5C000823F00208307FF22DB0E9A408907090E994000280BDA0007000F08388308FA484C
|
||||
:20D5E0009B001B18D86990430843D86170478308F6489B001B1818689043084318607047AA
|
||||
:20D6000070B50124F24960040860F24940108860F04940398860F04D6C602F20FEF7B6FDAC
|
||||
:20D62000AC60EE4D00242F206C61FEF7AFFD2C7170BDF0B5E94F2821BC6841430D19396962
|
||||
:20D640004A1C09D028224A431619AB68B268934204D8D21AB26069623861F0BD0A4602E066
|
||||
:20D660000A46796A9B1B4E1C0BD028264E433719BE689E42F4D328264E433619B768FF1A1A
|
||||
:20D68000B760AB60696228214A4311194862F0BD70B5D24C2269A5681346114606E0814212
|
||||
:20D6A00007D00A46282671434919496A4E1CF6D170BD002EFCD08A420CD1282043435819EC
|
||||
:20D6C000406A2061401C05D1C34B01209860002363616071282041434819282381685A4310
|
||||
:20D6E000406A52195062421CE2D028225043401982685118816070BDF8B5B84C2569681CF9
|
||||
:20D7000035D0B748002640686169401A07023F0A19E028204543A0682A189068B84214D8D0
|
||||
:20D72000A3693F1A8619556A002B09D0116AD0699847002807D00022114601F0FFFD02E048
|
||||
:20D74000D169106A8847681CE3D1A178E078814206D1401CC0B2E070022801D10020E07079
|
||||
:20D760009E490006800D1C310E5000F0BAF9F8BDF8B50446994800270169009146785CE038
|
||||
:20D780009648F100C2688D1851E0601C07D0934A28209268604321468018446A24E0287854
|
||||
:20D7A000182141436A68401CC0B252182870A978884200D12F70894B516828209B6848434C
|
||||
:20D7C000C0181368012B34D1037E002B31D19368C360D368036113694361526902627F4A52
|
||||
:20D7E0005279002A00D0C7607C4BC2685B6996469C46D31A1A027B4B120A9A4202D20369C3
|
||||
:20D80000D21808E0724663469A1A12020369120A934202D99A1A826000E08760C76001222E
|
||||
:20D8200007610276921E42620846FFF702FF601CABD1287869788842A7D13046761EF6B202
|
||||
:20D8400000289DD1654801690098814201D00120F8BD0020F8BD644900200860486088607F
|
||||
:20D86000C860614940390860486045E7FEB50020C0435A4D02906869019068462E6900F07B
|
||||
:20D8800035F9074600F04FF90446002F08D002AA0199009800F08FF90298FFF769FF06E050
|
||||
:20D8A0000298FFF765FF002801D1002C02D0304600F0AAF900206871FEBDFFB59807002448
|
||||
:20D8C00081B01E4615460F4600280BD1002E09D0FFF796FE41490A9888610F703246002042
|
||||
:20D8E0008E6008E0072005B0F0BD28234343D4509B181C76401CB842F7DB28204743BB19C1
|
||||
:20D90000032048700F461846CB6019461830002218232E465E43D3005B181C705C709D708A
|
||||
:20D9200058603018521C032AF5DB0020C0433861BC70FC7001242D482405046003211420A9
|
||||
:20D94000FFF740FE224880380460254C0198A06003211120FFF736FE606878610020C2E71A
|
||||
:20D9600070B51E4CA568002D06D0002A06D0002804D00023247809E0082070BD072070BDBB
|
||||
:20D9800028265E43AE59002E04D05B1CA342F7DB042070BD282401265C432E516419E261BF
|
||||
:20D9A00061600360002070BD07494868C005C00D2CD010381CD50207120F083A9208920097
|
||||
:20D9C0005118C96919E0000000ED00E000E400E080E100E040130140001001406028002054
|
||||
:20D9E00000150140FFFF7F004011014080E200E08108B14A8900891809688007C00EC1400B
|
||||
:20DA00000806800F012803D0032803D0022070470020704701207047FEB50446A74817469E
|
||||
:20DA200082680D46002A0CD001788C4201D2052D01D20720FEBD2146282359435358012B7D
|
||||
:20DA400001D00820FEBD8818406801281DD00026FFF7AAFFC00099490190C9684018694684
|
||||
:20DA600000F018F9002812D0012144600160944949680830E2C091490198C9684118009877
|
||||
:20DA8000487000F02EF80020FEBD2E46E0E70420FEBDF8B5894D0446A868002809D0297844
|
||||
:20DAA0008C4201D30720F8BD282161434058012801D00820F8BDFFF777FFC600E86869465B
|
||||
:20DAC000301800F0E7F8002809D0022112C0E86831180098487000F004F80020F8BD04206B
|
||||
:20DAE000F8BD0120774900050860704710B5734900238A78CC78A24212D0521CD2B28A70D0
|
||||
:20DB0000022A00D18B708A786C4B92001C339A580260486910180002000A4861012010BDA3
|
||||
:20DB20000360002010BDF8B5644801690091457833E06248E900C0680E1834782AE01820A2
|
||||
:20DB400060437168641C0818B178E4B2A14200D100240168022902D003291BD113E0574A00
|
||||
:20DB600040682821926841438F18397E002911D0FFF78EFD002038760CE028277843C018B1
|
||||
:20DB80000276406A03E04D4900228B680869471CF3D108617078A042D1D128466D1EEDB2D0
|
||||
:20DBA0000028C6D1454801690098814201D00120F8BD0020F8BDF7B5404C0025A7682369E0
|
||||
:20DBC0001EE028215943C9198E68864202D9301A886017E0801B751900268E600E764E6946
|
||||
:20DBE0009C464B6AB646002E0AD0019E76193602360ACE6076460E6116684E626146116045
|
||||
:20DC0000591CDED12361FEBDF8B52C4801694A1C3DD028225143826889188E6828494C681F
|
||||
:20DC200047690079E11B0D022D0AED1C002815D10120254A00045060234A403A506021491D
|
||||
:20DC4000400080310860214908602149012008602F20FEF79BFA194901200871B54200D208
|
||||
:20DC60003546E81900021649000A4031086014494968001B091B0902090A0002C91C000A88
|
||||
:20DC8000814203D901200F4940040860F8BDFFF7B7FCF8BD42788378521C934200D10022C2
|
||||
:20DCA0000378934201D1002070470A6041684078182250430818704700E400E06028002090
|
||||
:20DCC0000015014000E200E04013014000E100E00010014010B50446082904D000221146F9
|
||||
:20DCE000104601F02BFB21686068884710BD1CB501910090024A0821684601F09DFA1CBD53
|
||||
:20DD0000D5DC03000A48026803210A4302600948804709480047FEE7FEE7FEE7FEE7FEE797
|
||||
:20DD2000FEE7000005480649064A074B70470000240500404DDD0300C1C003009830002007
|
||||
:20DD4000983C00209834002098340020F8B500F035F82B4E002804D02A4870602A49F01300
|
||||
:20DD600088612A480124018CC9B201290DD1818C09070AD1018D0906090F042905D1808D56
|
||||
:20DD80000006000F01D1224884600027B461214D6F60A8058460686800280ED1C820FEF790
|
||||
:20DDA00005FA1D487F1C8742F5D30020B06101208007846068680028FCD0F8BD1348018CB5
|
||||
:20DDC000C9B2012917D1818C090714D1018D09060A0F03D1828D1206120F0ED0090F0129C2
|
||||
:20DDE00003D1828D1206120F07D0032903D1808D0006000F01D0002070470120704700008E
|
||||
:20DE000000050040DFFF07C0006C0040C00F00F000060040000100408813000030B585B071
|
||||
:20DE2000002822D00388FE4CA34220D0FD4B1B78002B1CD0FB4B10255B1C1D7059700024C0
|
||||
:20DE400001259A70032269460A820094019402940394028A0A808D708C8004A902910393E7
|
||||
:20DE600000886946A6DF05B030BD0E20FBE70820F9E7F0B58BB0044602276846077300268B
|
||||
:20DE800009968784C68408A80A900D46A18A208809AAA5DF002804D0E16A00291AD08847BE
|
||||
:20DEA00018E06846008CC007C00F13D068460682208803A9A8DF002813D1A97E28461B30BA
|
||||
:20DEC00001220B0001F055FC09430F1B202224263E284300FF20FE3069460882208803A94D
|
||||
:20DEE000A8DF0BB0F0BD00960AE0062219E069460A71029022E0204690470020F1E700920D
|
||||
:20DF00002B8B022BF3D2F0E700971DE003201AE0042018E0052016E0298B032905D20322BE
|
||||
:20DF200008212046FFF77AFFDBE741780278080210436946888003D006200090A26ADAE784
|
||||
:20DF40000720FAE7092000906946A26AD3E70322E7E730B585B00D46040038D0002D36D0EC
|
||||
:20DF60006868002833D00020C043AF4B20800FCB049301AB07C3AD4869460880891C01A888
|
||||
:20DF800063DF002822D1221D69460120A0DF00281CD168468078A071204600F0CEF8002886
|
||||
:20DFA00014D1204600F055F900280FD12946204600F002F9002809D16868A062A868002804
|
||||
:20DFC00000D0E06297490120087000204BE70E2049E73EB5002828D0002926D0826A002ABE
|
||||
:20DFE00023D00A88102A21D0112A30D0502A1FD0512A1AD104460846891D0A78022A14D196
|
||||
:20E000004A88238A9A4210D1807A04280DD006280BD0052809D0891C2046FFF72AFF002860
|
||||
:20E0200003D0E16A002900D088473EBD898810E0CA8803899A42F8D1082200928A7F6B4605
|
||||
:20E040001A7120310291826A694690473EBD0021C94301803EBDF0B585B00A4605002DD00F
|
||||
:20E0600028886F4988422BD06E480078002827D06C4C1020641C2070072060700127A770F8
|
||||
:20E080000321684601820026E11C104600F04CF801466846008A0918684601820096019680
|
||||
:20E0A00002960396298A01808770868004A80394029028886946A6DF05B0F0BD0E20FBE7D3
|
||||
:20E0C0000820F9E7F0B585B00A46050028D028885349884226D053480078002822D0514C3B
|
||||
:20E0E0001120641C20700127684607820026611C104600F019F801466846008A0918684638
|
||||
:20E1000001820096019602960396298A01808770868004A80394029028886946A6DFCBE782
|
||||
:20E120000E20C9E70820C7E70870020A4A70020C8A70000EC8700420704730B58FB0054655
|
||||
:20E140001C21684601F022FA694608780421084369460870002401940394049405940694E6
|
||||
:20E16000A87908A9887031486946801C0884601C00070794000F0C77103048778A7FF920B4
|
||||
:20E180000240921CE7200240012002438A77142109A801F0FBF908A8099007A80A906946D3
|
||||
:20E1A0008C851420CC8508860D942B46A888083309AAA2DF0FB030BDF0B58FB00F4605465A
|
||||
:20E1C0001C21684601F0E2F968460178022631430170002401940394049405940694A97917
|
||||
:20E1E00008A8817011496846091D0184601C0107090F103168460794017700200146684618
|
||||
:20E200004177817FF9200140891CE72001400120014368468177142109A801F0B7F907E086
|
||||
:20E22000FFFF000088280020FCF703003015000008A8099007A80A9068468685C4850686B5
|
||||
:20E240000D972B46A888203309AA6946A2DF0FB0F0BD30B58FB005461C21684601F096F9FD
|
||||
:20E2600069460878082108431022104369460870002401940394049405940694A87908A962
|
||||
:20E280008870144869460884601C00070794000F0C7710304877887FF9210840801CF72123
|
||||
:20E2A000084010430121084369468877142109A801F06CF908A8099007A80A9069468C851A
|
||||
:20E2C0001720CC8508860D942B46A888103309AAA2DF6FE731150000FFB583B0074600207F
|
||||
:20E2E0000C9C8646267805463AE07868A90041180A88684682804988C1800022694601A8F7
|
||||
:20E3000065DF002810D1684601780598814226D17046002801D0002200E002222078891824
|
||||
:20E3200041181F2902D90C2007B0F0BD7146002908D1401CC0B2411C069B049A21701A54AF
|
||||
:20E3400001208646217806980A18694601A865DF0028E9D1694620780978401820706D1CC0
|
||||
:20E360003888A842C1DC7046002804D020780699801B401E88550020D6E7F8B51546069C10
|
||||
:20E380001E46074602220094FFF7A6FF002806D133461022294638460094FFF79DFFF8BD07
|
||||
:20E3A000F7B582B000260546167000681446002805D02846039900F0CAF8060008D168794D
|
||||
:20E3C00000281ED02078039F001D1F2802D90C2005B0F0BD684679DF0028F9D1217803226A
|
||||
:20E3E000481C20707A5421781922481C20707A542078C1196846008800F0A4F821784018A0
|
||||
:20E400002070A8790223002810D02078039A411C2170135420780399471C012227700A54E5
|
||||
:20E420002078AA79471C039927700A54A868002815D00021415620788C460246C01C03992E
|
||||
:20E440001F28C4D8501C20708B5422780A23501C20708B5420786246431C23700A54A8899B
|
||||
:20E46000002809D028460094062202210C30039BFFF783FF0600ABD1A88A002809D02846D9
|
||||
:20E480000094072203211430039BFFF776FF06009ED1A88B002809D0284600941522142137
|
||||
:20E4A0001C30039BFFF769FF060091D1686A002805D02246039900F07FF8060088D1A86A01
|
||||
:20E4C000002805D02246039900F0B5F8060084D13020405D002806D022462846039900F0F6
|
||||
:20E4E000DCF80600C7D1304672E770B50C4692B000216A46117007251171002809D0817927
|
||||
:20E5000049070CD502A9FFF74BFF002808D102AE00E00026002C0ED0A079002802D028469D
|
||||
:20E5200012B070BD01AA0AA92046FFF739FF0028F6D10AAA00E0002268460379017830463C
|
||||
:20E5400072DFEDE70870000A487002207047F8B514780746A01C15460E461F2803D83879BF
|
||||
:20E56000801C1F2801D90C20F8BD1D20001B80B26946864608803019801C7DDF0028F3D143
|
||||
:20E580003868022805D168460088704501D8092107E038790821002801D0704501D96846F6
|
||||
:20E5A0000088421C3255641CE2B2B1542978801C081828700020F8BDF8B50D461178064636
|
||||
:20E5C000881D14461F2801D90C20F8BD33880720062BFAD31927FF01BB4202D94D4A9342D6
|
||||
:20E5E000F3D17288062AF0D3BA4202D9494FBA42EBD1484FBB4203D0BA4201D09342E4D87E
|
||||
:20E60000481C052220706A5420781222411C21702A54207841193088FFF794FF21784018C5
|
||||
:20E62000C0B2207041197088FFF78CFF2178401820700020F8BD70B5054600790E46801CD6
|
||||
:20E640001446C0B21178821C8A181F2A01D90C2070BD0A46491C401C2170B0542078FF224A
|
||||
:20E66000411C21703254207881192888FFF76AFF21784018C0B22070AA88002A09D0A968AC
|
||||
:20E68000002908D0801900F022FF2078297940182070002070BD072070BDF7B582B0029894
|
||||
:20E6A0001446C06A0F46002832D0029800252030009028E00298C16A0C2068430E18217855
|
||||
:20E6C00030794A1CC01C2270785421781622481C20707A542078C1193088FFF733FF217873
|
||||
:20E6E0004018C0B22070B288002A09D0B16800290ED0C01900F0EBFE207831794018207087
|
||||
:20E700006D1C0098EDB2007CA842D3D800205FE607205DE6FFFF000038B56749674A48883D
|
||||
:20E7200090420FD04A78664C521CD2B24A70237B934208D3083175DF002803D0A1690029FF
|
||||
:20E7400000D0884738BD00254D70217C002907D03B2176DF002803D0A169002900D0884728
|
||||
:20E7600061690029EED068460095884738BD70B5054601461C225248FDF75AFD4E4C002647
|
||||
:20E7800026702968002907D00822A01800F09FFE204608307ADF02E0474808307BDF0028C1
|
||||
:20E7A00008D1401E608044486670464A0021001DFFF7D6F870BD10B53F484068FFF769F9D5
|
||||
:20E7C00010BDF8B53C48103000F069F800263A4D3B4C002806D06169002919D001200090EB
|
||||
:20E7E000684614E02878002804D0616900290FD00096F5E7687800280CD0A16800226868B8
|
||||
:20E80000FFF70AF9002803D0A169002900D088472E70F8BD6168F1E7F8B5294C028800276B
|
||||
:20E82000254DE689102A18D029464968112A21D0122A2DD0502A0FD1801D0288B2420BD1FF
|
||||
:20E84000028B022A08D1C27E837E10021843C007C00F13D0FFF7B5FFF8BD81886980014667
|
||||
:20E86000154808221631103000F031FE6F70002EF0D0F8BD0020C04368806F700846FFF7BB
|
||||
:20E8800008F90028F5D0A1690029F2D08847F8BD811D09480822103000F019FEDAE7418827
|
||||
:20E8A000054808300288914204D34088814201D8012070470020704790280020FFFF0000B6
|
||||
:20E8C000CC2D002019E7030031B5054C04E0401E00902046FDF77AFC00980028F7D138BDC6
|
||||
:20E8E000E703000018225043FE4A00218018017181604161012281610261C1607047FFB577
|
||||
:20E9000081B0F94C049B039A054626691A4303200092002E03D1002A0ED001222261276919
|
||||
:20E92000039A0126360792003B0000F022FF072707162940526127000222EFE770693269FC
|
||||
:20E9400092B25043326933691204920C9BB2594329DF002812D102210FE0084628DF00286A
|
||||
:20E960000CD10399002901D0032106E00499002916D12978042946D017E0216105B0F0BDAE
|
||||
:20E980007069326992B25043326993B24B4301461846039A29DF0028F0D10499002901D0F4
|
||||
:20E9A0000421EAE72978042920D00521E5E773693069366980B2434368681B189B18B6B2C7
|
||||
:20E9C0004E43301880181946049A29DF0028E9D0D4E7306980B24843696880188A08696902
|
||||
:20E9E00029DF0028CAD1009900290CD00621C4E77069316989B24843316989B200F0D9FD08
|
||||
:20EA000028DF0028BAD10721B7E7F8B5B54918230A780F205A435418241DB3492278266970
|
||||
:20EA2000CF68022A1BD001252D07042A2AD0052A5BD1286981B2304600F0BBFD0146A36877
|
||||
:20EA400028699A1980B24843101A820860681818861928694B1C80B25843801B34E0B8023C
|
||||
:20EA600062686169121A0918A3683018181801239B029A4202D2920829DF31E0FF220132BA
|
||||
:20EA800029DF2DE0E268974914205043F4314018001D0BC8B04203D160685943814218D02E
|
||||
:20EAA000022A16D0286981B2304600F082FD0146286980B24843301A820828694B1C80B208
|
||||
:20EAC000584363689B19C01A83082046FFF717FF06E0286981B2304600F06BFDC01928DFED
|
||||
:20EAE000002802D17F4901228A70F8BDF8B57D4C069E65780A2D1DD027787D19EDB20A2D5B
|
||||
:20EB000001D30A3DEDB218277D432D192871AA6103C9EE60AB6069612861A1780020002978
|
||||
:20EB200004D1FFF772FF112800D100206178491C6170F8BD0420F8BD38B5024669481823B1
|
||||
:20EB400001785943081803690179022B0AD014246343644CF434E4588368009383691030F7
|
||||
:20EB6000A04738BD604B14331C68F5E7F8B55D4B9978012914D100255B499D700A69082A77
|
||||
:20EB800005D002280FD003280AD10D2006E0022807D00D7000F025FA002801D0FFF7CCFF37
|
||||
:20EBA000F8BD0D61F6E74F48182403784E496343CC681818641C001DCC600378022B05D11F
|
||||
:20EBC0004668A102B14201D3012700E00027052B01D1072A03D00021042B02D003E00121C1
|
||||
:20EBE000FAE7072A03D00026042B02D007E00126FAE74068A302834201D3002A1AD0002000
|
||||
:20EC0000314301433943C5D0374E28463561FFF793FF344C2078FFF765FEF5606078401E1E
|
||||
:20EC200060702078401CC0B220700A28B2D30A382070AFE70120E3E770B500252A4C2948D3
|
||||
:20EC4000E56025610570457085702E463046FFF749FE761C0A2EF9D3012212076560516952
|
||||
:20EC600028461269491E92B25143E560A1601D49F4310D608D600D61CD601B4914310D6090
|
||||
:20EC8000888001212170206170BDF8B5164A044610780E46002830D0002C30D0002E2ED058
|
||||
:20ECA000206800282BD0012000076768016989B28F4228D8102F26D3A168002923D09568E2
|
||||
:20ECC000794343694A19006980B243439A421AD801200007006980B2814212D901200007E1
|
||||
:20ECE000006903E0E82D0020A828002080B2394600F05FFC002906D103E00820F8BD0E20B9
|
||||
:20ED0000F8BDB80701D00720F8BDBD49486801281CD00F461421BB4A21C641438E18756092
|
||||
:20ED2000236853506168B160A168F160A268616800235143012212075B1C14699BB2A4B214
|
||||
:20ED40008C4205D21469A4B2091B02E00420F8BD00211469A4B265191469A4B28C42EBD985
|
||||
:20ED6000BD60401C336178600020F8BDF8B50446A3481E46007815460F46002807D0002F3D
|
||||
:20ED800007D0002C05D02068002817D103E00820F8BD0E20F8BD9B48016800290ED0C268E3
|
||||
:20EDA000816840684A4310186268904206D9002D04D0A94202D3A819884201D90720F8BD90
|
||||
:20EDC000384600F008F9002811D0304600F003F900280CD0606800F0FEF8002807D02B4637
|
||||
:20EDE0003A46214602200096FFF780FEF8BD1020F8BDFFB5824881B000781F4616460D462B
|
||||
:20EE0000002808D0002D08D00198002805D02868002817D103E00820B0E50E20AEE5794C91
|
||||
:20EE2000206800280ED0E168A0686268414389186A68914206D9002E04D0B04202D3F119AD
|
||||
:20EE4000814201D9072099E5019800F0C4F800281BD0384600F0BFF8002816D0686800F025
|
||||
:20EE6000BAF8002811D068683246C119019800F02EFB00962868142148432458002203215B
|
||||
:20EE80002846019BA047002078E5102076E5F8B505465B480F460078002805D0002D05D012
|
||||
:20EEA0002868002821D103E00820F8BD0E20F8BD544C00262068002817D0A168E0684843CC
|
||||
:20EEC00061684118686881420FD900F084F800280DD0296814225143091968684A68896834
|
||||
:20EEE000801A00F066FB002903D00720F8BD1020F8BD3B460022294604200096FFF7F6FDB5
|
||||
:20EF0000F8BD3F4A1278002A0DD000280DD000290BD00268002A08D0394A14321368002B3E
|
||||
:20EF200005D004207047082070470E20704702230B600068106000207047F8B504463048AF
|
||||
:20EF40001E46007817460D46002807D0002D07D0002C05D0206802281BD103E00820F8BDC3
|
||||
:20EF60000E20F8BD264814300068002811D0084600F031F800280ED0304600F02CF800286C
|
||||
:20EF800009D03B462A46214602200096FFF7AEFDF8BD0720F8BD1020F8BD08B5184A1278C8
|
||||
:20EFA000002A05D0002805D00268022A11D103E0082008BD0E2008BD114A14321268002AD5
|
||||
:20EFC00007D00B460022014604200092FFF78EFD08BD072008BD800701D000207047012068
|
||||
:20EFE0007047084910B5F43949780020002906D0FFF70BFD002802D0112800D1002010BD48
|
||||
:20F00000A8280020DC2E002070B500250C290ED304464318008941000919581A0A38C2B2BD
|
||||
:20F020001748022A027002D30A318B4201D2092070BD144800F04BFA134914480A8882422E
|
||||
:20F0400002D02388934217D14988814202D06088884211D10D4A0323521E20891B03A842DE
|
||||
:20F060000AD9690009194989914203D09E896D1CB142F4D1002070BD0B2070BD00207047C6
|
||||
:20F08000C4280020F02E002080100010FFFF000010B5FDF7ABF810BD10B50446002A02D054
|
||||
:20F0A0001088002210E00A48FBE7030A00020343A05C584003061B0F43401803584083B2EB
|
||||
:20F0C0001806C00C5840521C8A42EED310BD0000FFFF00004B48002101704C484A4A026039
|
||||
:20F0E0008160C160016108224161426081610846704710B500291DD000220A60434A5368A8
|
||||
:20F10000002B1BD0202817D85B1E5360D0682423401CD060106914684343E3180B60012366
|
||||
:20F1200083409169401C19434007400F91611061002010BD0E2010BD0C2010BD042010BD8F
|
||||
:20F14000F0B5324A0646916800292BD057691020791A4907490F14680B4624254D436519D6
|
||||
:20F16000B54206D1012495698C4065400020956104E0491C4907490F8F42EED1491C4E07DC
|
||||
:20F18000760F956901210C469C402B4623420AD19368002B07D05B1E936053685B1C53609D
|
||||
:20F1A0003346F0E70420F0BD184A2423117C1268491E4907490F594320315050002070470B
|
||||
:20F1C00070B500281AD0002918D0104AD368002B16D05B1ED360936824265B1C936053692A
|
||||
:20F1E00015681C467343EE1820330660E858641C08606007400F5061002070BD0E2070BD84
|
||||
:20F20000042070BDC5280020FC2E00201C30002030B5CB0008339DB293070024002B01D0E6
|
||||
:20F22000072030BD3B4B9A605219DA605C701C7058809980002030BDF7B5364C0E466088D5
|
||||
:20F24000814237D8344F00F069F822786078A188884201DA401C00E00020C0B2904202D155
|
||||
:20F2600000F062F824E065786078884201DA401C00E00020607000F057F8BD4218D0A0688C
|
||||
:20F28000EF000299C151009900290CD0002E0AD0608832464543E068281800F018F9A068B3
|
||||
:20F2A0003818868002E00021381881800020FEBD0420FEBD0920FEBD0EB504E068468188A8
|
||||
:20F2C000029A0098904702AA01A9684600F003F80028F3D00EBD70B50E4B05241D785E786C
|
||||
:20F2E000AE4215D01D781C789E88B44201DA641C00E000241C705C88DE686C43A41904600F
|
||||
:20F300009B68E800C418A4880C80185800241060204670BDCC280020FFFF000072B606484F
|
||||
:20F320000168491C0160704703490868401E086000D162B670470000DC280020BFF34F8F11
|
||||
:20F3400003490248C860BFF34F8FFEE70400FA0500ED00E010B5002904D000221146104619
|
||||
:20F36000FFF7ECFF00F010F810BD10B50021024A0846FFF761FF10BD55F3030010B50846E6
|
||||
:20F380001146FCF771FF10BDF8B5384C2078002837D02069002807D00026E068002805D0FB
|
||||
:20F3A0000025002E04D013E00126F6E70125F8E7684651DF052806D0002806D000221146D2
|
||||
:20F3C000FFF7BCFF04E0012602E0216900988847002D12D1608869460880A06861DF0528FA
|
||||
:20F3E00006D0002806D000221146FFF7A7FF04E0012502E0E168A0688847002ED8D0002D15
|
||||
:20F40000CFD0F8BD70B5002901D08C0701D0072070BD164C0125A16062801549636010DF46
|
||||
:20F420000028F5D1257016202EDF70BD002803D00E49C860002070470E207047002803D0A8
|
||||
:20F440000A490861002070470E20704710B507484068002807D08047002803D0002211463E
|
||||
:20F46000FFF76CFF10BDFFF78FFF10BDE02800207DF30300034610B50B439B070FD1042A66
|
||||
:20F480000DD308C810C9121FA342F8D018BA21BA884201D9012010BD0020C04310BD002AAC
|
||||
:20F4A00003D0D30703D0521C07E0002010BD03780C78401C491C1B1B07D103780C78401C61
|
||||
:20F4C000491C1B1B01D1921EF1D1184610BDF8B5042A2CD3830712D00B78491C0370401C25
|
||||
:20F4E000521E83070BD00B78491C0370401C521E830704D00B78491C0370401C521E8B07F9
|
||||
:20F500009B0F05D0C91ADF002023DE1B08C90AE0FCF78EFEF8BD1D4608C9FD401C46B440B8
|
||||
:20F520002C4310C0121F042AF5D2F308C91A521EF0D40B78491C0370401C521EEAD40B78EC
|
||||
:20F54000491C0370401C521EE4D409780170F8BD01E004C0091F0429FBD28B0701D50280F7
|
||||
:20F56000801CC90700D00270704700290BD0C30702D00270401C491E022904D3830702D5EE
|
||||
:20F580000280801C891EE3E70022EEE70022DFE70378C2781946437812061B0219438378A2
|
||||
:20F5A000C0781B04194311430902090A000608437047002203098B422CD3030A8B4211D366
|
||||
:20F5C00000239C464EE003460B433CD4002243088B4231D303098B421CD3030A8B4201D39D
|
||||
:20F5E00094463FE0C3098B4201D3CB01C01A524183098B4201D38B01C01A524143098B422D
|
||||
:20F6000001D34B01C01A524103098B4201D30B01C01A5241C3088B4201D3CB00C01A524193
|
||||
:20F6200083088B4201D38B00C01A524143088B4201D34B00C01A5241411A00D201465241FB
|
||||
:20F64000104670475DE0CA0F00D04942031000D34042534000229C4603098B422DD3030A47
|
||||
:20F660008B4212D3FC22890112BA030A8B420CD3890192118B4208D3890192118B4204D305
|
||||
:20F6800089013AD0921100E08909C3098B4201D3CB01C01A524183098B4201D38B01C01A88
|
||||
:20F6A000524143098B4201D34B01C01A524103098B4201D30B01C01A5241C3088B4201D37F
|
||||
:20F6C000CB00C01A524183088B4201D38B00C01A5241D9D243088B4201D34B00C01A52417F
|
||||
:20F6E000411A00D20146634652415B10104601D34042002B00D54942704763465B1000D31A
|
||||
:20F70000404201B50020C046C04602BD704770477047754600F022F8AE460500694653469B
|
||||
:20F72000C008C000854618B020B5FEF7FBFA60BC00274908B6460026C0C5C0C5C0C5C0C525
|
||||
:20F74000C0C5C0C5C0C5C0C5403D49008D4670470446C046C0462046FCF7FFFC004870479C
|
||||
:20F760003830002001491820ABBEFEE726000200704730B47446641E2578641CAB4200D256
|
||||
:20F780001D46635D5B00E31830BC184702000000000000000000000000000000040000009F
|
||||
:20F7A000000000000000000000000000000000000000000035C4030000000000000000004D
|
||||
:20F7C000020000000000000000000000000000000000000000000000030000000000000024
|
||||
:20F7E0000000000005000000000000000000000000000000000000000000000023D1BCEA6A
|
||||
:20F800005F782315DEEF1212000000002CF8030000280020F400000004C1030020F90300A1
|
||||
:20F82000F4280020A413000020C103000000000000000000000000000000000000000000F1
|
||||
:20F840000000000000000000000000000000000000000000000000000000000000000000A8
|
||||
:20F8600000000000000000000000FFFF000000003200000000000000000000000000000058
|
||||
:20F88000000000000000000000000000000000000000000000000000000000000000000068
|
||||
:20F8A000000000000000000000000000000000000024F40000000000000000000000000030
|
||||
:20F8C000000000000000000000000000000000000000000000000000000000000000000028
|
||||
:20F8E000000000000000000000000000000000000000000000000000000000000000000008
|
||||
:20F900000000000000000000000000000000000000000000000000000000000000000000E7
|
||||
:20FC00000100000000000000FE0000000000000000000000000000000000000000000000E5
|
||||
:020000041000EA
|
||||
:0410140000C0030015
|
||||
:040000050003C0C173
|
||||
:00000001FF
|
|
@ -0,0 +1,463 @@
|
|||
:020000040003F7
|
||||
:20C00000983C002005DD030017DD030019DD03000000000000000000000000000000000057
|
||||
:20C0200000000000000000000000000069C1030000000000000000001DDD03001FDD0300D7
|
||||
:20C0400021DD030021DD030021DD030021DD030021DD03000000000021DD030021DD0300D9
|
||||
:20C0600021DD030021DD030021DD030021DD030021DD030021DD030021DD030021DD0300B8
|
||||
:20C0800021DD030057D8030021DD030021DD03006DD8030021DD03004DF4030021DD0300DD
|
||||
:20C0A00021DD030021DD03000000000000000000000000000000000000000000000000007E
|
||||
:20C0C00000F002F800F040F80CA030C8083824182D18A246671EAB4654465D46AC4201D18E
|
||||
:20C0E00000F032F87E460F3E0FCCB6460126334200D0FB1AA246AB463343184710370000C8
|
||||
:20C1000030370000103A02D378C878C1FAD8520701D330C830C101D504680C6070470000D3
|
||||
:20C120000023002400250026103A01D378C1FBD8520700D330C100D50B6070471FB5C04655
|
||||
:20C14000C0461FBD10B510BD03F0E3FA1146FFF7F5FF00F0D3F803F0FBFA03B4FFF7F2FF19
|
||||
:20C1600003BC03F0FFFA00000648704502D1EFF3098101E0EFF30881886902380078024A97
|
||||
:20C1800010470000FDFFFFFF39D50300401E00BF00BF00BF00BF00BF00BF00BF00BF00BF28
|
||||
:20C1A00000BF00BF00BFF1D170470000401E00BF00BF00BF00BF00BF00BF00BF00BF00BFB4
|
||||
:20C1C00000BF00BF00BFF1D170470000401E00BF00BF00BF00BF00BF00BF00BF00BF00BF94
|
||||
:20C1E00000BF00BF00BFF1D170470000056885F3088846680A4AEFF305839A42304602D183
|
||||
:20C20000084CA6463047074C064D0646064FF0B4034C034D024E024FF0B404480047000005
|
||||
:20C2200000000000FFFFFFFF00000021F9FFFFFF70B505460C46164602E00FCC0FC5103EEE
|
||||
:20C24000102EFAD2082E02D303CC03C5083E042E07D301CC01C5361F03E021782970641C63
|
||||
:20C260006D1C761EF9D270BD0A4610B50146664803F064F810BD10B502F078FC10BD10B5C6
|
||||
:20C28000624C86B01ECC03946C460EC4002807D0684618DF002803D00022114603F04EF864
|
||||
:20C2A0000F20800313DF002803D00022114603F045F8574B48225749092003F0A3F80028AB
|
||||
:20C2C00003D00022114603F039F800200490059001206946087404A860DF002803D0002251
|
||||
:20C2E000114603F02BF84C4803F0A8F8002803D00022114603F022F806B010BD08B547485A
|
||||
:20C30000C169B12943D0002445480F2140698903884204D000221146104603F00FF8012068
|
||||
:20C320000007006901218902884204D000221146104603F003F83B4800903B4B05220321A1
|
||||
:20C34000002001F0BAFA002803D00022114602F0F5FF00F067FC00F0AAFC012500281AD09D
|
||||
:20C3600000F0B4FC002803D00022114602F0E6FF20466840FFF783FF00F038F800F0CCFC74
|
||||
:20C3800000280ED00022114602F0D8FF09E001240021C161B8E720466840FFF770FF00F002
|
||||
:20C3A00025F803252D03002C04D1A86800F090FB002807D100F047FC002803D000221146D5
|
||||
:20C3C00002F0BCFFA86800F083FB002806D000F06EFC002802D1A86800F041FCBFF34F8F12
|
||||
:20C3E00013491248C860BFF34F8FFEE7094A10B548321421082002F00BFF002803D00022E2
|
||||
:20C40000114602F09BFF10BDEFBEADDE8CF703006BF30300342B002077C20300000500404D
|
||||
:20C4200000100010EFDC0300F42800200400FA0500ED00E070B5FC4C1E46A06815460229A3
|
||||
:20C4400002D0042916D108E0052813D1A369002B10D03246294604200BE002280AD1F348B0
|
||||
:20C46000406880470320A060A369002B02D0324629469847280003D00022114602F05EFF98
|
||||
:20C4800070BD4CB5E84E0120307005200195009400F058FB4CBD10B5E34C2078002801D057
|
||||
:20C4A000082010BD206901F0F4FA002803D00022114602F043FF0F2100228904206901F01E
|
||||
:20C4C000ABFA040003D00022114602F037FF204610BDD54910B5D448243141610221816012
|
||||
:20C4E000C168243002F059FD002803D00022114602F024FF10BDCC4910B5CB481C31416145
|
||||
:20C50000022181600320000380680F218903081A4108C5481C3002F040FD002803D000223D
|
||||
:20C52000114602F00BFF10BD704700B589B01822BF4902A8FFF77CFE06980799009001917A
|
||||
:20C5400002A80FC800F0FEFA09B000BD00B5B64987B049886A461181032109038968069146
|
||||
:20C56000B249012050394A6803928A680492C9680591069A0091019202A90EC900F0E2FA6E
|
||||
:20C58000002007B000BD30B5A84CA748503C89B02430E16802F001FD002803D00022114679
|
||||
:20C5A00002F0CCFEA048E2681C3041680023083002F0C3FC050012D1182102A802F0E6FFEA
|
||||
:20C5C00000209949029049886A469181E1680691079A0091019203A90EC900F0B3FA284601
|
||||
:20C5E00009B030BD00B5904987B049886A4611818E49032050394A6803928A680492C9683A
|
||||
:20C600000591069A0091019202A90EC900F09AFA0020B6E73EB5864A6B46183207CA07C3A4
|
||||
:20C62000814D00246C7029466C802431684602F068FC002801D0AC603EBD03207A4900038F
|
||||
:20C6400080682431486024390A46526ACA610F218903091A490840187349764A1C31486068
|
||||
:20C6600071480021103001F07BF9002803D00022114602F063FE0F2100228904286901F013
|
||||
:20C68000CBF9002803D00022114602F057FE01206C60A86000203EBD63498861704770B59A
|
||||
:20C6A000426862481468536891685038D26804604360C26081600078440701D5840705D130
|
||||
:20C6C0009C0703D18C0701D1940701D0062070BD5B189A18544D0F239B02EA60994213D81A
|
||||
:20C6E0005549564B514CC60709D08868181A90420AD3534820605348606053480FE08968F6
|
||||
:20C70000591A4908914201D20C2070BD4F4921604F496160800701D54E4800E04E48A0607B
|
||||
:20C72000A868012802D00826304670BDFFF7B3FE0600FAD12168E8688847F5E770B50500F7
|
||||
:20C7400004D0287A800703D0102070BD0E2070BD354CA068032805D0042801D0052803D0CB
|
||||
:20C76000082070BD0520A0606868E168860060688019884204D90020C04360600C2070BD5C
|
||||
:20C78000FFF789FE0028FAD1A96832466368606902F0D3FB0028F2D1616889196160E268EB
|
||||
:20C7A0009142ECD0092070BD10B51F4C08206168002900D010BDA1680429FBD11B4861786F
|
||||
:20C7C000403802F021FC002802D00021617010BD0521A16010BDF8B5134C0746A068032899
|
||||
:20C7E00004D0042804D008252846F8BD0420A0606068002801D00820F8BDFFF74CFE05000E
|
||||
:20C80000FAD17868860060788119402901D90920F8BD064AB968403A1018324602F057FE82
|
||||
:20C82000607880196070DFE7002800201C2D00209CF7030083C403000030000000C003006D
|
||||
:20C84000D3C403002BC503004DC50300F7C4030029C50300E5C5030087C5030010B5894CF1
|
||||
:20C86000A068052813D1E168606888420FD10620A060FFF710FE002808D16069E1684068FF
|
||||
:20C8800002F0FCFB002801D10721A16010BD082010BD10B57B488168072901D0082010BD63
|
||||
:20C8A000006901F0F6F8002803D00022114602F045FD75488068804710BD1CB506200195C2
|
||||
:20C8C000009400F03FF91CBDF8B51C4617460D46064600F0C1F8002817D001200003854215
|
||||
:20C8E00007D92346291B301B1A46FFF7EDFF00280BD13A462946304600F0B9F8002804D117
|
||||
:20C900003A462946304600F0A7F8F8BDF0B589B0684600F015FA049800282AD001210903F7
|
||||
:20C92000079A4018904226D9501A45081046049A0C468718024668001618001908900320DF
|
||||
:20C9400000038068049988420DD261190846042200F08DF800280CD121460422084600F073
|
||||
:20C9600086F8002805D1BA1B2B4630460899FFF7ABFF09B0F0BD049A079800F078F8F8E75C
|
||||
:20C9800000B58DB004A800F0DBF9099800280DD0089800280CD008990B984018019000219D
|
||||
:20C9A0000998009180080290684618DF0DB000BD0320000380680F218903091A4908ECE7FB
|
||||
:20C9C00000B58DB004A800F0BBF909980028EDD00F210898890300280CD0089A0B98019158
|
||||
:20C9E0008018029003220998009280080390684618DFDBE70320000380680A1A5208EEE7D2
|
||||
:20CA000030B591B0684600F09BF90498002814D001210903079A4018904214D9501A43087B
|
||||
:20CA20001046049A5C0082180019611803242403A468049DAC4202D20E2011B030BD121AB5
|
||||
:20CA4000FFF742FFF9E703200CAB07C3049880080F900CA818DFF0E71FB5032301909008B3
|
||||
:20CA6000039000930291684618DF04B010BD1FB5012301909008039000930291684618DF58
|
||||
:20CA8000F3E70000002800201C2D002010B5BB480368012B02D1022900D10160100003D099
|
||||
:20CAA0000022114602F04AFC10BD10B5B34C48DF002803D00022114602F040FC02F0FCFB82
|
||||
:20CAC0002068022803D0032801D00428EFD110BD38B50068401C19D00024684600F058F96F
|
||||
:20CAE00000980168012910D1818800290AD0C168032000038068002202F0CEFA0099898861
|
||||
:20CB0000814201D1012400E00024204638BD10B504469A482021001D02F0B9F9002803D00E
|
||||
:20CB20000022114602F00AFC9448002320222146001D02F01BF9002803D00022114602F053
|
||||
:20CB4000FDFB10BD0FB4F8B5684600F021F96846818B069D0122894CFF238948002D13D090
|
||||
:20CB6000012D17D0032D2BD00021022D37D02A46052D46D0042D4ED0062A01D10420206071
|
||||
:20CB8000F8BC08BC04B0184781800A9983600260C16010E08180099D089949190A9D49195D
|
||||
:20CBA000C160A52183600160089901610999856141610B99C16122607148FFF7A8FFDFE7B9
|
||||
:20CBC00000990B6803608B888380C968C160AA21816008990161099941610A990BE0009D60
|
||||
:20CBE0002E68A52E09D00660AE888680ED68C5600161836041618161DDE781800360C160C5
|
||||
:20CC0000F6E700F085F9002803D00022114602F095FB0320B3E781800360C1600099896807
|
||||
:20CC20008160C9E70EB557480090202001900120029002F001F8002804D150496846091D98
|
||||
:20CC400002F023F80EBD10B5FFF7E4FC002805D100F02FFB0446FFF728FF204610BD70B58A
|
||||
:20CC600011DF002803D00022114602F067FB464900200B68444C012180340A4682401A4206
|
||||
:20CC800004D0C506ED0E0A46AA402260401C2028F3D303242403A06813DF002803D000226F
|
||||
:20CCA000114602F04BFBA06802F0F2F970BD08B5684600F06DF800980168A52904D0806888
|
||||
:20CCC000AA2801D0002008BD012008BD10B5FFF797FE002803D1FFF773FE00281BD064209C
|
||||
:20CCE00001F0F2FDFFF712FE002803D00022114602F024FBFFF784FE002803D000221146DD
|
||||
:20CD000002F01CFBFFF73CFE040003D00022114602F014FB204610BD00B589B018221B49CA
|
||||
:20CD200002A8FFF785FA069807990090019102A80FC8FFF707FFFFF7B8FE002009B000BDB5
|
||||
:20CD400010B50E4988B0044600232022091D684602F04FF80098206068468088A08003983A
|
||||
:20CD6000E0600298A06004982061059860610698A0610798E06108B010BD00002C280020E6
|
||||
:20CD8000282D00208DCA030000E100E0C0F70300014901607047000000FC030008280CD0DC
|
||||
:20CDA00004DC002807D006280FD108E00B280AD00C280AD105E001207047022070470320C9
|
||||
:20CDC000704704207047042901D0062070470520704770B515460A46032823D0042820D1FF
|
||||
:20CDE000FE4C002906D0E088FD49884219D0132176DF10E0284602F0A3F9002803D00022F7
|
||||
:20CE0000114602F09BFAE069A8420AD101220321F44801F003F8002803D00022114602F051
|
||||
:20CE20008DFA70BD01211046FFF7B8FF02460121EEE7F0B5054608790E4685B081070CD07C
|
||||
:20CE400003221146284600F0E9FF002803D00022114602F073FA05B0F0BDE04900901831D9
|
||||
:20CE600002F047F9010011D1DC4CB168009AA06902F02DFB009802F097F9010006D1204647
|
||||
:20CE80006946183002F09CF9010003D0284600F0AFFAE0E704200190009880080290A06902
|
||||
:20CEA000039001A8FFF74AFC07000BD0092F10D0A06902F045F9010002D0284600F098FA04
|
||||
:20CEC0003946E3E73079616940186061A069E061C1E7307961694118616160780028BAD073
|
||||
:20CEE0006089401E0004000C6081B4D1284601F0E9F8002803D00022114602F01FFA20890D
|
||||
:20CF00006081A8E710B50022114602F017FA10BD10B5B24C01202070E088B149884208D01B
|
||||
:20CF2000132176DF002810D00022114602F006FA0BE0A078002808D074DF002803D0002282
|
||||
:20CF4000114602F0FBF90020A07001F034FC002803D00022114602F0F1F9002010BD70B5E1
|
||||
:20CF60000D68044601209D4A2B0002F002FC0A2B3043061320575C466012FFF76FFC0421FD
|
||||
:20CF8000FFF70CFF024604212EE00022114602F0D5F970BDFFF7BCFF002803D0002211468A
|
||||
:20CFA00002F0CCF9FFF775FC002808D170BDFFF7AFFF002803D00022114602F0BFF9FFF76D
|
||||
:20CFC0007CFC70BD106188680078107170BD02201061886800780128F8D1FFF7E5FB02213F
|
||||
:20CFE000FFF7DCFE02460221204600F017FF0028CBD170BD0320106170BD12692046012ACC
|
||||
:20D0000006D0022A07D0032AF6D1FFF712FF70BD00F001FA70BD00F03BFA70BD50708888D5
|
||||
:20D020001081508170BD00205070108170BD2046516901F010F8DAE710B5044669488EB0EB
|
||||
:20D0400081796846817068490180342101A802F09DFA022001900021684641728472012131
|
||||
:20D0600001820590002101A801F03FFA002803D00022114602F062F90EB010BDF0B5574C10
|
||||
:20D080008BB0A07800283AD156481821183802F07DFA2046534CC078183C00250126002875
|
||||
:20D0A00037D02746483700950195029510226946F81D039502F0DEF9002822D0F81D08909D
|
||||
:20D0C00009976846067509A804906846067708A806900420FFF7B0FF25700220207204A813
|
||||
:20D0E000E060282020823F486582183873DF002803D00022114602F021F9384886700BB045
|
||||
:20D10000F0BD0520FFF798FF2670676025722582E9E70620FFF790FF257065602572E0E7E2
|
||||
:20D1200070B52E4C01880022E588A6B017290AD01EDC11293FD008DC022977D0102902D123
|
||||
:20D140008088E080A27026B070BD264C303426461836132951D01429F5D1C289638D002106
|
||||
:20D160009A4200D1314600238088E21D82DF1BE0512970D00EDC18296CD01929E3D18079F5
|
||||
:20D180000028E0D1A270E068401EE0604FD0FFF775FFD8E7522976D05529D4D18079002871
|
||||
:20D1A000D1D11321284676DF0028CCD00022114602F0C4F8C7E78020694688803220E06054
|
||||
:20D1C000012301AA06A92846AADF002803D00022114602F0B3F82078002807E038280020A2
|
||||
:20D1E000FFFF0000602D00203015000001D1FFF745FF0020C043E080A5E70722C14910A839
|
||||
:20D2000002F065F91022E11D0CA802F060F91C22314612A802F05BF90CA80A9012A8099039
|
||||
:20D2200006ABB94A852128467FDFBDE70DE01822B64906A8FEF7FCFF0A980B9900900191F8
|
||||
:20D2400006A80FC8FFF77EFC7DE70021284667DFAAE700E017E0817900299AD0807A042885
|
||||
:20D2600003D0062801D0052893D1022909D0012069460872FF208330888102A92846A8DF82
|
||||
:20D2800092E70220F4E700F08DF88DE710B5044601F0C2FA9B482146303800F09AFE2046D3
|
||||
:20D2A000FFF73EFF10BD10B50022114602F046F810BD30B5944D87B00024203D2C7094483D
|
||||
:20D2C0002C6102F0B3F800286AD19248FFF7E4F901F000FF002863D18A4800F059F900288C
|
||||
:20D2E00001D10120E87011206946087207228AA102A87CDF002803D00022114602F01EF8B4
|
||||
:20D3000000940C2168460194018018214180FF2184809131C1807ADF002803D0002211469A
|
||||
:20D3200002F00CF804206946009408807C4801907C4802907348303800F00BFE002803D046
|
||||
:20D340000022114601F0FAFF1C21684602F01EF9754801900120800302900094032168468C
|
||||
:20D360000173C4810474714806900594684601F0FEF9002803D00022114601F0DFFF624910
|
||||
:20D38000E12208784008400010400C30DF22104008700720487010208870FFF76FFE0020A3
|
||||
:20D3A00007B030BD70B5584C614D203CE088A84201D1082070BDE178002914D05149012359
|
||||
:20D3C00008223431A9DF0028F4D12A460C21E088A7DF5849884204D0082802D0891C88420E
|
||||
:20D3E000E8D1002070BD00231A461946A9DF70BD10B50A46044603211046FFF7CFFC0246AE
|
||||
:20D400000321204600F00AFD002803D00022114601F094FF10BD30B5054687B000200090AF
|
||||
:20D4200001900290039038486A46203800791070364A0C3A1068926804906846069205900E
|
||||
:20D4400008790C2806D003221BE00022114601F075FFA5E78C68204600F049F80190201D5E
|
||||
:20D4600000F045F802902046083000F040F8039004A8FFF714F9002892D00121FFF78EFCB9
|
||||
:20D4800002460121284600F0C9FC0028DDD187E7FEB50446087982070ED08207920F042385
|
||||
:20D4A0009B1A0022154604E08E683554401CC0B2521C9A42F8D30871012000908868029048
|
||||
:20D4C0000879800801906846FFF785F900280DD00221FFF763FC02460221204600F09EFCB8
|
||||
:20D4E000002803D00022114601F028FFFEBD10B5044602F04DF80002E178000A09060843E0
|
||||
:20D5000010BD0000902D002058280020E4F703008DD20300D3CD0300446675546172670031
|
||||
:20D520005FCF0300A7D20300CD0C000005CF0300FFFF00000230000010B50C46002802D04D
|
||||
:20D540000120086010BD2168002911D01C48421A814212D03C2A0DD23C303C3101220B78B9
|
||||
:20D5600003701346491E401E521C3C2BF7D904E00E200BE03C2201F0AAFF00223C211048A9
|
||||
:20D5800001F08AFD0E49891E08800020206010BD70B5054600223C21094801F07DFD084C21
|
||||
:20D5A000A41E2188884201D00B2070BD3C220449284601F08CFF2088401C2080002070BD87
|
||||
:20D5C000823F00208307FF22DB0E9A408907090E994000280BDA0007000F08388308FA484C
|
||||
:20D5E0009B001B18D86990430843D86170478308F6489B001B1818689043084318607047AA
|
||||
:20D6000070B50124F24960040860F24940108860F04940398860F04D6C602F20FEF7B6FDAC
|
||||
:20D62000AC60EE4D00242F206C61FEF7AFFD2C7170BDF0B5E94F2821BC6841430D19396962
|
||||
:20D640004A1C09D028224A431619AB68B268934204D8D21AB26069623861F0BD0A4602E066
|
||||
:20D660000A46796A9B1B4E1C0BD028264E433719BE689E42F4D328264E433619B768FF1A1A
|
||||
:20D68000B760AB60696228214A4311194862F0BD70B5D24C2269A5681346114606E0814212
|
||||
:20D6A00007D00A46282671434919496A4E1CF6D170BD002EFCD08A420CD1282043435819EC
|
||||
:20D6C000406A2061401C05D1C34B01209860002363616071282041434819282381685A4310
|
||||
:20D6E000406A52195062421CE2D028225043401982685118816070BDF8B5B84C2569681CF9
|
||||
:20D7000035D0B748002640686169401A07023F0A19E028204543A0682A189068B84214D8D0
|
||||
:20D72000A3693F1A8619556A002B09D0116AD0699847002807D00022114601F0FFFD02E048
|
||||
:20D74000D169106A8847681CE3D1A178E078814206D1401CC0B2E070022801D10020E07079
|
||||
:20D760009E490006800D1C310E5000F0BAF9F8BDF8B50446994800270169009146785CE038
|
||||
:20D780009648F100C2688D1851E0601C07D0934A28209268604321468018446A24E0287854
|
||||
:20D7A000182141436A68401CC0B252182870A978884200D12F70894B516828209B6848434C
|
||||
:20D7C000C0181368012B34D1037E002B31D19368C360D368036113694361526902627F4A52
|
||||
:20D7E0005279002A00D0C7607C4BC2685B6996469C46D31A1A027B4B120A9A4202D20369C3
|
||||
:20D80000D21808E0724663469A1A12020369120A934202D99A1A826000E08760C76001222E
|
||||
:20D8200007610276921E42620846FFF702FF601CABD1287869788842A7D13046761EF6B202
|
||||
:20D8400000289DD1654801690098814201D00120F8BD0020F8BD644900200860486088607F
|
||||
:20D86000C860614940390860486045E7FEB50020C0435A4D02906869019068462E6900F07B
|
||||
:20D8800035F9074600F04FF90446002F08D002AA0199009800F08FF90298FFF769FF06E050
|
||||
:20D8A0000298FFF765FF002801D1002C02D0304600F0AAF900206871FEBDFFB59807002448
|
||||
:20D8C00081B01E4615460F4600280BD1002E09D0FFF796FE41490A9888610F703246002042
|
||||
:20D8E0008E6008E0072005B0F0BD28234343D4509B181C76401CB842F7DB28204743BB19C1
|
||||
:20D90000032048700F461846CB6019461830002218232E465E43D3005B181C705C709D708A
|
||||
:20D9200058603018521C032AF5DB0020C0433861BC70FC7001242D482405046003211420A9
|
||||
:20D94000FFF740FE224880380460254C0198A06003211120FFF736FE606878610020C2E71A
|
||||
:20D9600070B51E4CA568002D06D0002A06D0002804D00023247809E0082070BD072070BDBB
|
||||
:20D9800028265E43AE59002E04D05B1CA342F7DB042070BD282401265C432E516419E261BF
|
||||
:20D9A00061600360002070BD07494868C005C00D2CD010381CD50207120F083A9208920097
|
||||
:20D9C0005118C96919E0000000ED00E000E400E080E100E040130140001001406028002054
|
||||
:20D9E00000150140FFFF7F004011014080E200E08108B14A8900891809688007C00EC1400B
|
||||
:20DA00000806800F012803D0032803D0022070470020704701207047FEB50446A74817469E
|
||||
:20DA200082680D46002A0CD001788C4201D2052D01D20720FEBD2146282359435358012B7D
|
||||
:20DA400001D00820FEBD8818406801281DD00026FFF7AAFFC00099490190C9684018694684
|
||||
:20DA600000F018F9002812D0012144600160944949680830E2C091490198C9684118009877
|
||||
:20DA8000487000F02EF80020FEBD2E46E0E70420FEBDF8B5894D0446A868002809D0297844
|
||||
:20DAA0008C4201D30720F8BD282161434058012801D00820F8BDFFF777FFC600E86869465B
|
||||
:20DAC000301800F0E7F8002809D0022112C0E86831180098487000F004F80020F8BD04206B
|
||||
:20DAE000F8BD0120774900050860704710B5734900238A78CC78A24212D0521CD2B28A70D0
|
||||
:20DB0000022A00D18B708A786C4B92001C339A580260486910180002000A4861012010BDA3
|
||||
:20DB20000360002010BDF8B5644801690091457833E06248E900C0680E1834782AE01820A2
|
||||
:20DB400060437168641C0818B178E4B2A14200D100240168022902D003291BD113E0574A00
|
||||
:20DB600040682821926841438F18397E002911D0FFF78EFD002038760CE028277843C018B1
|
||||
:20DB80000276406A03E04D4900228B680869471CF3D108617078A042D1D128466D1EEDB2D0
|
||||
:20DBA0000028C6D1454801690098814201D00120F8BD0020F8BDF7B5404C0025A7682369E0
|
||||
:20DBC0001EE028215943C9198E68864202D9301A886017E0801B751900268E600E764E6946
|
||||
:20DBE0009C464B6AB646002E0AD0019E76193602360ACE6076460E6116684E626146116045
|
||||
:20DC0000591CDED12361FEBDF8B52C4801694A1C3DD028225143826889188E6828494C681F
|
||||
:20DC200047690079E11B0D022D0AED1C002815D10120254A00045060234A403A506021491D
|
||||
:20DC4000400080310860214908602149012008602F20FEF79BFA194901200871B54200D208
|
||||
:20DC60003546E81900021649000A4031086014494968001B091B0902090A0002C91C000A88
|
||||
:20DC8000814203D901200F4940040860F8BDFFF7B7FCF8BD42788378521C934200D10022C2
|
||||
:20DCA0000378934201D1002070470A6041684078182250430818704700E400E06028002090
|
||||
:20DCC0000015014000E200E04013014000E100E00010014010B50446082904D000221146F9
|
||||
:20DCE000104601F02BFB21686068884710BD1CB501910090024A0821684601F09DFA1CBD53
|
||||
:20DD0000D5DC03000A48026803210A4302600948804709480047FEE7FEE7FEE7FEE7FEE797
|
||||
:20DD2000FEE7000005480649064A074B70470000240500404DDD0300C1C003009830002007
|
||||
:20DD4000983C00209834002098340020F8B500F035F82B4E002804D02A4870602A49F01300
|
||||
:20DD600088612A480124018CC9B201290DD1818C09070AD1018D0906090F042905D1808D56
|
||||
:20DD80000006000F01D1224884600027B461214D6F60A8058460686800280ED1C820FEF790
|
||||
:20DDA00005FA1D487F1C8742F5D30020B06101208007846068680028FCD0F8BD1348018CB5
|
||||
:20DDC000C9B2012917D1818C090714D1018D09060A0F03D1828D1206120F0ED0090F0129C2
|
||||
:20DDE00003D1828D1206120F07D0032903D1808D0006000F01D0002070470120704700008E
|
||||
:20DE000000050040DFFF07C0006C0040C00F00F000060040000100408813000030B585B071
|
||||
:20DE2000002822D00388FE4CA34220D0FD4B1B78002B1CD0FB4B10255B1C1D7059700024C0
|
||||
:20DE400001259A70032269460A820094019402940394028A0A808D708C8004A902910393E7
|
||||
:20DE600000886946A6DF05B030BD0E20FBE70820F9E7F0B58BB0044602276846077300268B
|
||||
:20DE800009968784C68408A80A900D46A18A208809AAA5DF002804D0E16A00291AD08847BE
|
||||
:20DEA00018E06846008CC007C00F13D068460682208803A9A8DF002813D1A97E28461B30BA
|
||||
:20DEC00001220B0001F055FC09430F1B202224263E284300FF20FE3069460882208803A94D
|
||||
:20DEE000A8DF0BB0F0BD00960AE0062219E069460A71029022E0204690470020F1E700920D
|
||||
:20DF00002B8B022BF3D2F0E700971DE003201AE0042018E0052016E0298B032905D20322BE
|
||||
:20DF200008212046FFF77AFFDBE741780278080210436946888003D006200090A26ADAE784
|
||||
:20DF40000720FAE7092000906946A26AD3E70322E7E730B585B00D46040038D0002D36D0EC
|
||||
:20DF60006868002833D00020C043AF4B20800FCB049301AB07C3AD4869460880891C01A888
|
||||
:20DF800063DF002822D1221D69460120A0DF00281CD168468078A071204600F0CEF8002886
|
||||
:20DFA00014D1204600F055F900280FD12946204600F002F9002809D16868A062A868002804
|
||||
:20DFC00000D0E06297490120087000204BE70E2049E73EB5002828D0002926D0826A002ABE
|
||||
:20DFE00023D00A88102A21D0112A30D0502A1FD0512A1AD104460846891D0A78022A14D196
|
||||
:20E000004A88238A9A4210D1807A04280DD006280BD0052809D0891C2046FFF72AFF002860
|
||||
:20E0200003D0E16A002900D088473EBD898810E0CA8803899A42F8D1082200928A7F6B4605
|
||||
:20E040001A7120310291826A694690473EBD0021C94301803EBDF0B585B00A4605002DD00F
|
||||
:20E0600028886F4988422BD06E480078002827D06C4C1020641C2070072060700127A770F8
|
||||
:20E080000321684601820026E11C104600F04CF801466846008A0918684601820096019680
|
||||
:20E0A00002960396298A01808770868004A80394029028886946A6DF05B0F0BD0E20FBE7D3
|
||||
:20E0C0000820F9E7F0B585B00A46050028D028885349884226D053480078002822D0514C3B
|
||||
:20E0E0001120641C20700127684607820026611C104600F019F801466846008A0918684638
|
||||
:20E1000001820096019602960396298A01808770868004A80394029028886946A6DFCBE782
|
||||
:20E120000E20C9E70820C7E70870020A4A70020C8A70000EC8700420704730B58FB0054655
|
||||
:20E140001C21684601F022FA694608780421084369460870002401940394049405940694E6
|
||||
:20E16000A87908A9887031486946801C0884601C00070794000F0C77103048778A7FF920B4
|
||||
:20E180000240921CE7200240012002438A77142109A801F0FBF908A8099007A80A906946D3
|
||||
:20E1A0008C851420CC8508860D942B46A888083309AAA2DF0FB030BDF0B58FB00F4605465A
|
||||
:20E1C0001C21684601F0E2F968460178022631430170002401940394049405940694A97917
|
||||
:20E1E00008A8817011496846091D0184601C0107090F103168460794017700200146684618
|
||||
:20E200004177817FF9200140891CE72001400120014368468177142109A801F0B7F907E086
|
||||
:20E22000FFFF000088280020FCF703003015000008A8099007A80A9068468685C4850686B5
|
||||
:20E240000D972B46A888203309AA6946A2DF0FB0F0BD30B58FB005461C21684601F096F9FD
|
||||
:20E2600069460878082108431022104369460870002401940394049405940694A87908A962
|
||||
:20E280008870144869460884601C00070794000F0C7710304877887FF9210840801CF72123
|
||||
:20E2A000084010430121084369468877142109A801F06CF908A8099007A80A9069468C851A
|
||||
:20E2C0001720CC8508860D942B46A888103309AAA2DF6FE731150000FFB583B0074600207F
|
||||
:20E2E0000C9C8646267805463AE07868A90041180A88684682804988C1800022694601A8F7
|
||||
:20E3000065DF002810D1684601780598814226D17046002801D0002200E002222078891824
|
||||
:20E3200041181F2902D90C2007B0F0BD7146002908D1401CC0B2411C069B049A21701A54AF
|
||||
:20E3400001208646217806980A18694601A865DF0028E9D1694620780978401820706D1CC0
|
||||
:20E360003888A842C1DC7046002804D020780699801B401E88550020D6E7F8B51546069C10
|
||||
:20E380001E46074602220094FFF7A6FF002806D133461022294638460094FFF79DFFF8BD07
|
||||
:20E3A000F7B582B000260546167000681446002805D02846039900F0CAF8060008D168794D
|
||||
:20E3C00000281ED02078039F001D1F2802D90C2005B0F0BD684679DF0028F9D1217803226A
|
||||
:20E3E000481C20707A5421781922481C20707A542078C1196846008800F0A4F821784018A0
|
||||
:20E400002070A8790223002810D02078039A411C2170135420780399471C012227700A54E5
|
||||
:20E420002078AA79471C039927700A54A868002815D00021415620788C460246C01C03992E
|
||||
:20E440001F28C4D8501C20708B5422780A23501C20708B5420786246431C23700A54A8899B
|
||||
:20E46000002809D028460094062202210C30039BFFF783FF0600ABD1A88A002809D02846D9
|
||||
:20E480000094072203211430039BFFF776FF06009ED1A88B002809D0284600941522142137
|
||||
:20E4A0001C30039BFFF769FF060091D1686A002805D02246039900F07FF8060088D1A86A01
|
||||
:20E4C000002805D02246039900F0B5F8060084D13020405D002806D022462846039900F0F6
|
||||
:20E4E000DCF80600C7D1304672E770B50C4692B000216A46117007251171002809D0817927
|
||||
:20E5000049070CD502A9FFF74BFF002808D102AE00E00026002C0ED0A079002802D028469D
|
||||
:20E5200012B070BD01AA0AA92046FFF739FF0028F6D10AAA00E0002268460379017830463C
|
||||
:20E5400072DFEDE70870000A487002207047F8B514780746A01C15460E461F2803D83879BF
|
||||
:20E56000801C1F2801D90C20F8BD1D20001B80B26946864608803019801C7DDF0028F3D143
|
||||
:20E580003868022805D168460088704501D8092107E038790821002801D0704501D96846F6
|
||||
:20E5A0000088421C3255641CE2B2B1542978801C081828700020F8BDF8B50D461178064636
|
||||
:20E5C000881D14461F2801D90C20F8BD33880720062BFAD31927FF01BB4202D94D4A9342D6
|
||||
:20E5E000F3D17288062AF0D3BA4202D9494FBA42EBD1484FBB4203D0BA4201D09342E4D87E
|
||||
:20E60000481C052220706A5420781222411C21702A54207841193088FFF794FF21784018C5
|
||||
:20E62000C0B2207041197088FFF78CFF2178401820700020F8BD70B5054600790E46801CD6
|
||||
:20E640001446C0B21178821C8A181F2A01D90C2070BD0A46491C401C2170B0542078FF224A
|
||||
:20E66000411C21703254207881192888FFF76AFF21784018C0B22070AA88002A09D0A968AC
|
||||
:20E68000002908D0801900F022FF2078297940182070002070BD072070BDF7B582B0029894
|
||||
:20E6A0001446C06A0F46002832D0029800252030009028E00298C16A0C2068430E18217855
|
||||
:20E6C00030794A1CC01C2270785421781622481C20707A542078C1193088FFF733FF217873
|
||||
:20E6E0004018C0B22070B288002A09D0B16800290ED0C01900F0EBFE207831794018207087
|
||||
:20E700006D1C0098EDB2007CA842D3D800205FE607205DE6FFFF000038B56749674A48883D
|
||||
:20E7200090420FD04A78664C521CD2B24A70237B934208D3083175DF002803D0A1690029FF
|
||||
:20E7400000D0884738BD00254D70217C002907D03B2176DF002803D0A169002900D0884728
|
||||
:20E7600061690029EED068460095884738BD70B5054601461C225248FDF75AFD4E4C002647
|
||||
:20E7800026702968002907D00822A01800F09FFE204608307ADF02E0474808307BDF0028C1
|
||||
:20E7A00008D1401E608044486670464A0021001DFFF7D6F870BD10B53F484068FFF769F9D5
|
||||
:20E7C00010BDF8B53C48103000F069F800263A4D3B4C002806D06169002919D001200090EB
|
||||
:20E7E000684614E02878002804D0616900290FD00096F5E7687800280CD0A16800226868B8
|
||||
:20E80000FFF70AF9002803D0A169002900D088472E70F8BD6168F1E7F8B5294C028800276B
|
||||
:20E82000254DE689102A18D029464968112A21D0122A2DD0502A0FD1801D0288B2420BD1FF
|
||||
:20E84000028B022A08D1C27E837E10021843C007C00F13D0FFF7B5FFF8BD81886980014667
|
||||
:20E86000154808221631103000F031FE6F70002EF0D0F8BD0020C04368806F700846FFF7BB
|
||||
:20E8800008F90028F5D0A1690029F2D08847F8BD811D09480822103000F019FEDAE7418827
|
||||
:20E8A000054808300288914204D34088814201D8012070470020704790280020FFFF0000B6
|
||||
:20E8C000CC2D002019E7030031B5054C04E0401E00902046FDF77AFC00980028F7D138BDC6
|
||||
:20E8E000E703000018225043FE4A00218018017181604161012281610261C1607047FFB577
|
||||
:20E9000081B0F94C049B039A054626691A4303200092002E03D1002A0ED001222261276919
|
||||
:20E92000039A0126360792003B0000F022FF072707162940526127000222EFE770693269FC
|
||||
:20E9400092B25043326933691204920C9BB2594329DF002812D102210FE0084628DF00286A
|
||||
:20E960000CD10399002901D0032106E00499002916D12978042946D017E0216105B0F0BDAE
|
||||
:20E980007069326992B25043326993B24B4301461846039A29DF0028F0D10499002901D0F4
|
||||
:20E9A0000421EAE72978042920D00521E5E773693069366980B2434368681B189B18B6B2C7
|
||||
:20E9C0004E43301880181946049A29DF0028E9D0D4E7306980B24843696880188A08696902
|
||||
:20E9E00029DF0028CAD1009900290CD00621C4E77069316989B24843316989B200F0D9FD08
|
||||
:20EA000028DF0028BAD10721B7E7F8B5B54918230A780F205A435418241DB3492278266970
|
||||
:20EA2000CF68022A1BD001252D07042A2AD0052A5BD1286981B2304600F0BBFD0146A36877
|
||||
:20EA400028699A1980B24843101A820860681818861928694B1C80B25843801B34E0B8023C
|
||||
:20EA600062686169121A0918A3683018181801239B029A4202D2920829DF31E0FF220132BA
|
||||
:20EA800029DF2DE0E268974914205043F4314018001D0BC8B04203D160685943814218D02E
|
||||
:20EAA000022A16D0286981B2304600F082FD0146286980B24843301A820828694B1C80B208
|
||||
:20EAC000584363689B19C01A83082046FFF717FF06E0286981B2304600F06BFDC01928DFED
|
||||
:20EAE000002802D17F4901228A70F8BDF8B57D4C069E65780A2D1DD027787D19EDB20A2D5B
|
||||
:20EB000001D30A3DEDB218277D432D192871AA6103C9EE60AB6069612861A1780020002978
|
||||
:20EB200004D1FFF772FF112800D100206178491C6170F8BD0420F8BD38B5024669481823B1
|
||||
:20EB400001785943081803690179022B0AD014246343644CF434E4588368009383691030F7
|
||||
:20EB6000A04738BD604B14331C68F5E7F8B55D4B9978012914D100255B499D700A69082A77
|
||||
:20EB800005D002280FD003280AD10D2006E0022807D00D7000F025FA002801D0FFF7CCFF37
|
||||
:20EBA000F8BD0D61F6E74F48182403784E496343CC681818641C001DCC600378022B05D11F
|
||||
:20EBC0004668A102B14201D3012700E00027052B01D1072A03D00021042B02D003E00121C1
|
||||
:20EBE000FAE7072A03D00026042B02D007E00126FAE74068A302834201D3002A1AD0002000
|
||||
:20EC0000314301433943C5D0374E28463561FFF793FF344C2078FFF765FEF5606078401E1E
|
||||
:20EC200060702078401CC0B220700A28B2D30A382070AFE70120E3E770B500252A4C2948D3
|
||||
:20EC4000E56025610570457085702E463046FFF749FE761C0A2EF9D3012212076560516952
|
||||
:20EC600028461269491E92B25143E560A1601D49F4310D608D600D61CD601B4914310D6090
|
||||
:20EC8000888001212170206170BDF8B5164A044610780E46002830D0002C30D0002E2ED058
|
||||
:20ECA000206800282BD0012000076768016989B28F4228D8102F26D3A168002923D09568E2
|
||||
:20ECC000794343694A19006980B243439A421AD801200007006980B2814212D901200007E1
|
||||
:20ECE000006903E0E82D0020A828002080B2394600F05FFC002906D103E00820F8BD0E20B9
|
||||
:20ED0000F8BDB80701D00720F8BDBD49486801281CD00F461421BB4A21C641438E18756092
|
||||
:20ED2000236853506168B160A168F160A268616800235143012212075B1C14699BB2A4B214
|
||||
:20ED40008C4205D21469A4B2091B02E00420F8BD00211469A4B265191469A4B28C42EBD985
|
||||
:20ED6000BD60401C336178600020F8BDF8B50446A3481E46007815460F46002807D0002F3D
|
||||
:20ED800007D0002C05D02068002817D103E00820F8BD0E20F8BD9B48016800290ED0C268E3
|
||||
:20EDA000816840684A4310186268904206D9002D04D0A94202D3A819884201D90720F8BD90
|
||||
:20EDC000384600F008F9002811D0304600F003F900280CD0606800F0FEF8002807D02B4637
|
||||
:20EDE0003A46214602200096FFF780FEF8BD1020F8BDFFB5824881B000781F4616460D462B
|
||||
:20EE0000002808D0002D08D00198002805D02868002817D103E00820B0E50E20AEE5794C91
|
||||
:20EE2000206800280ED0E168A0686268414389186A68914206D9002E04D0B04202D3F119AD
|
||||
:20EE4000814201D9072099E5019800F0C4F800281BD0384600F0BFF8002816D0686800F025
|
||||
:20EE6000BAF8002811D068683246C119019800F02EFB00962868142148432458002203215B
|
||||
:20EE80002846019BA047002078E5102076E5F8B505465B480F460078002805D0002D05D012
|
||||
:20EEA0002868002821D103E00820F8BD0E20F8BD544C00262068002817D0A168E0684843CC
|
||||
:20EEC00061684118686881420FD900F084F800280DD0296814225143091968684A68896834
|
||||
:20EEE000801A00F066FB002903D00720F8BD1020F8BD3B460022294604200096FFF7F6FDB5
|
||||
:20EF0000F8BD3F4A1278002A0DD000280DD000290BD00268002A08D0394A14321368002B3E
|
||||
:20EF200005D004207047082070470E20704702230B600068106000207047F8B504463048AF
|
||||
:20EF40001E46007817460D46002807D0002D07D0002C05D0206802281BD103E00820F8BDC3
|
||||
:20EF60000E20F8BD264814300068002811D0084600F031F800280ED0304600F02CF800286C
|
||||
:20EF800009D03B462A46214602200096FFF7AEFDF8BD0720F8BD1020F8BD08B5184A1278C8
|
||||
:20EFA000002A05D0002805D00268022A11D103E0082008BD0E2008BD114A14321268002AD5
|
||||
:20EFC00007D00B460022014604200092FFF78EFD08BD072008BD800701D000207047012068
|
||||
:20EFE0007047084910B5F43949780020002906D0FFF70BFD002802D0112800D1002010BD48
|
||||
:20F00000A8280020DC2E002070B500250C290ED304464318008941000919581A0A38C2B2BD
|
||||
:20F020001748022A027002D30A318B4201D2092070BD144800F04BFA134914480A8882422E
|
||||
:20F0400002D02388934217D14988814202D06088884211D10D4A0323521E20891B03A842DE
|
||||
:20F060000AD9690009194989914203D09E896D1CB142F4D1002070BD0B2070BD00207047C6
|
||||
:20F08000C4280020F02E002080100010FFFF000010B5FDF7ABF810BD10B50446002A02D054
|
||||
:20F0A0001088002210E00A48FBE7030A00020343A05C584003061B0F43401803584083B2EB
|
||||
:20F0C0001806C00C5840521C8A42EED310BD0000FFFF00004B48002101704C484A4A026039
|
||||
:20F0E0008160C160016108224161426081610846704710B500291DD000220A60434A5368A8
|
||||
:20F10000002B1BD0202817D85B1E5360D0682423401CD060106914684343E3180B60012366
|
||||
:20F1200083409169401C19434007400F91611061002010BD0E2010BD0C2010BD042010BD8F
|
||||
:20F14000F0B5324A0646916800292BD057691020791A4907490F14680B4624254D436519D6
|
||||
:20F16000B54206D1012495698C4065400020956104E0491C4907490F8F42EED1491C4E07DC
|
||||
:20F18000760F956901210C469C402B4623420AD19368002B07D05B1E936053685B1C53609D
|
||||
:20F1A0003346F0E70420F0BD184A2423117C1268491E4907490F594320315050002070470B
|
||||
:20F1C00070B500281AD0002918D0104AD368002B16D05B1ED360936824265B1C936053692A
|
||||
:20F1E00015681C467343EE1820330660E858641C08606007400F5061002070BD0E2070BD84
|
||||
:20F20000042070BDC5280020FC2E00201C30002030B5CB0008339DB293070024002B01D0E6
|
||||
:20F22000072030BD3B4B9A605219DA605C701C7058809980002030BDF7B5364C0E466088D5
|
||||
:20F24000814237D8344F00F069F822786078A188884201DA401C00E00020C0B2904202D155
|
||||
:20F2600000F062F824E065786078884201DA401C00E00020607000F057F8BD4218D0A0688C
|
||||
:20F28000EF000299C151009900290CD0002E0AD0608832464543E068281800F018F9A068B3
|
||||
:20F2A0003818868002E00021381881800020FEBD0420FEBD0920FEBD0EB504E068468188A8
|
||||
:20F2C000029A0098904702AA01A9684600F003F80028F3D00EBD70B50E4B05241D785E786C
|
||||
:20F2E000AE4215D01D781C789E88B44201DA641C00E000241C705C88DE686C43A41904600F
|
||||
:20F300009B68E800C418A4880C80185800241060204670BDCC280020FFFF000072B606484F
|
||||
:20F320000168491C0160704703490868401E086000D162B670470000DC280020BFF34F8F11
|
||||
:20F3400003490248C860BFF34F8FFEE70400FA0500ED00E010B5002904D000221146104619
|
||||
:20F36000FFF7ECFF00F010F810BD10B50021024A0846FFF761FF10BD55F3030010B50846E6
|
||||
:20F380001146FCF771FF10BDF8B5384C2078002837D02069002807D00026E068002805D0FB
|
||||
:20F3A0000025002E04D013E00126F6E70125F8E7684651DF052806D0002806D000221146D2
|
||||
:20F3C000FFF7BCFF04E0012602E0216900988847002D12D1608869460880A06861DF0528FA
|
||||
:20F3E00006D0002806D000221146FFF7A7FF04E0012502E0E168A0688847002ED8D0002D15
|
||||
:20F40000CFD0F8BD70B5002901D08C0701D0072070BD164C0125A16062801549636010DF46
|
||||
:20F420000028F5D1257016202EDF70BD002803D00E49C860002070470E207047002803D0A8
|
||||
:20F440000A490861002070470E20704710B507484068002807D08047002803D0002211463E
|
||||
:20F46000FFF76CFF10BDFFF78FFF10BDE02800207DF30300034610B50B439B070FD1042A66
|
||||
:20F480000DD308C810C9121FA342F8D018BA21BA884201D9012010BD0020C04310BD002AAC
|
||||
:20F4A00003D0D30703D0521C07E0002010BD03780C78401C491C1B1B07D103780C78401C61
|
||||
:20F4C000491C1B1B01D1921EF1D1184610BDF8B5042A2CD3830712D00B78491C0370401C25
|
||||
:20F4E000521E83070BD00B78491C0370401C521E830704D00B78491C0370401C521E8B07F9
|
||||
:20F500009B0F05D0C91ADF002023DE1B08C90AE0FCF78EFEF8BD1D4608C9FD401C46B440B8
|
||||
:20F520002C4310C0121F042AF5D2F308C91A521EF0D40B78491C0370401C521EEAD40B78EC
|
||||
:20F54000491C0370401C521EE4D409780170F8BD01E004C0091F0429FBD28B0701D50280F7
|
||||
:20F56000801CC90700D00270704700290BD0C30702D00270401C491E022904D3830702D5EE
|
||||
:20F580000280801C891EE3E70022EEE70022DFE70378C2781946437812061B0219438378A2
|
||||
:20F5A000C0781B04194311430902090A000608437047002203098B422CD3030A8B4211D366
|
||||
:20F5C00000239C464EE003460B433CD4002243088B4231D303098B421CD3030A8B4201D39D
|
||||
:20F5E00094463FE0C3098B4201D3CB01C01A524183098B4201D38B01C01A524143098B422D
|
||||
:20F6000001D34B01C01A524103098B4201D30B01C01A5241C3088B4201D3CB00C01A524193
|
||||
:20F6200083088B4201D38B00C01A524143088B4201D34B00C01A5241411A00D201465241FB
|
||||
:20F64000104670475DE0CA0F00D04942031000D34042534000229C4603098B422DD3030A47
|
||||
:20F660008B4212D3FC22890112BA030A8B420CD3890192118B4208D3890192118B4204D305
|
||||
:20F6800089013AD0921100E08909C3098B4201D3CB01C01A524183098B4201D38B01C01A88
|
||||
:20F6A000524143098B4201D34B01C01A524103098B4201D30B01C01A5241C3088B4201D37F
|
||||
:20F6C000CB00C01A524183088B4201D38B00C01A5241D9D243088B4201D34B00C01A52417F
|
||||
:20F6E000411A00D20146634652415B10104601D34042002B00D54942704763465B1000D31A
|
||||
:20F70000404201B50020C046C04602BD704770477047754600F022F8AE460500694653469B
|
||||
:20F72000C008C000854618B020B5FEF7FBFA60BC00274908B6460026C0C5C0C5C0C5C0C525
|
||||
:20F74000C0C5C0C5C0C5C0C5403D49008D4670470446C046C0462046FCF7FFFC004870479C
|
||||
:20F760003830002001491820ABBEFEE726000200704730B47446641E2578641CAB4200D256
|
||||
:20F780001D46635D5B00E31830BC184702000000000000000000000000000000040000009F
|
||||
:20F7A000000000000000000000000000000000000000000035C4030000000000000000004D
|
||||
:20F7C000020000000000000000000000000000000000000000000000030000000000000024
|
||||
:20F7E0000000000005000000000000000000000000000000000000000000000023D1BCEA6A
|
||||
:20F800005F782315DEEF1212000000002CF8030000280020F400000004C1030020F90300A1
|
||||
:20F82000F4280020A413000020C103000000000000000000000000000000000000000000F1
|
||||
:20F840000000000000000000000000000000000000000000000000000000000000000000A8
|
||||
:20F8600000000000000000000000FFFF000000003200000000000000000000000000000058
|
||||
:20F88000000000000000000000000000000000000000000000000000000000000000000068
|
||||
:20F8A000000000000000000000000000000000000024F40000000000000000000000000030
|
||||
:20F8C000000000000000000000000000000000000000000000000000000000000000000028
|
||||
:20F8E000000000000000000000000000000000000000000000000000000000000000000008
|
||||
:20F900000000000000000000000000000000000000000000000000000000000000000000E7
|
||||
:20FC00000100000000000000FE0000000000000000000000000000000000000000000000E5
|
||||
:020000041000EA
|
||||
:0410140000C0030015
|
||||
:040000050003C0C173
|
||||
:00000001FF
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* S110/S120/S130 License Agreement
|
||||
*
|
||||
* Copyright (c) 2015, Nordic Semiconductor ASA, All rights reserved.
|
||||
*
|
||||
* Redistribution. Redistribution and use in binary form, without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* • Redistributions must reproduce the above copyright notice and the following
|
||||
* disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* • Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* • No reverse engineering, decompilation, or disassembly of this software is
|
||||
* permitted.
|
||||
*
|
||||
* DISCLAIMER.
|
||||
* 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.
|
||||
*
|
||||
* /
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "ble-nrf51822",
|
||||
"version": "2.7.1",
|
||||
"description": "Nordic stack and drivers for the mbed BLE API.",
|
||||
"keywords": [
|
||||
"Bluetooth",
|
||||
"BLE",
|
||||
"mbed",
|
||||
"mbed-official"
|
||||
],
|
||||
"author": "Rohit Grover",
|
||||
"repository": {
|
||||
"url": "git@github.com:ARMmbed/ble-nRF51822.git",
|
||||
"type": "git"
|
||||
},
|
||||
"homepage": "https://developer.mbed.org/teams/Nordic-Semiconductor/",
|
||||
"licenses": [
|
||||
{
|
||||
"url": "https://spdx.org/licenses/Apache-2.0",
|
||||
"type": "Apache-2.0"
|
||||
},
|
||||
{
|
||||
"type": "LicenseRef-softdevice_nrf51822_licence_agreement.txt"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"ble": "^2.6.0",
|
||||
"nrf51-sdk": "^2.4.0"
|
||||
},
|
||||
"extraIncludes": [
|
||||
"source/btle",
|
||||
"source/btle/custom",
|
||||
"source/common"
|
||||
],
|
||||
"targetDependencies": {}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* S110/S120/S130 License Agreement
|
||||
*
|
||||
* Copyright (c) 2015, Nordic Semiconductor ASA, All rights reserved.
|
||||
*
|
||||
* Redistribution. Redistribution and use in binary form, without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* • Redistributions must reproduce the above copyright notice and the following
|
||||
* disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* • Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* • No reverse engineering, decompilation, or disassembly of this software is
|
||||
* permitted.
|
||||
*
|
||||
* DISCLAIMER.
|
||||
* 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.
|
||||
*
|
||||
* /
|
|
@ -0,0 +1,278 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "common/common.h"
|
||||
#include "nordic_common.h"
|
||||
|
||||
#include "btle.h"
|
||||
#include "btle_clock.h"
|
||||
|
||||
#include "ble_flash.h"
|
||||
#include "ble_conn_params.h"
|
||||
|
||||
#include "btle_gap.h"
|
||||
#include "btle_advertising.h"
|
||||
#include "custom/custom_helper.h"
|
||||
|
||||
#include "ble/GapEvents.h"
|
||||
#include "nRF5xn.h"
|
||||
|
||||
extern "C" {
|
||||
#include "pstorage.h"
|
||||
#include "device_manager.h"
|
||||
#include "softdevice_handler.h"
|
||||
#include "ble_stack_handler_types.h"
|
||||
}
|
||||
|
||||
#include "nrf_ble_hci.h"
|
||||
#include "btle_discovery.h"
|
||||
|
||||
#include "nRF5xGattClient.h"
|
||||
#include "nRF5xServiceDiscovery.h"
|
||||
#include "nRF5xCharacteristicDescriptorDiscoverer.h"
|
||||
|
||||
bool isEventsSignaled = false;
|
||||
|
||||
extern "C" void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name);
|
||||
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name);
|
||||
|
||||
static void btle_handler(ble_evt_t *p_ble_evt);
|
||||
|
||||
#if 0
|
||||
#define CENTRAL_LINK_COUNT (YOTTA_CFG_NORDIC_BLE_CENTRAL_LINKS) /**<number of central links used by the application. When changing this number remember to adjust the RAM settings */
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_PERIPHERAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
||||
#define PERIPHERAL_LINK_COUNT (YOTTA_CFG_NORDIC_BLE_PERIPHERAL_LINKS) /**<number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_CENTRAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
||||
#define GATTS_ATTR_TAB_SIZE (YOTTA_CFG_NORDIC_BLE_GATTS_ATTR_TAB_SIZE) /**< GATTS attribite table size. */
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_GATTS_ATTR_TAB_SIZE was used, ram settings are adjusted by the yotta target module. */
|
||||
#else
|
||||
#define CENTRAL_LINK_COUNT 3 /**<number of central links used by the application. When changing this number remember to adjust the RAM settings */
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_PERIPHERAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
||||
#define PERIPHERAL_LINK_COUNT 1 /**<number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_CENTRAL_LINKS was used, ram settings are adjusted by the yotta target module. */
|
||||
#define GATTS_ATTR_TAB_SIZE 0x600 /**< GATTS attribite table size. */
|
||||
/** If value for YOTTA_CFG_NORDIC_BLE_GATTS_ATTR_TAB_SIZE was used, ram settings are adjusted by the yotta target module. */
|
||||
|
||||
#endif
|
||||
|
||||
static void sys_evt_dispatch(uint32_t sys_evt)
|
||||
{
|
||||
pstorage_sys_event_handler(sys_evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called in interrupt context to handle BLE events; i.e. pull
|
||||
* system and user events out of the pending events-queue of the BLE stack. The
|
||||
* BLE stack signals the availability of events by the triggering the SWI2
|
||||
* interrupt, which forwards the handling to this function.
|
||||
*
|
||||
* The event processing loop is implemented in intern_softdevice_events_execute().
|
||||
*
|
||||
* This function will signal to the user code by calling signalEventsToProcess
|
||||
* that their is events to process and BLE::processEvents should be called.
|
||||
*/
|
||||
static uint32_t signalEvent()
|
||||
{
|
||||
if(isEventsSignaled == false) {
|
||||
isEventsSignaled = true;
|
||||
nRF5xn::Instance(BLE::DEFAULT_INSTANCE).signalEventsToProcess(BLE::DEFAULT_INSTANCE);
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
error_t btle_init(void)
|
||||
{
|
||||
nrf_clock_lf_cfg_t clockConfiguration;
|
||||
|
||||
// Configure the LF clock according to values provided by btle_clock.h.
|
||||
// It is input from the chain of the yotta configuration system.
|
||||
clockConfiguration.source = LFCLK_CONF_SOURCE;
|
||||
clockConfiguration.xtal_accuracy = LFCLK_CONF_ACCURACY;
|
||||
clockConfiguration.rc_ctiv = LFCLK_CONF_RC_CTIV;
|
||||
clockConfiguration.rc_temp_ctiv = LFCLK_CONF_RC_TEMP_CTIV;
|
||||
|
||||
SOFTDEVICE_HANDLER_INIT(&clockConfiguration, signalEvent);
|
||||
|
||||
// Enable BLE stack
|
||||
/**
|
||||
* Using this call, the application can select whether to include the
|
||||
* Service Changed characteristic in the GATT Server. The default in all
|
||||
* previous releases has been to include the Service Changed characteristic,
|
||||
* but this affects how GATT clients behave. Specifically, it requires
|
||||
* clients to subscribe to this attribute and not to cache attribute handles
|
||||
* between connections unless the devices are bonded. If the application
|
||||
* does not need to change the structure of the GATT server attributes at
|
||||
* runtime this adds unnecessary complexity to the interaction with peer
|
||||
* clients. If the SoftDevice is enabled with the Service Changed
|
||||
* Characteristics turned off, then clients are allowed to cache attribute
|
||||
* handles making applications simpler on both sides.
|
||||
*/
|
||||
static const bool IS_SRVC_CHANGED_CHARACT_PRESENT = true;
|
||||
|
||||
ble_enable_params_t ble_enable_params;
|
||||
uint32_t err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
|
||||
PERIPHERAL_LINK_COUNT,
|
||||
&ble_enable_params);
|
||||
|
||||
ble_enable_params.gatts_enable_params.attr_tab_size = GATTS_ATTR_TAB_SIZE;
|
||||
ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
|
||||
ble_enable_params.common_enable_params.vs_uuid_count = UUID_TABLE_MAX_ENTRIES;
|
||||
|
||||
if(err_code != NRF_SUCCESS) {
|
||||
return ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (softdevice_enable(&ble_enable_params) != NRF_SUCCESS) {
|
||||
return ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ble_gap_addr_t addr;
|
||||
if (sd_ble_gap_address_get(&addr) != NRF_SUCCESS) {
|
||||
return ERROR_INVALID_PARAM;
|
||||
}
|
||||
if (sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr) != NRF_SUCCESS) {
|
||||
return ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ASSERT_STATUS( softdevice_ble_evt_handler_set(btle_handler));
|
||||
ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch));
|
||||
|
||||
return btle_gap_init();
|
||||
}
|
||||
|
||||
static void btle_handler(ble_evt_t *p_ble_evt)
|
||||
{
|
||||
/* Library service handlers */
|
||||
#if SDK_CONN_PARAMS_MODULE_ENABLE
|
||||
ble_conn_params_on_ble_evt(p_ble_evt);
|
||||
#endif
|
||||
|
||||
dm_ble_evt_handler(p_ble_evt);
|
||||
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
bleGattcEventHandler(p_ble_evt);
|
||||
#endif
|
||||
|
||||
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
|
||||
nRF5xGap &gap = (nRF5xGap &) ble.getGap();
|
||||
nRF5xGattServer &gattServer = (nRF5xGattServer &) ble.getGattServer();
|
||||
nRF5xSecurityManager &securityManager = (nRF5xSecurityManager &) ble.getSecurityManager();
|
||||
|
||||
/* Custom event handler */
|
||||
switch (p_ble_evt->header.evt_id) {
|
||||
case BLE_GAP_EVT_CONNECTED: {
|
||||
Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle;
|
||||
#if defined(TARGET_MCU_NRF51_16K_S110) || defined(TARGET_MCU_NRF51_32K_S110)
|
||||
/* Only peripheral role is supported by S110 */
|
||||
Gap::Role_t role = Gap::PERIPHERAL;
|
||||
#else
|
||||
Gap::Role_t role = static_cast<Gap::Role_t>(p_ble_evt->evt.gap_evt.params.connected.role);
|
||||
#endif
|
||||
gap.setConnectionHandle(handle);
|
||||
const Gap::ConnectionParams_t *params = reinterpret_cast<Gap::ConnectionParams_t *>(&(p_ble_evt->evt.gap_evt.params.connected.conn_params));
|
||||
const ble_gap_addr_t *peer = &p_ble_evt->evt.gap_evt.params.connected.peer_addr;
|
||||
const ble_gap_addr_t *own = &p_ble_evt->evt.gap_evt.params.connected.own_addr;
|
||||
gap.processConnectionEvent(handle,
|
||||
role,
|
||||
static_cast<BLEProtocol::AddressType_t>(peer->addr_type), peer->addr,
|
||||
static_cast<BLEProtocol::AddressType_t>(own->addr_type), own->addr,
|
||||
params);
|
||||
break;
|
||||
}
|
||||
|
||||
case BLE_GAP_EVT_DISCONNECTED: {
|
||||
Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle;
|
||||
// Since we are not in a connection and have not started advertising,
|
||||
// store bonds
|
||||
gap.setConnectionHandle (BLE_CONN_HANDLE_INVALID);
|
||||
|
||||
Gap::DisconnectionReason_t reason;
|
||||
switch (p_ble_evt->evt.gap_evt.params.disconnected.reason) {
|
||||
case BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION:
|
||||
reason = Gap::LOCAL_HOST_TERMINATED_CONNECTION;
|
||||
break;
|
||||
case BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION:
|
||||
reason = Gap::REMOTE_USER_TERMINATED_CONNECTION;
|
||||
break;
|
||||
case BLE_HCI_CONN_INTERVAL_UNACCEPTABLE:
|
||||
reason = Gap::CONN_INTERVAL_UNACCEPTABLE;
|
||||
break;
|
||||
default:
|
||||
/* Please refer to the underlying transport library for an
|
||||
* interpretion of this reason's value. */
|
||||
reason = static_cast<Gap::DisconnectionReason_t>(p_ble_evt->evt.gap_evt.params.disconnected.reason);
|
||||
break;
|
||||
}
|
||||
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
// Close all pending discoveries for this connection
|
||||
nRF5xGattClient& gattClient = ble.getGattClient();
|
||||
gattClient.characteristicDescriptorDiscoverer().terminate(handle, BLE_ERROR_INVALID_STATE);
|
||||
gattClient.discovery().terminate(handle);
|
||||
#endif
|
||||
|
||||
gap.processDisconnectionEvent(handle, reason);
|
||||
break;
|
||||
}
|
||||
|
||||
case BLE_GAP_EVT_PASSKEY_DISPLAY:
|
||||
securityManager.processPasskeyDisplayEvent(p_ble_evt->evt.gap_evt.conn_handle, p_ble_evt->evt.gap_evt.params.passkey_display.passkey);
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_TIMEOUT:
|
||||
gap.processTimeoutEvent(static_cast<Gap::TimeoutSource_t>(p_ble_evt->evt.gap_evt.params.timeout.src));
|
||||
break;
|
||||
|
||||
case BLE_GATTC_EVT_TIMEOUT:
|
||||
case BLE_GATTS_EVT_TIMEOUT:
|
||||
// Disconnect on GATT Server and Client timeout events.
|
||||
// ASSERT_STATUS_RET_VOID (sd_ble_gap_disconnect(m_conn_handle,
|
||||
// BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION));
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_ADV_REPORT: {
|
||||
const ble_gap_evt_adv_report_t *advReport = &p_ble_evt->evt.gap_evt.params.adv_report;
|
||||
gap.processAdvertisementReport(advReport->peer_addr.addr,
|
||||
advReport->rssi,
|
||||
advReport->scan_rsp,
|
||||
static_cast<GapAdvertisingParams::AdvertisingType_t>(advReport->type),
|
||||
advReport->dlen,
|
||||
advReport->data);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gattServer.hwCallback(p_ble_evt);
|
||||
}
|
||||
|
||||
/*! @brief Callback when an error occurs inside the SoftDevice */
|
||||
void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
|
||||
{
|
||||
ASSERT(false, (void) 0);
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Handler for general errors above the SoftDevice layer.
|
||||
Typically we can' recover from this so we do a reset.
|
||||
*/
|
||||
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name)
|
||||
{
|
||||
ASSERT_STATUS_RET_VOID( error_code );
|
||||
NVIC_SystemReset();
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 _BTLE_H_
|
||||
#define _BTLE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common/common.h"
|
||||
|
||||
#include "ble_srv_common.h"
|
||||
#include "nrf_ble.h"
|
||||
|
||||
error_t btle_init(void);
|
||||
|
||||
// flag indicating if events have been signaled or not
|
||||
// It is used by processEvents and signalEventsToProcess
|
||||
// signalEventsToProcess raise the flag and processEvents
|
||||
// clears it.
|
||||
extern bool isEventsSignaled;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ifndef _BTLE_H_
|
|
@ -0,0 +1,46 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "common/common.h"
|
||||
|
||||
#include "ble_advdata.h"
|
||||
#include "btle.h"
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Starts the advertising process
|
||||
|
||||
@returns
|
||||
*/
|
||||
/**************************************************************************/
|
||||
error_t btle_advertising_start(void)
|
||||
{
|
||||
ble_gap_adv_params_t adv_para = {0};
|
||||
|
||||
/* Set the default advertising parameters */
|
||||
adv_para.type = BLE_GAP_ADV_TYPE_ADV_IND;
|
||||
adv_para.p_peer_addr = NULL; /* Undirected advertising */
|
||||
adv_para.fp = BLE_GAP_ADV_FP_ANY;
|
||||
adv_para.p_whitelist = NULL;
|
||||
adv_para.interval = (CFG_GAP_ADV_INTERVAL_MS * 8) / 5; /* Advertising
|
||||
* interval in
|
||||
* units of 0.625
|
||||
* ms */
|
||||
adv_para.timeout = CFG_GAP_ADV_TIMEOUT_S;
|
||||
|
||||
ASSERT_STATUS( sd_ble_gap_adv_start(&adv_para));
|
||||
|
||||
return ERROR_NONE;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 _BTLE_ADVERTISING_H_
|
||||
#define _BTLE_ADVERTISING_H_
|
||||
|
||||
#include "common/common.h"
|
||||
|
||||
error_t btle_advertising_start(void);
|
||||
|
||||
#endif // ifndef _BTLE_ADVERTISING_H_
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 _BTLE_CLOCK_H_
|
||||
#define _BTLE_CLOCK_H_
|
||||
|
||||
#include "nrf5x_lf_clk_helper.h"
|
||||
|
||||
/**
|
||||
* @brief Module that generates settings for the low-frequency (LF) clock configuration.
|
||||
*
|
||||
* This module provides macros that are generated from the mbed config system macros.
|
||||
*
|
||||
*
|
||||
*
|
||||
* As a result, this module provides the following: @n
|
||||
* - literal value LFCLK_CONF_SOURCE @n
|
||||
* - literal value LFCLK_CONF_ACCURACY @n
|
||||
* - literal value LFCLK_CONF_RC_CTIV @n
|
||||
* - literal value LFCLK_CONF_RC_TEMP_CTIV
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "nrf_sdm.h"
|
||||
|
||||
#define DEFAULT_LFCLK_CONF_ACCURACY NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM
|
||||
|
||||
#ifdef NRF52
|
||||
#define MAX_LFCLK_CONF_RC_CTIV 32
|
||||
#else
|
||||
#define MAX_LFCLK_CONF_RC_CTIV 64
|
||||
#endif
|
||||
|
||||
#define MAX_LFCLK_CONF_RC_TEMP_CTIV 33
|
||||
|
||||
#define DEFAULT_LFCLK_CONF_RC_CTIV 16 // Check temperature every 16 * 250ms.
|
||||
#define DEFAULT_LFCLK_CONF_RC_TEMP_CTIV 1 // Only calibrate if temperature has changed.
|
||||
|
||||
|
||||
#if MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC == NRF_LF_SRC_RC
|
||||
#define LFCLK_CONF_SOURCE NRF_CLOCK_LF_SRC_RC
|
||||
|
||||
#ifdef MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_TIMER_INTERVAL
|
||||
#define LFCLK_CONF_RC_CTIV MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_TIMER_INTERVAL
|
||||
#else
|
||||
#define LFCLK_CONF_RC_CTIV DEFAULT_LFCLK_CONF_RC_CTIV
|
||||
#endif
|
||||
|
||||
#ifdef MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_MODE_CONFIG
|
||||
#define LFCLK_CONF_RC_TEMP_CTIV MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_MODE_CONFIG
|
||||
#else
|
||||
#define LFCLK_CONF_RC_TEMP_CTIV DEFAULT_LFCLK_CONF_RC_TEMP_CTIV
|
||||
#endif
|
||||
|
||||
#if (LFCLK_CONF_RC_CTIV < 1) || (LFCLK_CONF_RC_CTIV > MAX_LFCLK_CONF_RC_CTIV)
|
||||
#error Calibration timer interval out of range!
|
||||
#endif
|
||||
|
||||
#if (LFCLK_CONF_RC_TEMP_CTIV < 0 ) || (LFCLK_CONF_RC_TEMP_CTIV > 33)
|
||||
#error Number/mode of LF RC calibration intervals out of range!
|
||||
#endif
|
||||
|
||||
#elif MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC == NRF_LF_SRC_SYNTH
|
||||
#define LFCLK_CONF_SOURCE NRF_CLOCK_LF_SRC_SYNTH
|
||||
#define LFCLK_CONF_RC_CTIV 0 // Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
|
||||
#define LFCLK_CONF_RC_TEMP_CTIV 0 // Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
|
||||
|
||||
#ifdef MBED_CONF_NORDIC_LF_CLOCK_HF_SYNTH_ACCURACY
|
||||
#define LFCLK_CONF_ACCURACY MBED_CONF_NORDIC_LF_CLOCK_HF_SYNTH_ACCURACY
|
||||
#endif
|
||||
|
||||
#else // default is NRF_LF_SRC_SYNTH
|
||||
#define LFCLK_CONF_SOURCE NRF_CLOCK_LF_SRC_XTAL
|
||||
#define LFCLK_CONF_RC_CTIV 0 // Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
|
||||
#define LFCLK_CONF_RC_TEMP_CTIV 0 // Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
|
||||
|
||||
#ifdef MBED_CONF_NORDIC_LF_CLOCK_XTAL_ACCURACY
|
||||
#define LFCLK_CONF_ACCURACY MBED_CONF_NORDIC_LF_CLOCK_XTAL_ACCURACY
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef LFCLK_CONF_ACCURACY
|
||||
#define LFCLK_CONF_ACCURACY DEFAULT_LFCLK_CONF_ACCURACY
|
||||
#endif
|
||||
|
||||
#if (LFCLK_CONF_ACCURACY > NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM) || (LFCLK_CONF_ACCURACY < NRF_CLOCK_LF_XTAL_ACCURACY_250_PPM)
|
||||
#error Low frequency clock accuracy out of range!
|
||||
#endif
|
||||
|
||||
|
||||
#endif //_BTLE_CLOCK_H_
|
||||
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "nRF5xServiceDiscovery.h"
|
||||
#include "nRF5xCharacteristicDescriptorDiscoverer.h"
|
||||
#include "nRF5xGattClient.h"
|
||||
#include "nRF5xn.h"
|
||||
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
|
||||
{
|
||||
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
|
||||
nRF5xGap &gap = (nRF5xGap &) ble.getGap();
|
||||
nRF5xGattClient &gattClient = (nRF5xGattClient &) ble.getGattClient();
|
||||
nRF5xServiceDiscovery &sdSingleton = gattClient.discovery();
|
||||
nRF5xCharacteristicDescriptorDiscoverer &characteristicDescriptorDiscoverer =
|
||||
gattClient.characteristicDescriptorDiscoverer();
|
||||
|
||||
switch (p_ble_evt->header.evt_id) {
|
||||
case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
|
||||
switch (p_ble_evt->evt.gattc_evt.gatt_status) {
|
||||
case BLE_GATT_STATUS_SUCCESS:
|
||||
sdSingleton.setupDiscoveredServices(&p_ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp);
|
||||
break;
|
||||
|
||||
case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
|
||||
default:
|
||||
sdSingleton.terminate();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GATTC_EVT_CHAR_DISC_RSP:
|
||||
switch (p_ble_evt->evt.gattc_evt.gatt_status) {
|
||||
case BLE_GATT_STATUS_SUCCESS:
|
||||
sdSingleton.setupDiscoveredCharacteristics(&p_ble_evt->evt.gattc_evt.params.char_disc_rsp);
|
||||
break;
|
||||
|
||||
case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
|
||||
default:
|
||||
sdSingleton.terminateCharacteristicDiscovery(BLE_ERROR_NONE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP:
|
||||
if (sdSingleton.isActive()) {
|
||||
sdSingleton.processDiscoverUUIDResponse(&p_ble_evt->evt.gattc_evt.params.char_val_by_uuid_read_rsp);
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GATTC_EVT_READ_RSP: {
|
||||
GattReadCallbackParams response = {
|
||||
.connHandle = p_ble_evt->evt.gattc_evt.conn_handle,
|
||||
.handle = p_ble_evt->evt.gattc_evt.params.read_rsp.handle,
|
||||
.offset = p_ble_evt->evt.gattc_evt.params.read_rsp.offset,
|
||||
.len = p_ble_evt->evt.gattc_evt.params.read_rsp.len,
|
||||
.data = p_ble_evt->evt.gattc_evt.params.read_rsp.data,
|
||||
};
|
||||
gattClient.processReadResponse(&response);
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GATTC_EVT_WRITE_RSP: {
|
||||
GattWriteCallbackParams response = {
|
||||
.connHandle = p_ble_evt->evt.gattc_evt.conn_handle,
|
||||
.handle = p_ble_evt->evt.gattc_evt.params.write_rsp.handle,
|
||||
.writeOp = (GattWriteCallbackParams::WriteOp_t)(p_ble_evt->evt.gattc_evt.params.write_rsp.write_op),
|
||||
.offset = p_ble_evt->evt.gattc_evt.params.write_rsp.offset,
|
||||
.len = p_ble_evt->evt.gattc_evt.params.write_rsp.len,
|
||||
.data = p_ble_evt->evt.gattc_evt.params.write_rsp.data,
|
||||
};
|
||||
gattClient.processWriteResponse(&response);
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GATTC_EVT_HVX: {
|
||||
GattHVXCallbackParams params;
|
||||
params.connHandle = p_ble_evt->evt.gattc_evt.conn_handle;
|
||||
params.handle = p_ble_evt->evt.gattc_evt.params.hvx.handle;
|
||||
params.type = static_cast<HVXType_t>(p_ble_evt->evt.gattc_evt.params.hvx.type);
|
||||
params.len = p_ble_evt->evt.gattc_evt.params.hvx.len;
|
||||
params.data = p_ble_evt->evt.gattc_evt.params.hvx.data;
|
||||
|
||||
gattClient.processHVXEvent(¶ms);
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GATTC_EVT_DESC_DISC_RSP: {
|
||||
uint16_t conn_handle = p_ble_evt->evt.gattc_evt.conn_handle;
|
||||
uint16_t status = p_ble_evt->evt.gattc_evt.gatt_status;
|
||||
const ble_gattc_evt_desc_disc_rsp_t& discovered_descriptors = p_ble_evt->evt.gattc_evt.params.desc_disc_rsp;
|
||||
|
||||
switch(status) {
|
||||
case BLE_GATT_STATUS_SUCCESS:
|
||||
characteristicDescriptorDiscoverer.process(
|
||||
conn_handle,
|
||||
discovered_descriptors
|
||||
);
|
||||
break;
|
||||
case BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND:
|
||||
// end of discovery
|
||||
characteristicDescriptorDiscoverer.terminate(conn_handle, BLE_ERROR_NONE);
|
||||
break;
|
||||
default:
|
||||
characteristicDescriptorDiscoverer.terminate(conn_handle, BLE_ERROR_UNSPECIFIED);
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case BLE_GATTC_EVT_ATTR_INFO_DISC_RSP : {
|
||||
uint16_t conn_handle = p_ble_evt->evt.gattc_evt.conn_handle;
|
||||
uint16_t status = p_ble_evt->evt.gattc_evt.gatt_status;
|
||||
const ble_gattc_evt_attr_info_disc_rsp_t& infos = p_ble_evt->evt.gattc_evt.params.attr_info_disc_rsp;
|
||||
|
||||
switch(status) {
|
||||
case BLE_GATT_STATUS_SUCCESS:
|
||||
characteristicDescriptorDiscoverer.processAttributeInformation(
|
||||
conn_handle,
|
||||
infos
|
||||
);
|
||||
break;
|
||||
default:
|
||||
characteristicDescriptorDiscoverer.terminate(conn_handle, BLE_ERROR_UNSPECIFIED);
|
||||
break;
|
||||
}
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
sdSingleton.progressCharacteristicDiscovery();
|
||||
sdSingleton.progressServiceDiscovery();
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,22 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 _BTLE_DISCOVERY_H_
|
||||
#define _BTLE_DISCOVERY_H_
|
||||
|
||||
void bleGattcEventHandler(const ble_evt_t *p_ble_evt);
|
||||
|
||||
#endif /*_BTLE_DISCOVERY_H_*/
|
|
@ -0,0 +1,99 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "common/common.h"
|
||||
|
||||
#include "nrf_ble_gap.h"
|
||||
#include "ble_conn_params.h"
|
||||
|
||||
static inline uint32_t msec_to_1_25msec(uint32_t interval_ms) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
#if SDK_CONN_PARAMS_MODULE_ENABLE
|
||||
static void error_callback(uint32_t nrf_error);
|
||||
#endif // SDK_CONN_PARAMS_MODULE_ENABLE
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initialise GAP in the underlying SoftDevice
|
||||
|
||||
@returns
|
||||
*/
|
||||
/**************************************************************************/
|
||||
error_t btle_gap_init(void)
|
||||
{
|
||||
ble_gap_conn_params_t gap_conn_params = {0};
|
||||
|
||||
gap_conn_params.min_conn_interval = msec_to_1_25msec(CFG_GAP_CONNECTION_MIN_INTERVAL_MS); // in 1.25ms units
|
||||
gap_conn_params.max_conn_interval = msec_to_1_25msec(CFG_GAP_CONNECTION_MAX_INTERVAL_MS); // in 1.25ms unit
|
||||
gap_conn_params.slave_latency = CFG_GAP_CONNECTION_SLAVE_LATENCY;
|
||||
gap_conn_params.conn_sup_timeout = CFG_GAP_CONNECTION_SUPERVISION_TIMEOUT_MS / 10; // in 10ms unit
|
||||
|
||||
ble_gap_conn_sec_mode_t sec_mode;
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed
|
||||
|
||||
ASSERT_STATUS( sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *) CFG_GAP_LOCAL_NAME, strlen(CFG_GAP_LOCAL_NAME)));
|
||||
ASSERT_STATUS( sd_ble_gap_appearance_set(CFG_GAP_APPEARANCE));
|
||||
ASSERT_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params));
|
||||
ASSERT_STATUS( sd_ble_gap_tx_power_set(CFG_BLE_TX_POWER_LEVEL));
|
||||
|
||||
/**
|
||||
* Call to conn_params_init() is not necessary; and so is disabled by default.
|
||||
* This API should be exposed to the user to be invoked when necessary.
|
||||
*/
|
||||
#if SDK_CONN_PARAMS_MODULE_ENABLE
|
||||
/* Connection Parameters */
|
||||
enum {
|
||||
FIRST_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER),
|
||||
NEXT_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER),
|
||||
MAX_UPDATE_COUNT = 3
|
||||
};
|
||||
|
||||
ble_conn_params_init_t cp_init = {0};
|
||||
|
||||
cp_init.p_conn_params = NULL;
|
||||
cp_init.first_conn_params_update_delay = FIRST_UPDATE_DELAY;
|
||||
cp_init.next_conn_params_update_delay = NEXT_UPDATE_DELAY;
|
||||
cp_init.max_conn_params_update_count = MAX_UPDATE_COUNT;
|
||||
cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID;
|
||||
cp_init.disconnect_on_fail = true;
|
||||
cp_init.evt_handler = NULL;
|
||||
cp_init.error_handler = error_callback;
|
||||
|
||||
ASSERT_STATUS ( ble_conn_params_init(&cp_init));
|
||||
#endif // SDK_CONN_PARAMS_MODULE_ENABLE
|
||||
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Converts msecs to an integer representing 1.25ms units
|
||||
|
||||
@param[in] ms
|
||||
The number of milliseconds to conver to 1.25ms units
|
||||
|
||||
@returns The number of 1.25ms units in the supplied number of ms
|
||||
*/
|
||||
/**************************************************************************/
|
||||
static inline uint32_t msec_to_1_25msec(uint32_t interval_ms)
|
||||
{
|
||||
return (interval_ms * 4) / 5;
|
||||
}
|
||||
|
||||
#if SDK_CONN_PARAMS_MODULE_ENABLE
|
||||
static void error_callback(uint32_t nrf_error)
|
||||
{
|
||||
ASSERT_STATUS_RET_VOID( nrf_error );
|
||||
}
|
||||
#endif // SDK_CONN_PARAMS_MODULE_ENABLE
|
|
@ -0,0 +1,24 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 _BTLE_GAP_H_
|
||||
#define _BTLE_GAP_H_
|
||||
|
||||
#include "common/common.h"
|
||||
|
||||
error_t btle_gap_init(void);
|
||||
|
||||
#endif // ifndef _BTLE_GAP_H_
|
|
@ -0,0 +1,325 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "btle.h"
|
||||
|
||||
#include "nRF5xn.h"
|
||||
|
||||
extern "C" {
|
||||
#include "pstorage.h"
|
||||
#include "device_manager.h"
|
||||
#include "id_manager.h"
|
||||
}
|
||||
|
||||
#include "btle_security.h"
|
||||
|
||||
static dm_application_instance_t applicationInstance;
|
||||
static bool initialized = false;
|
||||
static ret_code_t dm_handler(dm_handle_t const *p_handle, dm_event_t const *p_event, ret_code_t event_result);
|
||||
|
||||
// default security parameters. Avoid "holes" between member assigments in order to compile by gcc++11.
|
||||
static ble_gap_sec_params_t securityParameters = {
|
||||
.bond = true, /**< Perform bonding. */
|
||||
.mitm = true, /**< Man In The Middle protection required. */
|
||||
.lesc = false, /**< Enable LE Secure Connection pairing. */
|
||||
.keypress = false, /**< Enable generation of keypress notifications. */
|
||||
.io_caps = SecurityManager::IO_CAPS_NONE, /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */
|
||||
.oob = 0, /**< Out Of Band data available. */
|
||||
.min_key_size = 16, /**< Minimum encryption key size in octets between 7 and 16. If 0 then not applicable in this instance. */
|
||||
.max_key_size = 16, /**< Maximum encryption key size in octets between min_key_size and 16. */
|
||||
.kdist_own = {
|
||||
.enc = 0, /**< Long Term Key and Master Identification. */
|
||||
.id = 0, /**< Identity Resolving Key and Identity Address Information. */
|
||||
.sign = 0, /**< Connection Signature Resolving Key. */
|
||||
.link = 0 /**< Derive the Link Key from the LTK. */
|
||||
}, /**< Key distribution bitmap: keys that the local device will distribute. */
|
||||
.kdist_peer = {
|
||||
.enc = 1, /**< Long Term Key and Master Identification. */
|
||||
.id = 1, /**< Identity Resolving Key and Identity Address Information. */
|
||||
.sign = 1, /**< Connection Signature Resolving Key. */
|
||||
.link = 0 /**< Derive the Link Key from the LTK. */
|
||||
} /**< Key distribution bitmap: keys that the peripheral device will distribute. */
|
||||
};
|
||||
|
||||
bool
|
||||
btle_hasInitializedSecurity(void)
|
||||
{
|
||||
return initialized;
|
||||
}
|
||||
|
||||
ble_error_t
|
||||
btle_initializeSecurity(bool enableBonding,
|
||||
bool requireMITM,
|
||||
SecurityManager::SecurityIOCapabilities_t iocaps,
|
||||
const SecurityManager::Passkey_t passkey)
|
||||
{
|
||||
/* guard against multiple initializations */
|
||||
if (initialized) {
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
if (pstorage_init() != NRF_SUCCESS) {
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
ret_code_t rc;
|
||||
if (passkey) {
|
||||
ble_opt_t opts;
|
||||
opts.gap_opt.passkey.p_passkey = const_cast<uint8_t *>(passkey);
|
||||
if ((rc = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &opts)) != NRF_SUCCESS) {
|
||||
switch (rc) {
|
||||
case BLE_ERROR_INVALID_CONN_HANDLE:
|
||||
case NRF_ERROR_INVALID_ADDR:
|
||||
case NRF_ERROR_INVALID_PARAM:
|
||||
default:
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
case NRF_ERROR_INVALID_STATE:
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
case NRF_ERROR_BUSY:
|
||||
return BLE_STACK_BUSY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dm_init_param_t dm_init_param = {
|
||||
.clear_persistent_data = false /* Set to true in case the module should clear all persistent data. */
|
||||
};
|
||||
if (dm_init(&dm_init_param) != NRF_SUCCESS) {
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
// update default security parameters with function call parameters
|
||||
securityParameters.bond = enableBonding;
|
||||
securityParameters.mitm = requireMITM;
|
||||
securityParameters.io_caps = iocaps;
|
||||
|
||||
const dm_application_param_t dm_param = {
|
||||
.evt_handler = dm_handler,
|
||||
.service_type = DM_PROTOCOL_CNTXT_GATT_CLI_ID,
|
||||
.sec_param = securityParameters
|
||||
};
|
||||
|
||||
if ((rc = dm_register(&applicationInstance, &dm_param)) != NRF_SUCCESS) {
|
||||
switch (rc) {
|
||||
case NRF_ERROR_INVALID_STATE:
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
case NRF_ERROR_NO_MEM:
|
||||
return BLE_ERROR_NO_MEM;
|
||||
default:
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t
|
||||
btle_purgeAllBondingState(void)
|
||||
{
|
||||
ret_code_t rc;
|
||||
if ((rc = dm_device_delete_all(&applicationInstance)) == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
switch (rc) {
|
||||
case NRF_ERROR_INVALID_STATE:
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
case NRF_ERROR_NO_MEM:
|
||||
return BLE_ERROR_NO_MEM;
|
||||
default:
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
ble_error_t
|
||||
btle_getLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager::LinkSecurityStatus_t *securityStatusP)
|
||||
{
|
||||
ret_code_t rc;
|
||||
dm_handle_t dmHandle = {
|
||||
.appl_id = applicationInstance,
|
||||
};
|
||||
if ((rc = dm_handle_get(connectionHandle, &dmHandle)) != NRF_SUCCESS) {
|
||||
if (rc == NRF_ERROR_NOT_FOUND) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
} else {
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
if ((rc = dm_security_status_req(&dmHandle, reinterpret_cast<dm_security_status_t *>(securityStatusP))) != NRF_SUCCESS) {
|
||||
switch (rc) {
|
||||
case NRF_ERROR_INVALID_STATE:
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
case NRF_ERROR_NO_MEM:
|
||||
return BLE_ERROR_NO_MEM;
|
||||
default:
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t
|
||||
btle_setLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager::SecurityMode_t securityMode)
|
||||
{
|
||||
// use default and updated parameters as starting point
|
||||
// and modify structure based on security mode.
|
||||
ble_gap_sec_params_t params = securityParameters;
|
||||
|
||||
switch (securityMode) {
|
||||
case SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK:
|
||||
/**< Require no protection, open link. */
|
||||
securityParameters.bond = false;
|
||||
securityParameters.mitm = false;
|
||||
break;
|
||||
|
||||
case SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM:
|
||||
/**< Require encryption, but no MITM protection. */
|
||||
securityParameters.bond = true;
|
||||
securityParameters.mitm = false;
|
||||
break;
|
||||
|
||||
// not yet implemented security modes
|
||||
case SecurityManager::SECURITY_MODE_NO_ACCESS:
|
||||
case SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM:
|
||||
/**< Require encryption and MITM protection. */
|
||||
case SecurityManager::SECURITY_MODE_SIGNED_NO_MITM:
|
||||
/**< Require signing or encryption, but no MITM protection. */
|
||||
case SecurityManager::SECURITY_MODE_SIGNED_WITH_MITM:
|
||||
/**< Require signing or encryption, and MITM protection. */
|
||||
default:
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// update security settings for given connection
|
||||
uint32_t result = sd_ble_gap_authenticate(connectionHandle, ¶ms);
|
||||
|
||||
if (result == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
} else {
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
ret_code_t
|
||||
dm_handler(dm_handle_t const *p_handle, dm_event_t const *p_event, ret_code_t event_result)
|
||||
{
|
||||
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
|
||||
nRF5xSecurityManager &securityManager = (nRF5xSecurityManager &) ble.getSecurityManager();
|
||||
|
||||
switch (p_event->event_id) {
|
||||
case DM_EVT_SECURITY_SETUP: /* started */ {
|
||||
const ble_gap_sec_params_t *peerParams = &p_event->event_param.p_gap_param->params.sec_params_request.peer_params;
|
||||
securityManager.processSecuritySetupInitiatedEvent(p_event->event_param.p_gap_param->conn_handle,
|
||||
peerParams->bond,
|
||||
peerParams->mitm,
|
||||
(SecurityManager::SecurityIOCapabilities_t)peerParams->io_caps);
|
||||
break;
|
||||
}
|
||||
case DM_EVT_SECURITY_SETUP_COMPLETE:
|
||||
securityManager.
|
||||
processSecuritySetupCompletedEvent(p_event->event_param.p_gap_param->conn_handle,
|
||||
(SecurityManager::SecurityCompletionStatus_t)(p_event->event_param.p_gap_param->params.auth_status.auth_status));
|
||||
break;
|
||||
case DM_EVT_LINK_SECURED: {
|
||||
unsigned securityMode = p_event->event_param.p_gap_param->params.conn_sec_update.conn_sec.sec_mode.sm;
|
||||
unsigned level = p_event->event_param.p_gap_param->params.conn_sec_update.conn_sec.sec_mode.lv;
|
||||
SecurityManager::SecurityMode_t resolvedSecurityMode = SecurityManager::SECURITY_MODE_NO_ACCESS;
|
||||
switch (securityMode) {
|
||||
case 1:
|
||||
switch (level) {
|
||||
case 1:
|
||||
resolvedSecurityMode = SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK;
|
||||
break;
|
||||
case 2:
|
||||
resolvedSecurityMode = SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM;
|
||||
break;
|
||||
case 3:
|
||||
resolvedSecurityMode = SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (level) {
|
||||
case 1:
|
||||
resolvedSecurityMode = SecurityManager::SECURITY_MODE_SIGNED_NO_MITM;
|
||||
break;
|
||||
case 2:
|
||||
resolvedSecurityMode = SecurityManager::SECURITY_MODE_SIGNED_WITH_MITM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
securityManager.processLinkSecuredEvent(p_event->event_param.p_gap_param->conn_handle, resolvedSecurityMode);
|
||||
break;
|
||||
}
|
||||
case DM_EVT_DEVICE_CONTEXT_STORED:
|
||||
securityManager.processSecurityContextStoredEvent(p_event->event_param.p_gap_param->conn_handle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
ble_error_t
|
||||
btle_createWhitelistFromBondTable(ble_gap_whitelist_t *p_whitelist)
|
||||
{
|
||||
if (!btle_hasInitializedSecurity()) {
|
||||
return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
}
|
||||
ret_code_t err = dm_whitelist_create(&applicationInstance, p_whitelist);
|
||||
if (err == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
} else if (err == NRF_ERROR_NULL) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
} else {
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
btle_matchAddressAndIrk(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * p_irk)
|
||||
{
|
||||
/*
|
||||
* Use a helper function from the Nordic SDK to test whether the BLE
|
||||
* address can be generated using the IRK.
|
||||
*/
|
||||
return im_address_resolve(p_addr, p_irk);
|
||||
}
|
||||
|
||||
void
|
||||
btle_generateResolvableAddress(const ble_gap_irk_t &irk, ble_gap_addr_t &address)
|
||||
{
|
||||
/* Set type to resolvable */
|
||||
address.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;
|
||||
|
||||
/*
|
||||
* Assign a random number to the most significant 3 bytes
|
||||
* of the address.
|
||||
*/
|
||||
address.addr[BLE_GAP_ADDR_LEN - 3] = 0x8E;
|
||||
address.addr[BLE_GAP_ADDR_LEN - 2] = 0x4F;
|
||||
address.addr[BLE_GAP_ADDR_LEN - 1] = 0x7C;
|
||||
|
||||
/* Calculate the hash and store it in the top half of the address */
|
||||
ah(irk.irk, &address.addr[BLE_GAP_ADDR_LEN - 3], address.addr);
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 _BTLE_SECURITY_H_
|
||||
#define _BTLE_SECURITY_H_
|
||||
|
||||
#include "ble/Gap.h"
|
||||
#include "ble/SecurityManager.h"
|
||||
|
||||
/**
|
||||
* Function to test whether the SecurityManager has been initialized.
|
||||
* Possible by a call to @ref btle_initializeSecurity().
|
||||
*
|
||||
* @return True if the SecurityManager was previously initialized, false
|
||||
* otherwise.
|
||||
*/
|
||||
bool btle_hasInitializedSecurity(void);
|
||||
|
||||
/**
|
||||
* Enable Nordic's Device Manager, which brings in functionality from the
|
||||
* stack's Security Manager. The Security Manager implements the actual
|
||||
* cryptographic algorithms and protocol exchanges that allow two devices to
|
||||
* securely exchange data and privately detect each other.
|
||||
*
|
||||
* @param[in] enableBonding Allow for bonding.
|
||||
* @param[in] requireMITM Require protection for man-in-the-middle attacks.
|
||||
* @param[in] iocaps To specify IO capabilities of this peripheral,
|
||||
* such as availability of a display or keyboard to
|
||||
* support out-of-band exchanges of security data.
|
||||
* @param[in] passkey To specify a static passkey.
|
||||
*
|
||||
* @return BLE_ERROR_NONE on success.
|
||||
*/
|
||||
ble_error_t btle_initializeSecurity(bool enableBonding = true,
|
||||
bool requireMITM = true,
|
||||
SecurityManager::SecurityIOCapabilities_t iocaps = SecurityManager::IO_CAPS_NONE,
|
||||
const SecurityManager::Passkey_t passkey = NULL);
|
||||
|
||||
/**
|
||||
* Get the security status of a link.
|
||||
*
|
||||
* @param[in] connectionHandle
|
||||
* Handle to identify the connection.
|
||||
* @param[out] securityStatusP
|
||||
* security status.
|
||||
*
|
||||
* @return BLE_ERROR_NONE Or appropriate error code indicating reason for failure.
|
||||
*/
|
||||
ble_error_t btle_getLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager::LinkSecurityStatus_t *securityStatusP);
|
||||
|
||||
/**
|
||||
* Set the security mode on a connection. Useful for elevating the security mode
|
||||
* once certain conditions are met, e.g., a particular service is found.
|
||||
*
|
||||
* @param[in] connectionHandle
|
||||
* Handle to identify the connection.
|
||||
* @param[in] securityMode
|
||||
* security mode.
|
||||
*
|
||||
* @return BLE_ERROR_NONE Or appropriate error code indicating reason for failure.
|
||||
*/
|
||||
ble_error_t btle_setLinkSecurity(Gap::Handle_t connectionHandle, SecurityManager::SecurityMode_t securityMode);
|
||||
|
||||
/**
|
||||
* Function for deleting all peer device context and all related bonding
|
||||
* information from the database.
|
||||
*
|
||||
* @retval BLE_ERROR_NONE On success, else an error code indicating reason for failure.
|
||||
* @retval BLE_ERROR_INVALID_STATE If the API is called without module initialization and/or
|
||||
* application registration.
|
||||
*/
|
||||
ble_error_t btle_purgeAllBondingState(void);
|
||||
|
||||
/**
|
||||
* Query the SoftDevice bond table to extract a whitelist containing the BLE
|
||||
* addresses and IRKs of bonded devices.
|
||||
*
|
||||
* @param[in/out] p_whitelist
|
||||
* (on input) p_whitelist->addr_count and
|
||||
* p_whitelist->irk_count specify the maximum number of
|
||||
* addresses and IRKs added to the whitelist structure.
|
||||
* (on output) *p_whitelist is a whitelist containing the
|
||||
* addresses and IRKs of the bonded devices.
|
||||
*
|
||||
* @return BLE_ERROR_NONE Or appropriate error code indicating reason for failure.
|
||||
*/
|
||||
ble_error_t btle_createWhitelistFromBondTable(ble_gap_whitelist_t *p_whitelist);
|
||||
|
||||
/**
|
||||
* Function to test whether a BLE address is generated using an IRK.
|
||||
*
|
||||
* @param[in] p_addr
|
||||
* Pointer to a BLE address.
|
||||
* @param[in] p_irk
|
||||
* Pointer to an IRK.
|
||||
*
|
||||
* @return True if p_addr can be generated using p_irk, false otherwise.
|
||||
*/
|
||||
bool btle_matchAddressAndIrk(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * p_irk);
|
||||
|
||||
/**
|
||||
* Function to generate a private resolvable BLE address.
|
||||
*
|
||||
* @param[out] p_addr
|
||||
* The output address.
|
||||
* @param[in] p_irk
|
||||
* A reference to a IRK.
|
||||
*
|
||||
* @note This function does not generate a secure address since the prand number in the
|
||||
* resolvable address is not truly random. Therefore, the output of this function
|
||||
* is only meant to be used by the application internally but never exported.
|
||||
*/
|
||||
void btle_generateResolvableAddress(const ble_gap_irk_t &irk, ble_gap_addr_t &address);
|
||||
|
||||
#endif /* _BTLE_SECURITY_H_ */
|
|
@ -0,0 +1,364 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "custom_helper.h"
|
||||
|
||||
/*
|
||||
* The current version of the soft-device doesn't handle duplicate 128-bit UUIDs
|
||||
* very well. It is therefore necessary to filter away duplicates before
|
||||
* passing long UUIDs to sd_ble_uuid_vs_add(). The following types and data
|
||||
* structures involved in maintaining a local cache of 128-bit UUIDs.
|
||||
*/
|
||||
typedef struct {
|
||||
UUID::LongUUIDBytes_t uuid;
|
||||
uint8_t type;
|
||||
} converted_uuid_table_entry_t;
|
||||
|
||||
static unsigned uuidTableEntries = 0; /* current usage of the table */
|
||||
converted_uuid_table_entry_t convertedUUIDTable[UUID_TABLE_MAX_ENTRIES];
|
||||
|
||||
void custom_reset_128bits_uuid_table() {
|
||||
uuidTableEntries = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* lookup the cache of previously converted 128-bit UUIDs to find a type value.
|
||||
* @param uuid base 128-bit UUID
|
||||
* @param recoveredType the type field of the 3-byte nRF's uuid.
|
||||
* @return true if a match is found.
|
||||
*/
|
||||
static bool
|
||||
lookupConvertedUUIDTable(const UUID::LongUUIDBytes_t uuid, uint8_t *recoveredType)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < uuidTableEntries; i++) {
|
||||
unsigned byteIndex;
|
||||
for (byteIndex = 0; byteIndex < UUID::LENGTH_OF_LONG_UUID; byteIndex++) {
|
||||
/* Skip bytes 2 and 3, because they contain the shortUUID (16-bit) version of the
|
||||
* long UUID; and we're comparing against the remainder. */
|
||||
if ((byteIndex == 2) || (byteIndex == 3)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (convertedUUIDTable[i].uuid[byteIndex] != uuid[byteIndex]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (byteIndex == UUID::LENGTH_OF_LONG_UUID) {
|
||||
*recoveredType = convertedUUIDTable[i].type;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
addToConvertedUUIDTable(const UUID::LongUUIDBytes_t uuid, uint8_t type)
|
||||
{
|
||||
if (uuidTableEntries == UUID_TABLE_MAX_ENTRIES) {
|
||||
return; /* recovery needed; or at least the user should be warned about this fact.*/
|
||||
}
|
||||
|
||||
memcpy(convertedUUIDTable[uuidTableEntries].uuid, uuid, UUID::LENGTH_OF_LONG_UUID);
|
||||
convertedUUIDTable[uuidTableEntries].uuid[2] = 0;
|
||||
convertedUUIDTable[uuidTableEntries].uuid[3] = 0;
|
||||
convertedUUIDTable[uuidTableEntries].type = type;
|
||||
uuidTableEntries++;
|
||||
}
|
||||
|
||||
/**
|
||||
* The nRF transport has its own 3-byte representation of a UUID. If the user-
|
||||
* specified UUID is 128-bits wide, then the UUID base needs to be added to the
|
||||
* soft-device and converted to a 3-byte handle before being used further. This
|
||||
* function is responsible for this translation of user-specified UUIDs into
|
||||
* nRF's representation.
|
||||
*
|
||||
* @param[in] uuid
|
||||
* user-specified UUID
|
||||
* @return nRF
|
||||
* 3-byte UUID (containing a type and 16-bit UUID) representation
|
||||
* to be used with SVC calls.
|
||||
*/
|
||||
ble_uuid_t custom_convert_to_nordic_uuid(const UUID &uuid)
|
||||
{
|
||||
ble_uuid_t nordicUUID;
|
||||
nordicUUID.uuid = uuid.getShortUUID();
|
||||
nordicUUID.type = BLE_UUID_TYPE_UNKNOWN; /* to be set below */
|
||||
|
||||
if (uuid.shortOrLong() == UUID::UUID_TYPE_SHORT) {
|
||||
nordicUUID.type = BLE_UUID_TYPE_BLE;
|
||||
} else {
|
||||
if (!lookupConvertedUUIDTable(uuid.getBaseUUID(), &nordicUUID.type)) {
|
||||
nordicUUID.type = custom_add_uuid_base(uuid.getBaseUUID());
|
||||
addToConvertedUUIDTable(uuid.getBaseUUID(), nordicUUID.type);
|
||||
}
|
||||
}
|
||||
|
||||
return nordicUUID;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Adds the base UUID to the custom service. All UUIDs used
|
||||
by this service are based on this 128-bit UUID.
|
||||
|
||||
@note This UUID needs to be added to the SoftDevice stack before
|
||||
adding the service's primary service via
|
||||
'sd_ble_gatts_service_add'
|
||||
|
||||
@param[in] p_uuid_base A pointer to the 128-bit UUID array (8*16)
|
||||
|
||||
@returns The UUID type.
|
||||
A return value of 0 should be considered an error.
|
||||
|
||||
@retval 0x00 BLE_UUID_TYPE_UNKNOWN
|
||||
@retval 0x01 BLE_UUID_TYPE_BLE
|
||||
@retval 0x02 BLE_UUID_TYPE_VENDOR_BEGIN
|
||||
|
||||
@section EXAMPLE
|
||||
@code
|
||||
|
||||
// Take note that bytes 2/3 are blank since these are used to identify
|
||||
// the primary service and individual characteristics
|
||||
#define CFG_CUSTOM_UUID_BASE "\x6E\x40\x00\x00\xB5\xA3\xF3\x93\xE0\xA9\xE5\x0E\x24\xDC\xCA\x9E"
|
||||
|
||||
uint8_t uuid_type = custom_add_uuid_base(CFG_CUSTOM_UUID_BASE);
|
||||
ASSERT(uuid_type > 0, ERROR_NOT_FOUND);
|
||||
|
||||
// We can now safely add the primary service and any characteristics
|
||||
// for our custom service ...
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t custom_add_uuid_base(uint8_t const *const p_uuid_base)
|
||||
{
|
||||
ble_uuid128_t base_uuid;
|
||||
uint8_t uuid_type = 0;
|
||||
|
||||
for (unsigned i = 0; i < UUID::LENGTH_OF_LONG_UUID; i++) {
|
||||
base_uuid.uuid128[i] = p_uuid_base[i];
|
||||
}
|
||||
|
||||
ASSERT_INT( ERROR_NONE, sd_ble_uuid_vs_add( &base_uuid, &uuid_type ), 0);
|
||||
|
||||
return uuid_type;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
||||
*/
|
||||
/**************************************************************************/
|
||||
error_t custom_decode_uuid_base(uint8_t const *const p_uuid_base,
|
||||
ble_uuid_t *p_uuid)
|
||||
{
|
||||
UUID::LongUUIDBytes_t uuid_base_le;
|
||||
|
||||
for (uint8_t i = 0; i < UUID::LENGTH_OF_LONG_UUID; i++) {
|
||||
uuid_base_le[i] = p_uuid_base[i];
|
||||
}
|
||||
|
||||
ASSERT_STATUS( sd_ble_uuid_decode(UUID::LENGTH_OF_LONG_UUID, uuid_base_le, p_uuid));
|
||||
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Adds a new characteristic to the custom service, assigning
|
||||
properties, a UUID add-on value, etc.
|
||||
|
||||
@param[in] service_handle
|
||||
@param[in] p_uuid The 16-bit value to add to the base UUID
|
||||
for this characteristic (normally >1
|
||||
since 1 is typically used by the primary
|
||||
service).
|
||||
@param[in] char_props The characteristic properties, as
|
||||
defined by ble_gatt_char_props_t
|
||||
@param[in] max_length The maximum length of this characeristic
|
||||
@param[in] has_variable_len Whether the characteristic data has
|
||||
variable length.
|
||||
@param[out] p_char_handle
|
||||
|
||||
@returns
|
||||
@retval ERROR_NONE Everything executed normally
|
||||
*/
|
||||
/**************************************************************************/
|
||||
error_t custom_add_in_characteristic(uint16_t service_handle,
|
||||
ble_uuid_t *p_uuid,
|
||||
uint8_t properties,
|
||||
SecurityManager::SecurityMode_t requiredSecurity,
|
||||
uint8_t *p_data,
|
||||
uint16_t length,
|
||||
uint16_t max_length,
|
||||
bool has_variable_len,
|
||||
const uint8_t *userDescriptionDescriptorValuePtr,
|
||||
uint16_t userDescriptionDescriptorValueLen,
|
||||
bool readAuthorization,
|
||||
bool writeAuthorization,
|
||||
ble_gatts_char_handles_t *p_char_handle)
|
||||
{
|
||||
/* Characteristic metadata */
|
||||
ble_gatts_attr_md_t cccd_md;
|
||||
ble_gatt_char_props_t char_props;
|
||||
|
||||
memcpy(&char_props, &properties, 1);
|
||||
|
||||
if (char_props.notify || char_props.indicate) {
|
||||
/* Notification requires cccd */
|
||||
memclr_( &cccd_md, sizeof(ble_gatts_attr_md_t));
|
||||
cccd_md.vloc = BLE_GATTS_VLOC_STACK;
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);
|
||||
}
|
||||
|
||||
ble_gatts_char_md_t char_md = {0};
|
||||
|
||||
char_md.char_props = char_props;
|
||||
char_md.p_cccd_md =
|
||||
(char_props.notify || char_props.indicate) ? &cccd_md : NULL;
|
||||
if ((userDescriptionDescriptorValueLen > 0) && (userDescriptionDescriptorValuePtr != NULL)) {
|
||||
char_md.p_char_user_desc = const_cast<uint8_t *>(userDescriptionDescriptorValuePtr);
|
||||
char_md.char_user_desc_max_size = userDescriptionDescriptorValueLen;
|
||||
char_md.char_user_desc_size = userDescriptionDescriptorValueLen;
|
||||
}
|
||||
|
||||
/* Attribute declaration */
|
||||
ble_gatts_attr_md_t attr_md = {0};
|
||||
|
||||
attr_md.rd_auth = readAuthorization;
|
||||
attr_md.wr_auth = writeAuthorization;
|
||||
|
||||
attr_md.vloc = BLE_GATTS_VLOC_STACK;
|
||||
/* Always set variable size */
|
||||
attr_md.vlen = has_variable_len;
|
||||
|
||||
if (char_props.read || char_props.notify || char_props.indicate) {
|
||||
switch (requiredSecurity) {
|
||||
case SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK :
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
|
||||
break;
|
||||
case SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM :
|
||||
BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.read_perm);
|
||||
break;
|
||||
case SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM :
|
||||
BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&attr_md.read_perm);
|
||||
break;
|
||||
case SecurityManager::SECURITY_MODE_SIGNED_NO_MITM :
|
||||
BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(&attr_md.read_perm);
|
||||
break;
|
||||
case SecurityManager::SECURITY_MODE_SIGNED_WITH_MITM :
|
||||
BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(&attr_md.read_perm);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
if (char_props.write || char_props.write_wo_resp) {
|
||||
switch (requiredSecurity) {
|
||||
case SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK :
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
|
||||
break;
|
||||
case SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM :
|
||||
BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.write_perm);
|
||||
break;
|
||||
case SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM :
|
||||
BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(&attr_md.write_perm);
|
||||
break;
|
||||
case SecurityManager::SECURITY_MODE_SIGNED_NO_MITM :
|
||||
BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(&attr_md.write_perm);
|
||||
break;
|
||||
case SecurityManager::SECURITY_MODE_SIGNED_WITH_MITM :
|
||||
BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(&attr_md.write_perm);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
ble_gatts_attr_t attr_char_value = {0};
|
||||
|
||||
attr_char_value.p_uuid = p_uuid;
|
||||
attr_char_value.p_attr_md = &attr_md;
|
||||
attr_char_value.init_len = length;
|
||||
attr_char_value.max_len = max_length;
|
||||
attr_char_value.p_value = p_data;
|
||||
|
||||
ASSERT_STATUS ( sd_ble_gatts_characteristic_add(service_handle,
|
||||
&char_md,
|
||||
&attr_char_value,
|
||||
p_char_handle));
|
||||
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Adds a new descriptor to the custom service, assigning
|
||||
value, a UUID add-on value, etc.
|
||||
|
||||
@param[in] char_handle
|
||||
@param[in] p_uuid The 16-bit value to add to the base UUID
|
||||
for this descriptor (normally >1
|
||||
since 1 is typically used by the primary
|
||||
service).
|
||||
@param[in] max_length The maximum length of this descriptor
|
||||
@param[in] has_variable_len Whether the characteristic data has
|
||||
variable length.
|
||||
|
||||
@returns
|
||||
@retval ERROR_NONE Everything executed normally
|
||||
*/
|
||||
/**************************************************************************/
|
||||
error_t custom_add_in_descriptor(uint16_t char_handle,
|
||||
ble_uuid_t *p_uuid,
|
||||
uint8_t *p_data,
|
||||
uint16_t length,
|
||||
uint16_t max_length,
|
||||
bool has_variable_len,
|
||||
uint16_t *p_desc_handle)
|
||||
{
|
||||
/* Descriptor metadata */
|
||||
ble_gatts_attr_md_t desc_md = {0};
|
||||
|
||||
desc_md.vloc = BLE_GATTS_VLOC_STACK;
|
||||
/* Always set variable size */
|
||||
desc_md.vlen = has_variable_len;
|
||||
|
||||
/* Make it readable and writable */
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&desc_md.read_perm);
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&desc_md.write_perm);
|
||||
|
||||
ble_gatts_attr_t attr_desc = {0};
|
||||
|
||||
attr_desc.p_uuid = p_uuid;
|
||||
attr_desc.p_attr_md = &desc_md;
|
||||
attr_desc.init_len = length;
|
||||
attr_desc.max_len = max_length;
|
||||
attr_desc.p_value = p_data;
|
||||
|
||||
ASSERT_STATUS ( sd_ble_gatts_descriptor_add(char_handle,
|
||||
&attr_desc,
|
||||
p_desc_handle));
|
||||
|
||||
return ERROR_NONE;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 _CUSTOM_HELPER_H_
|
||||
#define _CUSTOM_HELPER_H_
|
||||
|
||||
#include "common/common.h"
|
||||
#include "nrf_ble.h"
|
||||
#include "ble/UUID.h"
|
||||
#include "ble/GattCharacteristic.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UUID_TABLE_MAX_ENTRIES (4) /* This is the maximum number of 128-bit UUIDs with distinct bases that
|
||||
* we expect to be in use; increase this limit if needed. */
|
||||
|
||||
/**
|
||||
* Reset the table of 128bits uuids.
|
||||
* This table is used to keep track of vendors uuids added to the softdevice.
|
||||
* It is important to reset it before disabling the softdevice otherwise the
|
||||
* next time the softdevice will be enabled, this table will not be synchronmized
|
||||
* with the softdevice table.
|
||||
*/
|
||||
void custom_reset_128bits_uuid_table();
|
||||
uint8_t custom_add_uuid_base(uint8_t const *const p_uuid_base);
|
||||
error_t custom_decode_uuid(uint8_t const *const p_uuid_base,
|
||||
ble_uuid_t *p_uuid);
|
||||
ble_uuid_t custom_convert_to_nordic_uuid(const UUID &uuid);
|
||||
|
||||
error_t custom_add_in_characteristic(uint16_t service_handle,
|
||||
ble_uuid_t *p_uuid,
|
||||
uint8_t properties,
|
||||
SecurityManager::SecurityMode_t requiredSecurity,
|
||||
uint8_t *p_data,
|
||||
uint16_t length,
|
||||
uint16_t max_length,
|
||||
bool has_variable_len,
|
||||
const uint8_t *userDescriptionDescriptorValuePtr,
|
||||
uint16_t userDescriptionDescriptorValueLen,
|
||||
bool readAuthorization,
|
||||
bool writeAuthorization,
|
||||
ble_gatts_char_handles_t *p_char_handle);
|
||||
|
||||
error_t custom_add_in_descriptor(uint16_t char_handle,
|
||||
ble_uuid_t *p_uuid,
|
||||
uint8_t *p_data,
|
||||
uint16_t length,
|
||||
uint16_t max_length,
|
||||
bool has_variable_len,
|
||||
uint16_t *p_desc_handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ifndef _CUSTOM_HELPER_H_
|
|
@ -0,0 +1,103 @@
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@file ansi_esc_code.h
|
||||
@author hathach (tinyusb.org)
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2013, hathach (tinyusb.org)
|
||||
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 the copyright holders 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 ''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 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.
|
||||
|
||||
This file is part of the tinyusb stack.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
/** \file
|
||||
* \brief TBD
|
||||
*
|
||||
* \note TBD
|
||||
*/
|
||||
|
||||
/** \ingroup TBD
|
||||
* \defgroup TBD
|
||||
* \brief TBD
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _ANSI_ESC_CODE_H_
|
||||
#define _ANSI_ESC_CODE_H_
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CSI_CODE(seq) "\33[" seq
|
||||
#define CSI_SGR(x) CSI_CODE(#x) "m"
|
||||
|
||||
//------------- Cursor movement -------------//
|
||||
#define ANSI_CURSOR_UP(n) CSI_CODE(#n "A")
|
||||
#define ANSI_CURSOR_DOWN(n) CSI_CODE(#n "B")
|
||||
#define ANSI_CURSOR_FORWARD(n) CSI_CODE(#n "C")
|
||||
#define ANSI_CURSOR_BACKWARD(n) CSI_CODE(#n "D")
|
||||
#define ANSI_CURSOR_LINE_DOWN(n) CSI_CODE(#n "E")
|
||||
#define ANSI_CURSOR_LINE_UP(n) CSI_CODE(#n "F")
|
||||
#define ANSI_CURSOR_POSITION(n, m) CSI_CODE(#n ";" #m "H")
|
||||
|
||||
#define ANSI_ERASE_SCREEN(n) CSI_CODE(#n "J")
|
||||
#define ANSI_ERASE_LINE(n) CSI_CODE(#n "K")
|
||||
|
||||
/** text color */
|
||||
#define ANSI_TEXT_BLACK CSI_SGR(30)
|
||||
#define ANSI_TEXT_RED CSI_SGR(31)
|
||||
#define ANSI_TEXT_GREEN CSI_SGR(32)
|
||||
#define ANSI_TEXT_YELLOW CSI_SGR(33)
|
||||
#define ANSI_TEXT_BLUE CSI_SGR(34)
|
||||
#define ANSI_TEXT_MAGENTA CSI_SGR(35)
|
||||
#define ANSI_TEXT_CYAN CSI_SGR(36)
|
||||
#define ANSI_TEXT_WHITE CSI_SGR(37)
|
||||
#define ANSI_TEXT_DEFAULT CSI_SGR(39)
|
||||
|
||||
/** background color */
|
||||
#define ANSI_BG_BLACK CSI_SGR(40)
|
||||
#define ANSI_BG_RED CSI_SGR(41)
|
||||
#define ANSI_BG_GREEN CSI_SGR(42)
|
||||
#define ANSI_BG_YELLOW CSI_SGR(43)
|
||||
#define ANSI_BG_BLUE CSI_SGR(44)
|
||||
#define ANSI_BG_MAGENTA CSI_SGR(45)
|
||||
#define ANSI_BG_CYAN CSI_SGR(46)
|
||||
#define ANSI_BG_WHITE CSI_SGR(47)
|
||||
#define ANSI_BG_DEFAULT CSI_SGR(49)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_ANSI_ESC_CODE_H_ */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,198 @@
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@file assertion.h
|
||||
@author hathach (tinyusb.org)
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2013, K. Townsend (microBuilder.eu)
|
||||
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 the copyright holders 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 ''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 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.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
/** \file
|
||||
* \brief TBD
|
||||
*
|
||||
* \note TBD
|
||||
*/
|
||||
|
||||
/** \ingroup TBD
|
||||
* \defgroup TBD
|
||||
* \brief TBD
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _ASSERTION_H_
|
||||
#define _ASSERTION_H_
|
||||
|
||||
#include "projectconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
static inline void debugger_breakpoint(void) ATTR_ALWAYS_INLINE;
|
||||
static inline void debugger_breakpoint(void)
|
||||
{
|
||||
#ifndef _TEST_
|
||||
__asm("BKPT #0\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Compile-time Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
|
||||
#define _ASSERT_COUNTER __COUNTER__
|
||||
#else
|
||||
#define _ASSERT_COUNTER __LINE__
|
||||
#endif
|
||||
|
||||
#define ASSERT_STATIC(const_expr, message) enum { XSTRING_CONCAT_(static_assert_, _ASSERT_COUNTER) = 1/(!!(const_expr)) }
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Assert Helper
|
||||
//--------------------------------------------------------------------+
|
||||
//#ifndef _TEST_
|
||||
// #define ASSERT_MESSAGE(format, ...) _PRINTF("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
//#else
|
||||
// #define ASSERT_MESSAGE(format, ...) _PRINTF("%d:note: Assert " format "\n", __LINE__, __VA_ARGS__)
|
||||
//#endif
|
||||
|
||||
#if CFG_DEBUG == 3
|
||||
#define ASSERT_MESSAGE(format, ...) debugger_breakpoint()
|
||||
#elif CFG_DEBUG == 2
|
||||
#define ASSERT_MESSAGE(format, ...) printf("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define ASSERT_MESSAGE(format, ...)
|
||||
#endif
|
||||
|
||||
#define ASSERT_ERROR_HANDLER(x, para) \
|
||||
return (x)
|
||||
|
||||
#define ASSERT_DEFINE_WITH_HANDLER(error_handler, handler_para, setup_statement, condition, error, format, ...) \
|
||||
do{\
|
||||
setup_statement;\
|
||||
if (!(condition)) {\
|
||||
ASSERT_MESSAGE(format, __VA_ARGS__);\
|
||||
error_handler(error, handler_para);\
|
||||
}\
|
||||
}while(0)
|
||||
|
||||
#define ASSERT_DEFINE(...) ASSERT_DEFINE_WITH_HANDLER(ASSERT_ERROR_HANDLER, NULL, __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// error_t Status Assert TODO use ASSERT_DEFINE
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT_STATUS_MESSAGE(sts, message) \
|
||||
ASSERT_DEFINE(error_t status = (error_t)(sts),\
|
||||
ERROR_NONE == status, status, "%s: %s", ErrorStr[status], message)
|
||||
|
||||
#define ASSERT_STATUS(sts) \
|
||||
ASSERT_DEFINE(error_t status = (error_t)(sts),\
|
||||
ERROR_NONE == status, status, "error = %d", status)
|
||||
|
||||
#define ASSERT_STATUS_RET_VOID(sts) \
|
||||
ASSERT_DEFINE(error_t status = (error_t)(sts),\
|
||||
ERROR_NONE == status, (void) 0, "error = %d", status)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Logical Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT(...) ASSERT_TRUE(__VA_ARGS__)
|
||||
#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false")
|
||||
#define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true")
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Pointer Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT_PTR(...) ASSERT_PTR_NOT_NULL(__VA_ARGS__)
|
||||
#define ASSERT_PTR_NOT_NULL(pointer, error) ASSERT_DEFINE( , NULL != (pointer), error, "%s", "pointer is NULL")
|
||||
#define ASSERT_PTR_NULL(pointer, error) ASSERT_DEFINE( , NULL == (pointer), error, "%s", "pointer is not NULL")
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Integral Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT_XXX_EQUAL(type_format, expected, actual, error) \
|
||||
ASSERT_DEFINE(\
|
||||
uint32_t exp = (expected); uint32_t act = (actual),\
|
||||
exp==act,\
|
||||
error,\
|
||||
"expected " type_format ", actual " type_format, exp, act)
|
||||
|
||||
#define ASSERT_XXX_WITHIN(type_format, lower, upper, actual, error) \
|
||||
ASSERT_DEFINE(\
|
||||
uint32_t low = (lower); uint32_t up = (upper); uint32_t act = (actual),\
|
||||
(low <= act) && (act <= up),\
|
||||
error,\
|
||||
"expected within " type_format " - " type_format ", actual " type_format, low, up, act)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Integer Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT_INT(...) ASSERT_INT_EQUAL(__VA_ARGS__)
|
||||
#define ASSERT_INT_EQUAL(...) ASSERT_XXX_EQUAL("%d", __VA_ARGS__)
|
||||
#define ASSERT_INT_WITHIN(...) ASSERT_XXX_WITHIN("%d", __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Hex Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#define ASSERT_HEX(...) ASSERT_HEX_EQUAL(__VA_ARGS__)
|
||||
#define ASSERT_HEX_EQUAL(...) ASSERT_XXX_EQUAL("0x%x", __VA_ARGS__)
|
||||
#define ASSERT_HEX_WITHIN(...) ASSERT_XXX_WITHIN("0x%x", __VA_ARGS__)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Bin Assert
|
||||
//--------------------------------------------------------------------+
|
||||
#define BIN8_PRINTF_PATTERN "%d%d%d%d%d%d%d%d"
|
||||
#define BIN8_PRINTF_CONVERT(byte) \
|
||||
((byte) & 0x80 ? 1 : 0), \
|
||||
((byte) & 0x40 ? 1 : 0), \
|
||||
((byte) & 0x20 ? 1 : 0), \
|
||||
((byte) & 0x10 ? 1 : 0), \
|
||||
((byte) & 0x08 ? 1 : 0), \
|
||||
((byte) & 0x04 ? 1 : 0), \
|
||||
((byte) & 0x02 ? 1 : 0), \
|
||||
((byte) & 0x01 ? 1 : 0)
|
||||
|
||||
#define ASSERT_BIN8(...) ASSERT_BIN8_EQUAL(__VA_ARGS__)
|
||||
#define ASSERT_BIN8_EQUAL(expected, actual, error)\
|
||||
ASSERT_DEFINE(\
|
||||
uint8_t exp = (expected); uint8_t act = (actual),\
|
||||
exp==act,\
|
||||
error,\
|
||||
"expected " BIN8_PRINTF_PATTERN ", actual " BIN8_PRINTF_PATTERN, BIN8_PRINTF_CONVERT(exp), BIN8_PRINTF_CONVERT(act) )
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ASSERTION_H_ */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,96 @@
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@file binary.h
|
||||
@author hathach (tinyusb.org)
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2013, K. Townsend (microBuilder.eu)
|
||||
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 the copyright holders 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 ''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 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.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
/** \ingroup TBD
|
||||
* \defgroup TBD
|
||||
* \brief TBD
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _BINARY_H_
|
||||
#define _BINARY_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// n-th Bit
|
||||
#define BIT(n) (1 << (n))
|
||||
|
||||
/// set n-th bit of x to 1
|
||||
#define BIT_SET(x, n) ( (x) | BIT(n) )
|
||||
|
||||
/// clear n-th bit of x
|
||||
#define BIT_CLR(x, n) ( (x) & (~BIT(n)) )
|
||||
|
||||
/// test n-th bit of x
|
||||
#define BIT_TEST(x, n) ( (x) & BIT(n) )
|
||||
|
||||
#if defined(__GNUC__) && !defined(__CC_ARM) // keil does not support binary format
|
||||
|
||||
#define BIN8(x) ((uint8_t) (0b##x))
|
||||
#define BIN16(b1, b2) ((uint16_t) (0b##b1##b2))
|
||||
#define BIN32(b1, b2, b3, b4) ((uint32_t) (0b##b1##b2##b3##b4))
|
||||
|
||||
#else
|
||||
|
||||
// internal macro of B8, B16, B32
|
||||
#define _B8__(x) (((x&0x0000000FUL)?1:0) \
|
||||
+((x&0x000000F0UL)?2:0) \
|
||||
+((x&0x00000F00UL)?4:0) \
|
||||
+((x&0x0000F000UL)?8:0) \
|
||||
+((x&0x000F0000UL)?16:0) \
|
||||
+((x&0x00F00000UL)?32:0) \
|
||||
+((x&0x0F000000UL)?64:0) \
|
||||
+((x&0xF0000000UL)?128:0))
|
||||
|
||||
#define BIN8(d) ((uint8_t) _B8__(0x##d##UL))
|
||||
#define BIN16(dmsb,dlsb) (((uint16_t)BIN8(dmsb)<<8) + BIN8(dlsb))
|
||||
#define BIN32(dmsb,db2,db3,dlsb) \
|
||||
(((uint32_t)BIN8(dmsb)<<24) \
|
||||
+ ((uint32_t)BIN8(db2)<<16) \
|
||||
+ ((uint32_t)BIN8(db3)<<8) \
|
||||
+ BIN8(dlsb))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BINARY_H_ */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,151 @@
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@file ble_error.h
|
||||
@author hathach (tinyusb.org)
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2013, K. Townsend (microBuilder.eu)
|
||||
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 the copyright holders 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 ''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 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.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
/** \file
|
||||
* \brief Error Header
|
||||
*
|
||||
* \note TBD
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Common
|
||||
* \defgroup Group_Error Error Codes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _BLE_ERROR_H_
|
||||
#define _BLE_ERROR_H_
|
||||
|
||||
#include "projectconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/*=======================================================================
|
||||
NORDIC GLOBAL ERRORS 0x0000 .. 0x00FF
|
||||
-----------------------------------------------------------------------
|
||||
Errors mapped from nrf_error.h
|
||||
-----------------------------------------------------------------------*/
|
||||
ERROR_NONE = 0x0000 , ///< Successful command
|
||||
ERROR_SVC_HANDLER_MISSING = 0x0001 , ///< SVC handler is missing
|
||||
ERROR_SOFTDEVICE_NOT_ENABLED = 0x0002 , ///< SoftDevice has not been enabled
|
||||
ERROR_INTERNAL = 0x0003 , ///< Internal Error
|
||||
ERROR_NO_MEM = 0x0004 , ///< No Memory for operation
|
||||
ERROR_NOT_FOUND = 0x0005 , ///< Not found
|
||||
ERROR_NOT_SUPPORTED = 0x0006 , ///< Not supported
|
||||
ERROR_INVALID_PARAM = 0x0007 , ///< Invalid Parameter
|
||||
ERROR_INVALID_STATE = 0x0008 , ///< Invalid state, operation disallowed in this state
|
||||
ERROR_INVALID_LENGTH = 0x0009 , ///< Invalid Length
|
||||
ERROR_INVALID_FLAGS = 0x000A , ///< Invalid Flags
|
||||
ERROR_INVALID_DATA = 0x000B , ///< Invalid Data
|
||||
ERROR_DATA_SIZE = 0x000C , ///< Data size exceeds limit
|
||||
ERROR_TIMEOUT = 0x000D , ///< Operation timed out
|
||||
ERROR_NULL = 0x000E , ///< Null Pointer
|
||||
ERROR_FORBIDDEN = 0x000F , ///< Forbidden Operation
|
||||
ERROR_INVALID_ADDR = 0x0010 , ///< Bad Memory Address
|
||||
ERROR_BUSY = 0x0011 , ///< Busy
|
||||
/*=======================================================================*/
|
||||
|
||||
ERROR_INVALIDPARAMETER = 0x0100 , /**< An invalid parameter value was provided */
|
||||
ERROR_I2C_XFER_FAILED = 0x0101 , /**< an failed attempt to make I2C transfer */
|
||||
|
||||
/*=======================================================================
|
||||
SIMPLE BINARY PROTOCOL ERRORS 0x0120 .. 0x013F
|
||||
-----------------------------------------------------------------------
|
||||
Errors relating to the simple binary protocol (/src//protocol)
|
||||
-----------------------------------------------------------------------*/
|
||||
ERROR_PROT_INVALIDMSGTYPE = 0x121, /**< Unexpected msg type encountered */
|
||||
ERROR_PROT_INVALIDCOMMANDID = 0x122, /**< Unknown or out of range command ID */
|
||||
ERROR_PROT_INVALIDPAYLOAD = 0x123, /**< Message payload has a problem (invalid len, etc.) */
|
||||
/*=======================================================================*/
|
||||
|
||||
//------------- based on Nordic SDM nrf_error_sdm.h -------------//
|
||||
ERROR_SDM_LFCLK_SOURCE_UNKNOWN = 0x1000 , ///< Unknown lfclk source
|
||||
ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION = 0x1001 , ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts)
|
||||
ERROR_SDM_INCORRECT_CLENR0 = 0x1002 , ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing)
|
||||
|
||||
//------------- based on Nordic SOC nrf_error_soc.h -------------//
|
||||
/* Mutex Errors */
|
||||
ERROR_SOC_MUTEX_ALREADY_TAKEN = 0x2000 , ///< Mutex already taken
|
||||
|
||||
/* NVIC errors */
|
||||
ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE = 0x2001 , ///< NVIC interrupt not available
|
||||
ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED = 0x2002 , ///< NVIC interrupt priority not allowed
|
||||
ERROR_SOC_NVIC_SHOULD_NOT_RETURN = 0x2003 , ///< NVIC should not return
|
||||
|
||||
/* Power errors */
|
||||
ERROR_SOC_POWER_MODE_UNKNOWN = 0x2004 , ///< Power mode unknown
|
||||
ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN = 0x2005 , ///< Power POF threshold unknown
|
||||
ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN = 0x2006 , ///< Power off should not return
|
||||
|
||||
/* Rand errors */
|
||||
ERROR_SOC_RAND_NOT_ENOUGH_VALUES = 0x2007 , ///< RAND not enough values
|
||||
|
||||
/* PPI errors */
|
||||
ERROR_SOC_PPI_INVALID_CHANNEL = 0x2008 , ///< Invalid PPI Channel
|
||||
ERROR_SOC_PPI_INVALID_GROUP = 0x2009 , ///< Invalid PPI Group
|
||||
|
||||
//------------- based on Nordic STK (ble) ble_err.h -------------//
|
||||
ERROR_BLE_INVALID_CONN_HANDLE = 0x3001 , /**< Invalid connection handle. */
|
||||
ERROR_BLE_INVALID_ATTR_HANDLE = 0x3002 , /**< Invalid attribute handle. */
|
||||
ERROR_BLE_NO_TX_BUFFERS = 0x3003 , /**< Buffer capacity exceeded. */
|
||||
|
||||
// L2CAP
|
||||
ERROR_BLE_L2CAP_CID_IN_USE = 0x3100 , /**< CID already in use. */
|
||||
|
||||
// GAP
|
||||
ERROR_BLE_GAP_UUID_LIST_MISMATCH = 0x3200 , /**< UUID list does not contain an integral number of UUIDs. */
|
||||
ERROR_BLE_GAP_DISCOVERABLE_WITH_WHITELIST = 0x3201 , /**< Use of Whitelist not permitted with discoverable advertising. */
|
||||
ERROR_BLE_GAP_INVALID_BLE_ADDR = 0x3202 , /**< The upper two bits of the address do not correspond to the specified address type. */
|
||||
|
||||
// GATTC
|
||||
ERROR_BLE_GATTC_PROC_NOT_PERMITTED = 0x3300 ,
|
||||
|
||||
// GATTS
|
||||
ERROR_BLEGATTS_INVALID_ATTR_TYPE = 0x3400 , /**< Invalid attribute type. */
|
||||
ERROR_BLEGATTS_SYS_ATTR_MISSING = 0x3401 , /**< System Attributes missing. */
|
||||
|
||||
}error_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_ERROR_H_ */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,236 @@
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@file common.h
|
||||
@author hathach (tinyusb.org)
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2013, K. Townsend (microBuilder.eu)
|
||||
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 the copyright holders 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 ''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 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.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
/** \defgroup Group_Common Common Files
|
||||
* @{
|
||||
*
|
||||
* \defgroup Group_CommonH common.h
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _COMMON_H_
|
||||
#define _COMMON_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INCLUDES
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//------------- Standard Header -------------//
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//------------- General Header -------------//
|
||||
#include "projectconfig.h"
|
||||
#include "compiler.h"
|
||||
#include "assertion.h"
|
||||
#include "binary.h"
|
||||
#include "ble_error.h"
|
||||
|
||||
//------------- MCU header -------------//
|
||||
//#include "nrf.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// TYPEDEFS
|
||||
//--------------------------------------------------------------------+
|
||||
typedef unsigned char byte_t;
|
||||
typedef float float32_t;
|
||||
typedef double float64_t;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACROS
|
||||
//--------------------------------------------------------------------+
|
||||
#define STRING_(x) #x // stringify without expand
|
||||
#define XSTRING_(x) STRING_(x) // expand then stringify
|
||||
#define STRING_CONCAT_(a, b) a##b // concat without expand
|
||||
#define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) // expand then concat
|
||||
|
||||
#define U16_HIGH_U8(u16) ((uint8_t) (((u16) >> 8) & 0x00ff))
|
||||
#define U16_LOW_U8(u16) ((uint8_t) ((u16) & 0x00ff))
|
||||
#define U16_TO_U8S_BE(u16) U16_HIGH_U8(u16), U16_LOW_U8(u16)
|
||||
#define U16_TO_U8S_LE(u16) U16_LOW_U8(u16), U16_HIGH_U8(u16)
|
||||
|
||||
#define U32_B1_U8(u32) ((uint8_t) (((u32) >> 24) & 0x000000ff)) // MSB
|
||||
#define U32_B2_U8(u32) ((uint8_t) (((u32) >> 16) & 0x000000ff))
|
||||
#define U32_B3_U8(u32) ((uint8_t) (((u32) >> 8) & 0x000000ff))
|
||||
#define U32_B4_U8(u32) ((uint8_t) ((u32) & 0x000000ff)) // LSB
|
||||
|
||||
#define U32_TO_U8S_BE(u32) U32_B1_U8(u32), U32_B2_U8(u32), U32_B3_U8(u32), U32_B4_U8(u32)
|
||||
#define U32_TO_U8S_LE(u32) U32_B4_U8(u32), U32_B3_U8(u32), U32_B2_U8(u32), U32_B1_U8(u32)
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INLINE FUNCTION
|
||||
//--------------------------------------------------------------------+
|
||||
#define memclr_(buffer, size) memset(buffer, 0, size)
|
||||
|
||||
//------------- Conversion -------------//
|
||||
/// form an uint32_t from 4 x uint8_t
|
||||
static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4)
|
||||
{
|
||||
return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4;
|
||||
}
|
||||
|
||||
static inline uint8_t u16_high_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t u16_high_u8(uint16_t u16)
|
||||
{
|
||||
return (uint8_t) ((u16 >> 8) & 0x00ff);
|
||||
}
|
||||
|
||||
static inline uint8_t u16_low_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t u16_low_u8(uint16_t u16)
|
||||
{
|
||||
return (uint8_t) (u16 & 0x00ff);
|
||||
}
|
||||
|
||||
//------------- Min -------------//
|
||||
static inline uint8_t min8_of(uint8_t x, uint8_t y) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint8_t min8_of(uint8_t x, uint8_t y)
|
||||
{
|
||||
return (x < y) ? x : y;
|
||||
}
|
||||
|
||||
static inline uint16_t min16_of(uint16_t x, uint16_t y) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint16_t min16_of(uint16_t x, uint16_t y)
|
||||
{
|
||||
return (x < y) ? x : y;
|
||||
}
|
||||
|
||||
static inline uint32_t min32_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t min32_of(uint32_t x, uint32_t y)
|
||||
{
|
||||
return (x < y) ? x : y;
|
||||
}
|
||||
|
||||
//------------- Max -------------//
|
||||
static inline uint32_t max32_of(uint32_t x, uint32_t y) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t max32_of(uint32_t x, uint32_t y)
|
||||
{
|
||||
return (x > y) ? x : y;
|
||||
}
|
||||
|
||||
//------------- Align -------------//
|
||||
static inline uint32_t align32 (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t align32 (uint32_t value)
|
||||
{
|
||||
return (value & 0xFFFFFFE0UL);
|
||||
}
|
||||
|
||||
static inline uint32_t align16 (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t align16 (uint32_t value)
|
||||
{
|
||||
return (value & 0xFFFFFFF0UL);
|
||||
}
|
||||
|
||||
static inline uint32_t align_n (uint32_t alignment, uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t align_n (uint32_t alignment, uint32_t value)
|
||||
{
|
||||
return value & (~(alignment-1));
|
||||
}
|
||||
|
||||
static inline uint32_t align4k (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t align4k (uint32_t value)
|
||||
{
|
||||
return (value & 0xFFFFF000UL);
|
||||
}
|
||||
|
||||
static inline uint32_t offset4k(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint32_t offset4k(uint32_t value)
|
||||
{
|
||||
return (value & 0xFFFUL);
|
||||
}
|
||||
|
||||
//------------- Mathematics -------------//
|
||||
/// inclusive range checking
|
||||
static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline bool is_in_range(uint32_t lower, uint32_t value, uint32_t upper)
|
||||
{
|
||||
return (lower <= value) && (value <= upper);
|
||||
}
|
||||
|
||||
/// exclusive range checking
|
||||
static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_t upper) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_t upper)
|
||||
{
|
||||
return (lower < value) && (value < upper);
|
||||
}
|
||||
|
||||
static inline uint8_t log2_of(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint8_t log2_of(uint32_t value)
|
||||
{
|
||||
uint8_t result = 0; // log2 of a value is its MSB's position
|
||||
|
||||
while (value >>= 1)
|
||||
{
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// return the number of set bits in value
|
||||
static inline uint8_t cardinality_of(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
|
||||
static inline uint8_t cardinality_of(uint32_t value)
|
||||
{
|
||||
// Brian Kernighan's method goes through as many iterations as there are set bits. So if we have a 32-bit word with only
|
||||
// the high bit set, then it will only go once through the loop
|
||||
// Published in 1988, the C Programming Language 2nd Ed. (by Brian W. Kernighan and Dennis M. Ritchie)
|
||||
// mentions this in exercise 2-9. On April 19, 2006 Don Knuth pointed out to me that this method
|
||||
// "was first published by Peter Wegner in CACM 3 (1960), 322. (Also discovered independently by Derrick Lehmer and
|
||||
// published in 1964 in a book edited by Beckenbach.)"
|
||||
uint8_t count;
|
||||
for (count = 0; value; count++)
|
||||
{
|
||||
value &= value - 1; // clear the least significant bit set
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _COMMON_H_ */
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
|
@ -0,0 +1,160 @@
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@file compiler.h
|
||||
@author hathach (tinyusb.org)
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2013, K. Townsend (microBuilder.eu)
|
||||
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 the copyright holders 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 ''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 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.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
/** \file
|
||||
* \brief GCC Header
|
||||
*/
|
||||
|
||||
/** \ingroup Group_Compiler
|
||||
* \defgroup Group_GCC GNU GCC
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _COMPILER_GCC_H_
|
||||
#define _COMPILER_GCC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "projectconfig.h"
|
||||
|
||||
//#ifndef __GNUC__
|
||||
// #define ATTR_ALWAYS_INLINE
|
||||
// #define ATTR_CONST
|
||||
//#else
|
||||
|
||||
#ifdef _TEST_
|
||||
#define ATTR_ALWAYS_INLINE
|
||||
#define STATIC_
|
||||
#define INLINE_
|
||||
#else
|
||||
#define STATIC_ static
|
||||
#define INLINE_ inline
|
||||
|
||||
#if CFG_DEBUG == 3
|
||||
#define ATTR_ALWAYS_INLINE // no inline for debug = 3
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#define ALIGN_OF(x) __alignof__(x)
|
||||
|
||||
/// Normally, the compiler places the objects it generates in sections like data or bss & function in text. Sometimes, however, you need additional sections, or you need certain particular variables to appear in special sections, for example to map to special hardware. The section attribute specifies that a variable (or function) lives in a particular section
|
||||
#define ATTR_SECTION(section) __attribute__ ((#section))
|
||||
|
||||
/// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, an error that includes message is diagnosed. This is useful for compile-time checking
|
||||
#define ATTR_ERROR(Message) __attribute__ ((error(Message)))
|
||||
|
||||
/// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, a warning that includes message is diagnosed. This is useful for compile-time checking
|
||||
#define ATTR_WARNING(Message) __attribute__ ((warning(Message)))
|
||||
|
||||
/**
|
||||
* \defgroup Group_VariableAttr Variable Attributes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// This attribute specifies a minimum alignment for the variable or structure field, measured in bytes
|
||||
#define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
|
||||
|
||||
/// The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute
|
||||
#define ATTR_PACKED __attribute__ ((packed))
|
||||
|
||||
#define ATTR_PREPACKED
|
||||
|
||||
#define ATTR_PACKED_STRUCT(x) x __attribute__ ((packed))
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \defgroup Group_FuncAttr Function Attributes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef ATTR_ALWAYS_INLINE
|
||||
/// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified
|
||||
#define ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
|
||||
#endif
|
||||
|
||||
/// The nonnull attribute specifies that some function parameters should be non-null pointers. f the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the -Wnonnull option is enabled, a warning is issued. All pointer arguments are marked as non-null
|
||||
#define ATTR_NON_NULL __attribute__ ((nonull))
|
||||
|
||||
/// Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pure
|
||||
#define ATTR_PURE __attribute__ ((pure))
|
||||
|
||||
/// Many functions do not examine any values except their arguments, and have no effects except the return value. Basically this is just slightly more strict class than the pure attribute below, since function is not allowed to read global memory.
|
||||
/// Note that a function that has pointer arguments and examines the data pointed to must not be declared const. Likewise, a function that calls a non-const function usually must not be const. It does not make sense for a const function to return void
|
||||
#define ATTR_CONST __attribute__ ((const))
|
||||
|
||||
/// The deprecated attribute results in a warning if the function is used anywhere in the source file. This is useful when identifying functions that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated function, to enable users to easily find further information about why the function is deprecated, or what they should do instead. Note that the warnings only occurs for uses
|
||||
#define ATTR_DEPRECATED __attribute__ ((deprecated))
|
||||
|
||||
/// Same as the deprecated attribute with optional message in the warning
|
||||
#define ATTR_DEPRECATED_MESS(mess) __attribute__ ((deprecated(mess)))
|
||||
|
||||
/// The weak attribute causes the declaration to be emitted as a weak symbol rather than a global. This is primarily useful in defining library functions that can be overridden in user code
|
||||
#define ATTR_WEAK __attribute__ ((weak))
|
||||
|
||||
/// The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified
|
||||
#define ATTR_ALIAS(func) __attribute__ ((alias(#func)))
|
||||
|
||||
/// The weakref attribute marks a declaration as a weak reference. It is equivalent with weak + alias attribute, but require function is static
|
||||
#define ATTR_WEAKREF(func) __attribute__ ((weakref(#func)))
|
||||
|
||||
/// The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug
|
||||
#define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
|
||||
|
||||
/// This attribute, attached to a function, means that code must be emitted for the function even if it appears that the function is not referenced. This is useful, for example, when the function is referenced only in inline assembly.
|
||||
#define ATTR_USED __attribute__ ((used))
|
||||
|
||||
/// This attribute, attached to a function, means that the function is meant to be possibly unused. GCC does not produce a warning for this function.
|
||||
#define ATTR_UNUSED __attribute__ ((unused))
|
||||
|
||||
#elif defined (__ICCARM__) //IAR
|
||||
#define ATTR_ALWAYS_INLINE // IAR dosn't provide such a syntax extension in function's prototypes.
|
||||
#define ATTR_CONST // IAR dosn't provide such a syntax extension in function's prototypes.
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _COMPILER_GCC_H_ */
|
||||
|
||||
/// @}
|
|
@ -0,0 +1,303 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2015 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 "nRF5xCharacteristicDescriptorDiscoverer.h"
|
||||
#include "nrf_ble_err.h"
|
||||
#include "ble/DiscoveredCharacteristicDescriptor.h"
|
||||
|
||||
nRF5xCharacteristicDescriptorDiscoverer::nRF5xCharacteristicDescriptorDiscoverer() :
|
||||
discoveryRunning() {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
nRF5xCharacteristicDescriptorDiscoverer::~nRF5xCharacteristicDescriptorDiscoverer() {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
ble_error_t nRF5xCharacteristicDescriptorDiscoverer::launch(
|
||||
const DiscoveredCharacteristic& characteristic,
|
||||
const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback,
|
||||
const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback
|
||||
) {
|
||||
Gap::Handle_t connHandle = characteristic.getConnectionHandle();
|
||||
// it is ok to deduce that the start handle for descriptors is after
|
||||
// the characteristic declaration and the characteristic value declaration
|
||||
// see BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] (3.3)
|
||||
Gap::Handle_t descriptorStartHandle = characteristic.getDeclHandle() + 2;
|
||||
Gap::Handle_t descriptorEndHandle = characteristic.getLastHandle();
|
||||
|
||||
// check if there is any descriptor to discover
|
||||
if (descriptorEndHandle < descriptorStartHandle) {
|
||||
CharacteristicDescriptorDiscovery::TerminationCallbackParams_t termParams = {
|
||||
characteristic,
|
||||
BLE_ERROR_NONE
|
||||
};
|
||||
terminationCallback.call(&termParams);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
// check if we can run this discovery
|
||||
if (isConnectionInUse(connHandle)) {
|
||||
return BLE_STACK_BUSY;
|
||||
}
|
||||
|
||||
// get a new discovery slot, if none are available, just return
|
||||
Discovery* discovery = getAvailableDiscoverySlot();
|
||||
if(discovery == NULL) {
|
||||
return BLE_STACK_BUSY;
|
||||
}
|
||||
|
||||
// try to launch the discovery
|
||||
ble_error_t err = gattc_descriptors_discover(connHandle, descriptorStartHandle, descriptorEndHandle);
|
||||
if(!err) {
|
||||
// commit the new discovery to its slot
|
||||
*discovery = Discovery(characteristic, discoveryCallback, terminationCallback);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
bool nRF5xCharacteristicDescriptorDiscoverer::isActive(const DiscoveredCharacteristic& characteristic) const {
|
||||
for(size_t i = 0; i < MAXIMUM_CONCURRENT_CONNECTIONS_COUNT; ++i) {
|
||||
if(discoveryRunning[i].getCharacteristic() == characteristic) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void nRF5xCharacteristicDescriptorDiscoverer::requestTerminate(const DiscoveredCharacteristic& characteristic) {
|
||||
Discovery* discovery = findRunningDiscovery(characteristic);
|
||||
if(discovery) {
|
||||
// call terminate anyway
|
||||
terminate(discovery, BLE_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
void nRF5xCharacteristicDescriptorDiscoverer::process(uint16_t connectionHandle, const ble_gattc_evt_desc_disc_rsp_t& descriptors) {
|
||||
Discovery* discovery = findRunningDiscovery(connectionHandle);
|
||||
// the discovery has been removed
|
||||
if(!discovery) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < descriptors.count; ++i) {
|
||||
const ble_gattc_desc_t& desc = descriptors.descs[i];
|
||||
const ble_uuid_t& uuid = desc.uuid;
|
||||
|
||||
if (uuid.type == BLE_UUID_TYPE_BLE) {
|
||||
discovery->process(
|
||||
desc.handle, UUID(uuid.uuid)
|
||||
);
|
||||
} else {
|
||||
// discover attribute infos of the descriptor
|
||||
ble_error_t err = gattc_attr_info_discover(connectionHandle, desc.handle, desc.handle);
|
||||
if (err) {
|
||||
terminate(discovery, err);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// prepare the next discovery request (if needed)
|
||||
uint16_t startHandle = descriptors.descs[descriptors.count - 1].handle + 1;
|
||||
uint16_t endHandle = discovery->getCharacteristic().getLastHandle();
|
||||
|
||||
if(startHandle > endHandle) {
|
||||
terminate(discovery, BLE_ERROR_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
ble_error_t err = gattc_descriptors_discover(connectionHandle, startHandle, endHandle);
|
||||
if(err) {
|
||||
terminate(discovery, err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void nRF5xCharacteristicDescriptorDiscoverer::processAttributeInformation(
|
||||
uint16_t connectionHandle, const ble_gattc_evt_attr_info_disc_rsp_t& infos) {
|
||||
Discovery* discovery = findRunningDiscovery(connectionHandle);
|
||||
// the discovery has been removed
|
||||
if(!discovery) {
|
||||
return;
|
||||
}
|
||||
|
||||
// for all UUIDS found, process the discovery
|
||||
for (uint16_t i = 0; i < infos.count; ++i) {
|
||||
bool use_16bits_uuids = infos.format == BLE_GATTC_ATTR_INFO_FORMAT_16BIT;
|
||||
const ble_gattc_attr_info_t& attr_info = infos.attr_info[i];
|
||||
UUID uuid = use_16bits_uuids ? UUID(attr_info.info.uuid16.uuid) : UUID(attr_info.info.uuid128.uuid128, UUID::LSB);
|
||||
discovery->process(attr_info.handle, uuid);
|
||||
}
|
||||
|
||||
// prepare the next round of descriptors discovery
|
||||
uint16_t startHandle = infos.attr_info[infos.count - 1].handle + 1;
|
||||
uint16_t endHandle = discovery->getCharacteristic().getLastHandle();
|
||||
|
||||
if(startHandle > endHandle) {
|
||||
terminate(discovery, BLE_ERROR_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
ble_error_t err = gattc_descriptors_discover(connectionHandle, startHandle, endHandle);
|
||||
if(err) {
|
||||
terminate(discovery, err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void nRF5xCharacteristicDescriptorDiscoverer::terminate(uint16_t handle, ble_error_t err) {
|
||||
Discovery* discovery = findRunningDiscovery(handle);
|
||||
// the discovery has already been terminated
|
||||
if(!discovery) {
|
||||
return;
|
||||
}
|
||||
|
||||
terminate(discovery, err);
|
||||
}
|
||||
|
||||
void nRF5xCharacteristicDescriptorDiscoverer::terminate(Discovery* discovery, ble_error_t err) {
|
||||
// temporary copy, user code can try to launch a new discovery in the onTerminate
|
||||
// callback. So, this discovery should not appear in such case.
|
||||
Discovery tmp = *discovery;
|
||||
*discovery = Discovery();
|
||||
tmp.terminate(err);
|
||||
}
|
||||
|
||||
nRF5xCharacteristicDescriptorDiscoverer::Discovery*
|
||||
nRF5xCharacteristicDescriptorDiscoverer::findRunningDiscovery(const DiscoveredCharacteristic& characteristic) {
|
||||
for(size_t i = 0; i < MAXIMUM_CONCURRENT_CONNECTIONS_COUNT; ++i) {
|
||||
if((discoveryRunning[i].getCharacteristic() == characteristic) &&
|
||||
(discoveryRunning[i].isEmpty() == false)) {
|
||||
return &discoveryRunning[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nRF5xCharacteristicDescriptorDiscoverer::Discovery*
|
||||
nRF5xCharacteristicDescriptorDiscoverer::findRunningDiscovery(uint16_t handle) {
|
||||
for(size_t i = 0; i < MAXIMUM_CONCURRENT_CONNECTIONS_COUNT; ++i) {
|
||||
if((discoveryRunning[i].getCharacteristic().getConnectionHandle() == handle) &&
|
||||
(discoveryRunning[i].isEmpty() == false)) {
|
||||
return &discoveryRunning[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nRF5xCharacteristicDescriptorDiscoverer::Discovery*
|
||||
nRF5xCharacteristicDescriptorDiscoverer::getAvailableDiscoverySlot() {
|
||||
for(size_t i = 0; i < MAXIMUM_CONCURRENT_CONNECTIONS_COUNT; ++i) {
|
||||
if(discoveryRunning[i].isEmpty()) {
|
||||
return &discoveryRunning[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool nRF5xCharacteristicDescriptorDiscoverer::isConnectionInUse(uint16_t connHandle) {
|
||||
return findRunningDiscovery(connHandle) != NULL;
|
||||
}
|
||||
|
||||
ble_error_t nRF5xCharacteristicDescriptorDiscoverer::gattc_descriptors_discover(
|
||||
uint16_t connection_handle, uint16_t start_handle, uint16_t end_handle) {
|
||||
|
||||
ble_gattc_handle_range_t discoveryRange = {
|
||||
start_handle,
|
||||
end_handle
|
||||
};
|
||||
uint32_t err = sd_ble_gattc_descriptors_discover(connection_handle, &discoveryRange);
|
||||
|
||||
switch(err) {
|
||||
case NRF_SUCCESS:
|
||||
return BLE_ERROR_NONE;
|
||||
case BLE_ERROR_INVALID_CONN_HANDLE:
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
case NRF_ERROR_INVALID_ADDR:
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
case NRF_ERROR_BUSY:
|
||||
return BLE_STACK_BUSY;
|
||||
default:
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
ble_error_t nRF5xCharacteristicDescriptorDiscoverer::gattc_attr_info_discover(
|
||||
uint16_t connection_handle, uint16_t start_handle, uint16_t end_handle) {
|
||||
ble_gattc_handle_range_t handle_range = { start_handle, end_handle };
|
||||
uint32_t err = sd_ble_gattc_attr_info_discover(connection_handle, &handle_range);
|
||||
|
||||
switch(err) {
|
||||
case NRF_SUCCESS:
|
||||
return BLE_ERROR_NONE;
|
||||
case BLE_ERROR_INVALID_CONN_HANDLE:
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
case NRF_ERROR_INVALID_ADDR:
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
case NRF_ERROR_BUSY:
|
||||
return BLE_STACK_BUSY;
|
||||
case NRF_ERROR_INVALID_STATE:
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
default:
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// implementation of nRF5xCharacteristicDescriptorDiscoverer::Discovery
|
||||
|
||||
nRF5xCharacteristicDescriptorDiscoverer::Discovery::Discovery() :
|
||||
characteristic(), onDiscovery(), onTerminate() {
|
||||
}
|
||||
|
||||
nRF5xCharacteristicDescriptorDiscoverer::Discovery::Discovery(
|
||||
const DiscoveredCharacteristic& c, const DiscoveryCallback_t& dCb, const TerminationCallback_t& tCb) :
|
||||
characteristic(c), onDiscovery(dCb), onTerminate(tCb) {
|
||||
}
|
||||
|
||||
void nRF5xCharacteristicDescriptorDiscoverer::Discovery::process(
|
||||
GattAttribute::Handle_t handle, const UUID& uuid) {
|
||||
CharacteristicDescriptorDiscovery::DiscoveryCallbackParams_t params = {
|
||||
characteristic,
|
||||
DiscoveredCharacteristicDescriptor(
|
||||
characteristic.getGattClient(),
|
||||
characteristic.getConnectionHandle(),
|
||||
handle,
|
||||
uuid
|
||||
)
|
||||
};
|
||||
onDiscovery.call(¶ms);
|
||||
}
|
||||
|
||||
void nRF5xCharacteristicDescriptorDiscoverer::Discovery::terminate(ble_error_t err) {
|
||||
CharacteristicDescriptorDiscovery::TerminationCallbackParams_t params = {
|
||||
characteristic,
|
||||
err
|
||||
};
|
||||
|
||||
onTerminate.call(¶ms);
|
||||
}
|
||||
|
||||
bool nRF5xCharacteristicDescriptorDiscoverer::Discovery::isEmpty() const {
|
||||
return *this == Discovery();
|
||||
}
|
||||
|
||||
const DiscoveredCharacteristic& nRF5xCharacteristicDescriptorDiscoverer::Discovery::getCharacteristic() const {
|
||||
return characteristic;
|
||||
}
|
|
@ -0,0 +1,227 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2015 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 __NRF_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__
|
||||
#define __NRF_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__
|
||||
|
||||
#include "ble/Gap.h"
|
||||
#include "ble/DiscoveredCharacteristic.h"
|
||||
#include "ble/CharacteristicDescriptorDiscovery.h"
|
||||
#include "ble/GattClient.h"
|
||||
#include "nrf_ble_gattc.h"
|
||||
|
||||
/**
|
||||
* @brief Manage the discovery of Characteristic descriptors
|
||||
* @details is a bridge between BLE API and Nordic stack regarding Characteristic
|
||||
* Descriptor discovery. The BLE API can launch, monitor and ask for termination
|
||||
* of a discovery. The Nordic stack will provide new descriptors and indicate when
|
||||
* the discovery is done.
|
||||
*/
|
||||
class nRF5xCharacteristicDescriptorDiscoverer
|
||||
{
|
||||
typedef CharacteristicDescriptorDiscovery::DiscoveryCallback_t DiscoveryCallback_t;
|
||||
typedef CharacteristicDescriptorDiscovery::TerminationCallback_t TerminationCallback_t;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new characteristic descriptor discoverer.
|
||||
*/
|
||||
nRF5xCharacteristicDescriptorDiscoverer();
|
||||
|
||||
/**
|
||||
* @brief Destroy a characteristic descriptor discoverer.
|
||||
*/
|
||||
~nRF5xCharacteristicDescriptorDiscoverer();
|
||||
|
||||
/**
|
||||
* Launch a new characteristic descriptor discovery for a given DiscoveredCharacteristic.
|
||||
* @param characteristic The characteristic owning the descriptors to discover.
|
||||
* @param discoveryCallback The callback called when a descriptor is discovered.
|
||||
* @param terminationCallback The callback called when the discovery process end.
|
||||
* @return BLE_ERROR_NONE if characteristic descriptor discovery is launched successfully;
|
||||
* else an appropriate error.
|
||||
* @note: this will be called by BLE API side.
|
||||
*/
|
||||
ble_error_t launch(
|
||||
const DiscoveredCharacteristic& characteristic,
|
||||
const DiscoveryCallback_t& discoveryCallback,
|
||||
const TerminationCallback_t& terminationCallback
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief indicate if a characteristic descriptor discovery is active for a
|
||||
* given DiscoveredCharacteristic.
|
||||
* @param characteristic The characteristic for whom the descriptor might be
|
||||
* currently discovered.
|
||||
* @return true if descriptors of characteristic are discovered, false otherwise.
|
||||
* @note: this will be called by BLE API side.
|
||||
*/
|
||||
bool isActive(const DiscoveredCharacteristic& characteristic) const;
|
||||
|
||||
/**
|
||||
* @brief request the termination of characteristic descriptor discovery
|
||||
* for a give DiscoveredCharacteristic
|
||||
* @param characteristic The characteristic for whom the descriptor discovery
|
||||
* should be stopped.
|
||||
* @note: this will be called by BLE API side.
|
||||
*/
|
||||
void requestTerminate(const DiscoveredCharacteristic& characteristic);
|
||||
|
||||
/**
|
||||
* @brief process descriptors discovered from the Nordic stack.
|
||||
* @param connectionHandle The connection handle upon which descriptors has been
|
||||
* discovered.
|
||||
* @param descriptors Discovered descriptors.
|
||||
* @note This will be called by the Nordic stack.
|
||||
*/
|
||||
void process(uint16_t connectionHandle, const ble_gattc_evt_desc_disc_rsp_t& descriptors);
|
||||
|
||||
/**
|
||||
* @brief Called by the Nordic stack when the discovery is over.
|
||||
* @param The connection handle upon which the discovery process is done.
|
||||
* @param err An error if the termination is due to an error.
|
||||
*/
|
||||
void terminate(uint16_t connectionHandle, ble_error_t err);
|
||||
|
||||
/**
|
||||
* @brief process attribute informations from the Nordic stack.
|
||||
* @param connectionHandle The connection handle upon which
|
||||
* attribute informations has been fetch.
|
||||
* @param infos Informations around attribute, in that case the
|
||||
* 128bit UUID of a descriptor.
|
||||
* @note This will be called by the Nordic stack.
|
||||
*/
|
||||
void processAttributeInformation(uint16_t handle, const ble_gattc_evt_attr_info_disc_rsp_t& infos);
|
||||
|
||||
private:
|
||||
// protection against copy construction and assignment
|
||||
nRF5xCharacteristicDescriptorDiscoverer(const nRF5xCharacteristicDescriptorDiscoverer&);
|
||||
nRF5xCharacteristicDescriptorDiscoverer& operator=(const nRF5xCharacteristicDescriptorDiscoverer&);
|
||||
|
||||
/**
|
||||
* @brief Discovery process, it store the DiscoveredCharacteristic, the
|
||||
* discovery callback and the termination callback.
|
||||
*/
|
||||
class Discovery {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct an empty discovery, such can be considerate as a not running discovery.
|
||||
* @note #isEmpty function will return true
|
||||
*/
|
||||
Discovery();
|
||||
|
||||
/**
|
||||
* @brief Construct a valid discovery process.
|
||||
*
|
||||
* @param c the characteristic from whom descriptors will be discovered.
|
||||
* @param dCb The discovery callback called each time a descriptor is discovered.
|
||||
* @param tCb The termination callback called when the discovery terminate.
|
||||
*
|
||||
* @note #isEmpty function will return false
|
||||
*/
|
||||
Discovery(const DiscoveredCharacteristic& c, const DiscoveryCallback_t& dCb, const TerminationCallback_t& tCb);
|
||||
|
||||
/**
|
||||
* @brief Process the discovery of a descriptor.
|
||||
*
|
||||
* @param handle The attribute handle of the descriptor found
|
||||
* @param uuid The UUID of the descriptor found.
|
||||
*/
|
||||
void process(GattAttribute::Handle_t handle, const UUID& uuid);
|
||||
|
||||
/**
|
||||
* @brief Terminate the discovery process.
|
||||
*
|
||||
* @param err Error associate with the termination
|
||||
* @note after this call #isEmpty function will return true.
|
||||
*/
|
||||
void terminate(ble_error_t err);
|
||||
|
||||
/**
|
||||
* @brief check if the discovery process is empty or not. Empty discovery are
|
||||
* not running.
|
||||
*
|
||||
* @detail Discovery are empty after:
|
||||
* - a default construction
|
||||
* - a copy construction form a default constructed
|
||||
* - an assignment from a default constructed Discovery
|
||||
* @return true if the Discovery is empty and false otherwise.
|
||||
*/
|
||||
bool isEmpty() const;
|
||||
|
||||
/**
|
||||
* @brief return the characteristic from whom descriptors are discovered.
|
||||
* @return the characteristic from whom descriptors are discovered.
|
||||
*/
|
||||
const DiscoveredCharacteristic& getCharacteristic() const;
|
||||
|
||||
/**
|
||||
* @brief equal to operator, test if two discovery process are equal
|
||||
*
|
||||
* @param lhs left hand side of the expression
|
||||
* @param rhs right hand side of the expression
|
||||
* @return true if lhs == rhs
|
||||
*/
|
||||
friend bool operator==(const Discovery& lhs, const Discovery& rhs) {
|
||||
return lhs.characteristic == rhs.characteristic &&
|
||||
lhs.onDiscovery == rhs.onDiscovery &&
|
||||
lhs.onTerminate == rhs.onTerminate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief not equal to operator, test if two discovery process are not equal
|
||||
*
|
||||
* @param lhs left hand side of the expression
|
||||
* @param rhs right hand side of the expression
|
||||
* @return true if lhs != rhs
|
||||
*/
|
||||
friend bool operator!=(const Discovery& lhs, const Discovery& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
DiscoveredCharacteristic characteristic;
|
||||
DiscoveryCallback_t onDiscovery;
|
||||
TerminationCallback_t onTerminate;
|
||||
};
|
||||
|
||||
// find a running discovery process
|
||||
Discovery* findRunningDiscovery(const DiscoveredCharacteristic& characteristic);
|
||||
Discovery* findRunningDiscovery(uint16_t handle);
|
||||
|
||||
// Called to terminate a discovery is over.
|
||||
void terminate(Discovery* discovery, ble_error_t err);
|
||||
|
||||
// get one slot for a discovery process
|
||||
Discovery* getAvailableDiscoverySlot();
|
||||
|
||||
// indicate if a connection is already running a discovery
|
||||
bool isConnectionInUse(uint16_t connHandle);
|
||||
|
||||
// low level start of a discovery
|
||||
static ble_error_t gattc_descriptors_discover(uint16_t connection_handle, uint16_t start_handle, uint16_t end_handle);
|
||||
|
||||
// discovery of 128bits UUIDS
|
||||
static ble_error_t gattc_attr_info_discover(uint16_t connection_handle, uint16_t start_handle, uint16_t end_handle);
|
||||
|
||||
// count of concurrent connections which can run a descriptor discovery process
|
||||
static const size_t MAXIMUM_CONCURRENT_CONNECTIONS_COUNT = 3;
|
||||
|
||||
// array of running discoveries
|
||||
Discovery discoveryRunning[MAXIMUM_CONCURRENT_CONNECTIONS_COUNT];
|
||||
};
|
||||
|
||||
#endif /*__NRF_CHARACTERISTIC_DESCRIPTOR_DISCOVERY_H__*/
|
|
@ -0,0 +1,63 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "nRF5xDiscoveredCharacteristic.h"
|
||||
#include "nRF5xGattClient.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
|
||||
void
|
||||
nRF5xDiscoveredCharacteristic::setup(nRF5xGattClient *gattcIn,
|
||||
Gap::Handle_t connectionHandleIn,
|
||||
ble_gatt_char_props_t propsIn,
|
||||
GattAttribute::Handle_t declHandleIn,
|
||||
GattAttribute::Handle_t valueHandleIn)
|
||||
{
|
||||
gattc = gattcIn;
|
||||
connHandle = connectionHandleIn;
|
||||
declHandle = declHandleIn;
|
||||
valueHandle = valueHandleIn;
|
||||
|
||||
props._broadcast = propsIn.broadcast;
|
||||
props._read = propsIn.read;
|
||||
props._writeWoResp = propsIn.write_wo_resp;
|
||||
props._write = propsIn.write;
|
||||
props._notify = propsIn.notify;
|
||||
props._indicate = propsIn.indicate;
|
||||
props._authSignedWrite = propsIn.auth_signed_wr;
|
||||
}
|
||||
|
||||
void
|
||||
nRF5xDiscoveredCharacteristic::setup(nRF5xGattClient *gattcIn,
|
||||
Gap::Handle_t connectionHandleIn,
|
||||
UUID::ShortUUIDBytes_t uuidIn,
|
||||
ble_gatt_char_props_t propsIn,
|
||||
GattAttribute::Handle_t declHandleIn,
|
||||
GattAttribute::Handle_t valueHandleIn)
|
||||
{
|
||||
gattc = gattcIn;
|
||||
connHandle = connectionHandleIn;
|
||||
uuid = uuidIn;
|
||||
declHandle = declHandleIn;
|
||||
valueHandle = valueHandleIn;
|
||||
|
||||
props._broadcast = propsIn.broadcast;
|
||||
props._read = propsIn.read;
|
||||
props._writeWoResp = propsIn.write_wo_resp;
|
||||
props._write = propsIn.write;
|
||||
props._notify = propsIn.notify;
|
||||
props._indicate = propsIn.indicate;
|
||||
props._authSignedWrite = propsIn.auth_signed_wr;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 __NRF_DISCOVERED_CHARACTERISTIC_H__
|
||||
#define __NRF_DISCOVERED_CHARACTERISTIC_H__
|
||||
|
||||
#include "ble/DiscoveredCharacteristic.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
|
||||
class nRF5xGattClient; /* forward declaration */
|
||||
|
||||
class nRF5xDiscoveredCharacteristic : public DiscoveredCharacteristic {
|
||||
public:
|
||||
void setup(nRF5xGattClient *gattcIn,
|
||||
Gap::Handle_t connectionHandleIn,
|
||||
ble_gatt_char_props_t propsIn,
|
||||
GattAttribute::Handle_t declHandleIn,
|
||||
GattAttribute::Handle_t valueHandleIn);
|
||||
|
||||
void setup(nRF5xGattClient *gattcIn,
|
||||
Gap::Handle_t connectionHandleIn,
|
||||
UUID::ShortUUIDBytes_t uuidIn,
|
||||
ble_gatt_char_props_t propsIn,
|
||||
GattAttribute::Handle_t declHandleIn,
|
||||
GattAttribute::Handle_t valueHandleIn);
|
||||
|
||||
void setLastHandle(GattAttribute::Handle_t last) {
|
||||
lastHandle = last;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* __NRF_DISCOVERED_CHARACTERISTIC_H__ */
|
|
@ -0,0 +1,947 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "nRF5xn.h"
|
||||
#ifdef YOTTA_CFG_MBED_OS
|
||||
#include "mbed-drivers/mbed.h"
|
||||
#else
|
||||
#include "mbed.h"
|
||||
#endif
|
||||
#include "ble/BLE.h"
|
||||
|
||||
#include "common/common.h"
|
||||
#include "ble_advdata.h"
|
||||
#include "nrf_ble_hci.h"
|
||||
|
||||
void radioNotificationStaticCallback(bool param) {
|
||||
nRF5xGap &gap = (nRF5xGap &) nRF5xn::Instance(BLE::DEFAULT_INSTANCE).getGap();
|
||||
gap.processRadioNotificationEvent(param);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Sets the advertising parameters and payload for the device
|
||||
|
||||
@param[in] params
|
||||
Basic advertising details, including the advertising
|
||||
delay, timeout and how the device should be advertised
|
||||
@params[in] advData
|
||||
The primary advertising data payload
|
||||
@params[in] scanResponse
|
||||
The optional Scan Response payload if the advertising
|
||||
type is set to \ref GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED
|
||||
in \ref GapAdveritinngParams
|
||||
|
||||
@returns \ref ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
|
||||
@retval BLE_ERROR_BUFFER_OVERFLOW
|
||||
The proposed action would cause a buffer overflow. All
|
||||
advertising payloads must be <= 31 bytes, for example.
|
||||
|
||||
@retval BLE_ERROR_NOT_IMPLEMENTED
|
||||
A feature was requested that is not yet supported in the
|
||||
nRF51 firmware or hardware.
|
||||
|
||||
@retval BLE_ERROR_PARAM_OUT_OF_RANGE
|
||||
One of the proposed values is outside the valid range.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, const GapAdvertisingData &scanResponse)
|
||||
{
|
||||
/* Make sure we don't exceed the advertising payload length */
|
||||
if (advData.getPayloadLen() > GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
|
||||
return BLE_ERROR_BUFFER_OVERFLOW;
|
||||
}
|
||||
|
||||
/* Make sure we have a payload! */
|
||||
if (advData.getPayloadLen() == 0) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
/* Check the scan response payload limits */
|
||||
//if ((params.getAdvertisingType() == GapAdvertisingParams::ADV_SCANNABLE_UNDIRECTED))
|
||||
//{
|
||||
// /* Check if we're within the upper limit */
|
||||
// if (advData.getPayloadLen() > GAP_ADVERTISING_DATA_MAX_PAYLOAD)
|
||||
// {
|
||||
// return BLE_ERROR_BUFFER_OVERFLOW;
|
||||
// }
|
||||
// /* Make sure we have a payload! */
|
||||
// if (advData.getPayloadLen() == 0)
|
||||
// {
|
||||
// return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
// }
|
||||
//}
|
||||
|
||||
/* Send advertising data! */
|
||||
ASSERT(ERROR_NONE ==
|
||||
sd_ble_gap_adv_data_set(advData.getPayload(),
|
||||
advData.getPayloadLen(),
|
||||
scanResponse.getPayload(),
|
||||
scanResponse.getPayloadLen()),
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
|
||||
/* Make sure the GAP Service appearance value is aligned with the
|
||||
*appearance from GapAdvertisingData */
|
||||
ASSERT(ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()),
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
|
||||
/* ToDo: Perform some checks on the payload, for example the Scan Response can't */
|
||||
/* contains a flags AD type, etc. */
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Starts the BLE HW, initialising any services that were
|
||||
added before this function was called.
|
||||
|
||||
@note All services must be added before calling this function!
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams ¶ms)
|
||||
{
|
||||
/* Make sure we support the advertising type */
|
||||
if (params.getAdvertisingType() == GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) {
|
||||
/* ToDo: This requires a propery security implementation, etc. */
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* Check interval range */
|
||||
if (params.getAdvertisingType() == GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED) {
|
||||
/* Min delay is slightly longer for unconnectable devices */
|
||||
if ((params.getIntervalInADVUnits() < GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN_NONCON) ||
|
||||
(params.getIntervalInADVUnits() > GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MAX)) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
if ((params.getIntervalInADVUnits() < GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN) ||
|
||||
(params.getIntervalInADVUnits() > GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MAX)) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check timeout is zero for Connectable Directed */
|
||||
if ((params.getAdvertisingType() == GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) && (params.getTimeout() != 0)) {
|
||||
/* Timeout must be 0 with this type, although we'll never get here */
|
||||
/* since this isn't implemented yet anyway */
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
/* Check timeout for other advertising types */
|
||||
if ((params.getAdvertisingType() != GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) &&
|
||||
(params.getTimeout() > GapAdvertisingParams::GAP_ADV_PARAMS_TIMEOUT_MAX)) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
/* Allocate the stack's whitelist statically */
|
||||
ble_gap_whitelist_t whitelist;
|
||||
ble_gap_addr_t *whitelistAddressPtrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
ble_gap_irk_t *whitelistIrkPtrs[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
|
||||
/* Initialize the whitelist */
|
||||
whitelist.pp_addrs = whitelistAddressPtrs;
|
||||
whitelist.pp_irks = whitelistIrkPtrs;
|
||||
whitelist.addr_count = 0;
|
||||
whitelist.irk_count = 0;
|
||||
|
||||
/* Add missing IRKs to whitelist from the bond table held by the SoftDevice */
|
||||
if (advertisingPolicyMode != Gap::ADV_POLICY_IGNORE_WHITELIST) {
|
||||
ble_error_t error = generateStackWhitelist(whitelist);
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/* Start Advertising */
|
||||
ble_gap_adv_params_t adv_para = {0};
|
||||
|
||||
adv_para.type = params.getAdvertisingType();
|
||||
adv_para.p_peer_addr = NULL; // Undirected advertisement
|
||||
adv_para.fp = advertisingPolicyMode;
|
||||
adv_para.p_whitelist = &whitelist;
|
||||
adv_para.interval = params.getIntervalInADVUnits(); // advertising interval (in units of 0.625 ms)
|
||||
adv_para.timeout = params.getTimeout();
|
||||
|
||||
uint32_t err = sd_ble_gap_adv_start(&adv_para);
|
||||
switch(err) {
|
||||
case ERROR_NONE:
|
||||
return BLE_ERROR_NONE;
|
||||
case NRF_ERROR_NO_MEM:
|
||||
return BLE_ERROR_NO_MEM;
|
||||
default:
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Observer role is not supported by S110, return BLE_ERROR_NOT_IMPLEMENTED */
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
ble_error_t nRF5xGap::startRadioScan(const GapScanningParams &scanningParams)
|
||||
{
|
||||
/* Allocate the stack's whitelist statically */
|
||||
ble_gap_whitelist_t whitelist;
|
||||
ble_gap_addr_t *whitelistAddressPtrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
ble_gap_irk_t *whitelistIrkPtrs[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
|
||||
/* Initialize the whitelist */
|
||||
whitelist.pp_addrs = whitelistAddressPtrs;
|
||||
whitelist.pp_irks = whitelistIrkPtrs;
|
||||
whitelist.addr_count = 0;
|
||||
whitelist.irk_count = 0;
|
||||
|
||||
/* Add missing IRKs to whitelist from the bond table held by the SoftDevice */
|
||||
if (scanningPolicyMode != Gap::SCAN_POLICY_IGNORE_WHITELIST) {
|
||||
ble_error_t error = generateStackWhitelist(whitelist);
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
ble_gap_scan_params_t scanParams;
|
||||
|
||||
scanParams.active = scanningParams.getActiveScanning(); /**< If 1, perform active scanning (scan requests). */
|
||||
scanParams.selective = scanningPolicyMode; /**< If 1, ignore unknown devices (non whitelisted). */
|
||||
scanParams.p_whitelist = &whitelist; /**< Pointer to whitelist, NULL if none is given. */
|
||||
scanParams.interval = scanningParams.getInterval(); /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
||||
scanParams.window = scanningParams.getWindow(); /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
||||
scanParams.timeout = scanningParams.getTimeout(); /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
|
||||
|
||||
if (sd_ble_gap_scan_start(&scanParams) != NRF_SUCCESS) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::stopScan(void) {
|
||||
if (sd_ble_gap_scan_stop() == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
return BLE_STACK_BUSY;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Stops the BLE HW and disconnects from any devices
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::stopAdvertising(void)
|
||||
{
|
||||
/* Stop Advertising */
|
||||
ASSERT(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
|
||||
state.advertising = 0;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::connect(const Address_t peerAddr,
|
||||
BLEProtocol::AddressType_t peerAddrType,
|
||||
const ConnectionParams_t *connectionParams,
|
||||
const GapScanningParams *scanParamsIn)
|
||||
{
|
||||
ble_gap_addr_t addr;
|
||||
addr.addr_type = peerAddrType;
|
||||
memcpy(addr.addr, peerAddr, Gap::ADDR_LEN);
|
||||
|
||||
ble_gap_conn_params_t connParams;
|
||||
if (connectionParams != NULL) {
|
||||
connParams.min_conn_interval = connectionParams->minConnectionInterval;
|
||||
connParams.max_conn_interval = connectionParams->maxConnectionInterval;
|
||||
connParams.slave_latency = connectionParams->slaveLatency;
|
||||
connParams.conn_sup_timeout = connectionParams->connectionSupervisionTimeout;
|
||||
} else {
|
||||
connParams.min_conn_interval = 50;
|
||||
connParams.max_conn_interval = 100;
|
||||
connParams.slave_latency = 0;
|
||||
connParams.conn_sup_timeout = 600;
|
||||
}
|
||||
|
||||
/* Allocate the stack's whitelist statically */
|
||||
ble_gap_whitelist_t whitelist;
|
||||
ble_gap_addr_t *whitelistAddressPtrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
ble_gap_irk_t *whitelistIrkPtrs[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
|
||||
/* Initialize the whitelist */
|
||||
whitelist.pp_addrs = whitelistAddressPtrs;
|
||||
whitelist.pp_irks = whitelistIrkPtrs;
|
||||
whitelist.addr_count = 0;
|
||||
whitelist.irk_count = 0;
|
||||
|
||||
/* Add missing IRKs to whitelist from the bond table held by the SoftDevice */
|
||||
if (scanningPolicyMode != Gap::SCAN_POLICY_IGNORE_WHITELIST) {
|
||||
ble_error_t error = generateStackWhitelist(whitelist);
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
ble_gap_scan_params_t scanParams;
|
||||
scanParams.selective = scanningPolicyMode; /**< If 1, ignore unknown devices (non whitelisted). */
|
||||
scanParams.p_whitelist = &whitelist; /**< Pointer to whitelist, NULL if none is given. */
|
||||
if (scanParamsIn != NULL) {
|
||||
scanParams.active = scanParamsIn->getActiveScanning(); /**< If 1, perform active scanning (scan requests). */
|
||||
scanParams.interval = scanParamsIn->getInterval(); /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
||||
scanParams.window = scanParamsIn->getWindow(); /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
||||
scanParams.timeout = scanParamsIn->getTimeout(); /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
|
||||
} else {
|
||||
scanParams.active = _scanningParams.getActiveScanning(); /**< If 1, perform active scanning (scan requests). */
|
||||
scanParams.interval = _scanningParams.getInterval(); /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
||||
scanParams.window = _scanningParams.getWindow(); /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
||||
scanParams.timeout = _scanningParams.getTimeout(); /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
|
||||
}
|
||||
|
||||
uint32_t rc = sd_ble_gap_connect(&addr, &scanParams, &connParams);
|
||||
if (rc == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
switch (rc) {
|
||||
case NRF_ERROR_INVALID_ADDR:
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
case NRF_ERROR_INVALID_PARAM:
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
case NRF_ERROR_INVALID_STATE:
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
case BLE_ERROR_GAP_INVALID_BLE_ADDR:
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
case NRF_ERROR_NO_MEM:
|
||||
return BLE_ERROR_NO_MEM;
|
||||
case NRF_ERROR_BUSY:
|
||||
return BLE_STACK_BUSY;
|
||||
default:
|
||||
case BLE_ERROR_GAP_WHITELIST_IN_USE:
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::disconnect(Handle_t connectionHandle, DisconnectionReason_t reason)
|
||||
{
|
||||
uint8_t code = BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION;
|
||||
switch (reason) {
|
||||
case REMOTE_USER_TERMINATED_CONNECTION:
|
||||
code = BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION;
|
||||
break;
|
||||
case CONN_INTERVAL_UNACCEPTABLE:
|
||||
code = BLE_HCI_CONN_INTERVAL_UNACCEPTABLE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Disconnect if we are connected to a central device */
|
||||
ASSERT_INT(ERROR_NONE, sd_ble_gap_disconnect(connectionHandle, code), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Disconnects if we are connected to a central device
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
*/
|
||||
ble_error_t nRF5xGap::disconnect(DisconnectionReason_t reason)
|
||||
{
|
||||
return disconnect(m_connectionHandle, reason);
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::getPreferredConnectionParams(ConnectionParams_t *params)
|
||||
{
|
||||
ASSERT_INT(NRF_SUCCESS,
|
||||
sd_ble_gap_ppcp_get(reinterpret_cast<ble_gap_conn_params_t *>(params)),
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::setPreferredConnectionParams(const ConnectionParams_t *params)
|
||||
{
|
||||
ASSERT_INT(NRF_SUCCESS,
|
||||
sd_ble_gap_ppcp_set(reinterpret_cast<const ble_gap_conn_params_t *>(params)),
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::updateConnectionParams(Handle_t handle, const ConnectionParams_t *newParams)
|
||||
{
|
||||
uint32_t rc;
|
||||
|
||||
rc = sd_ble_gap_conn_param_update(handle, reinterpret_cast<ble_gap_conn_params_t *>(const_cast<ConnectionParams_t*>(newParams)));
|
||||
if (rc == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
} else {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Clear nRF5xGap's state.
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::reset(void)
|
||||
{
|
||||
/* Clear all state that is from the parent, including private members */
|
||||
if (Gap::reset() != BLE_ERROR_NONE) {
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
/* Clear derived class members */
|
||||
m_connectionHandle = BLE_CONN_HANDLE_INVALID;
|
||||
|
||||
/* Set the whitelist policy filter modes to IGNORE_WHITELIST */
|
||||
advertisingPolicyMode = Gap::ADV_POLICY_IGNORE_WHITELIST;
|
||||
scanningPolicyMode = Gap::SCAN_POLICY_IGNORE_WHITELIST;
|
||||
|
||||
/* Clear the internal whitelist */
|
||||
whitelistAddressesSize = 0;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Sets the 16-bit connection handle
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void nRF5xGap::setConnectionHandle(uint16_t con_handle)
|
||||
{
|
||||
m_connectionHandle = con_handle;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Gets the 16-bit connection handle
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint16_t nRF5xGap::getConnectionHandle(void)
|
||||
{
|
||||
return m_connectionHandle;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Sets the BLE device address
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
uint8_t device_address[6] = { 0xca, 0xfe, 0xf0, 0xf0, 0xf0, 0xf0 };
|
||||
nrf.getGap().setAddress(Gap::BLEProtocol::AddressType::RANDOM_STATIC, device_address);
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
|
||||
{
|
||||
uint8_t cycle_mode;
|
||||
ble_gap_addr_t dev_addr;
|
||||
|
||||
/* When using Public or Static addresses, the cycle mode must be None.
|
||||
When using Random Private addresses, the cycle mode must be Auto.
|
||||
In auto mode, the given address is ignored.
|
||||
*/
|
||||
if ((type == BLEProtocol::AddressType::PUBLIC) || (type == BLEProtocol::AddressType::RANDOM_STATIC))
|
||||
{
|
||||
cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_NONE;
|
||||
memcpy(dev_addr.addr, address, ADDR_LEN);
|
||||
}
|
||||
else if ((type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE) || (type == BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE))
|
||||
{
|
||||
cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_AUTO;
|
||||
// address is ignored when in auto mode
|
||||
}
|
||||
else
|
||||
{
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
dev_addr.addr_type = type;
|
||||
ASSERT_INT(ERROR_NONE, sd_ble_gap_address_set(cycle_mode, &dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::getAddress(AddressType_t *typeP, Address_t address)
|
||||
{
|
||||
ble_gap_addr_t dev_addr;
|
||||
if (sd_ble_gap_address_get(&dev_addr) != NRF_SUCCESS) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
if (typeP != NULL) {
|
||||
*typeP = static_cast<AddressType_t>(dev_addr.addr_type);
|
||||
}
|
||||
if (address != NULL) {
|
||||
memcpy(address, dev_addr.addr, ADDR_LEN);
|
||||
}
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::setDeviceName(const uint8_t *deviceName)
|
||||
{
|
||||
ble_gap_conn_sec_mode_t sec_mode;
|
||||
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed
|
||||
|
||||
if (sd_ble_gap_device_name_set(&sec_mode, deviceName, strlen((const char *)deviceName)) == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
} else {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::getDeviceName(uint8_t *deviceName, unsigned *lengthP)
|
||||
{
|
||||
if (sd_ble_gap_device_name_get(deviceName, (uint16_t *)lengthP) == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
} else {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::setAppearance(GapAdvertisingData::Appearance appearance)
|
||||
{
|
||||
if (sd_ble_gap_appearance_set(appearance) == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
} else {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGap::getAppearance(GapAdvertisingData::Appearance *appearanceP)
|
||||
{
|
||||
if ((sd_ble_gap_appearance_get(reinterpret_cast<uint16_t *>(appearanceP)) == NRF_SUCCESS)) {
|
||||
return BLE_ERROR_NONE;
|
||||
} else {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
|
||||
/* (Valid values are -40, -20, -16, -12, -8, -4, 0, 4) */
|
||||
ble_error_t nRF5xGap::setTxPower(int8_t txPower)
|
||||
{
|
||||
unsigned rc;
|
||||
if ((rc = sd_ble_gap_tx_power_set(txPower)) != NRF_SUCCESS) {
|
||||
switch (rc) {
|
||||
case NRF_ERROR_BUSY:
|
||||
return BLE_STACK_BUSY;
|
||||
case NRF_ERROR_INVALID_PARAM:
|
||||
default:
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
}
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
void nRF5xGap::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP)
|
||||
{
|
||||
#if defined(NRF51)
|
||||
static const int8_t permittedTxValues[] = {
|
||||
-30, -20, -16, -12, -8, -4, 0, 4
|
||||
};
|
||||
#elif defined(NRF52)
|
||||
static const int8_t permittedTxValues[] = {
|
||||
-40, -20, -16, -12, -8, -4, 0, 4
|
||||
};
|
||||
#else
|
||||
#error permitted TX power values unknown for this SOC
|
||||
#endif
|
||||
|
||||
*valueArrayPP = permittedTxValues;
|
||||
*countP = sizeof(permittedTxValues) / sizeof(int8_t);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get the capacity of the internal whitelist maintained by this
|
||||
implementation.
|
||||
|
||||
@returns The capacity of the internal whitelist.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t nRF5xGap::getMaxWhitelistSize(void) const
|
||||
{
|
||||
return YOTTA_CFG_WHITELIST_MAX_SIZE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get a copy of the implementation's internal whitelist.
|
||||
|
||||
@param[out] whitelistOut
|
||||
A \ref Gap::Whitelist_t structure containing a copy of the
|
||||
addresses in the implemenetation's internal whitelist.
|
||||
|
||||
@returns \ref ble_errror_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::getWhitelist(Gap::Whitelist_t &whitelistOut) const
|
||||
{
|
||||
uint8_t i;
|
||||
for (i = 0; i < whitelistAddressesSize && i < whitelistOut.capacity; ++i) {
|
||||
memcpy(&whitelistOut.addresses[i], &whitelistAddresses[i], sizeof(BLEProtocol::Address_t));
|
||||
}
|
||||
whitelistOut.size = i;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set the whitelist that will be used in the next call to
|
||||
startAdvertising().
|
||||
|
||||
@param[in] whitelistIn
|
||||
A reference to a \ref Gap::Whitelist_t structure
|
||||
representing a whitelist containing all the white listed
|
||||
BLE addresses.
|
||||
|
||||
@returns \ref ble_errror_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly.
|
||||
|
||||
BLE_ERROR_INVALID_PARAM
|
||||
The supplied whitelist contains a private non-resolvable
|
||||
address
|
||||
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE
|
||||
The size of the supplied whitelist exceeds the maximum
|
||||
capacity of the implementation's internal whitelist.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::setWhitelist(const Gap::Whitelist_t &whitelistIn)
|
||||
{
|
||||
if (whitelistIn.size > getMaxWhitelistSize()) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
/* Test for invalid parameters before we change the internal state */
|
||||
for (uint8_t i = 0; i < whitelistIn.size; ++i) {
|
||||
if (whitelistIn.addresses[i].type == BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE) {
|
||||
/* This is not allowed because it is completely meaningless */
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
}
|
||||
|
||||
whitelistAddressesSize = 0;
|
||||
for (uint8_t i = 0; i < whitelistIn.size; ++i) {
|
||||
memcpy(&whitelistAddresses[whitelistAddressesSize], &whitelistIn.addresses[i], sizeof(BLEProtocol::Address_t));
|
||||
whitelistAddressesSize++;
|
||||
}
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set the advertising policy filter mode that will be used in
|
||||
the next call to startAdvertising().
|
||||
|
||||
@returns \ref ble_errror_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly.
|
||||
|
||||
BLE_ERROR_NOT_IMPLEMENTED
|
||||
This feature is currently note implemented.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::setAdvertisingPolicyMode(Gap::AdvertisingPolicyMode_t mode)
|
||||
{
|
||||
advertisingPolicyMode = mode;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set the scanning policy filter mode that will be used in
|
||||
the next call to startAdvertising().
|
||||
|
||||
@returns \ref ble_errror_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly.
|
||||
|
||||
BLE_ERROR_NOT_IMPLEMENTED
|
||||
This feature is currently note implemented.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::setScanningPolicyMode(Gap::ScanningPolicyMode_t mode)
|
||||
{
|
||||
scanningPolicyMode = mode;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Set the initiator policy filter mode that will be used in
|
||||
the next call to startAdvertising()
|
||||
|
||||
@returns \ref ble_errror_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly.
|
||||
|
||||
BLE_ERROR_NOT_IMPLEMENTED
|
||||
This feature is currently note implemented.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::setInitiatorPolicyMode(Gap::InitiatorPolicyMode_t mode)
|
||||
{
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get the current advertising policy filter mode.
|
||||
|
||||
@returns The advertising policy filter mode.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Gap::AdvertisingPolicyMode_t nRF5xGap::getAdvertisingPolicyMode(void) const
|
||||
{
|
||||
return advertisingPolicyMode;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get the current scanning policy filter mode.
|
||||
|
||||
@returns The scanning policy filter mode.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Gap::ScanningPolicyMode_t nRF5xGap::getScanningPolicyMode(void) const
|
||||
{
|
||||
return scanningPolicyMode;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Get the current initiator policy filter mode.
|
||||
|
||||
@returns The initiator policy filter mode.
|
||||
|
||||
@note Currently initiator filtering using the whitelist is not
|
||||
implemented in this module.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Gap::InitiatorPolicyMode_t nRF5xGap::getInitiatorPolicyMode(void) const
|
||||
{
|
||||
return Gap::INIT_POLICY_IGNORE_WHITELIST;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Helper function used to populate the ble_gap_whitelist_t that
|
||||
will be used by the SoftDevice for filtering requests.
|
||||
|
||||
@returns \ref ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
|
||||
@retval BLE_ERROR_INVALID_STATE
|
||||
The internal stack was not initialized correctly.
|
||||
|
||||
@note Both the SecurityManager and Gap must initialize correctly for
|
||||
this function to succeed.
|
||||
|
||||
@note This function is needed because for the BLE API the whitelist
|
||||
is just a collection of keys, but for the stack it also includes
|
||||
the IRK table.
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGap::generateStackWhitelist(ble_gap_whitelist_t &whitelist)
|
||||
{
|
||||
ble_gap_whitelist_t whitelistFromBondTable;
|
||||
ble_gap_addr_t *addressPtr[1];
|
||||
ble_gap_irk_t *irkPtr[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
|
||||
|
||||
nRF5xSecurityManager& securityManager = (nRF5xSecurityManager&) nRF5xn::Instance(0).getSecurityManager();
|
||||
|
||||
if (securityManager.hasInitialized()) {
|
||||
/* We do not care about the addresses, set the count to 0 */
|
||||
whitelistFromBondTable.addr_count = 0;
|
||||
/* The Nordic SDK will return a failure if we set pp_addr to NULL */
|
||||
whitelistFromBondTable.pp_addrs = addressPtr;
|
||||
/* We want all the IRKs we can get because we do not know which ones match the addresses */
|
||||
whitelistFromBondTable.irk_count = YOTTA_CFG_IRK_TABLE_MAX_SIZE;
|
||||
whitelistFromBondTable.pp_irks = irkPtr;
|
||||
|
||||
/* Use the security manager to get the IRKs from the bond table */
|
||||
ble_error_t error = securityManager.createWhitelistFromBondTable(whitelistFromBondTable);
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* If there is no security manager then we cannot access the bond table,
|
||||
* so disable IRK matching
|
||||
*/
|
||||
whitelistFromBondTable.addr_count = 0;
|
||||
whitelistFromBondTable.irk_count = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* For every private resolvable address in the local whitelist check if
|
||||
* there is an IRK for said address in the bond table and add it to the
|
||||
* local IRK list.
|
||||
*/
|
||||
whitelist.irk_count = 0;
|
||||
whitelist.addr_count = 0;
|
||||
for (uint8_t i = 0; i < whitelistAddressesSize; ++i) {
|
||||
if (whitelistAddresses[i].addr_type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE) {
|
||||
/* Test if there is a matching IRK for this private resolvable address */
|
||||
for (uint8_t j = 0; j < whitelistFromBondTable.irk_count; ++j) {
|
||||
if (securityManager.matchAddressAndIrk(&whitelistAddresses[i], whitelistFromBondTable.pp_irks[j])) {
|
||||
/* Found the corresponding IRK, add it to our local whitelist */
|
||||
whitelist.pp_irks[whitelist.irk_count] = whitelistFromBondTable.pp_irks[j];
|
||||
whitelist.irk_count++;
|
||||
/* Make sure we do not look at this IRK again */
|
||||
if (j != whitelistFromBondTable.irk_count - 1) {
|
||||
/**
|
||||
* This is not the last IRK, so replace the pointer
|
||||
* with the last pointer in the array
|
||||
*/
|
||||
whitelistFromBondTable.pp_irks[j] =
|
||||
whitelistFromBondTable.pp_irks[whitelistFromBondTable.irk_count - 1];
|
||||
}
|
||||
/**
|
||||
* If the IRK is the last pointer in the array simply
|
||||
* decrement the total IRK count
|
||||
*/
|
||||
whitelistFromBondTable.irk_count--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Include the address into the whitelist */
|
||||
whitelist.pp_addrs[whitelist.addr_count] = &whitelistAddresses[i];
|
||||
whitelist.addr_count++;
|
||||
}
|
||||
}
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
|
@ -0,0 +1,247 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 __NRF5x_GAP_H__
|
||||
#define __NRF5x_GAP_H__
|
||||
|
||||
#ifdef YOTTA_CFG_MBED_OS
|
||||
#include "mbed-drivers/mbed.h"
|
||||
#else
|
||||
#include "mbed.h"
|
||||
#endif
|
||||
#ifndef YOTTA_CFG_WHITELIST_MAX_SIZE
|
||||
#define YOTTA_CFG_WHITELIST_MAX_SIZE BLE_GAP_WHITELIST_ADDR_MAX_COUNT
|
||||
#elif YOTTA_CFG_WHITELIST_MAX_SIZE > BLE_GAP_WHITELIST_ADDR_MAX_COUNT
|
||||
#undef YOTTA_CFG_WHITELIST_MAX_SIZE
|
||||
#define YOTTA_CFG_WHITELIST_MAX_SIZE BLE_GAP_WHITELIST_ADDR_MAX_COUNT
|
||||
#endif
|
||||
#ifndef YOTTA_CFG_IRK_TABLE_MAX_SIZE
|
||||
#define YOTTA_CFG_IRK_TABLE_MAX_SIZE BLE_GAP_WHITELIST_IRK_MAX_COUNT
|
||||
#elif YOTTA_CFG_IRK_TABLE_MAX_SIZE > BLE_GAP_WHITELIST_IRK_MAX_COUNT
|
||||
#undef YOTTA_CFG_IRK_TABLE_MAX_SIZE
|
||||
#define YOTTA_CFG_IRK_TABLE_MAX_SIZE BLE_GAP_WHITELIST_IRK_MAX_COUNT
|
||||
#endif
|
||||
#include "ble/blecommon.h"
|
||||
#include "nrf_ble.h"
|
||||
#include "ble/GapAdvertisingParams.h"
|
||||
#include "ble/GapAdvertisingData.h"
|
||||
#include "ble/Gap.h"
|
||||
#include "ble/GapScanningParams.h"
|
||||
|
||||
#include "nrf_soc.h"
|
||||
|
||||
extern "C" {
|
||||
#include "ble_radio_notification.h"
|
||||
#include "app_util_platform.h"
|
||||
}
|
||||
|
||||
#include "btle_security.h"
|
||||
|
||||
void radioNotificationStaticCallback(bool param);
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
\brief
|
||||
|
||||
*/
|
||||
/**************************************************************************/
|
||||
class nRF5xGap : public Gap
|
||||
{
|
||||
public:
|
||||
/* Functions that must be implemented from Gap */
|
||||
virtual ble_error_t setAddress(AddressType_t type, const Address_t address);
|
||||
virtual ble_error_t getAddress(AddressType_t *typeP, Address_t address);
|
||||
virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, const GapAdvertisingData &);
|
||||
|
||||
virtual uint16_t getMinAdvertisingInterval(void) const {return GapAdvertisingParams::ADVERTISEMENT_DURATION_UNITS_TO_MS(BLE_GAP_ADV_INTERVAL_MIN);}
|
||||
virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const {return GapAdvertisingParams::ADVERTISEMENT_DURATION_UNITS_TO_MS(BLE_GAP_ADV_NONCON_INTERVAL_MIN);}
|
||||
virtual uint16_t getMaxAdvertisingInterval(void) const {return GapAdvertisingParams::ADVERTISEMENT_DURATION_UNITS_TO_MS(BLE_GAP_ADV_INTERVAL_MAX);}
|
||||
|
||||
virtual ble_error_t startAdvertising(const GapAdvertisingParams &);
|
||||
virtual ble_error_t stopAdvertising(void);
|
||||
virtual ble_error_t connect(const Address_t, BLEProtocol::AddressType_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams);
|
||||
virtual ble_error_t disconnect(Handle_t connectionHandle, DisconnectionReason_t reason);
|
||||
virtual ble_error_t disconnect(DisconnectionReason_t reason);
|
||||
|
||||
virtual ble_error_t setDeviceName(const uint8_t *deviceName);
|
||||
virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP);
|
||||
virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance);
|
||||
virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP);
|
||||
|
||||
virtual ble_error_t setTxPower(int8_t txPower);
|
||||
virtual void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP);
|
||||
|
||||
void setConnectionHandle(uint16_t con_handle);
|
||||
uint16_t getConnectionHandle(void);
|
||||
|
||||
virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params);
|
||||
virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params);
|
||||
virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params);
|
||||
|
||||
virtual ble_error_t reset(void);
|
||||
|
||||
/*
|
||||
* The following functions are part of the whitelisting experimental API.
|
||||
* Therefore, this functionality can change in the near future.
|
||||
*/
|
||||
virtual uint8_t getMaxWhitelistSize(void) const;
|
||||
virtual ble_error_t getWhitelist(Gap::Whitelist_t &whitelistOut) const;
|
||||
virtual ble_error_t setWhitelist(const Gap::Whitelist_t &whitelistIn);
|
||||
|
||||
virtual ble_error_t setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode);
|
||||
virtual ble_error_t setScanningPolicyMode(ScanningPolicyMode_t mode);
|
||||
virtual ble_error_t setInitiatorPolicyMode(InitiatorPolicyMode_t mode);
|
||||
virtual Gap::AdvertisingPolicyMode_t getAdvertisingPolicyMode(void) const;
|
||||
virtual Gap::ScanningPolicyMode_t getScanningPolicyMode(void) const;
|
||||
virtual Gap::InitiatorPolicyMode_t getInitiatorPolicyMode(void) const;
|
||||
|
||||
virtual ble_error_t initRadioNotification(void) {
|
||||
if (ble_radio_notification_init(APP_IRQ_PRIORITY_HIGH /*MID*/, NRF_RADIO_NOTIFICATION_DISTANCE_800US, radioNotificationStaticCallback) == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
return BLE_ERROR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
/* Observer role is not supported by S110, return BLE_ERROR_NOT_IMPLEMENTED */
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams);
|
||||
virtual ble_error_t stopScan(void);
|
||||
#endif
|
||||
|
||||
private:
|
||||
/*
|
||||
* Whitelisting API related structures and helper functions.
|
||||
*/
|
||||
|
||||
/* Policy modes set by the user. By default these are set to ignore the whitelist */
|
||||
Gap::AdvertisingPolicyMode_t advertisingPolicyMode;
|
||||
Gap::ScanningPolicyMode_t scanningPolicyMode;
|
||||
|
||||
/* Internal representation of a whitelist */
|
||||
uint8_t whitelistAddressesSize;
|
||||
ble_gap_addr_t whitelistAddresses[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
|
||||
/*
|
||||
* An internal function used to populate the ble_gap_whitelist_t that will be used by
|
||||
* the SoftDevice for filtering requests. This function is needed because for the BLE
|
||||
* API the whitelist is just a collection of keys, but for the stack it also includes
|
||||
* the IRK table.
|
||||
*/
|
||||
ble_error_t generateStackWhitelist(ble_gap_whitelist_t &whitelist);
|
||||
|
||||
private:
|
||||
bool radioNotificationCallbackParam; /* parameter to be passed into the Timeout-generated radio notification callback. */
|
||||
Timeout radioNotificationTimeout;
|
||||
|
||||
/*
|
||||
* A helper function to post radio notification callbacks with low interrupt priority.
|
||||
*/
|
||||
void postRadioNotificationCallback(void) {
|
||||
#ifdef YOTTA_CFG_MBED_OS
|
||||
/*
|
||||
* In mbed OS, all user-facing BLE events (interrupts) are posted to the
|
||||
* MINAR scheduler to be executed as callbacks in thread mode. MINAR guards
|
||||
* its critical sections from interrupts by acquiring CriticalSectionLock,
|
||||
* which results in a call to sd_nvic_critical_region_enter(). Thus, it is
|
||||
* safe to invoke MINAR APIs from interrupt context as long as those
|
||||
* interrupts are blocked by sd_nvic_critical_region_enter().
|
||||
*
|
||||
* Radio notifications are a special case for the above. The Radio
|
||||
* Notification IRQ is handled at a very high priority--higher than the
|
||||
* level blocked by sd_nvic_critical_region_enter(). Thus Radio Notification
|
||||
* events can preempt MINAR's critical sections. Using MINAR APIs (such as
|
||||
* posting an event) directly in processRadioNotification() may result in a
|
||||
* race condition ending in a hard-fault.
|
||||
*
|
||||
* The solution is to *not* call MINAR APIs directly from the Radio
|
||||
* Notification handling; i.e. to do the bulk of RadioNotification
|
||||
* processing at a reduced priority which respects MINAR's critical
|
||||
* sections. Unfortunately, on a cortex-M0, there is no clean way to demote
|
||||
* priority for the currently executing interrupt--we wouldn't want to
|
||||
* demote the radio notification handling anyway because it is sensitive to
|
||||
* timing, and the system expects to finish this handling very quickly. The
|
||||
* workaround is to employ a Timeout to trigger
|
||||
* postRadioNotificationCallback() after a very short delay (~0 us) and post
|
||||
* the MINAR callback that context.
|
||||
*
|
||||
* !!!WARNING!!! Radio notifications are very time critical events. The
|
||||
* current solution is expected to work under the assumption that
|
||||
* postRadioNotificationCalback() will be executed BEFORE the next radio
|
||||
* notification event is generated.
|
||||
*/
|
||||
minar::Scheduler::postCallback(
|
||||
mbed::util::FunctionPointer1<void, bool>(&radioNotificationCallback, &FunctionPointerWithContext<bool>::call).bind(radioNotificationCallbackParam)
|
||||
);
|
||||
#else
|
||||
/*
|
||||
* In mbed classic, all user-facing BLE events execute callbacks in interrupt
|
||||
* mode. Radio Notifications are a special case because its IRQ is handled at
|
||||
* a very high priority. Thus Radio Notification events can preempt other
|
||||
* operations that require interaction with the SoftDevice such as advertising
|
||||
* payload updates and changing the Gap state. Therefore, executing a Radio
|
||||
* Notification callback directly from processRadioNotification() may result
|
||||
* in a race condition ending in a hard-fault.
|
||||
*
|
||||
* The solution is to *not* execute the Radio Notification callback directly
|
||||
* from the Radio Notification handling; i.e. to do the bulk of the
|
||||
* Radio Notification processing at a reduced priority. Unfortunately, on a
|
||||
* cortex-M0, there is no clean way to demote priority for the currently
|
||||
* executing interrupt--we wouldn't want to demote the radio notification
|
||||
* handling anyway because it is sensitive to timing, and the system expects
|
||||
* to finish this handling very quickly. The workaround is to employ a Timeout
|
||||
* to trigger postRadioNotificationCallback() after a very short delay (~0 us)
|
||||
* and execute the callback in that context.
|
||||
*
|
||||
* !!!WARNING!!! Radio notifications are very time critical events. The
|
||||
* current solution is expected to work under the assumption that
|
||||
* postRadioNotificationCalback() will be executed BEFORE the next radio
|
||||
* notification event is generated.
|
||||
*/
|
||||
radioNotificationCallback.call(radioNotificationCallbackParam);
|
||||
#endif /* #ifdef YOTTA_CFG_MBED_OS */
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function to process radio-notification events; to be called internally.
|
||||
* @param param [description]
|
||||
*/
|
||||
void processRadioNotificationEvent(bool param) {
|
||||
radioNotificationCallbackParam = param;
|
||||
radioNotificationTimeout.attach_us(this, &nRF5xGap::postRadioNotificationCallback, 0);
|
||||
}
|
||||
friend void radioNotificationStaticCallback(bool param); /* allow invocations of processRadioNotificationEvent() */
|
||||
|
||||
private:
|
||||
uint16_t m_connectionHandle;
|
||||
|
||||
/*
|
||||
* Allow instantiation from nRF5xn when required.
|
||||
*/
|
||||
friend class nRF5xn;
|
||||
|
||||
nRF5xGap() :
|
||||
advertisingPolicyMode(Gap::ADV_POLICY_IGNORE_WHITELIST),
|
||||
scanningPolicyMode(Gap::SCAN_POLICY_IGNORE_WHITELIST),
|
||||
whitelistAddressesSize(0) {
|
||||
m_connectionHandle = BLE_CONN_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
nRF5xGap(nRF5xGap const &);
|
||||
void operator=(nRF5xGap const &);
|
||||
};
|
||||
|
||||
#endif // ifndef __NRF5x_GAP_H__
|
|
@ -0,0 +1,50 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "nRF5xGattClient.h"
|
||||
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
ble_error_t
|
||||
nRF5xGattClient::launchServiceDiscovery(Gap::Handle_t connectionHandle,
|
||||
ServiceDiscovery::ServiceCallback_t sc,
|
||||
ServiceDiscovery::CharacteristicCallback_t cc,
|
||||
const UUID &matchingServiceUUIDIn,
|
||||
const UUID &matchingCharacteristicUUIDIn)
|
||||
{
|
||||
return _discovery.launch(connectionHandle, sc, cc, matchingServiceUUIDIn, matchingCharacteristicUUIDIn);
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGattClient::discoverCharacteristicDescriptors(
|
||||
const DiscoveredCharacteristic& characteristic,
|
||||
const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback,
|
||||
const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback)
|
||||
{
|
||||
return _characteristicDescriptorDiscoverer.launch(
|
||||
characteristic,
|
||||
discoveryCallback,
|
||||
terminationCallback
|
||||
);
|
||||
}
|
||||
|
||||
bool nRF5xGattClient::isCharacteristicDescriptorsDiscoveryActive(const DiscoveredCharacteristic& characteristic) const {
|
||||
return _characteristicDescriptorDiscoverer.isActive(characteristic);
|
||||
}
|
||||
|
||||
void nRF5xGattClient::terminateCharacteristicDescriptorsDiscovery(const DiscoveredCharacteristic& characteristic) {
|
||||
return _characteristicDescriptorDiscoverer.requestTerminate(characteristic);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,218 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 __NRF51822_GATT_CLIENT_H__
|
||||
#define __NRF51822_GATT_CLIENT_H__
|
||||
|
||||
#include "ble/GattClient.h"
|
||||
#include "nRF5xServiceDiscovery.h"
|
||||
#include "nRF5xCharacteristicDescriptorDiscoverer.h"
|
||||
|
||||
class nRF5xGattClient : public GattClient
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* When using S110, all Gatt client features will return
|
||||
* BLE_ERROR_NOT_IMPLEMENTED
|
||||
*/
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
|
||||
/**
|
||||
* Launch service discovery. Once launched, service discovery will remain
|
||||
* active with callbacks being issued back into the application for matching
|
||||
* services/characteristics. isActive() can be used to determine status; and
|
||||
* a termination callback (if setup) will be invoked at the end. Service
|
||||
* discovery can be terminated prematurely if needed using terminate().
|
||||
*
|
||||
* @param connectionHandle
|
||||
* Handle for the connection with the peer.
|
||||
* @param sc
|
||||
* This is the application callback for matching service. Taken as
|
||||
* NULL by default. Note: service discovery may still be active
|
||||
* when this callback is issued; calling asynchronous BLE-stack
|
||||
* APIs from within this application callback might cause the
|
||||
* stack to abort service discovery. If this becomes an issue, it
|
||||
* may be better to make local copy of the discoveredService and
|
||||
* wait for service discovery to terminate before operating on the
|
||||
* service.
|
||||
* @param cc
|
||||
* This is the application callback for matching characteristic.
|
||||
* Taken as NULL by default. Note: service discovery may still be
|
||||
* active when this callback is issued; calling asynchronous
|
||||
* BLE-stack APIs from within this application callback might cause
|
||||
* the stack to abort service discovery. If this becomes an issue,
|
||||
* it may be better to make local copy of the discoveredCharacteristic
|
||||
* and wait for service discovery to terminate before operating on the
|
||||
* characteristic.
|
||||
* @param matchingServiceUUID
|
||||
* UUID based filter for specifying a service in which the application is
|
||||
* interested. By default it is set as the wildcard UUID_UNKNOWN,
|
||||
* in which case it matches all services. If characteristic-UUID
|
||||
* filter (below) is set to the wildcard value, then a service
|
||||
* callback will be invoked for the matching service (or for every
|
||||
* service if the service filter is a wildcard).
|
||||
* @param matchingCharacteristicUUIDIn
|
||||
* UUID based filter for specifying characteristic in which the application
|
||||
* is interested. By default it is set as the wildcard UUID_UKNOWN
|
||||
* to match against any characteristic. If both service-UUID
|
||||
* filter and characteristic-UUID filter are used with non- wildcard
|
||||
* values, then only a single characteristic callback is
|
||||
* invoked for the matching characteristic.
|
||||
*
|
||||
* @Note Using wildcard values for both service-UUID and characteristic-
|
||||
* UUID will result in complete service discovery--callbacks being
|
||||
* called for every service and characteristic.
|
||||
*
|
||||
* @return
|
||||
* BLE_ERROR_NONE if service discovery is launched successfully; else an appropriate error.
|
||||
*/
|
||||
virtual ble_error_t launchServiceDiscovery(Gap::Handle_t connectionHandle,
|
||||
ServiceDiscovery::ServiceCallback_t sc = NULL,
|
||||
ServiceDiscovery::CharacteristicCallback_t cc = NULL,
|
||||
const UUID &matchingServiceUUID = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN),
|
||||
const UUID &matchingCharacteristicUUIDIn = UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN));
|
||||
|
||||
virtual void onServiceDiscoveryTermination(ServiceDiscovery::TerminationCallback_t callback) {
|
||||
_discovery.onTermination(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is service-discovery currently active?
|
||||
*/
|
||||
virtual bool isServiceDiscoveryActive(void) const {
|
||||
return _discovery.isActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminate an ongoing service-discovery. This should result in an
|
||||
* invocation of the TerminationCallback if service-discovery is active.
|
||||
*/
|
||||
virtual void terminateServiceDiscovery(void) {
|
||||
_discovery.terminate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Implementation of GattClient::discoverCharacteristicDescriptors
|
||||
* @see GattClient::discoverCharacteristicDescriptors
|
||||
*/
|
||||
virtual ble_error_t discoverCharacteristicDescriptors(
|
||||
const DiscoveredCharacteristic& characteristic,
|
||||
const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback,
|
||||
const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Implementation of GattClient::isCharacteristicDiscoveryActive
|
||||
* @see GattClient::isCharacteristicDiscoveryActive
|
||||
*/
|
||||
virtual bool isCharacteristicDescriptorsDiscoveryActive(const DiscoveredCharacteristic& characteristic) const;
|
||||
|
||||
/**
|
||||
* @brief Implementation of GattClient::terminateCharacteristicDiscovery
|
||||
* @see GattClient::terminateCharacteristicDiscovery
|
||||
*/
|
||||
virtual void terminateCharacteristicDescriptorsDiscovery(const DiscoveredCharacteristic& characteristic);
|
||||
|
||||
virtual ble_error_t read(Gap::Handle_t connHandle, GattAttribute::Handle_t attributeHandle, uint16_t offset) const {
|
||||
uint32_t rc = sd_ble_gattc_read(connHandle, attributeHandle, offset);
|
||||
if (rc == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
switch (rc) {
|
||||
case NRF_ERROR_BUSY:
|
||||
return BLE_STACK_BUSY;
|
||||
case BLE_ERROR_INVALID_CONN_HANDLE:
|
||||
case NRF_ERROR_INVALID_STATE:
|
||||
case NRF_ERROR_INVALID_ADDR:
|
||||
default:
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
virtual ble_error_t write(GattClient::WriteOp_t cmd, Gap::Handle_t connHandle, GattAttribute::Handle_t attributeHandle, size_t length, const uint8_t *value) const {
|
||||
ble_gattc_write_params_t writeParams;
|
||||
writeParams.write_op = cmd;
|
||||
writeParams.flags = 0; /* this is inconsequential */
|
||||
writeParams.handle = attributeHandle;
|
||||
writeParams.offset = 0;
|
||||
writeParams.len = length;
|
||||
writeParams.p_value = const_cast<uint8_t *>(value);
|
||||
|
||||
uint32_t rc = sd_ble_gattc_write(connHandle, &writeParams);
|
||||
if (rc == NRF_SUCCESS) {
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
switch (rc) {
|
||||
case NRF_ERROR_BUSY:
|
||||
return BLE_STACK_BUSY;
|
||||
case BLE_ERROR_NO_TX_PACKETS:
|
||||
return BLE_ERROR_NO_MEM;
|
||||
case BLE_ERROR_INVALID_CONN_HANDLE:
|
||||
case NRF_ERROR_INVALID_STATE:
|
||||
case NRF_ERROR_INVALID_ADDR:
|
||||
default:
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear nRF5xGattClient's state.
|
||||
*
|
||||
* @return
|
||||
* BLE_ERROR_NONE if successful.
|
||||
*/
|
||||
virtual ble_error_t reset(void) {
|
||||
/* Clear all state that is from the parent, including private members */
|
||||
if (GattClient::reset() != BLE_ERROR_NONE) {
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
/* Clear derived class members */
|
||||
_discovery.reset();
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
public:
|
||||
/*
|
||||
* Allow instantiation from nRF5xn when required.
|
||||
*/
|
||||
friend class nRF5xn;
|
||||
|
||||
nRF5xGattClient() : _discovery(this) {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
nRF5xServiceDiscovery& discovery() {
|
||||
return _discovery;
|
||||
}
|
||||
|
||||
nRF5xCharacteristicDescriptorDiscoverer& characteristicDescriptorDiscoverer() {
|
||||
return _characteristicDescriptorDiscoverer;
|
||||
}
|
||||
|
||||
private:
|
||||
nRF5xGattClient(const nRF5xGattClient &);
|
||||
const nRF5xGattClient& operator=(const nRF5xGattClient &);
|
||||
|
||||
private:
|
||||
nRF5xServiceDiscovery _discovery;
|
||||
nRF5xCharacteristicDescriptorDiscoverer _characteristicDescriptorDiscoverer;
|
||||
|
||||
#endif // if !S110
|
||||
};
|
||||
|
||||
#endif // ifndef __NRF51822_GATT_CLIENT_H__
|
|
@ -0,0 +1,543 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "nRF5xGattServer.h"
|
||||
#ifdef YOTTA_CFG_MBED_OS
|
||||
#include "mbed-drivers/mbed.h"
|
||||
#else
|
||||
#include "mbed.h"
|
||||
#endif
|
||||
|
||||
#include "common/common.h"
|
||||
#include "btle/custom/custom_helper.h"
|
||||
|
||||
#include "nRF5xn.h"
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Adds a new service to the GATT table on the peripheral
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
|
||||
@section EXAMPLE
|
||||
|
||||
@code
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGattServer::addService(GattService &service)
|
||||
{
|
||||
/* ToDo: Make sure this service UUID doesn't already exist (?) */
|
||||
/* ToDo: Basic validation */
|
||||
|
||||
/* Add the service to the nRF51 */
|
||||
ble_uuid_t nordicUUID;
|
||||
nordicUUID = custom_convert_to_nordic_uuid(service.getUUID());
|
||||
|
||||
uint16_t serviceHandle;
|
||||
ASSERT( ERROR_NONE ==
|
||||
sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
|
||||
&nordicUUID,
|
||||
&serviceHandle),
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE );
|
||||
service.setHandle(serviceHandle);
|
||||
|
||||
/* Add characteristics to the service */
|
||||
for (uint8_t i = 0; i < service.getCharacteristicCount(); i++) {
|
||||
if (characteristicCount >= BLE_TOTAL_CHARACTERISTICS) {
|
||||
return BLE_ERROR_NO_MEM;
|
||||
}
|
||||
GattCharacteristic *p_char = service.getCharacteristic(i);
|
||||
|
||||
/* Skip any incompletely defined, read-only characteristics. */
|
||||
if ((p_char->getValueAttribute().getValuePtr() == NULL) &&
|
||||
(p_char->getValueAttribute().getLength() == 0) &&
|
||||
(p_char->getProperties() == GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nordicUUID = custom_convert_to_nordic_uuid(p_char->getValueAttribute().getUUID());
|
||||
|
||||
/* The user-description descriptor is a special case which needs to be
|
||||
* handled at the time of adding the characteristic. The following block
|
||||
* is meant to discover its presence. */
|
||||
const uint8_t *userDescriptionDescriptorValuePtr = NULL;
|
||||
uint16_t userDescriptionDescriptorValueLen = 0;
|
||||
for (uint8_t j = 0; j < p_char->getDescriptorCount(); j++) {
|
||||
GattAttribute *p_desc = p_char->getDescriptor(j);
|
||||
if (p_desc->getUUID() == BLE_UUID_DESCRIPTOR_CHAR_USER_DESC) {
|
||||
userDescriptionDescriptorValuePtr = p_desc->getValuePtr();
|
||||
userDescriptionDescriptorValueLen = p_desc->getLength();
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT ( ERROR_NONE ==
|
||||
custom_add_in_characteristic(BLE_GATT_HANDLE_INVALID,
|
||||
&nordicUUID,
|
||||
p_char->getProperties(),
|
||||
p_char->getRequiredSecurity(),
|
||||
p_char->getValueAttribute().getValuePtr(),
|
||||
p_char->getValueAttribute().getLength(),
|
||||
p_char->getValueAttribute().getMaxLength(),
|
||||
p_char->getValueAttribute().hasVariableLength(),
|
||||
userDescriptionDescriptorValuePtr,
|
||||
userDescriptionDescriptorValueLen,
|
||||
p_char->isReadAuthorizationEnabled(),
|
||||
p_char->isWriteAuthorizationEnabled(),
|
||||
&nrfCharacteristicHandles[characteristicCount]),
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE );
|
||||
|
||||
/* Update the characteristic handle */
|
||||
p_characteristics[characteristicCount] = p_char;
|
||||
p_char->getValueAttribute().setHandle(nrfCharacteristicHandles[characteristicCount].value_handle);
|
||||
characteristicCount++;
|
||||
|
||||
/* Add optional descriptors if any */
|
||||
for (uint8_t j = 0; j < p_char->getDescriptorCount(); j++) {
|
||||
if (descriptorCount >= BLE_TOTAL_DESCRIPTORS) {
|
||||
return BLE_ERROR_NO_MEM;
|
||||
}
|
||||
|
||||
GattAttribute *p_desc = p_char->getDescriptor(j);
|
||||
/* skip the user-description-descriptor here; this has already been handled when adding the characteristic (above). */
|
||||
if (p_desc->getUUID() == BLE_UUID_DESCRIPTOR_CHAR_USER_DESC) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nordicUUID = custom_convert_to_nordic_uuid(p_desc->getUUID());
|
||||
|
||||
ASSERT(ERROR_NONE ==
|
||||
custom_add_in_descriptor(BLE_GATT_HANDLE_INVALID,
|
||||
&nordicUUID,
|
||||
p_desc->getValuePtr(),
|
||||
p_desc->getLength(),
|
||||
p_desc->getMaxLength(),
|
||||
p_desc->hasVariableLength(),
|
||||
&nrfDescriptorHandles[descriptorCount]),
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
|
||||
p_descriptors[descriptorCount] = p_desc;
|
||||
p_desc->setHandle(nrfDescriptorHandles[descriptorCount]);
|
||||
descriptorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
serviceCount++;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Reads the value of a characteristic, based on the service
|
||||
and characteristic index fields
|
||||
|
||||
@param[in] attributeHandle
|
||||
The handle of the GattCharacteristic to read from
|
||||
@param[in] buffer
|
||||
Buffer to hold the the characteristic's value
|
||||
(raw byte array in LSB format)
|
||||
@param[in/out] len
|
||||
input: Length in bytes to be read.
|
||||
output: Total length of attribute value upon successful return.
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGattServer::read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP)
|
||||
{
|
||||
return read(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, lengthP);
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGattServer::read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP)
|
||||
{
|
||||
ble_gatts_value_t value = {
|
||||
.len = *lengthP,
|
||||
.offset = 0,
|
||||
.p_value = buffer,
|
||||
};
|
||||
|
||||
ASSERT( ERROR_NONE ==
|
||||
sd_ble_gatts_value_get(connectionHandle, attributeHandle, &value),
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||
*lengthP = value.len;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Updates the value of a characteristic, based on the service
|
||||
and characteristic index fields
|
||||
|
||||
@param[in] charHandle
|
||||
The handle of the GattCharacteristic to write to
|
||||
@param[in] buffer
|
||||
Data to use when updating the characteristic's value
|
||||
(raw byte array in LSB format)
|
||||
@param[in] len
|
||||
The number of bytes in buffer
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGattServer::write(GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly)
|
||||
{
|
||||
return write(BLE_CONN_HANDLE_INVALID, attributeHandle, buffer, len, localOnly);
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGattServer::write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly)
|
||||
{
|
||||
ble_error_t returnValue = BLE_ERROR_NONE;
|
||||
|
||||
ble_gatts_value_t value = {
|
||||
.len = len,
|
||||
.offset = 0,
|
||||
.p_value = const_cast<uint8_t *>(buffer),
|
||||
};
|
||||
|
||||
if (localOnly) {
|
||||
/* Only update locally regardless of notify/indicate */
|
||||
ASSERT_INT( ERROR_NONE,
|
||||
sd_ble_gatts_value_set(connectionHandle, attributeHandle, &value),
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE );
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
int characteristicIndex = resolveValueHandleToCharIndex(attributeHandle);
|
||||
if ((characteristicIndex != -1) &&
|
||||
(p_characteristics[characteristicIndex]->getProperties() & (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY))) {
|
||||
/* HVX update for the characteristic value */
|
||||
ble_gatts_hvx_params_t hvx_params;
|
||||
|
||||
hvx_params.handle = attributeHandle;
|
||||
hvx_params.type =
|
||||
(p_characteristics[characteristicIndex]->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) ? BLE_GATT_HVX_NOTIFICATION : BLE_GATT_HVX_INDICATION;
|
||||
hvx_params.offset = 0;
|
||||
hvx_params.p_data = const_cast<uint8_t *>(buffer);
|
||||
hvx_params.p_len = &len;
|
||||
|
||||
if (connectionHandle == BLE_CONN_HANDLE_INVALID) { /* use the default connection handle if the caller hasn't specified a valid connectionHandle. */
|
||||
nRF5xGap &gap = (nRF5xGap &) nRF5xn::Instance(BLE::DEFAULT_INSTANCE).getGap();
|
||||
connectionHandle = gap.getConnectionHandle();
|
||||
}
|
||||
error_t error = (error_t) sd_ble_gatts_hvx(connectionHandle, &hvx_params);
|
||||
if (error != ERROR_NONE) {
|
||||
switch (error) {
|
||||
case ERROR_BLE_NO_TX_BUFFERS: /* Notifications consume application buffers. The return value can be used for resending notifications. */
|
||||
case ERROR_BUSY:
|
||||
returnValue = BLE_STACK_BUSY;
|
||||
break;
|
||||
|
||||
case ERROR_INVALID_STATE:
|
||||
case ERROR_BLEGATTS_SYS_ATTR_MISSING:
|
||||
returnValue = BLE_ERROR_INVALID_STATE;
|
||||
break;
|
||||
|
||||
default :
|
||||
ASSERT_INT( ERROR_NONE,
|
||||
sd_ble_gatts_value_set(connectionHandle, attributeHandle, &value),
|
||||
BLE_ERROR_PARAM_OUT_OF_RANGE );
|
||||
|
||||
/* Notifications consume application buffers. The return value can
|
||||
* be used for resending notifications. */
|
||||
returnValue = BLE_STACK_BUSY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uint32_t err = sd_ble_gatts_value_set(connectionHandle, attributeHandle, &value);
|
||||
switch(err) {
|
||||
case NRF_SUCCESS:
|
||||
returnValue = BLE_ERROR_NONE;
|
||||
break;
|
||||
case NRF_ERROR_INVALID_ADDR:
|
||||
case NRF_ERROR_INVALID_PARAM:
|
||||
returnValue = BLE_ERROR_INVALID_PARAM;
|
||||
break;
|
||||
case NRF_ERROR_NOT_FOUND:
|
||||
case NRF_ERROR_DATA_SIZE:
|
||||
case BLE_ERROR_INVALID_CONN_HANDLE:
|
||||
case BLE_ERROR_GATTS_INVALID_ATTR_TYPE:
|
||||
returnValue = BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
break;
|
||||
case NRF_ERROR_FORBIDDEN:
|
||||
returnValue = BLE_ERROR_OPERATION_NOT_PERMITTED;
|
||||
break;
|
||||
default:
|
||||
returnValue = BLE_ERROR_UNSPECIFIED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGattServer::areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP)
|
||||
{
|
||||
/* Forward the call with the default connection handle. */
|
||||
nRF5xGap &gap = (nRF5xGap &) nRF5xn::Instance(BLE::DEFAULT_INSTANCE).getGap();
|
||||
return areUpdatesEnabled(gap.getConnectionHandle(), characteristic, enabledP);
|
||||
}
|
||||
|
||||
ble_error_t nRF5xGattServer::areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP)
|
||||
{
|
||||
int characteristicIndex = resolveValueHandleToCharIndex(characteristic.getValueHandle());
|
||||
if (characteristicIndex == -1) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
/* Read the cccd value from the GATT server. */
|
||||
GattAttribute::Handle_t cccdHandle = nrfCharacteristicHandles[characteristicIndex].cccd_handle;
|
||||
uint16_t cccdValue;
|
||||
uint16_t length = sizeof(cccdValue);
|
||||
ble_error_t rc = read(connectionHandle, cccdHandle, reinterpret_cast<uint8_t *>(&cccdValue), &length);
|
||||
if (rc != BLE_ERROR_NONE) {
|
||||
return rc;
|
||||
}
|
||||
if (length != sizeof(cccdValue)) {
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
/* Check for NOTFICATION or INDICATION in CCCD. */
|
||||
if ((cccdValue & BLE_GATT_HVX_NOTIFICATION) || (cccdValue & BLE_GATT_HVX_INDICATION)) {
|
||||
*enabledP = true;
|
||||
}
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Clear nRF5xGattServer's state.
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xGattServer::reset(void)
|
||||
{
|
||||
/* Clear all state that is from the parent, including private members */
|
||||
if (GattServer::reset() != BLE_ERROR_NONE) {
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
/* Clear derived class members */
|
||||
memset(p_characteristics, 0, sizeof(p_characteristics));
|
||||
memset(p_descriptors, 0, sizeof(p_descriptors));
|
||||
memset(nrfCharacteristicHandles, 0, sizeof(ble_gatts_char_handles_t));
|
||||
memset(nrfDescriptorHandles, 0, sizeof(nrfDescriptorHandles));
|
||||
descriptorCount = 0;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Callback handler for events getting pushed up from the SD
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void nRF5xGattServer::hwCallback(ble_evt_t *p_ble_evt)
|
||||
{
|
||||
GattAttribute::Handle_t handle_value;
|
||||
GattServerEvents::gattEvent_t eventType;
|
||||
const ble_gatts_evt_t *gattsEventP = &p_ble_evt->evt.gatts_evt;
|
||||
|
||||
switch (p_ble_evt->header.evt_id) {
|
||||
case BLE_GATTS_EVT_WRITE: {
|
||||
/* There are 2 use case here: Values being updated & CCCD (indicate/notify) enabled */
|
||||
|
||||
/* 1.) Handle CCCD changes */
|
||||
handle_value = gattsEventP->params.write.handle;
|
||||
int characteristicIndex = resolveCCCDHandleToCharIndex(handle_value);
|
||||
if ((characteristicIndex != -1) &&
|
||||
(p_characteristics[characteristicIndex]->getProperties() &
|
||||
(GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY))) {
|
||||
|
||||
uint16_t cccd_value = (gattsEventP->params.write.data[1] << 8) | gattsEventP->params.write.data[0]; /* Little Endian but M0 may be mis-aligned */
|
||||
|
||||
if (((p_characteristics[characteristicIndex]->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE) && (cccd_value & BLE_GATT_HVX_INDICATION)) ||
|
||||
((p_characteristics[characteristicIndex]->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) && (cccd_value & BLE_GATT_HVX_NOTIFICATION))) {
|
||||
eventType = GattServerEvents::GATT_EVENT_UPDATES_ENABLED;
|
||||
} else {
|
||||
eventType = GattServerEvents::GATT_EVENT_UPDATES_DISABLED;
|
||||
}
|
||||
|
||||
handleEvent(eventType, p_characteristics[characteristicIndex]->getValueHandle());
|
||||
return;
|
||||
}
|
||||
|
||||
/* 2.) Changes to the characteristic value will be handled with other events below */
|
||||
eventType = GattServerEvents::GATT_EVENT_DATA_WRITTEN;
|
||||
}
|
||||
break;
|
||||
|
||||
case BLE_GATTS_EVT_HVC:
|
||||
/* Indication confirmation received */
|
||||
eventType = GattServerEvents::GATT_EVENT_CONFIRMATION_RECEIVED;
|
||||
handle_value = gattsEventP->params.hvc.handle;
|
||||
break;
|
||||
|
||||
case BLE_EVT_TX_COMPLETE: {
|
||||
handleDataSentEvent(p_ble_evt->evt.common_evt.params.tx_complete.count);
|
||||
return;
|
||||
}
|
||||
|
||||
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
|
||||
sd_ble_gatts_sys_attr_set(gattsEventP->conn_handle, NULL, 0, 0);
|
||||
return;
|
||||
|
||||
case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
|
||||
switch (gattsEventP->params.authorize_request.type) {
|
||||
case BLE_GATTS_AUTHORIZE_TYPE_READ:
|
||||
eventType = GattServerEvents::GATT_EVENT_READ_AUTHORIZATION_REQ;
|
||||
handle_value = gattsEventP->params.authorize_request.request.read.handle;
|
||||
break;
|
||||
case BLE_GATTS_AUTHORIZE_TYPE_WRITE:
|
||||
eventType = GattServerEvents::GATT_EVENT_WRITE_AUTHORIZATION_REQ;
|
||||
handle_value = gattsEventP->params.authorize_request.request.write.handle;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
int characteristicIndex = resolveValueHandleToCharIndex(handle_value);
|
||||
if (characteristicIndex == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Find index (charHandle) in the pool */
|
||||
switch (eventType) {
|
||||
case GattServerEvents::GATT_EVENT_DATA_WRITTEN: {
|
||||
GattWriteCallbackParams cbParams = {
|
||||
.connHandle = gattsEventP->conn_handle,
|
||||
.handle = handle_value,
|
||||
.writeOp = static_cast<GattWriteCallbackParams::WriteOp_t>(gattsEventP->params.write.op),
|
||||
.offset = gattsEventP->params.write.offset,
|
||||
.len = gattsEventP->params.write.len,
|
||||
.data = gattsEventP->params.write.data
|
||||
};
|
||||
handleDataWrittenEvent(&cbParams);
|
||||
break;
|
||||
}
|
||||
case GattServerEvents::GATT_EVENT_WRITE_AUTHORIZATION_REQ: {
|
||||
GattWriteAuthCallbackParams cbParams = {
|
||||
.connHandle = gattsEventP->conn_handle,
|
||||
.handle = handle_value,
|
||||
.offset = gattsEventP->params.authorize_request.request.write.offset,
|
||||
.len = gattsEventP->params.authorize_request.request.write.len,
|
||||
.data = gattsEventP->params.authorize_request.request.write.data,
|
||||
.authorizationReply = AUTH_CALLBACK_REPLY_SUCCESS /* the callback handler must leave this member
|
||||
* set to AUTH_CALLBACK_REPLY_SUCCESS if the client
|
||||
* request is to proceed. */
|
||||
};
|
||||
|
||||
ble_gatts_rw_authorize_reply_params_t reply = {
|
||||
.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE,
|
||||
.params = {
|
||||
.write = {
|
||||
.gatt_status = p_characteristics[characteristicIndex]->authorizeWrite(&cbParams),
|
||||
.update = 1,
|
||||
.offset = cbParams.offset,
|
||||
.len = cbParams.len,
|
||||
.p_data = cbParams.data
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (reply.params.write.gatt_status != BLE_GATT_STATUS_SUCCESS)
|
||||
{
|
||||
reply.params.write.update = 0;
|
||||
}
|
||||
|
||||
sd_ble_gatts_rw_authorize_reply(gattsEventP->conn_handle, &reply);
|
||||
|
||||
/*
|
||||
* If write-authorization is enabled for a characteristic,
|
||||
* AUTHORIZATION_REQ event (if replied with true) is *not*
|
||||
* followed by another DATA_WRITTEN event; so we still need
|
||||
* to invoke handleDataWritten(), much the same as we would
|
||||
* have done if write-authorization had not been enabled.
|
||||
*/
|
||||
if (reply.params.write.gatt_status == BLE_GATT_STATUS_SUCCESS) {
|
||||
GattWriteCallbackParams cbParams = {
|
||||
.connHandle = gattsEventP->conn_handle,
|
||||
.handle = handle_value,
|
||||
.writeOp = static_cast<GattWriteCallbackParams::WriteOp_t>(gattsEventP->params.authorize_request.request.write.op),
|
||||
.offset = gattsEventP->params.authorize_request.request.write.offset,
|
||||
.len = gattsEventP->params.authorize_request.request.write.len,
|
||||
.data = gattsEventP->params.authorize_request.request.write.data,
|
||||
};
|
||||
handleDataWrittenEvent(&cbParams);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GattServerEvents::GATT_EVENT_READ_AUTHORIZATION_REQ: {
|
||||
GattReadAuthCallbackParams cbParams = {
|
||||
.connHandle = gattsEventP->conn_handle,
|
||||
.handle = handle_value,
|
||||
.offset = gattsEventP->params.authorize_request.request.read.offset,
|
||||
.len = 0,
|
||||
.data = NULL,
|
||||
.authorizationReply = AUTH_CALLBACK_REPLY_SUCCESS /* the callback handler must leave this member
|
||||
* set to AUTH_CALLBACK_REPLY_SUCCESS if the client
|
||||
* request is to proceed. */
|
||||
};
|
||||
|
||||
ble_gatts_rw_authorize_reply_params_t reply = {
|
||||
.type = BLE_GATTS_AUTHORIZE_TYPE_READ,
|
||||
.params = {
|
||||
.read = {
|
||||
.gatt_status = p_characteristics[characteristicIndex]->authorizeRead(&cbParams)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (cbParams.authorizationReply == BLE_GATT_STATUS_SUCCESS) {
|
||||
if (cbParams.data != NULL) {
|
||||
reply.params.read.update = 1;
|
||||
reply.params.read.offset = cbParams.offset;
|
||||
reply.params.read.len = cbParams.len;
|
||||
reply.params.read.p_data = cbParams.data;
|
||||
}
|
||||
}
|
||||
|
||||
sd_ble_gatts_rw_authorize_reply(gattsEventP->conn_handle, &reply);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
handleEvent(eventType, handle_value);
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 __NRF51822_GATT_SERVER_H__
|
||||
#define __NRF51822_GATT_SERVER_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ble/blecommon.h"
|
||||
#include "nrf_ble.h" /* nordic ble */
|
||||
#include "ble/Gap.h"
|
||||
#include "ble/GattServer.h"
|
||||
|
||||
class nRF5xGattServer : public GattServer
|
||||
{
|
||||
public:
|
||||
/* Functions that must be implemented from GattServer */
|
||||
virtual ble_error_t addService(GattService &);
|
||||
virtual ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
|
||||
virtual ble_error_t read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
|
||||
virtual ble_error_t write(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
|
||||
virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
|
||||
virtual ble_error_t areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP);
|
||||
virtual ble_error_t areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP);
|
||||
virtual ble_error_t reset(void);
|
||||
|
||||
/* nRF51 Functions */
|
||||
void eventCallback(void);
|
||||
void hwCallback(ble_evt_t *p_ble_evt);
|
||||
|
||||
|
||||
private:
|
||||
const static unsigned BLE_TOTAL_CHARACTERISTICS = 20;
|
||||
const static unsigned BLE_TOTAL_DESCRIPTORS = 8;
|
||||
|
||||
private:
|
||||
/**
|
||||
* resolve a value attribute to its owning characteristic.
|
||||
* @param valueHandle the value handle to be resolved.
|
||||
* @return characteristic index if a resolution is found, else -1.
|
||||
*/
|
||||
int resolveValueHandleToCharIndex(GattAttribute::Handle_t valueHandle) const {
|
||||
unsigned charIndex;
|
||||
for (charIndex = 0; charIndex < characteristicCount; charIndex++) {
|
||||
if (nrfCharacteristicHandles[charIndex].value_handle == valueHandle) {
|
||||
return charIndex;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* resolve a CCCD attribute handle to its owning characteristic.
|
||||
* @param cccdHandle the CCCD handle to be resolved.
|
||||
* @return characteristic index if a resolution is found, else -1.
|
||||
*/
|
||||
int resolveCCCDHandleToCharIndex(GattAttribute::Handle_t cccdHandle) const {
|
||||
unsigned charIndex;
|
||||
for (charIndex = 0; charIndex < characteristicCount; charIndex++) {
|
||||
if (nrfCharacteristicHandles[charIndex].cccd_handle == cccdHandle) {
|
||||
return charIndex;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private:
|
||||
GattCharacteristic *p_characteristics[BLE_TOTAL_CHARACTERISTICS];
|
||||
ble_gatts_char_handles_t nrfCharacteristicHandles[BLE_TOTAL_CHARACTERISTICS];
|
||||
GattAttribute *p_descriptors[BLE_TOTAL_DESCRIPTORS];
|
||||
uint8_t descriptorCount;
|
||||
uint16_t nrfDescriptorHandles[BLE_TOTAL_DESCRIPTORS];
|
||||
|
||||
/*
|
||||
* Allow instantiation from nRF5xn when required.
|
||||
*/
|
||||
friend class nRF5xn;
|
||||
|
||||
nRF5xGattServer() : GattServer(), p_characteristics(), nrfCharacteristicHandles(), p_descriptors(), descriptorCount(0), nrfDescriptorHandles() {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
private:
|
||||
nRF5xGattServer(const nRF5xGattServer &);
|
||||
const nRF5xGattServer& operator=(const nRF5xGattServer &);
|
||||
};
|
||||
|
||||
#endif // ifndef __NRF51822_GATT_SERVER_H__
|
|
@ -0,0 +1,174 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 __NRF51822_SECURITY_MANAGER_H__
|
||||
#define __NRF51822_SECURITY_MANAGER_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "nRF5xGap.h"
|
||||
#include "ble/SecurityManager.h"
|
||||
#include "btle_security.h"
|
||||
|
||||
class nRF5xSecurityManager : public SecurityManager
|
||||
{
|
||||
public:
|
||||
/* Functions that must be implemented from SecurityManager */
|
||||
virtual ble_error_t init(bool enableBonding,
|
||||
bool requireMITM,
|
||||
SecurityIOCapabilities_t iocaps,
|
||||
const Passkey_t passkey) {
|
||||
return btle_initializeSecurity(enableBonding, requireMITM, iocaps, passkey);
|
||||
}
|
||||
|
||||
virtual ble_error_t getLinkSecurity(Gap::Handle_t connectionHandle, LinkSecurityStatus_t *securityStatusP) {
|
||||
return btle_getLinkSecurity(connectionHandle, securityStatusP);
|
||||
}
|
||||
|
||||
virtual ble_error_t setLinkSecurity(Gap::Handle_t connectionHandle, SecurityMode_t securityMode) {
|
||||
return btle_setLinkSecurity(connectionHandle, securityMode);
|
||||
}
|
||||
|
||||
virtual ble_error_t purgeAllBondingState(void) {
|
||||
return btle_purgeAllBondingState();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a list of addresses from peers in the stacks bond table.
|
||||
*
|
||||
* @param[in/out] addresses
|
||||
* (on input) @ref Gap::Whitelist_t structure where at
|
||||
* most addresses.capacity addresses from bonded peers will
|
||||
* be stored.
|
||||
* (on output) A copy of the addresses from bonded peers.
|
||||
*
|
||||
* @return
|
||||
* BLE_ERROR_NONE if successful.
|
||||
*/
|
||||
virtual ble_error_t getAddressesFromBondTable(Gap::Whitelist_t &addresses) const {
|
||||
uint8_t i;
|
||||
|
||||
ble_gap_whitelist_t whitelistFromBondTable;
|
||||
ble_gap_addr_t *addressPtr[YOTTA_CFG_WHITELIST_MAX_SIZE];
|
||||
ble_gap_irk_t *irkPtr[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
|
||||
|
||||
/* Initialize the structure so that we get as many addreses as the whitelist can hold */
|
||||
whitelistFromBondTable.addr_count = YOTTA_CFG_IRK_TABLE_MAX_SIZE;
|
||||
whitelistFromBondTable.pp_addrs = addressPtr;
|
||||
whitelistFromBondTable.irk_count = YOTTA_CFG_IRK_TABLE_MAX_SIZE;
|
||||
whitelistFromBondTable.pp_irks = irkPtr;
|
||||
|
||||
ble_error_t error = createWhitelistFromBondTable(whitelistFromBondTable);
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
addresses.size = 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Put all the addresses in the structure */
|
||||
for (i = 0; i < whitelistFromBondTable.addr_count; ++i) {
|
||||
if (i >= addresses.capacity) {
|
||||
/* Ran out of space in the output Gap::Whitelist_t */
|
||||
addresses.size = i;
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
memcpy(&addresses.addresses[i], whitelistFromBondTable.pp_addrs[i], sizeof(BLEProtocol::Address_t));
|
||||
}
|
||||
|
||||
/* Update the current address count */
|
||||
addresses.size = i;
|
||||
|
||||
/* The assumption here is that the underlying implementation of
|
||||
* createWhitelistFromBondTable() will not return the private resolvable
|
||||
* addresses (which is the case in the SoftDevice). Rather it returns the
|
||||
* IRKs, so we need to generate the private resolvable address by ourselves.
|
||||
*/
|
||||
for (i = 0; i < whitelistFromBondTable.irk_count; ++i) {
|
||||
if (i + addresses.size >= addresses.capacity) {
|
||||
/* Ran out of space in the output Gap::Whitelist_t */
|
||||
addresses.size += i;
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
btle_generateResolvableAddress(
|
||||
*whitelistFromBondTable.pp_irks[i],
|
||||
(ble_gap_addr_t &) addresses.addresses[i + addresses.size]
|
||||
);
|
||||
}
|
||||
|
||||
/* Update the current address count */
|
||||
addresses.size += i;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear nRF5xSecurityManager's state.
|
||||
*
|
||||
* @return
|
||||
* BLE_ERROR_NONE if successful.
|
||||
*/
|
||||
virtual ble_error_t reset(void)
|
||||
{
|
||||
if (SecurityManager::reset() != BLE_ERROR_NONE) {
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
bool hasInitialized(void) const {
|
||||
return btle_hasInitializedSecurity();
|
||||
}
|
||||
|
||||
public:
|
||||
/*
|
||||
* Allow instantiation from nRF5xn when required.
|
||||
*/
|
||||
friend class nRF5xn;
|
||||
|
||||
nRF5xSecurityManager() {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
private:
|
||||
nRF5xSecurityManager(const nRF5xSecurityManager &);
|
||||
const nRF5xSecurityManager& operator=(const nRF5xSecurityManager &);
|
||||
|
||||
/*
|
||||
* Expose an interface that allows us to query the SoftDevice bond table
|
||||
* and extract a whitelist.
|
||||
*/
|
||||
ble_error_t createWhitelistFromBondTable(ble_gap_whitelist_t &whitelistFromBondTable) const {
|
||||
return btle_createWhitelistFromBondTable(&whitelistFromBondTable);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a BLE address and a IRK this function check whether the address
|
||||
* can be generated from the IRK. To do so, this function uses the hash
|
||||
* function and algorithm described in the Bluetooth low Energy
|
||||
* Specification. Internally, Nordic SDK functions are used.
|
||||
*/
|
||||
bool matchAddressAndIrk(ble_gap_addr_t *address, ble_gap_irk_t *irk) const {
|
||||
return btle_matchAddressAndIrk(address, irk);
|
||||
}
|
||||
|
||||
/*
|
||||
* Give nRF5xGap access to createWhitelistFromBondTable() and
|
||||
* matchAddressAndIrk()
|
||||
*/
|
||||
friend class nRF5xGap;
|
||||
};
|
||||
|
||||
#endif // ifndef __NRF51822_SECURITY_MANAGER_H__
|
|
@ -0,0 +1,312 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "nRF5xServiceDiscovery.h"
|
||||
|
||||
ble_error_t
|
||||
nRF5xServiceDiscovery::launchCharacteristicDiscovery(Gap::Handle_t connectionHandle,
|
||||
Gap::Handle_t startHandle,
|
||||
Gap::Handle_t endHandle)
|
||||
{
|
||||
characteristicDiscoveryStarted(connectionHandle);
|
||||
|
||||
ble_gattc_handle_range_t handleRange = {
|
||||
.start_handle = startHandle,
|
||||
.end_handle = endHandle
|
||||
};
|
||||
uint32_t rc = sd_ble_gattc_characteristics_discover(connectionHandle, &handleRange);
|
||||
ble_error_t err = BLE_ERROR_NONE;
|
||||
|
||||
switch (rc) {
|
||||
case NRF_SUCCESS:
|
||||
err = BLE_ERROR_NONE;
|
||||
break;
|
||||
case BLE_ERROR_INVALID_CONN_HANDLE:
|
||||
case NRF_ERROR_INVALID_ADDR:
|
||||
err = BLE_ERROR_INVALID_PARAM;
|
||||
break;
|
||||
case NRF_ERROR_BUSY:
|
||||
err = BLE_STACK_BUSY;
|
||||
break;
|
||||
case NRF_ERROR_INVALID_STATE:
|
||||
err = BLE_ERROR_INVALID_STATE;
|
||||
break;
|
||||
default:
|
||||
err = BLE_ERROR_UNSPECIFIED;
|
||||
break;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
terminateCharacteristicDiscovery(err);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
nRF5xServiceDiscovery::setupDiscoveredServices(const ble_gattc_evt_prim_srvc_disc_rsp_t *response)
|
||||
{
|
||||
serviceIndex = 0;
|
||||
numServices = response->count;
|
||||
|
||||
/* Account for the limitation on the number of discovered services we can handle at a time. */
|
||||
if (numServices > BLE_DB_DISCOVERY_MAX_SRV) {
|
||||
numServices = BLE_DB_DISCOVERY_MAX_SRV;
|
||||
}
|
||||
|
||||
serviceUUIDDiscoveryQueue.reset();
|
||||
for (unsigned i = 0; i < numServices; ++i) {
|
||||
if (response->services[i].uuid.type == BLE_UUID_TYPE_UNKNOWN) {
|
||||
serviceUUIDDiscoveryQueue.enqueue(i);
|
||||
services[i].setup(response->services[i].handle_range.start_handle,
|
||||
response->services[i].handle_range.end_handle);
|
||||
} else {
|
||||
services[i].setup(response->services[i].uuid.uuid,
|
||||
response->services[i].handle_range.start_handle,
|
||||
response->services[i].handle_range.end_handle);
|
||||
}
|
||||
}
|
||||
|
||||
/* Trigger discovery of service UUID if necessary. */
|
||||
if (serviceUUIDDiscoveryQueue.getCount()) {
|
||||
serviceUUIDDiscoveryQueue.triggerFirst();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nRF5xServiceDiscovery::setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response)
|
||||
{
|
||||
numCharacteristics = response->count;
|
||||
|
||||
/* Account for the limitation on the number of discovered characteristics we can handle at a time. */
|
||||
if (numCharacteristics > BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV) {
|
||||
numCharacteristics = BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV;
|
||||
}
|
||||
|
||||
charUUIDDiscoveryQueue.reset();
|
||||
for (unsigned charIndex = 0; charIndex < numCharacteristics; charIndex++) {
|
||||
if (response->chars[charIndex].uuid.type == BLE_UUID_TYPE_UNKNOWN) {
|
||||
charUUIDDiscoveryQueue.enqueue(charIndex);
|
||||
characteristics[charIndex].setup(gattc,
|
||||
connHandle,
|
||||
response->chars[charIndex].char_props,
|
||||
response->chars[charIndex].handle_decl,
|
||||
response->chars[charIndex].handle_value);
|
||||
} else {
|
||||
characteristics[charIndex].setup(gattc,
|
||||
connHandle,
|
||||
response->chars[charIndex].uuid.uuid,
|
||||
response->chars[charIndex].char_props,
|
||||
response->chars[charIndex].handle_decl,
|
||||
response->chars[charIndex].handle_value);
|
||||
}
|
||||
}
|
||||
|
||||
/* Trigger discovery of char UUID if necessary. */
|
||||
if (charUUIDDiscoveryQueue.getCount()) {
|
||||
charUUIDDiscoveryQueue.triggerFirst();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nRF5xServiceDiscovery::progressCharacteristicDiscovery(void)
|
||||
{
|
||||
if (state != CHARACTERISTIC_DISCOVERY_ACTIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((discoveredCharacteristic != nRF5xDiscoveredCharacteristic()) && (numCharacteristics > 0)) {
|
||||
discoveredCharacteristic.setLastHandle(characteristics[0].getDeclHandle() - 1);
|
||||
|
||||
if ((matchingCharacteristicUUID == UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) ||
|
||||
((matchingCharacteristicUUID == discoveredCharacteristic.getUUID()) &&
|
||||
(matchingServiceUUID != UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)))) {
|
||||
if (characteristicCallback) {
|
||||
characteristicCallback(&discoveredCharacteristic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < numCharacteristics; ++i) {
|
||||
if (state != CHARACTERISTIC_DISCOVERY_ACTIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (i == (numCharacteristics - 1)) {
|
||||
discoveredCharacteristic = characteristics[i];
|
||||
break;
|
||||
} else {
|
||||
characteristics[i].setLastHandle(characteristics[i + 1].getDeclHandle() - 1);
|
||||
}
|
||||
|
||||
if ((matchingCharacteristicUUID == UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) ||
|
||||
((matchingCharacteristicUUID == characteristics[i].getUUID()) &&
|
||||
(matchingServiceUUID != UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)))) {
|
||||
if (characteristicCallback) {
|
||||
characteristicCallback(&characteristics[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state != CHARACTERISTIC_DISCOVERY_ACTIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gap::Handle_t startHandle = (numCharacteristics > 0) ? characteristics[numCharacteristics - 1].getValueHandle() + 1 : SRV_DISC_END_HANDLE;
|
||||
Gap::Handle_t endHandle = services[serviceIndex].getEndHandle();
|
||||
resetDiscoveredCharacteristics(); /* Note: resetDiscoveredCharacteristics() must come after fetching start and end Handles. */
|
||||
|
||||
if (startHandle < endHandle) {
|
||||
ble_gattc_handle_range_t handleRange = {
|
||||
.start_handle = startHandle,
|
||||
.end_handle = endHandle
|
||||
};
|
||||
if (sd_ble_gattc_characteristics_discover(connHandle, &handleRange) != NRF_SUCCESS) {
|
||||
terminateCharacteristicDiscovery(BLE_ERROR_UNSPECIFIED);
|
||||
}
|
||||
} else {
|
||||
terminateCharacteristicDiscovery(BLE_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nRF5xServiceDiscovery::progressServiceDiscovery(void)
|
||||
{
|
||||
/* Iterate through the previously discovered services cached in services[]. */
|
||||
while ((state == SERVICE_DISCOVERY_ACTIVE) && (serviceIndex < numServices)) {
|
||||
if ((matchingServiceUUID == UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) ||
|
||||
(matchingServiceUUID == services[serviceIndex].getUUID())) {
|
||||
|
||||
if (serviceCallback && (matchingCharacteristicUUID == UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN))) {
|
||||
serviceCallback(&services[serviceIndex]);
|
||||
}
|
||||
|
||||
if ((state == SERVICE_DISCOVERY_ACTIVE) && characteristicCallback) {
|
||||
launchCharacteristicDiscovery(connHandle, services[serviceIndex].getStartHandle(), services[serviceIndex].getEndHandle());
|
||||
} else {
|
||||
serviceIndex++;
|
||||
}
|
||||
} else {
|
||||
serviceIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Relaunch discovery of new services beyond the last entry cached in services[]. */
|
||||
if ((state == SERVICE_DISCOVERY_ACTIVE) && (numServices > 0) && (serviceIndex > 0)) {
|
||||
/* Determine the ending handle of the last cached service. */
|
||||
Gap::Handle_t endHandle = services[serviceIndex - 1].getEndHandle();
|
||||
resetDiscoveredServices(); /* Note: resetDiscoveredServices() must come after fetching endHandle. */
|
||||
|
||||
if (endHandle == SRV_DISC_END_HANDLE) {
|
||||
terminateServiceDiscovery();
|
||||
} else {
|
||||
// the next service is located after the last handle discovered
|
||||
// Launch a new discovery from [endHandle + 1 : 0xFFFF]
|
||||
if (sd_ble_gattc_primary_services_discover(connHandle, endHandle + 1, NULL) != NRF_SUCCESS) {
|
||||
terminateServiceDiscovery();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nRF5xServiceDiscovery::ServiceUUIDDiscoveryQueue::triggerFirst(void)
|
||||
{
|
||||
while (numIndices) { /* loop until a call to char_value_by_uuid_read() succeeds or we run out of pending indices. */
|
||||
parentDiscoveryObject->state = DISCOVER_SERVICE_UUIDS;
|
||||
|
||||
unsigned serviceIndex = getFirst();
|
||||
ble_uuid_t uuid = {
|
||||
.uuid = BLE_UUID_SERVICE_PRIMARY,
|
||||
.type = BLE_UUID_TYPE_BLE,
|
||||
};
|
||||
ble_gattc_handle_range_t handleRange = {
|
||||
.start_handle = parentDiscoveryObject->services[serviceIndex].getStartHandle(),
|
||||
.end_handle = parentDiscoveryObject->services[serviceIndex].getEndHandle(),
|
||||
};
|
||||
if (sd_ble_gattc_char_value_by_uuid_read(parentDiscoveryObject->connHandle, &uuid, &handleRange) == NRF_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Skip this service if we fail to launch a read for its service-declaration
|
||||
* attribute. Its UUID will remain INVALID, and it may not match any filters. */
|
||||
dequeue();
|
||||
}
|
||||
|
||||
/* Switch back to service discovery upon exhausting the service-indices pending UUID discovery. */
|
||||
if (parentDiscoveryObject->state == DISCOVER_SERVICE_UUIDS) {
|
||||
parentDiscoveryObject->state = SERVICE_DISCOVERY_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nRF5xServiceDiscovery::CharUUIDDiscoveryQueue::triggerFirst(void)
|
||||
{
|
||||
while (numIndices) { /* loop until a call to char_value_by_uuid_read() succeeds or we run out of pending indices. */
|
||||
parentDiscoveryObject->state = DISCOVER_CHARACTERISTIC_UUIDS;
|
||||
|
||||
unsigned charIndex = getFirst();
|
||||
ble_uuid_t uuid = {
|
||||
.uuid = BLE_UUID_CHARACTERISTIC,
|
||||
.type = BLE_UUID_TYPE_BLE,
|
||||
};
|
||||
ble_gattc_handle_range_t handleRange = { };
|
||||
handleRange.start_handle = parentDiscoveryObject->characteristics[charIndex].getDeclHandle();
|
||||
handleRange.end_handle = parentDiscoveryObject->characteristics[charIndex].getDeclHandle() + 1;
|
||||
if (sd_ble_gattc_char_value_by_uuid_read(parentDiscoveryObject->connHandle, &uuid, &handleRange) == NRF_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Skip this service if we fail to launch a read for its service-declaration
|
||||
* attribute. Its UUID will remain INVALID, and it may not match any filters. */
|
||||
dequeue();
|
||||
}
|
||||
|
||||
/* Switch back to service discovery upon exhausting the service-indices pending UUID discovery. */
|
||||
if (parentDiscoveryObject->state == DISCOVER_CHARACTERISTIC_UUIDS) {
|
||||
parentDiscoveryObject->state = CHARACTERISTIC_DISCOVERY_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nRF5xServiceDiscovery::processDiscoverUUIDResponse(const ble_gattc_evt_char_val_by_uuid_read_rsp_t *response)
|
||||
{
|
||||
if (state == DISCOVER_SERVICE_UUIDS) {
|
||||
if ((response->count == 1) && (response->value_len == UUID::LENGTH_OF_LONG_UUID)) {
|
||||
UUID::LongUUIDBytes_t uuid;
|
||||
memcpy(uuid, response->handle_value[0].p_value, UUID::LENGTH_OF_LONG_UUID);
|
||||
|
||||
unsigned serviceIndex = serviceUUIDDiscoveryQueue.dequeue();
|
||||
services[serviceIndex].setupLongUUID(uuid, UUID::LSB);
|
||||
|
||||
serviceUUIDDiscoveryQueue.triggerFirst();
|
||||
} else {
|
||||
serviceUUIDDiscoveryQueue.dequeue();
|
||||
}
|
||||
} else if (state == DISCOVER_CHARACTERISTIC_UUIDS) {
|
||||
if ((response->count == 1) && (response->value_len == UUID::LENGTH_OF_LONG_UUID + 1 /* props */ + 2 /* value handle */)) {
|
||||
UUID::LongUUIDBytes_t uuid;
|
||||
|
||||
memcpy(uuid, &(response->handle_value[0].p_value[3]), UUID::LENGTH_OF_LONG_UUID);
|
||||
|
||||
unsigned charIndex = charUUIDDiscoveryQueue.dequeue();
|
||||
characteristics[charIndex].setupLongUUID(uuid, UUID::LSB);
|
||||
|
||||
charUUIDDiscoveryQueue.triggerFirst();
|
||||
} else {
|
||||
charUUIDDiscoveryQueue.dequeue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,366 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 __NRF_SERVICE_DISCOVERY_H__
|
||||
#define __NRF_SERVICE_DISCOVERY_H__
|
||||
|
||||
#include "ble/ServiceDiscovery.h"
|
||||
#include "ble/DiscoveredService.h"
|
||||
#include "nRF5xDiscoveredCharacteristic.h"
|
||||
|
||||
#include "nrf_ble.h"
|
||||
#include "nrf_ble_gattc.h"
|
||||
|
||||
class nRF5xGattClient; /* forward declaration */
|
||||
|
||||
class nRF5xServiceDiscovery : public ServiceDiscovery
|
||||
{
|
||||
public:
|
||||
static const uint16_t SRV_DISC_START_HANDLE = 0x0001; /**< The start handle value used during service discovery. */
|
||||
static const uint16_t SRV_DISC_END_HANDLE = 0xFFFF; /**< The end handle value used during service discovery. */
|
||||
|
||||
public:
|
||||
static const unsigned BLE_DB_DISCOVERY_MAX_SRV = 4; /**< Maximum number of services we can retain information for after a single discovery. */
|
||||
static const unsigned BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV = 4; /**< Maximum number of characteristics per service we can retain information for. */
|
||||
|
||||
public:
|
||||
nRF5xServiceDiscovery(nRF5xGattClient *gattcIn) :
|
||||
gattc(gattcIn),
|
||||
serviceIndex(0),
|
||||
numServices(0),
|
||||
numCharacteristics(0),
|
||||
state(INACTIVE),
|
||||
services(),
|
||||
characteristics(),
|
||||
serviceUUIDDiscoveryQueue(this),
|
||||
charUUIDDiscoveryQueue(this),
|
||||
onTerminationCallback(NULL) {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
virtual ble_error_t launch(Gap::Handle_t connectionHandle,
|
||||
ServiceDiscovery::ServiceCallback_t sc,
|
||||
ServiceDiscovery::CharacteristicCallback_t cc,
|
||||
const UUID &matchingServiceUUIDIn,
|
||||
const UUID &matchingCharacteristicUUIDIn)
|
||||
{
|
||||
if (isActive()) {
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
serviceCallback = sc;
|
||||
characteristicCallback = cc;
|
||||
matchingServiceUUID = matchingServiceUUIDIn;
|
||||
matchingCharacteristicUUID = matchingCharacteristicUUIDIn;
|
||||
|
||||
serviceDiscoveryStarted(connectionHandle);
|
||||
|
||||
uint32_t rc;
|
||||
if ((rc = sd_ble_gattc_primary_services_discover(connectionHandle, SRV_DISC_START_HANDLE, NULL)) != NRF_SUCCESS) {
|
||||
terminate();
|
||||
switch (rc) {
|
||||
case NRF_ERROR_INVALID_PARAM:
|
||||
case BLE_ERROR_INVALID_CONN_HANDLE:
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
case NRF_ERROR_BUSY:
|
||||
return BLE_STACK_BUSY;
|
||||
default:
|
||||
case NRF_ERROR_INVALID_STATE:
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
virtual bool isActive(void) const {
|
||||
return state != INACTIVE;
|
||||
}
|
||||
|
||||
virtual void terminate(void) {
|
||||
terminateServiceDiscovery();
|
||||
}
|
||||
|
||||
void terminate(Gap::Handle_t connectionHandle) {
|
||||
if(connHandle == connectionHandle) {
|
||||
terminate();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void onTermination(ServiceDiscovery::TerminationCallback_t callback) {
|
||||
onTerminationCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear nRF5xServiceDiscovery's state.
|
||||
*
|
||||
* @return
|
||||
* BLE_ERROR_NONE if successful.
|
||||
*/
|
||||
virtual ble_error_t reset(void) {
|
||||
/* Clear all state that is from the parent, including private members */
|
||||
if (ServiceDiscovery::reset() != BLE_ERROR_NONE) {
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
/* Clear derived class members */
|
||||
serviceIndex = 0;
|
||||
numServices = 0;
|
||||
numCharacteristics = 0;
|
||||
|
||||
state = INACTIVE;
|
||||
|
||||
serviceUUIDDiscoveryQueue.reset();
|
||||
charUUIDDiscoveryQueue.reset();
|
||||
|
||||
onTerminationCallback = NULL;
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
private:
|
||||
ble_error_t launchCharacteristicDiscovery(Gap::Handle_t connectionHandle, Gap::Handle_t startHandle, Gap::Handle_t endHandle);
|
||||
|
||||
private:
|
||||
void setupDiscoveredServices(const ble_gattc_evt_prim_srvc_disc_rsp_t *response);
|
||||
void setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response);
|
||||
|
||||
void triggerServiceUUIDDiscovery(void);
|
||||
void processDiscoverUUIDResponse(const ble_gattc_evt_char_val_by_uuid_read_rsp_t *response);
|
||||
void removeFirstServiceNeedingUUIDDiscovery(void);
|
||||
|
||||
void terminateServiceDiscovery(void) {
|
||||
discoveredCharacteristic = nRF5xDiscoveredCharacteristic();
|
||||
|
||||
bool wasActive = isActive();
|
||||
state = INACTIVE;
|
||||
|
||||
if (wasActive && onTerminationCallback) {
|
||||
onTerminationCallback(connHandle);
|
||||
}
|
||||
}
|
||||
|
||||
void terminateCharacteristicDiscovery(ble_error_t err) {
|
||||
if (state == CHARACTERISTIC_DISCOVERY_ACTIVE) {
|
||||
if(discoveredCharacteristic != nRF5xDiscoveredCharacteristic()) {
|
||||
if(err == BLE_ERROR_NONE) {
|
||||
// fullfill the last characteristic
|
||||
discoveredCharacteristic.setLastHandle(services[serviceIndex].getEndHandle());
|
||||
|
||||
if ((matchingCharacteristicUUID == UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) ||
|
||||
((matchingCharacteristicUUID == discoveredCharacteristic.getUUID()) &&
|
||||
(matchingServiceUUID != UUID::ShortUUIDBytes_t(BLE_UUID_UNKNOWN)))) {
|
||||
if (characteristicCallback) {
|
||||
characteristicCallback(&discoveredCharacteristic);
|
||||
}
|
||||
}
|
||||
}
|
||||
discoveredCharacteristic = nRF5xDiscoveredCharacteristic();
|
||||
}
|
||||
|
||||
state = SERVICE_DISCOVERY_ACTIVE;
|
||||
}
|
||||
serviceIndex++; /* Progress service index to keep discovery alive. */
|
||||
}
|
||||
|
||||
private:
|
||||
void resetDiscoveredServices(void) {
|
||||
numServices = 0;
|
||||
serviceIndex = 0;
|
||||
}
|
||||
|
||||
void resetDiscoveredCharacteristics(void) {
|
||||
numCharacteristics = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
void serviceDiscoveryStarted(Gap::Handle_t connectionHandle) {
|
||||
connHandle = connectionHandle;
|
||||
resetDiscoveredServices();
|
||||
state = SERVICE_DISCOVERY_ACTIVE;
|
||||
}
|
||||
|
||||
private:
|
||||
void characteristicDiscoveryStarted(Gap::Handle_t connectionHandle) {
|
||||
connHandle = connectionHandle;
|
||||
resetDiscoveredCharacteristics();
|
||||
state = CHARACTERISTIC_DISCOVERY_ACTIVE;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* A datatype to contain service-indices for which long UUIDs need to be
|
||||
* discovered using read_val_by_uuid().
|
||||
*/
|
||||
class ServiceUUIDDiscoveryQueue {
|
||||
public:
|
||||
ServiceUUIDDiscoveryQueue(nRF5xServiceDiscovery *parent) :
|
||||
numIndices(0),
|
||||
serviceIndices(),
|
||||
parentDiscoveryObject(parent) {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
public:
|
||||
void reset(void) {
|
||||
numIndices = 0;
|
||||
for (unsigned i = 0; i < BLE_DB_DISCOVERY_MAX_SRV; i++) {
|
||||
serviceIndices[i] = INVALID_INDEX;
|
||||
}
|
||||
}
|
||||
void enqueue(int serviceIndex) {
|
||||
serviceIndices[numIndices++] = serviceIndex;
|
||||
}
|
||||
int dequeue(void) {
|
||||
if (numIndices == 0) {
|
||||
return INVALID_INDEX;
|
||||
}
|
||||
|
||||
unsigned valueToReturn = serviceIndices[0];
|
||||
numIndices--;
|
||||
for (unsigned i = 0; i < numIndices; i++) {
|
||||
serviceIndices[i] = serviceIndices[i + 1];
|
||||
}
|
||||
|
||||
return valueToReturn;
|
||||
}
|
||||
unsigned getFirst(void) const {
|
||||
return serviceIndices[0];
|
||||
}
|
||||
size_t getCount(void) const {
|
||||
return numIndices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger UUID discovery for the first of the enqueued ServiceIndices.
|
||||
*/
|
||||
void triggerFirst(void);
|
||||
|
||||
private:
|
||||
static const int INVALID_INDEX = -1;
|
||||
|
||||
private:
|
||||
size_t numIndices;
|
||||
int serviceIndices[BLE_DB_DISCOVERY_MAX_SRV];
|
||||
|
||||
nRF5xServiceDiscovery *parentDiscoveryObject;
|
||||
};
|
||||
friend class ServiceUUIDDiscoveryQueue;
|
||||
|
||||
/**
|
||||
* A datatype to contain characteristic-indices for which long UUIDs need to
|
||||
* be discovered using read_val_by_uuid().
|
||||
*/
|
||||
class CharUUIDDiscoveryQueue {
|
||||
public:
|
||||
CharUUIDDiscoveryQueue(nRF5xServiceDiscovery *parent) :
|
||||
numIndices(0),
|
||||
charIndices(),
|
||||
parentDiscoveryObject(parent) {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
public:
|
||||
void reset(void) {
|
||||
numIndices = 0;
|
||||
for (unsigned i = 0; i < BLE_DB_DISCOVERY_MAX_SRV; i++) {
|
||||
charIndices[i] = INVALID_INDEX;
|
||||
}
|
||||
}
|
||||
void enqueue(int serviceIndex) {
|
||||
charIndices[numIndices++] = serviceIndex;
|
||||
}
|
||||
int dequeue(void) {
|
||||
if (numIndices == 0) {
|
||||
return INVALID_INDEX;
|
||||
}
|
||||
|
||||
unsigned valueToReturn = charIndices[0];
|
||||
numIndices--;
|
||||
for (unsigned i = 0; i < numIndices; i++) {
|
||||
charIndices[i] = charIndices[i + 1];
|
||||
}
|
||||
|
||||
return valueToReturn;
|
||||
}
|
||||
unsigned getFirst(void) const {
|
||||
return charIndices[0];
|
||||
}
|
||||
size_t getCount(void) const {
|
||||
return numIndices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger UUID discovery for the first of the enqueued charIndices.
|
||||
*/
|
||||
void triggerFirst(void);
|
||||
|
||||
private:
|
||||
static const int INVALID_INDEX = -1;
|
||||
|
||||
private:
|
||||
size_t numIndices;
|
||||
int charIndices[BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV];
|
||||
|
||||
nRF5xServiceDiscovery *parentDiscoveryObject;
|
||||
};
|
||||
friend class CharUUIDDiscoveryQueue;
|
||||
|
||||
private:
|
||||
friend void bleGattcEventHandler(const ble_evt_t *p_ble_evt);
|
||||
void progressCharacteristicDiscovery(void);
|
||||
void progressServiceDiscovery(void);
|
||||
|
||||
private:
|
||||
nRF5xGattClient *gattc;
|
||||
|
||||
private:
|
||||
uint8_t serviceIndex; /**< Index of the current service being discovered. This is intended for internal use during service discovery.*/
|
||||
uint8_t numServices; /**< Number of services at the peers GATT database.*/
|
||||
uint8_t numCharacteristics; /**< Number of characteristics within the service.*/
|
||||
|
||||
enum State_t {
|
||||
INACTIVE,
|
||||
SERVICE_DISCOVERY_ACTIVE,
|
||||
CHARACTERISTIC_DISCOVERY_ACTIVE,
|
||||
DISCOVER_SERVICE_UUIDS,
|
||||
DISCOVER_CHARACTERISTIC_UUIDS,
|
||||
} state;
|
||||
|
||||
DiscoveredService services[BLE_DB_DISCOVERY_MAX_SRV]; /**< Information related to the current service being discovered.
|
||||
* This is intended for internal use during service discovery. */
|
||||
nRF5xDiscoveredCharacteristic characteristics[BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV];
|
||||
|
||||
ServiceUUIDDiscoveryQueue serviceUUIDDiscoveryQueue;
|
||||
CharUUIDDiscoveryQueue charUUIDDiscoveryQueue;
|
||||
|
||||
TerminationCallback_t onTerminationCallback;
|
||||
|
||||
/*
|
||||
* The currently discovered characteristic. Discovery of a characteristic
|
||||
* is a two phase process.
|
||||
* First, declaration handle is fetched, it provide the UUID, the value handle and
|
||||
* the properties of a characteristic.
|
||||
* Second, the next declaration handle is fetched, with its declaration handle, it is
|
||||
* possible to compute the last handle of the discovered characteristic and fill the
|
||||
* missing part of the object.
|
||||
* If there is no remaining characteristic to discover, the last handle of the
|
||||
* discovered characteristic will be set to the last handle of its enclosing service.
|
||||
*/
|
||||
nRF5xDiscoveredCharacteristic discoveredCharacteristic;
|
||||
};
|
||||
|
||||
#endif /*__NRF_SERVICE_DISCOVERY_H__*/
|
|
@ -0,0 +1,220 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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.
|
||||
*/
|
||||
|
||||
#ifdef YOTTA_CFG_MBED_OS
|
||||
#include "mbed-drivers/mbed.h"
|
||||
#else
|
||||
#include "mbed.h"
|
||||
#endif
|
||||
#include "nRF5xn.h"
|
||||
#include "ble/blecommon.h"
|
||||
#include "nrf_soc.h"
|
||||
|
||||
#include "btle/btle.h"
|
||||
#include "btle/custom/custom_helper.h"
|
||||
#include "nrf_delay.h"
|
||||
|
||||
extern "C" {
|
||||
#include "softdevice_handler.h"
|
||||
}
|
||||
|
||||
/**
|
||||
* The singleton which represents the nRF51822 transport for the BLE.
|
||||
*/
|
||||
static nRF5xn deviceInstance;
|
||||
|
||||
/**
|
||||
* BLE-API requires an implementation of the following function in order to
|
||||
* obtain its transport handle.
|
||||
*/
|
||||
BLEInstanceBase *
|
||||
createBLEInstance(void)
|
||||
{
|
||||
return &nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
|
||||
}
|
||||
|
||||
nRF5xn& nRF5xn::Instance(BLE::InstanceID_t instanceId)
|
||||
{
|
||||
return deviceInstance;
|
||||
}
|
||||
|
||||
nRF5xn::nRF5xn(void) :
|
||||
initialized(false),
|
||||
instanceID(BLE::DEFAULT_INSTANCE),
|
||||
gapInstance(),
|
||||
gattServerInstance(NULL),
|
||||
gattClientInstance(NULL),
|
||||
securityManagerInstance(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
nRF5xn::~nRF5xn(void)
|
||||
{
|
||||
}
|
||||
|
||||
const char *nRF5xn::getVersion(void)
|
||||
{
|
||||
if (!initialized) {
|
||||
return "INITIALIZATION_INCOMPLETE";
|
||||
}
|
||||
|
||||
static char versionString[32];
|
||||
static bool versionFetched = false;
|
||||
|
||||
if (!versionFetched) {
|
||||
ble_version_t version;
|
||||
if ((sd_ble_version_get(&version) == NRF_SUCCESS) && (version.company_id == 0x0059)) {
|
||||
switch (version.version_number) {
|
||||
case 0x07:
|
||||
case 0x08:
|
||||
snprintf(versionString, sizeof(versionString), "Nordic BLE4.1 ver:%u fw:%04x", version.version_number, version.subversion_number);
|
||||
break;
|
||||
default:
|
||||
snprintf(versionString, sizeof(versionString), "Nordic (spec unknown) ver:%u fw:%04x", version.version_number, version.subversion_number);
|
||||
break;
|
||||
}
|
||||
versionFetched = true;
|
||||
} else {
|
||||
strncpy(versionString, "unknown", sizeof(versionString));
|
||||
}
|
||||
}
|
||||
|
||||
return versionString;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initialize the BLE stack.
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE if everything executed properly and
|
||||
BLE_ERROR_ALREADY_INITIALIZED if the stack has already
|
||||
been initialized (possibly through a call to nRF5xn::init()).
|
||||
BLE_ERROR_INTERNAL_STACK_FAILURE is returned if initialization
|
||||
of the internal stack (SoftDevice) failed.
|
||||
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xn::init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> callback)
|
||||
{
|
||||
if (initialized) {
|
||||
BLE::InitializationCompleteCallbackContext context = {
|
||||
BLE::Instance(instanceID),
|
||||
BLE_ERROR_ALREADY_INITIALIZED
|
||||
};
|
||||
callback.call(&context);
|
||||
return BLE_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
instanceID = instanceID;
|
||||
|
||||
/* ToDo: Clear memory contents, reset the SD, etc. */
|
||||
if (btle_init() != ERROR_NONE) {
|
||||
return BLE_ERROR_INTERNAL_STACK_FAILURE;
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
BLE::InitializationCompleteCallbackContext context = {
|
||||
BLE::Instance(instanceID),
|
||||
BLE_ERROR_NONE
|
||||
};
|
||||
callback.call(&context);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Purge the BLE stack of GATT and GAP state.
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
@retval BLE_ERROR_NONE
|
||||
Everything executed properly
|
||||
|
||||
@note When using S110, GattClient::shutdown() will not be called
|
||||
since Gatt client features are not supported.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
ble_error_t nRF5xn::shutdown(void)
|
||||
{
|
||||
if (!initialized) {
|
||||
return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shutdown the SoftDevice first. This is because we need to disable all
|
||||
* interrupts. Otherwise if we clear the BLE API and glue code first there
|
||||
* will be many NULL references and no config information which could lead
|
||||
* to errors if the shutdown process is interrupted.
|
||||
*/
|
||||
if (softdevice_handler_sd_disable() != NRF_SUCCESS) {
|
||||
return BLE_STACK_BUSY;
|
||||
}
|
||||
|
||||
|
||||
/* Shutdown the BLE API and nRF51 glue code */
|
||||
ble_error_t error;
|
||||
|
||||
if (gattServerInstance != NULL) {
|
||||
error = gattServerInstance->reset();
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
if (securityManagerInstance != NULL) {
|
||||
error = securityManagerInstance->reset();
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/* S110 does not support BLE client features, nothing to reset. */
|
||||
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
|
||||
if (gattClientInstance != NULL) {
|
||||
error = gattClientInstance->reset();
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Gap instance is always present */
|
||||
error = gapInstance.reset();
|
||||
if (error != BLE_ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
|
||||
custom_reset_128bits_uuid_table();
|
||||
|
||||
initialized = false;
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
nRF5xn::waitForEvent(void)
|
||||
{
|
||||
processEvents();
|
||||
sd_app_evt_wait();
|
||||
}
|
||||
|
||||
void nRF5xn::processEvents() {
|
||||
if (isEventsSignaled) {
|
||||
isEventsSignaled = false;
|
||||
intern_softdevice_events_execute();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 __NRF51822_H__
|
||||
#define __NRF51822_H__
|
||||
|
||||
#include "ble/BLE.h"
|
||||
#include "ble/blecommon.h"
|
||||
#include "ble/BLEInstanceBase.h"
|
||||
|
||||
#include "nRF5xGap.h"
|
||||
#include "nRF5xGattServer.h"
|
||||
#include "nRF5xGattClient.h"
|
||||
#include "nRF5xSecurityManager.h"
|
||||
|
||||
#include "btle.h"
|
||||
|
||||
class nRF5xn : public BLEInstanceBase
|
||||
{
|
||||
public:
|
||||
nRF5xn(void);
|
||||
virtual ~nRF5xn(void);
|
||||
|
||||
virtual ble_error_t init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> callback);
|
||||
virtual bool hasInitialized(void) const {
|
||||
return initialized;
|
||||
}
|
||||
virtual ble_error_t shutdown(void);
|
||||
virtual const char *getVersion(void);
|
||||
|
||||
/**
|
||||
* Accessors to GAP. This function checks whether gapInstance points to an
|
||||
* object. If if does not, then the gapInstance is updated to
|
||||
* &_getInstance before returning.
|
||||
*
|
||||
* @return A reference to GattServer.
|
||||
*
|
||||
* @note Unlike the GattClient, GattServer and SecurityManager, Gap is
|
||||
* always needed in a BLE application. Therefore it is allocated
|
||||
* statically.
|
||||
*/
|
||||
virtual Gap &getGap() {
|
||||
return gapInstance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Accessors to GATT Server. This function checks whether a GattServer
|
||||
* object was previously instantiated. If such object does not exist, then
|
||||
* it is created before returning.
|
||||
*
|
||||
* @return A reference to GattServer.
|
||||
*/
|
||||
virtual GattServer &getGattServer() {
|
||||
if (gattServerInstance == NULL) {
|
||||
gattServerInstance = new nRF5xGattServer();
|
||||
}
|
||||
return *gattServerInstance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Accessors to GATT Client. This function checks whether a GattClient
|
||||
* object was previously instantiated. If such object does not exist, then
|
||||
* it is created before returning.
|
||||
*
|
||||
* @return A reference to GattClient.
|
||||
*/
|
||||
virtual nRF5xGattClient &getGattClient() {
|
||||
if (gattClientInstance == NULL) {
|
||||
gattClientInstance = new nRF5xGattClient();
|
||||
}
|
||||
return *gattClientInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessors to Security Manager. This function checks whether a SecurityManager
|
||||
* object was previously instantiated. If such object does not exist, then
|
||||
* it is created before returning.
|
||||
*
|
||||
* @return A reference to GattServer.
|
||||
*/
|
||||
virtual nRF5xSecurityManager &getSecurityManager() {
|
||||
if (securityManagerInstance == NULL) {
|
||||
securityManagerInstance = new nRF5xSecurityManager();
|
||||
}
|
||||
return *securityManagerInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessors to GAP. This function checks whether gapInstance points to an
|
||||
* object. If if does not, then the gapInstance is updated to
|
||||
* &_getInstance before returning.
|
||||
*
|
||||
* @return A const reference to GattServer.
|
||||
*
|
||||
* @note Unlike the GattClient, GattServer and SecurityManager, Gap is
|
||||
* always needed in a BLE application. Therefore it is allocated
|
||||
* statically.
|
||||
*
|
||||
* @note The accessor is able to modify the object's state because the
|
||||
* internal pointer has been declared mutable.
|
||||
*/
|
||||
virtual const nRF5xGap &getGap() const {
|
||||
return gapInstance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Accessors to GATT Server. This function checks whether a GattServer
|
||||
* object was previously instantiated. If such object does not exist, then
|
||||
* it is created before returning.
|
||||
*
|
||||
* @return A const reference to GattServer.
|
||||
*
|
||||
* @note The accessor is able to modify the object's state because the
|
||||
* internal pointer has been declared mutable.
|
||||
*/
|
||||
virtual const nRF5xGattServer &getGattServer() const {
|
||||
if (gattServerInstance == NULL) {
|
||||
gattServerInstance = new nRF5xGattServer();
|
||||
}
|
||||
return *gattServerInstance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Accessors to Security Manager. This function checks whether a SecurityManager
|
||||
* object was previously instantiated. If such object does not exist, then
|
||||
* it is created before returning.
|
||||
*
|
||||
* @return A const reference to GattServer.
|
||||
*
|
||||
* @note The accessor is able to modify the object's state because the
|
||||
* internal pointer has been declared mutable.
|
||||
*/
|
||||
virtual const nRF5xSecurityManager &getSecurityManager() const {
|
||||
if (securityManagerInstance == NULL) {
|
||||
securityManagerInstance = new nRF5xSecurityManager();
|
||||
}
|
||||
return *securityManagerInstance;
|
||||
}
|
||||
|
||||
virtual void waitForEvent(void);
|
||||
|
||||
virtual void processEvents();
|
||||
|
||||
public:
|
||||
static nRF5xn& Instance(BLE::InstanceID_t instanceId);
|
||||
|
||||
private:
|
||||
bool initialized;
|
||||
BLE::InstanceID_t instanceID;
|
||||
|
||||
private:
|
||||
mutable nRF5xGap gapInstance; /**< Gap instance whose reference is returned from a call to
|
||||
* getGap(). Unlike the GattClient, GattServer and
|
||||
* SecurityManager, Gap is always needed in a BLE application. */
|
||||
|
||||
private:
|
||||
mutable nRF5xGattServer *gattServerInstance; /**< Pointer to the GattServer object instance.
|
||||
* If NULL, then GattServer has not been initialized.
|
||||
* The pointer has been declared as 'mutable' so that
|
||||
* it can be assigned inside a 'const' function. */
|
||||
mutable nRF5xGattClient *gattClientInstance; /**< Pointer to the GattClient object instance.
|
||||
* If NULL, then GattClient has not been initialized.
|
||||
* The pointer has been declared as 'mutable' so that
|
||||
* it can be assigned inside a 'const' function. */
|
||||
mutable nRF5xSecurityManager *securityManagerInstance; /**< Pointer to the SecurityManager object instance.
|
||||
* If NULL, then SecurityManager has not been initialized.
|
||||
* The pointer has been declared as 'mutable' so that
|
||||
* it can be assigned inside a 'const' function. */
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,136 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 _PROJECTCONFIG_H_
|
||||
#define _PROJECTCONFIG_H_
|
||||
|
||||
#include "ble/GapAdvertisingData.h"
|
||||
|
||||
/*=========================================================================
|
||||
MCU & BOARD SELCTION
|
||||
|
||||
CFG_BOARD is one of the value defined in board.h
|
||||
-----------------------------------------------------------------------*/
|
||||
#define CFG_BOARD BOARD_PCA10001
|
||||
#define CFG_MCU_STRING "nRF51822"
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
CODE BASE VERSION SETTINGS
|
||||
|
||||
Please do not modify this version number. To set a version number
|
||||
for your project or firmware, change the values in your 'boards/'
|
||||
config file.
|
||||
-----------------------------------------------------------------------*/
|
||||
#define CFG_CODEBASE_VERSION_MAJOR 0
|
||||
#define CFG_CODEBASE_VERSION_MINOR 1
|
||||
#define CFG_CODEBASE_VERSION_REVISION 0
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
FIRMWARE VERSION SETTINGS
|
||||
-----------------------------------------------------------------------*/
|
||||
#define CFG_FIRMWARE_VERSION_MAJOR 0
|
||||
#define CFG_FIRMWARE_VERSION_MINOR 0
|
||||
#define CFG_FIRMWARE_VERSION_REVISION 0
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
DEBUG LEVEL
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
CFG_DEBUG Level 3: Full debug output, any failed assert
|
||||
will produce a breakpoint for the
|
||||
debugger
|
||||
Level 2: ATTR_ALWAYS_INLINE is null, ASSERT
|
||||
has text
|
||||
Level 1: ATTR_ALWAYS_INLINE is an attribute,
|
||||
ASSERT has no text
|
||||
Level 0: No debug information generated
|
||||
|
||||
-----------------------------------------------------------------------*/
|
||||
#define CFG_DEBUG (1)
|
||||
|
||||
#if (CFG_DEBUG > 3) || (CFG_DEBUG < 0)
|
||||
#error "CFG_DEBUG must be a value between 0 (no debug) and 3"
|
||||
#endif
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
GENERAL NRF51 PERIPHERAL SETTINGS
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
CFG_SCHEDULER_ENABLE Set this to 'true' or 'false' depending on
|
||||
if you use the event scheduler or not
|
||||
|
||||
-----------------------------------------------------------------------*/
|
||||
#define CFG_SCHEDULER_ENABLE false
|
||||
|
||||
/*------------------------------- GPIOTE ------------------------------*/
|
||||
#define CFG_GPIOTE_MAX_USERS 1 /**< Maximum number of users of the GPIOTE handler. */
|
||||
|
||||
/*-------------------------------- TIMER ------------------------------*/
|
||||
#define CFG_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. freq = (32768/(PRESCALER+1)) */
|
||||
#define CFG_TIMER_MAX_INSTANCE 1 /**< Maximum number of simultaneously created timers. */
|
||||
#define CFG_TIMER_OPERATION_QUEUE_SIZE 2 /**< Size of timer operation queues. */
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
BTLE SETTINGS
|
||||
-----------------------------------------------------------------------*/
|
||||
|
||||
#define CFG_BLE_TX_POWER_LEVEL 0 /**< in dBm (Valid values are -40, -20, -16, -12, -8, -4, 0, 4) */
|
||||
|
||||
/*---------------------------- BOND MANAGER ---------------------------*/
|
||||
#define CFG_BLE_BOND_FLASH_PAGE_BOND (BLE_FLASH_PAGE_END-1) /**< Flash page used for bond manager bonding information.*/
|
||||
#define CFG_BLE_BOND_FLASH_PAGE_SYS_ATTR (BLE_FLASH_PAGE_END-3) /**< Flash page used for bond manager system attribute information. TODO check if we can use BLE_FLASH_PAGE_END-2*/
|
||||
#define CFG_BLE_BOND_DELETE_BUTTON_NUM 0 /**< Button to press to delete bond details during init */
|
||||
|
||||
/*------------------------------ SECURITY -----------------------------*/
|
||||
#define CFG_BLE_SEC_PARAM_MITM 0 /**< Man In The Middle protection not required. */
|
||||
#define CFG_BLE_SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE /**< No I/O capabilities. */
|
||||
#define CFG_BLE_SEC_PARAM_OOB 0 /**< Out Of Band data not available. */
|
||||
#define CFG_BLE_SEC_PARAM_MIN_KEY_SIZE 7 /**< Minimum encryption key size. */
|
||||
#define CFG_BLE_SEC_PARAM_MAX_KEY_SIZE 16
|
||||
|
||||
/*--------------------------------- GAP -------------------------------*/
|
||||
#define CFG_GAP_APPEARANCE GapAdvertisingData::GENERIC_TAG
|
||||
#define CFG_GAP_LOCAL_NAME "nRF5x"
|
||||
|
||||
#define CFG_GAP_CONNECTION_MIN_INTERVAL_MS 50 /**< Minimum acceptable connection interval */
|
||||
#define CFG_GAP_CONNECTION_MAX_INTERVAL_MS 500 /**< Maximum acceptable connection interval */
|
||||
#define CFG_GAP_CONNECTION_SUPERVISION_TIMEOUT_MS 4000 /**< Connection supervisory timeout */
|
||||
#define CFG_GAP_CONNECTION_SLAVE_LATENCY 0 /**< Slave Latency in number of connection events. */
|
||||
|
||||
#define CFG_GAP_ADV_INTERVAL_MS 25 /**< The advertising interval in miliseconds, should be multiply of 0.625 */
|
||||
#define CFG_GAP_ADV_TIMEOUT_S 180 /**< The advertising timeout in units of seconds. */
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
VALIDATION
|
||||
-----------------------------------------------------------------------*/
|
||||
#if CFG_BLE_TX_POWER_LEVEL != -40 && CFG_BLE_TX_POWER_LEVEL != -20 && CFG_BLE_TX_POWER_LEVEL != -16 && CFG_BLE_TX_POWER_LEVEL != -12 && CFG_BLE_TX_POWER_LEVEL != -8 && CFG_BLE_TX_POWER_LEVEL != -4 && CFG_BLE_TX_POWER_LEVEL != 0 && CFG_BLE_TX_POWER_LEVEL != 4
|
||||
#error "CFG_BLE_TX_POWER_LEVEL must be -40, -20, -16, -12, -8, -4, 0 or 4"
|
||||
#endif
|
||||
/*=========================================================================*/
|
||||
|
||||
#endif /* _PROJECTCONFIG_H_ */
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2015 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.
|
||||
|
||||
message("suppressing warnings from ble-nrf51822")
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
set_target_properties(ble-nrf51822
|
||||
PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function -Wno-missing-field-initializers"
|
||||
)
|
||||
endif()
|
115
hal/targets.json
115
hal/targets.json
|
@ -1456,7 +1456,7 @@
|
|||
"extra_labels_add": ["DELTA_DFCM_NNN40"],
|
||||
"macros_add": ["TARGET_DELTA_DFCM_NNN40", "TARGET_NRF_LFCLK_RC"]
|
||||
},
|
||||
"NRF51_DK": {
|
||||
"NRF51_DK_LEGACY": {
|
||||
"supported_form_factors": ["ARDUINO"],
|
||||
"inherits": ["MCU_NRF51_32K"],
|
||||
"progen": {"target": "nrf51-dk"},
|
||||
|
@ -1837,6 +1837,119 @@
|
|||
"device_has": ["ANALOGIN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SERIAL_FC", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH"],
|
||||
"default_build": "standard"
|
||||
},
|
||||
"MCU_NRF51_UNIFIED": {
|
||||
"inherits": ["Target"],
|
||||
"core": "Cortex-M0",
|
||||
"OVERRIDE_BOOTLOADER_FILENAME": "nrf51822_bootloader.hex",
|
||||
"macros": [
|
||||
"NRF51",
|
||||
"TARGET_NRF51822",
|
||||
"BLE_STACK_SUPPORT_REQD",
|
||||
"SOFTDEVICE_PRESENT",
|
||||
"S130",
|
||||
"TARGET_MCU_NRF51822"
|
||||
],
|
||||
"MERGE_BOOTLOADER": false,
|
||||
"extra_labels": ["NORDIC", "MCU_NRF51", "MCU_NRF51822_UNIFIED", "NRF5"],
|
||||
"OUTPUT_EXT": "hex",
|
||||
"is_disk_virtual": true,
|
||||
"supported_toolchains": ["ARM", "GCC_ARM", "IAR"],
|
||||
"public": false,
|
||||
"MERGE_SOFT_DEVICE": true,
|
||||
"EXPECTED_SOFTDEVICES_WITH_OFFSETS": [
|
||||
{
|
||||
"boot": "",
|
||||
"name": "s130_nrf51_2.0.0_softdevice.hex",
|
||||
"offset": 110592
|
||||
}
|
||||
],
|
||||
"detect_code": ["1070"],
|
||||
"post_binary_hook": {
|
||||
"function": "MCU_NRF51Code.binary_hook",
|
||||
"toolchains": ["ARM_STD", "GCC_ARM", "IAR"]
|
||||
},
|
||||
"program_cycle_s": 6,
|
||||
"default_build": "small",
|
||||
"features": ["BLE"],
|
||||
"config":{
|
||||
"lf_clock_src": {
|
||||
"value": "NRF_LF_SRC_XTAL",
|
||||
"macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC"
|
||||
}
|
||||
}
|
||||
},
|
||||
"MCU_NRF51_32K_UNIFIED": {
|
||||
"inherits": ["MCU_NRF51_UNIFIED"],
|
||||
"extra_labels_add": ["MCU_NORDIC_32K", "MCU_NRF51_32K"],
|
||||
"macros_add": ["TARGET_MCU_NORDIC_32K", "TARGET_MCU_NRF51_32K"],
|
||||
"public": false
|
||||
},
|
||||
"NRF51_DK": {
|
||||
"supported_form_factors": ["ARDUINO"],
|
||||
"inherits": ["MCU_NRF51_32K_UNIFIED"],
|
||||
"progen": {"target": "nrf51-dk"},
|
||||
"device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"]
|
||||
},
|
||||
"MCU_NRF52": {
|
||||
"inherits": ["Target"],
|
||||
"core": "Cortex-M4F",
|
||||
"macros": ["NRF52", "TARGET_NRF52832", "BLE_STACK_SUPPORT_REQD", "SOFTDEVICE_PRESENT", "S132"],
|
||||
"extra_labels": ["NORDIC", "MCU_NRF52", "MCU_NRF52832", "NRF5"],
|
||||
"OUTPUT_EXT": "hex",
|
||||
"is_disk_virtual": true,
|
||||
"supported_toolchains": ["GCC_ARM", "ARM", "IAR"],
|
||||
"public": false,
|
||||
"detect_code": ["1101"],
|
||||
"program_cycle_s": 6,
|
||||
"MERGE_SOFT_DEVICE": true,
|
||||
"EXPECTED_SOFTDEVICES_WITH_OFFSETS": [
|
||||
{
|
||||
"boot": "",
|
||||
"name": "s132_nrf52_2.0.0_softdevice.hex",
|
||||
"offset": 114688
|
||||
}
|
||||
],
|
||||
"post_binary_hook": {
|
||||
"function": "MCU_NRF51Code.binary_hook",
|
||||
"toolchains": ["ARM_STD", "GCC_ARM", "IAR"]
|
||||
},
|
||||
"MERGE_BOOTLOADER": false,
|
||||
"features": ["BLE"],
|
||||
"config":{
|
||||
"lf_clock_src": {
|
||||
"value": "NRF_LF_SRC_XTAL",
|
||||
"macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC"
|
||||
}
|
||||
},
|
||||
"default_build": "small"
|
||||
},
|
||||
"NRF52_DK": {
|
||||
"supported_form_factors": ["ARDUINO"],
|
||||
"inherits": ["MCU_NRF52"],
|
||||
"progen": {"target": "nrf52-dk"},
|
||||
"macros_add": [
|
||||
"BOARD_PCA10040",
|
||||
"NRF52_PAN_12",
|
||||
"NRF52_PAN_15",
|
||||
"NRF52_PAN_58",
|
||||
"NRF52_PAN_55",
|
||||
"NRF52_PAN_54",
|
||||
"NRF52_PAN_31",
|
||||
"NRF52_PAN_30",
|
||||
"NRF52_PAN_51",
|
||||
"NRF52_PAN_36",
|
||||
"NRF52_PAN_53",
|
||||
"S132",
|
||||
"CONFIG_GPIO_AS_PINRESET",
|
||||
"BLE_STACK_SUPPORT_REQD",
|
||||
"SWI_DISABLE0",
|
||||
"NRF52_PAN_20",
|
||||
"NRF52_PAN_64",
|
||||
"NRF52_PAN_62",
|
||||
"NRF52_PAN_63"
|
||||
],
|
||||
"device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"]
|
||||
},
|
||||
"BLUEPILL_F103C8": {
|
||||
"core": "Cortex-M3",
|
||||
"default_toolchain": "GCC_ARM",
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
; mbed Microcontroller Library
|
||||
; Copyright (c) 2013 Nordic Semiconductor.
|
||||
;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.
|
||||
|
||||
; Description message
|
||||
|
||||
__initial_sp EQU 0x20004000
|
||||
|
||||
|
||||
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 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD POWER_CLOCK_IRQHandler ;POWER_CLOCK
|
||||
DCD RADIO_IRQHandler ;RADIO
|
||||
DCD UART0_IRQHandler ;UART0
|
||||
DCD SPI0_TWI0_IRQHandler ;SPI0_TWI0
|
||||
DCD SPI1_TWI1_IRQHandler ;SPI1_TWI1
|
||||
DCD 0 ;Reserved
|
||||
DCD GPIOTE_IRQHandler ;GPIOTE
|
||||
DCD ADC_IRQHandler ;ADC
|
||||
DCD TIMER0_IRQHandler ;TIMER0
|
||||
DCD TIMER1_IRQHandler ;TIMER1
|
||||
DCD TIMER2_IRQHandler ;TIMER2
|
||||
DCD RTC0_IRQHandler ;RTC0
|
||||
DCD TEMP_IRQHandler ;TEMP
|
||||
DCD RNG_IRQHandler ;RNG
|
||||
DCD ECB_IRQHandler ;ECB
|
||||
DCD CCM_AAR_IRQHandler ;CCM_AAR
|
||||
DCD WDT_IRQHandler ;WDT
|
||||
DCD RTC1_IRQHandler ;RTC1
|
||||
DCD QDEC_IRQHandler ;QDEC
|
||||
DCD LPCOMP_COMP_IRQHandler ;LPCOMP_COMP
|
||||
DCD SWI0_IRQHandler ;SWI0
|
||||
DCD SWI1_IRQHandler ;SWI1
|
||||
DCD SWI2_IRQHandler ;SWI2
|
||||
DCD SWI3_IRQHandler ;SWI3
|
||||
DCD SWI4_IRQHandler ;SWI4
|
||||
DCD SWI5_IRQHandler ;SWI5
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset Handler
|
||||
|
||||
NRF_POWER_RAMON_ADDRESS EQU 0x40000524 ; NRF_POWER->RAMON address
|
||||
NRF_POWER_RAMON_RAMxON_ONMODE_Msk EQU 0xF ; All RAM blocks on in onmode bit mask
|
||||
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
LDR R0, =NRF_POWER_RAMON_ADDRESS
|
||||
LDR R2, [R0]
|
||||
MOVS R1, #NRF_POWER_RAMON_RAMxON_ONMODE_Msk
|
||||
ORRS R2, R2, R1
|
||||
STR R2, [R0]
|
||||
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
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_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 POWER_CLOCK_IRQHandler [WEAK]
|
||||
EXPORT RADIO_IRQHandler [WEAK]
|
||||
EXPORT UART0_IRQHandler [WEAK]
|
||||
EXPORT SPI0_TWI0_IRQHandler [WEAK]
|
||||
EXPORT SPI1_TWI1_IRQHandler [WEAK]
|
||||
EXPORT GPIOTE_IRQHandler [WEAK]
|
||||
EXPORT ADC_IRQHandler [WEAK]
|
||||
EXPORT TIMER0_IRQHandler [WEAK]
|
||||
EXPORT TIMER1_IRQHandler [WEAK]
|
||||
EXPORT TIMER2_IRQHandler [WEAK]
|
||||
EXPORT RTC0_IRQHandler [WEAK]
|
||||
EXPORT TEMP_IRQHandler [WEAK]
|
||||
EXPORT RNG_IRQHandler [WEAK]
|
||||
EXPORT ECB_IRQHandler [WEAK]
|
||||
EXPORT CCM_AAR_IRQHandler [WEAK]
|
||||
EXPORT WDT_IRQHandler [WEAK]
|
||||
EXPORT RTC1_IRQHandler [WEAK]
|
||||
EXPORT QDEC_IRQHandler [WEAK]
|
||||
EXPORT LPCOMP_COMP_IRQHandler [WEAK]
|
||||
EXPORT SWI0_IRQHandler [WEAK]
|
||||
EXPORT SWI1_IRQHandler [WEAK]
|
||||
EXPORT SWI2_IRQHandler [WEAK]
|
||||
EXPORT SWI3_IRQHandler [WEAK]
|
||||
EXPORT SWI4_IRQHandler [WEAK]
|
||||
EXPORT SWI5_IRQHandler [WEAK]
|
||||
POWER_CLOCK_IRQHandler
|
||||
RADIO_IRQHandler
|
||||
UART0_IRQHandler
|
||||
SPI0_TWI0_IRQHandler
|
||||
SPI1_TWI1_IRQHandler
|
||||
GPIOTE_IRQHandler
|
||||
ADC_IRQHandler
|
||||
TIMER0_IRQHandler
|
||||
TIMER1_IRQHandler
|
||||
TIMER2_IRQHandler
|
||||
RTC0_IRQHandler
|
||||
TEMP_IRQHandler
|
||||
RNG_IRQHandler
|
||||
ECB_IRQHandler
|
||||
CCM_AAR_IRQHandler
|
||||
WDT_IRQHandler
|
||||
RTC1_IRQHandler
|
||||
QDEC_IRQHandler
|
||||
LPCOMP_COMP_IRQHandler
|
||||
SWI0_IRQHandler
|
||||
SWI1_IRQHandler
|
||||
SWI2_IRQHandler
|
||||
SWI3_IRQHandler
|
||||
SWI4_IRQHandler
|
||||
SWI5_IRQHandler
|
||||
|
||||
B .
|
||||
ENDP
|
||||
ALIGN
|
||||
END
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
;WITHOUT SOFTDEVICE:
|
||||
;LR_IROM1 0x00000000 0x00040000 {
|
||||
; ER_IROM1 0x00000000 0x00040000 {
|
||||
; *.o (RESET, +First)
|
||||
; *(InRoot$$Sections)
|
||||
; .ANY (+RO)
|
||||
; }
|
||||
; RW_IRAM1 0x20000000 0x00008000 {
|
||||
; .ANY (+RW +ZI)
|
||||
; }
|
||||
;}
|
||||
;
|
||||
;WITH SOFTDEVICE:
|
||||
|
||||
LR_IROM1 0x0001B000 0x0025000 {
|
||||
ER_IROM1 0x0001B000 0x0025000 {
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
}
|
||||
RW_IRAM1 0x20002ef8 0x5108 {
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
; mbed Microcontroller Library
|
||||
; Copyright (c) 2013 Nordic Semiconductor.
|
||||
;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.
|
||||
|
||||
; Description message
|
||||
|
||||
__initial_sp EQU 0x20008000
|
||||
|
||||
|
||||
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 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD POWER_CLOCK_IRQHandler ;POWER_CLOCK
|
||||
DCD RADIO_IRQHandler ;RADIO
|
||||
DCD UART0_IRQHandler ;UART0
|
||||
DCD SPI0_TWI0_IRQHandler ;SPI0_TWI0
|
||||
DCD SPI1_TWI1_IRQHandler ;SPI1_TWI1
|
||||
DCD 0 ;Reserved
|
||||
DCD GPIOTE_IRQHandler ;GPIOTE
|
||||
DCD ADC_IRQHandler ;ADC
|
||||
DCD TIMER0_IRQHandler ;TIMER0
|
||||
DCD TIMER1_IRQHandler ;TIMER1
|
||||
DCD TIMER2_IRQHandler ;TIMER2
|
||||
DCD RTC0_IRQHandler ;RTC0
|
||||
DCD TEMP_IRQHandler ;TEMP
|
||||
DCD RNG_IRQHandler ;RNG
|
||||
DCD ECB_IRQHandler ;ECB
|
||||
DCD CCM_AAR_IRQHandler ;CCM_AAR
|
||||
DCD WDT_IRQHandler ;WDT
|
||||
DCD RTC1_IRQHandler ;RTC1
|
||||
DCD QDEC_IRQHandler ;QDEC
|
||||
DCD LPCOMP_IRQHandler ;LPCOMP
|
||||
DCD SWI0_IRQHandler ;SWI0
|
||||
DCD SWI1_IRQHandler ;SWI1
|
||||
DCD SWI2_IRQHandler ;SWI2
|
||||
DCD SWI3_IRQHandler ;SWI3
|
||||
DCD SWI4_IRQHandler ;SWI4
|
||||
DCD SWI5_IRQHandler ;SWI5
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset Handler
|
||||
|
||||
NRF_POWER_RAMON_ADDRESS EQU 0x40000524 ; NRF_POWER->RAMON address
|
||||
NRF_POWER_RAMONB_ADDRESS EQU 0x40000554 ; NRF_POWER->RAMONB address
|
||||
NRF_POWER_RAMONx_RAMxON_ONMODE_Msk EQU 0x3 ; All RAM blocks on in onmode bit mask
|
||||
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
|
||||
MOVS R1, #NRF_POWER_RAMONx_RAMxON_ONMODE_Msk
|
||||
|
||||
LDR R0, =NRF_POWER_RAMON_ADDRESS
|
||||
LDR R2, [R0]
|
||||
ORRS R2, R2, R1
|
||||
STR R2, [R0]
|
||||
|
||||
LDR R0, =NRF_POWER_RAMONB_ADDRESS
|
||||
LDR R2, [R0]
|
||||
ORRS R2, R2, R1
|
||||
STR R2, [R0]
|
||||
|
||||
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
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_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 POWER_CLOCK_IRQHandler [WEAK]
|
||||
EXPORT RADIO_IRQHandler [WEAK]
|
||||
EXPORT UART0_IRQHandler [WEAK]
|
||||
EXPORT SPI0_TWI0_IRQHandler [WEAK]
|
||||
EXPORT SPI1_TWI1_IRQHandler [WEAK]
|
||||
EXPORT GPIOTE_IRQHandler [WEAK]
|
||||
EXPORT ADC_IRQHandler [WEAK]
|
||||
EXPORT TIMER0_IRQHandler [WEAK]
|
||||
EXPORT TIMER1_IRQHandler [WEAK]
|
||||
EXPORT TIMER2_IRQHandler [WEAK]
|
||||
EXPORT RTC0_IRQHandler [WEAK]
|
||||
EXPORT TEMP_IRQHandler [WEAK]
|
||||
EXPORT RNG_IRQHandler [WEAK]
|
||||
EXPORT ECB_IRQHandler [WEAK]
|
||||
EXPORT CCM_AAR_IRQHandler [WEAK]
|
||||
EXPORT WDT_IRQHandler [WEAK]
|
||||
EXPORT RTC1_IRQHandler [WEAK]
|
||||
EXPORT QDEC_IRQHandler [WEAK]
|
||||
EXPORT LPCOMP_IRQHandler [WEAK]
|
||||
EXPORT SWI0_IRQHandler [WEAK]
|
||||
EXPORT SWI1_IRQHandler [WEAK]
|
||||
EXPORT SWI2_IRQHandler [WEAK]
|
||||
EXPORT SWI3_IRQHandler [WEAK]
|
||||
EXPORT SWI4_IRQHandler [WEAK]
|
||||
EXPORT SWI5_IRQHandler [WEAK]
|
||||
POWER_CLOCK_IRQHandler
|
||||
RADIO_IRQHandler
|
||||
UART0_IRQHandler
|
||||
SPI0_TWI0_IRQHandler
|
||||
SPI1_TWI1_IRQHandler
|
||||
GPIOTE_IRQHandler
|
||||
ADC_IRQHandler
|
||||
TIMER0_IRQHandler
|
||||
TIMER1_IRQHandler
|
||||
TIMER2_IRQHandler
|
||||
RTC0_IRQHandler
|
||||
TEMP_IRQHandler
|
||||
RNG_IRQHandler
|
||||
ECB_IRQHandler
|
||||
CCM_AAR_IRQHandler
|
||||
WDT_IRQHandler
|
||||
RTC1_IRQHandler
|
||||
QDEC_IRQHandler
|
||||
LPCOMP_IRQHandler
|
||||
SWI0_IRQHandler
|
||||
SWI1_IRQHandler
|
||||
SWI2_IRQHandler
|
||||
SWI3_IRQHandler
|
||||
SWI4_IRQHandler
|
||||
SWI5_IRQHandler
|
||||
|
||||
B .
|
||||
ENDP
|
||||
ALIGN
|
||||
END
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
;WITHOUT SOFTDEVICE:
|
||||
;LR_IROM1 0x00000000 0x00040000 {
|
||||
; ER_IROM1 0x00000000 0x00040000 {
|
||||
; *.o (RESET, +First)
|
||||
; *(InRoot$$Sections)
|
||||
; .ANY (+RO)
|
||||
; }
|
||||
; RW_IRAM1 0x20000000 0x00004000 {
|
||||
; .ANY (+RW +ZI)
|
||||
; }
|
||||
;}
|
||||
;
|
||||
;WITH SOFTDEVICE:
|
||||
|
||||
LR_IROM1 0x0001B000 0x0025000 {
|
||||
ER_IROM1 0x0001B000 0x0025000 {
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
}
|
||||
RW_IRAM1 0x20002ef8 0x1108 {
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
;WITHOUT SOFTDEVICE:
|
||||
;LR_IROM1 0x00000000 0x00040000 {
|
||||
; ER_IROM1 0x00000000 0x00040000 {
|
||||
; *.o (RESET, +First)
|
||||
; *(InRoot$$Sections)
|
||||
; .ANY (+RO)
|
||||
; }
|
||||
; RW_IRAM1 0x20000000 0x00004000 {
|
||||
; .ANY (+RW +ZI)
|
||||
; }
|
||||
;}
|
||||
;
|
||||
;WITH SOFTDEVICE:
|
||||
|
||||
LR_IROM1 0x0001B000 0x0025000 {
|
||||
ER_IROM1 0x0001B000 0x0025000 {
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
}
|
||||
RW_IRAM1 0x20002ef8 0x1108 {
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/* mbed Microcontroller Library - stackheap
|
||||
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
|
||||
*
|
||||
* Setup a fixed single stack/heap memory model,
|
||||
* between the top of the RW/ZI region and the stackpointer
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rt_misc.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern char Image$$RW_IRAM1$$ZI$$Limit[];
|
||||
|
||||
extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) {
|
||||
uint32_t zi_limit = (uint32_t)Image$$RW_IRAM1$$ZI$$Limit;
|
||||
uint32_t sp_limit = __current_sp();
|
||||
|
||||
zi_limit = (zi_limit + 7) & ~0x7; // ensure zi_limit is 8-byte aligned
|
||||
|
||||
struct __initial_stackheap r;
|
||||
r.heap_base = zi_limit;
|
||||
r.heap_limit = sp_limit;
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,162 @@
|
|||
/* Linker script to configure memory regions. */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x0001B000, LENGTH = 0x25000
|
||||
RAM (rwx) : ORIGIN = 0x20002ef8, LENGTH = 0x5108
|
||||
}
|
||||
|
||||
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with other linker script that defines memory regions FLASH and RAM.
|
||||
* It references following symbols, which must be defined in code:
|
||||
* Reset_Handler : Entry of reset handler
|
||||
*
|
||||
* It defines following symbols, which code can use without definition:
|
||||
* __exidx_start
|
||||
* __exidx_end
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __preinit_array_start
|
||||
* __preinit_array_end
|
||||
* __init_array_start
|
||||
* __init_array_end
|
||||
* __fini_array_start
|
||||
* __fini_array_end
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __end__
|
||||
* end
|
||||
* __HeapLimit
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
*/
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.Vectors))
|
||||
*(.text*)
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > FLASH
|
||||
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > FLASH
|
||||
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > FLASH
|
||||
__exidx_end = .;
|
||||
|
||||
__etext = .;
|
||||
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
*(.jcr)
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
|
||||
} > RAM
|
||||
|
||||
__edata = .;
|
||||
|
||||
.fs_data :
|
||||
{
|
||||
PROVIDE(__start_fs_data = .);
|
||||
KEEP(*(.fs_data))
|
||||
PROVIDE(__stop_fs_data = .);
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > RAM
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
__HeapBase = .;
|
||||
*(.heap*)
|
||||
. = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size;
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
*(.stack*)
|
||||
} > RAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
/* Linker script to configure memory regions. */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x00018000, LENGTH = 0x28000
|
||||
RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000
|
||||
}
|
||||
|
||||
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with other linker script that defines memory regions FLASH and RAM.
|
||||
* It references following symbols, which must be defined in code:
|
||||
* Reset_Handler : Entry of reset handler
|
||||
*
|
||||
* It defines following symbols, which code can use without definition:
|
||||
* __exidx_start
|
||||
* __exidx_end
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __preinit_array_start
|
||||
* __preinit_array_end
|
||||
* __init_array_start
|
||||
* __init_array_end
|
||||
* __fini_array_start
|
||||
* __fini_array_end
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __end__
|
||||
* end
|
||||
* __HeapLimit
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
*/
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.Vectors))
|
||||
*(.text*)
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > FLASH
|
||||
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > FLASH
|
||||
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > FLASH
|
||||
__exidx_end = .;
|
||||
|
||||
__etext = .;
|
||||
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
*(.jcr)
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > RAM
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
__HeapBase = .;
|
||||
*(.heap*)
|
||||
. = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size;
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
*(.stack*)
|
||||
} > RAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
/* Linker script to configure memory regions. */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x0001C000, LENGTH = 0x24000
|
||||
RAM (rwx) : ORIGIN = 0x20002800, LENGTH = 0x1800
|
||||
}
|
||||
|
||||
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with other linker script that defines memory regions FLASH and RAM.
|
||||
* It references following symbols, which must be defined in code:
|
||||
* Reset_Handler : Entry of reset handler
|
||||
*
|
||||
* It defines following symbols, which code can use without definition:
|
||||
* __exidx_start
|
||||
* __exidx_end
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __preinit_array_start
|
||||
* __preinit_array_end
|
||||
* __init_array_start
|
||||
* __init_array_end
|
||||
* __fini_array_start
|
||||
* __fini_array_end
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __end__
|
||||
* end
|
||||
* __HeapLimit
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
*/
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.Vectors))
|
||||
*(.text*)
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > FLASH
|
||||
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > FLASH
|
||||
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > FLASH
|
||||
__exidx_end = .;
|
||||
|
||||
__etext = .;
|
||||
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
*(.jcr)
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > RAM
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
__HeapBase = .;
|
||||
*(.heap*)
|
||||
. = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size;
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (NOLOAD):
|
||||
{
|
||||
*(.stack*)
|
||||
} > RAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||
}
|
|
@ -0,0 +1,264 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
NOTE: Template files (including this one) are application specific and therefore
|
||||
expected to be copied into the application project folder prior to its use!
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.arch armv6-m
|
||||
|
||||
.section .stack
|
||||
.align 3
|
||||
#ifdef __STACK_SIZE
|
||||
.equ Stack_Size, __STACK_SIZE
|
||||
#else
|
||||
.equ Stack_Size, 2048
|
||||
#endif
|
||||
.globl Stack_Size
|
||||
.globl __StackTop
|
||||
.globl __StackLimit
|
||||
__StackLimit:
|
||||
.space Stack_Size
|
||||
.size __StackLimit, . - __StackLimit
|
||||
__StackTop:
|
||||
.size __StackTop, . - __StackTop
|
||||
|
||||
.section .heap
|
||||
.align 3
|
||||
.globl __HeapBase
|
||||
.globl __HeapLimit
|
||||
|
||||
.section .Vectors
|
||||
.align 2
|
||||
.globl __Vectors
|
||||
__Vectors:
|
||||
.long __StackTop /* Top of Stack */
|
||||
.long Reset_Handler /* Reset Handler */
|
||||
.long NMI_Handler /* NMI Handler */
|
||||
.long HardFault_Handler /* Hard Fault Handler */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long SVC_Handler /* SVCall Handler */
|
||||
.long 0 /* Reserved */
|
||||
.long 0 /* Reserved */
|
||||
.long PendSV_Handler /* PendSV Handler */
|
||||
.long SysTick_Handler /* SysTick Handler */
|
||||
|
||||
/* External Interrupts */
|
||||
.long POWER_CLOCK_IRQHandler /*POWER_CLOCK */
|
||||
.long RADIO_IRQHandler /*RADIO */
|
||||
.long UART0_IRQHandler /*UART0 */
|
||||
.long SPI0_TWI0_IRQHandler /*SPI0_TWI0 */
|
||||
.long SPI1_TWI1_IRQHandler /*SPI1_TWI1 */
|
||||
.long 0 /*Reserved */
|
||||
.long GPIOTE_IRQHandler /*GPIOTE */
|
||||
.long ADC_IRQHandler /*ADC */
|
||||
.long TIMER0_IRQHandler /*TIMER0 */
|
||||
.long TIMER1_IRQHandler /*TIMER1 */
|
||||
.long TIMER2_IRQHandler /*TIMER2 */
|
||||
.long RTC0_IRQHandler /*RTC0 */
|
||||
.long TEMP_IRQHandler /*TEMP */
|
||||
.long RNG_IRQHandler /*RNG */
|
||||
.long ECB_IRQHandler /*ECB */
|
||||
.long CCM_AAR_IRQHandler /*CCM_AAR */
|
||||
.long WDT_IRQHandler /*WDT */
|
||||
.long RTC1_IRQHandler /*RTC1 */
|
||||
.long QDEC_IRQHandler /*QDEC */
|
||||
.long LPCOMP_IRQHandler /*LPCOMP */
|
||||
.long SWI0_IRQHandler /*SWI0 */
|
||||
.long SWI1_IRQHandler /*SWI1 */
|
||||
.long SWI2_IRQHandler /*SWI2 */
|
||||
.long SWI3_IRQHandler /*SWI3 */
|
||||
.long SWI4_IRQHandler /*SWI4 */
|
||||
.long SWI5_IRQHandler /*SWI5 */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
/* Reset Handler */
|
||||
|
||||
.equ NRF_POWER_RAMON_ADDRESS, 0x40000524
|
||||
.equ NRF_POWER_RAMONB_ADDRESS, 0x40000554
|
||||
.equ NRF_POWER_RAMONx_RAMxON_ONMODE_Msk, 0x3
|
||||
|
||||
.text
|
||||
.thumb
|
||||
.thumb_func
|
||||
.align 1
|
||||
.globl Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.fnstart
|
||||
|
||||
MOVS R1, #NRF_POWER_RAMONx_RAMxON_ONMODE_Msk
|
||||
LDR R0, =NRF_POWER_RAMON_ADDRESS
|
||||
LDR R2, [R0]
|
||||
ORRS R2, R1
|
||||
STR R2, [R0]
|
||||
|
||||
LDR R0, =NRF_POWER_RAMONB_ADDRESS
|
||||
LDR R2, [R0]
|
||||
ORRS R2, R1
|
||||
STR R2, [R0]
|
||||
|
||||
/* Loop to copy data from read only memory to RAM. The ranges
|
||||
* of copy from/to are specified by following symbols evaluated in
|
||||
* linker script.
|
||||
* __etext: End of code section, i.e., begin of data sections to copy from.
|
||||
* __data_start__/__data_end__: RAM address range that data should be
|
||||
* copied to. Both must be aligned to 4 bytes boundary. */
|
||||
|
||||
ldr r1, =__etext
|
||||
ldr r2, =__data_start__
|
||||
ldr r3, =__data_end__
|
||||
|
||||
subs r3, r2
|
||||
ble .LC0
|
||||
|
||||
.LC1:
|
||||
subs r3, 4
|
||||
ldr r0, [r1,r3]
|
||||
str r0, [r2,r3]
|
||||
bgt .LC1
|
||||
.LC0:
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =_start
|
||||
BX R0
|
||||
|
||||
.pool
|
||||
.cantunwind
|
||||
.fnend
|
||||
.size Reset_Handler,.-Reset_Handler
|
||||
|
||||
.section ".text"
|
||||
|
||||
|
||||
/* Dummy Exception Handlers (infinite loops which can be modified) */
|
||||
|
||||
.weak NMI_Handler
|
||||
.type NMI_Handler, %function
|
||||
NMI_Handler:
|
||||
B .
|
||||
.size NMI_Handler, . - NMI_Handler
|
||||
|
||||
|
||||
.weak HardFault_Handler
|
||||
.type HardFault_Handler, %function
|
||||
HardFault_Handler:
|
||||
B .
|
||||
.size HardFault_Handler, . - HardFault_Handler
|
||||
|
||||
|
||||
.weak SVC_Handler
|
||||
.type SVC_Handler, %function
|
||||
SVC_Handler:
|
||||
B .
|
||||
.size SVC_Handler, . - SVC_Handler
|
||||
|
||||
|
||||
.weak PendSV_Handler
|
||||
.type PendSV_Handler, %function
|
||||
PendSV_Handler:
|
||||
B .
|
||||
.size PendSV_Handler, . - PendSV_Handler
|
||||
|
||||
|
||||
.weak SysTick_Handler
|
||||
.type SysTick_Handler, %function
|
||||
SysTick_Handler:
|
||||
B .
|
||||
.size SysTick_Handler, . - SysTick_Handler
|
||||
|
||||
|
||||
/* IRQ Handlers */
|
||||
|
||||
.globl Default_Handler
|
||||
.type Default_Handler, %function
|
||||
Default_Handler:
|
||||
B .
|
||||
.size Default_Handler, . - Default_Handler
|
||||
|
||||
.macro IRQ handler
|
||||
.weak \handler
|
||||
.set \handler, Default_Handler
|
||||
.endm
|
||||
|
||||
IRQ POWER_CLOCK_IRQHandler
|
||||
IRQ RADIO_IRQHandler
|
||||
IRQ UART0_IRQHandler
|
||||
IRQ SPI0_TWI0_IRQHandler
|
||||
IRQ SPI1_TWI1_IRQHandler
|
||||
IRQ GPIOTE_IRQHandler
|
||||
IRQ ADC_IRQHandler
|
||||
IRQ TIMER0_IRQHandler
|
||||
IRQ TIMER1_IRQHandler
|
||||
IRQ TIMER2_IRQHandler
|
||||
IRQ RTC0_IRQHandler
|
||||
IRQ TEMP_IRQHandler
|
||||
IRQ RNG_IRQHandler
|
||||
IRQ ECB_IRQHandler
|
||||
IRQ CCM_AAR_IRQHandler
|
||||
IRQ WDT_IRQHandler
|
||||
IRQ RTC1_IRQHandler
|
||||
IRQ QDEC_IRQHandler
|
||||
IRQ LPCOMP_IRQHandler
|
||||
IRQ SWI0_IRQHandler
|
||||
IRQ SWI1_IRQHandler
|
||||
IRQ SWI2_IRQHandler
|
||||
IRQ SWI3_IRQHandler
|
||||
IRQ SWI4_IRQHandler
|
||||
IRQ SWI5_IRQHandler
|
||||
|
||||
|
||||
.end
|
|
@ -0,0 +1,43 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x0001b000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x0001b0c0;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20002ef8;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x900;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define symbol __code_start_soft_device__ = 0x0;
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
keep { section .intvec };
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
block HEAP,
|
||||
block CSTACK };
|
||||
|
||||
/*This is used for mbed applications build inside the Embedded workbench
|
||||
Applications build with the python scritps use a hex merge so need to merge it
|
||||
inside the linker. The linker can only use binary files so the hex merge is not possible
|
||||
through the linker. That is why a binary is used instead of a hex image for the embedded project.
|
||||
*/
|
||||
if(isdefinedsymbol(SOFT_DEVICE_BIN))
|
||||
{
|
||||
place at address mem:__code_start_soft_device__ { section .noinit_softdevice };
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
;; Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
|
||||
;; The information contained herein is confidential property of Nordic
|
||||
;; Semiconductor ASA.Terms and conditions of usage are described in detail
|
||||
;; in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
;; Licensees are granted free, non-transferable use of the information. NO
|
||||
;; WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
;; the file.
|
||||
|
||||
;; Description message
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
;; Stack size default : 1024
|
||||
;; Heap size default : 2048
|
||||
|
||||
;; Forward declaration of sections.
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
|
||||
SECTION .intvec:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
EXTERN SystemInit
|
||||
PUBLIC __vector_table
|
||||
PUBLIC __Vectors
|
||||
PUBLIC __Vectors_End
|
||||
PUBLIC __Vectors_Size
|
||||
|
||||
DATA
|
||||
|
||||
__vector_table
|
||||
DCD sfe(CSTACK)
|
||||
DCD Reset_Handler
|
||||
DCD NMI_Handler
|
||||
DCD HardFault_Handler
|
||||
DCD 0
|
||||
DCD 0
|
||||
DCD 0
|
||||
;__vector_table_0x1c
|
||||
DCD 0
|
||||
DCD 0
|
||||
DCD 0
|
||||
DCD 0
|
||||
DCD SVC_Handler
|
||||
DCD 0
|
||||
DCD 0
|
||||
DCD PendSV_Handler
|
||||
DCD SysTick_Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD POWER_CLOCK_IRQHandler ;POWER_CLOCK
|
||||
DCD RADIO_IRQHandler ;RADIO
|
||||
DCD UART0_IRQHandler ;UART0
|
||||
DCD SPI0_TWI0_IRQHandler ;SPI0_TWI0
|
||||
DCD SPI1_TWI1_IRQHandler ;SPI1_TWI1
|
||||
DCD 0 ;Reserved
|
||||
DCD GPIOTE_IRQHandler ;GPIOTE
|
||||
DCD ADC_IRQHandler ;ADC
|
||||
DCD TIMER0_IRQHandler ;TIMER0
|
||||
DCD TIMER1_IRQHandler ;TIMER1
|
||||
DCD TIMER2_IRQHandler ;TIMER2
|
||||
DCD RTC0_IRQHandler ;RTC0
|
||||
DCD TEMP_IRQHandler ;TEMP
|
||||
DCD RNG_IRQHandler ;RNG
|
||||
DCD ECB_IRQHandler ;ECB
|
||||
DCD CCM_AAR_IRQHandler ;CCM_AAR
|
||||
DCD WDT_IRQHandler ;WDT
|
||||
DCD RTC1_IRQHandler ;RTC1
|
||||
DCD QDEC_IRQHandler ;QDEC
|
||||
DCD LPCOMP_COMP_IRQHandler ;LPCOMP_COMP
|
||||
DCD SWI0_IRQHandler ;SWI0
|
||||
DCD SWI1_IRQHandler ;SWI1
|
||||
DCD SWI2_IRQHandler ;SWI2
|
||||
DCD SWI3_IRQHandler ;SWI3
|
||||
DCD SWI4_IRQHandler ;SWI4
|
||||
DCD SWI5_IRQHandler ;SWI5
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
|
||||
|
||||
__Vectors_End
|
||||
__Vectors EQU __vector_table
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
NRF_POWER_RAMON_ADDRESS EQU 0x40000524 ; NRF_POWER->RAMON address
|
||||
NRF_POWER_RAMON_RAMxON_ONMODE_Msk EQU 0xF ; All RAM blocks on in onmode bit mask
|
||||
|
||||
; Default handlers.
|
||||
THUMB
|
||||
|
||||
PUBWEAK Reset_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(2)
|
||||
Reset_Handler
|
||||
LDR R0, =NRF_POWER_RAMON_ADDRESS
|
||||
LDR R2, [R0]
|
||||
MOVS R1, #NRF_POWER_RAMON_RAMxON_ONMODE_Msk
|
||||
ORRS R2, R2, R1
|
||||
STR R2, [R0]
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__iar_program_start
|
||||
BX R0
|
||||
|
||||
; Dummy exception handlers
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
NMI_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK HardFault_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
HardFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SVC_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SVC_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK PendSV_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
PendSV_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SysTick_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SysTick_Handler
|
||||
B .
|
||||
|
||||
; Dummy interrupt handlers
|
||||
|
||||
PUBWEAK POWER_CLOCK_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
POWER_CLOCK_IRQHandler
|
||||
B .
|
||||
PUBWEAK RADIO_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RADIO_IRQHandler
|
||||
B .
|
||||
PUBWEAK UART0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
UART0_IRQHandler
|
||||
B .
|
||||
PUBWEAK SPI0_TWI0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SPI0_TWI0_IRQHandler
|
||||
B .
|
||||
PUBWEAK SPI1_TWI1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SPI1_TWI1_IRQHandler
|
||||
B .
|
||||
PUBWEAK GPIOTE_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
GPIOTE_IRQHandler
|
||||
B .
|
||||
PUBWEAK ADC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
ADC_IRQHandler
|
||||
B .
|
||||
PUBWEAK TIMER0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIMER0_IRQHandler
|
||||
B .
|
||||
PUBWEAK TIMER1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIMER1_IRQHandler
|
||||
B .
|
||||
PUBWEAK TIMER2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIMER2_IRQHandler
|
||||
B .
|
||||
PUBWEAK RTC0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RTC0_IRQHandler
|
||||
B .
|
||||
PUBWEAK TEMP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TEMP_IRQHandler
|
||||
B .
|
||||
PUBWEAK RNG_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RNG_IRQHandler
|
||||
B .
|
||||
PUBWEAK ECB_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
ECB_IRQHandler
|
||||
B .
|
||||
PUBWEAK CCM_AAR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
CCM_AAR_IRQHandler
|
||||
B .
|
||||
PUBWEAK WDT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
WDT_IRQHandler
|
||||
B .
|
||||
PUBWEAK RTC1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RTC1_IRQHandler
|
||||
B .
|
||||
PUBWEAK QDEC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
QDEC_IRQHandler
|
||||
B .
|
||||
PUBWEAK LPCOMP_COMP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
LPCOMP_COMP_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI0_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI1_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI2_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI3_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI3_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI4_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI4_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI5_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI5_IRQHandler
|
||||
B .
|
||||
|
||||
|
||||
END
|
|
@ -0,0 +1,44 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x0001b000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x0001b0c0;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0003FFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20002ef8;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
|
||||
/*-Sizes-*/
|
||||
/*Heap 1/4 of ram and stack 1/8*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0xc00;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x1800;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define symbol __code_start_soft_device__ = 0x0;
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
keep { section .intvec };
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
block HEAP,
|
||||
block CSTACK };
|
||||
|
||||
/*This is used for mbed applications build inside the Embedded workbench
|
||||
Applications build with the python scritps use a hex merge so need to merge it
|
||||
inside the linker. The linker can only use binary files so the hex merge is not possible
|
||||
through the linker. That is why a binary is used instead of a hex image for the embedded project.
|
||||
*/
|
||||
if(isdefinedsymbol(SOFT_DEVICE_BIN))
|
||||
{
|
||||
place at address mem:__code_start_soft_device__ { section .noinit_softdevice };
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
;; Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
|
||||
;; The information contained herein is confidential property of Nordic
|
||||
;; Semiconductor ASA.Terms and conditions of usage are described in detail
|
||||
;; in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
;; Licensees are granted free, non-transferable use of the information. NO
|
||||
;; WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
;; the file.
|
||||
|
||||
;; Description message
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
;; Stack size default : 1024
|
||||
;; Heap size default : 2048
|
||||
|
||||
;; Forward declaration of sections.
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
|
||||
SECTION .intvec:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
EXTERN SystemInit
|
||||
PUBLIC __vector_table
|
||||
PUBLIC __Vectors
|
||||
PUBLIC __Vectors_End
|
||||
PUBLIC __Vectors_Size
|
||||
|
||||
DATA
|
||||
|
||||
__vector_table
|
||||
DCD sfe(CSTACK)
|
||||
DCD Reset_Handler
|
||||
DCD NMI_Handler
|
||||
DCD HardFault_Handler
|
||||
DCD 0
|
||||
DCD 0
|
||||
DCD 0
|
||||
;__vector_table_0x1c
|
||||
DCD 0
|
||||
DCD 0
|
||||
DCD 0
|
||||
DCD 0
|
||||
DCD SVC_Handler
|
||||
DCD 0
|
||||
DCD 0
|
||||
DCD PendSV_Handler
|
||||
DCD SysTick_Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD POWER_CLOCK_IRQHandler ;POWER_CLOCK
|
||||
DCD RADIO_IRQHandler ;RADIO
|
||||
DCD UART0_IRQHandler ;UART0
|
||||
DCD SPI0_TWI0_IRQHandler ;SPI0_TWI0
|
||||
DCD SPI1_TWI1_IRQHandler ;SPI1_TWI1
|
||||
DCD 0 ;Reserved
|
||||
DCD GPIOTE_IRQHandler ;GPIOTE
|
||||
DCD ADC_IRQHandler ;ADC
|
||||
DCD TIMER0_IRQHandler ;TIMER0
|
||||
DCD TIMER1_IRQHandler ;TIMER1
|
||||
DCD TIMER2_IRQHandler ;TIMER2
|
||||
DCD RTC0_IRQHandler ;RTC0
|
||||
DCD TEMP_IRQHandler ;TEMP
|
||||
DCD RNG_IRQHandler ;RNG
|
||||
DCD ECB_IRQHandler ;ECB
|
||||
DCD CCM_AAR_IRQHandler ;CCM_AAR
|
||||
DCD WDT_IRQHandler ;WDT
|
||||
DCD RTC1_IRQHandler ;RTC1
|
||||
DCD QDEC_IRQHandler ;QDEC
|
||||
DCD LPCOMP_COMP_IRQHandler ;LPCOMP_COMP
|
||||
DCD SWI0_IRQHandler ;SWI0
|
||||
DCD SWI1_IRQHandler ;SWI1
|
||||
DCD SWI2_IRQHandler ;SWI2
|
||||
DCD SWI3_IRQHandler ;SWI3
|
||||
DCD SWI4_IRQHandler ;SWI4
|
||||
DCD SWI5_IRQHandler ;SWI5
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
DCD 0 ;Reserved
|
||||
|
||||
|
||||
__Vectors_End
|
||||
__Vectors EQU __vector_table
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
NRF_POWER_RAMON_ADDRESS EQU 0x40000524 ; NRF_POWER->RAMON address
|
||||
NRF_POWER_RAMON_RAMxON_ONMODE_Msk EQU 0xF ; All RAM blocks on in onmode bit mask
|
||||
|
||||
; Default handlers.
|
||||
THUMB
|
||||
|
||||
PUBWEAK Reset_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(2)
|
||||
Reset_Handler
|
||||
LDR R0, =NRF_POWER_RAMON_ADDRESS
|
||||
LDR R2, [R0]
|
||||
MOVS R1, #NRF_POWER_RAMON_RAMxON_ONMODE_Msk
|
||||
ORRS R2, R2, R1
|
||||
STR R2, [R0]
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__iar_program_start
|
||||
BX R0
|
||||
|
||||
; Dummy exception handlers
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
NMI_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK HardFault_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
HardFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SVC_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SVC_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK PendSV_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
PendSV_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SysTick_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SysTick_Handler
|
||||
B .
|
||||
|
||||
; Dummy interrupt handlers
|
||||
|
||||
PUBWEAK POWER_CLOCK_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
POWER_CLOCK_IRQHandler
|
||||
B .
|
||||
PUBWEAK RADIO_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RADIO_IRQHandler
|
||||
B .
|
||||
PUBWEAK UART0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
UART0_IRQHandler
|
||||
B .
|
||||
PUBWEAK SPI0_TWI0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SPI0_TWI0_IRQHandler
|
||||
B .
|
||||
PUBWEAK SPI1_TWI1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SPI1_TWI1_IRQHandler
|
||||
B .
|
||||
PUBWEAK GPIOTE_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
GPIOTE_IRQHandler
|
||||
B .
|
||||
PUBWEAK ADC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
ADC_IRQHandler
|
||||
B .
|
||||
PUBWEAK TIMER0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIMER0_IRQHandler
|
||||
B .
|
||||
PUBWEAK TIMER1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIMER1_IRQHandler
|
||||
B .
|
||||
PUBWEAK TIMER2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIMER2_IRQHandler
|
||||
B .
|
||||
PUBWEAK RTC0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RTC0_IRQHandler
|
||||
B .
|
||||
PUBWEAK TEMP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TEMP_IRQHandler
|
||||
B .
|
||||
PUBWEAK RNG_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RNG_IRQHandler
|
||||
B .
|
||||
PUBWEAK ECB_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
ECB_IRQHandler
|
||||
B .
|
||||
PUBWEAK CCM_AAR_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
CCM_AAR_IRQHandler
|
||||
B .
|
||||
PUBWEAK WDT_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
WDT_IRQHandler
|
||||
B .
|
||||
PUBWEAK RTC1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RTC1_IRQHandler
|
||||
B .
|
||||
PUBWEAK QDEC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
QDEC_IRQHandler
|
||||
B .
|
||||
PUBWEAK LPCOMP_COMP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
LPCOMP_COMP_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI0_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI1_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI2_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI3_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI3_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI4_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI4_IRQHandler
|
||||
B .
|
||||
PUBWEAK SWI5_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SWI5_IRQHandler
|
||||
B .
|
||||
|
||||
|
||||
END
|
|
@ -0,0 +1,13 @@
|
|||
/* mbed Microcontroller Library - CMSIS
|
||||
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
|
||||
*
|
||||
* A generic CMSIS include header, pulling in LPC407x_8x specifics
|
||||
*/
|
||||
|
||||
#ifndef MBED_CMSIS_H
|
||||
#define MBED_CMSIS_H
|
||||
|
||||
#include "nrf.h"
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,103 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2011 ARM Limited. All rights reserved.
|
||||
* 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 ARM Limited 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 "cmsis_nvic.h"
|
||||
|
||||
/* In the M0, there is no VTOR. In the LPC range such as the LPC11U,
|
||||
* whilst the vector table may only be something like 48 entries (192 bytes, 0xC0),
|
||||
* the SYSMEMREMAP register actually remaps the memory from 0x10000000-0x100001FF
|
||||
* to adress 0x0-0x1FF. In this case, RAM can be addressed at both 0x10000000 and 0x0
|
||||
*
|
||||
* If we just copy the vectors to RAM and switch the SYSMEMMAP, any accesses to FLASH
|
||||
* above the vector table before 0x200 will actually go to RAM. So we need to provide
|
||||
* a solution where the compiler gets the right results based on the memory map
|
||||
*
|
||||
* Option 1 - We allocate and copy 0x200 of RAM rather than just the table
|
||||
* - const data and instructions before 0x200 will be copied to and fetched/exec from RAM
|
||||
* - RAM overhead: 0x200 - 0xC0 = 320 bytes, FLASH overhead: 0
|
||||
*
|
||||
* Option 2 - We pad the flash to 0x200 to ensure the compiler doesn't allocate anything there
|
||||
* - No flash accesses will go to ram, as there will be nothing there
|
||||
* - RAM only needs to be allocated for the vectors, as all other ram addresses are normal
|
||||
* - RAM overhead: 0, FLASH overhead: 320 bytes
|
||||
*
|
||||
* Option 2 is the one to go for, as RAM is the most valuable resource
|
||||
*/
|
||||
|
||||
|
||||
#define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Location of vectors in RAM
|
||||
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
|
||||
/*
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn) {
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
return vectors[IRQn + 16];
|
||||
}*/
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
// int i;
|
||||
// Space for dynamic vectors, initialised to allocate in R/W
|
||||
static volatile uint32_t* vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
/*
|
||||
// Copy and switch to dynamic vectors if first time called
|
||||
if((LPC_SYSCON->SYSMEMREMAP & 0x3) != 0x1) {
|
||||
uint32_t *old_vectors = (uint32_t *)0; // FLASH vectors are at 0x0
|
||||
for(i = 0; i < NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
LPC_SYSCON->SYSMEMREMAP = 0x1; // Remaps 0x0-0x1FF FLASH block to RAM block
|
||||
}*/
|
||||
|
||||
// Set the vector
|
||||
vectors[IRQn + 16] = vector;
|
||||
}
|
||||
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn) {
|
||||
// We can always read vectors at 0x0, as the addresses are remapped
|
||||
uint32_t *vectors = (uint32_t*)0;
|
||||
|
||||
// Return the vector
|
||||
return vectors[IRQn + 16];
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2011 ARM Limited. All rights reserved.
|
||||
* 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 ARM Limited 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_CMSIS_NVIC_H
|
||||
#define MBED_CMSIS_NVIC_H
|
||||
|
||||
#define NVIC_NUM_VECTORS (16 + 32) // CORE + MCU Peripherals
|
||||
#define NVIC_USER_IRQ_OFFSET 16
|
||||
|
||||
#include "nrf51.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* NOTE: Template files (including this one) are application specific and therefore expected to
|
||||
be copied into the application project folder prior to its use! */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf.h"
|
||||
#include "system_nrf51.h"
|
||||
#include "nrf5x_lf_clk_helper.h"
|
||||
|
||||
/*lint ++flb "Enter library region" */
|
||||
|
||||
|
||||
#define __SYSTEM_CLOCK (16000000UL) /*!< nRF51 devices use a fixed System Clock Frequency of 16MHz */
|
||||
|
||||
static bool is_manual_peripheral_setup_needed(void);
|
||||
static bool is_disabled_in_debug_needed(void);
|
||||
static bool is_peripheral_domain_setup_needed(void);
|
||||
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK;
|
||||
#elif defined ( __ICCARM__ )
|
||||
__root uint32_t SystemCoreClock = __SYSTEM_CLOCK;
|
||||
#elif defined ( __GNUC__ )
|
||||
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK;
|
||||
#endif
|
||||
|
||||
void SystemCoreClockUpdate(void)
|
||||
{
|
||||
SystemCoreClock = __SYSTEM_CLOCK;
|
||||
}
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* If desired, switch off the unused RAM to lower consumption by the use of RAMON register.
|
||||
It can also be done in the application main() function. */
|
||||
|
||||
/* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required
|
||||
to enable the use of peripherals" found at Product Anomaly document for your device found at
|
||||
https://www.nordicsemi.com/. The side effect of executing these instructions in the devices
|
||||
that do not need it is that the new peripherals in the second generation devices (LPCOMP for
|
||||
example) will not be available. */
|
||||
if (is_manual_peripheral_setup_needed())
|
||||
{
|
||||
*(uint32_t volatile *)0x40000504 = 0xC007FFDF;
|
||||
*(uint32_t volatile *)0x40006C18 = 0x00008000;
|
||||
}
|
||||
|
||||
/* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG
|
||||
register is incorrect" found at Product Anomaly document for your device found at
|
||||
https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. */
|
||||
if (is_disabled_in_debug_needed())
|
||||
{
|
||||
NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos;
|
||||
}
|
||||
|
||||
/* Execute the following code to eliminate excessive current in sleep mode with RAM retention in nRF51802 devices,
|
||||
as indicated by PAN 76 "System: Excessive current in sleep mode with retention" found at Product Anomaly document
|
||||
for your device found at https://www.nordicsemi.com/. */
|
||||
if (is_peripheral_domain_setup_needed()){
|
||||
if (*(uint32_t volatile *)0x4006EC00 != 1){
|
||||
*(uint32_t volatile *)0x4006EC00 = 0x9375;
|
||||
while (*(uint32_t volatile *)0x4006EC00 != 1){
|
||||
}
|
||||
}
|
||||
*(uint32_t volatile *)0x4006EC14 = 0xC0;
|
||||
}
|
||||
|
||||
// Start the LF oscilator according to the mbed configuration (over the nrf5x_lf_clk_helper.h file)
|
||||
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_TO_USE << CLOCK_LFCLKSRC_SRC_Pos);
|
||||
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
|
||||
NRF_CLOCK->TASKS_LFCLKSTART = 1;
|
||||
|
||||
// Wait for the external oscillator to start up.
|
||||
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool is_manual_peripheral_setup_needed(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x1) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x00) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x10) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool is_disabled_in_debug_needed(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x1) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool is_peripheral_domain_setup_needed(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x1) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0xA0) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0xD0) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*lint --flb "Leave library region" */
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 SYSTEM_NRF51_H
|
||||
#define SYSTEM_NRF51_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system.
|
||||
* Initialize the System and update the SystemCoreClock variable.
|
||||
*/
|
||||
extern void SystemInit (void);
|
||||
|
||||
/**
|
||||
* Update SystemCoreClock variable
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Updates the SystemCoreClock with current core Clock
|
||||
* retrieved from cpu registers.
|
||||
*/
|
||||
extern void SystemCoreClockUpdate (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSTEM_NRF51_H */
|
|
@ -0,0 +1,24 @@
|
|||
;WITHOUT SOFTDEVICE:
|
||||
;LR_IROM1 0x00000000 0x00040000 {
|
||||
; ER_IROM1 0x00000000 0x00040000 {
|
||||
; *.o (RESET, +First)
|
||||
; *(InRoot$$Sections)
|
||||
; .ANY (+RO)
|
||||
; }
|
||||
; RW_IRAM1 0x20000000 0x00004000 {
|
||||
; .ANY (+RW +ZI)
|
||||
; }
|
||||
;}
|
||||
;
|
||||
;WITH SOFTDEVICE:
|
||||
|
||||
LR_IROM1 0x1C000 0x0064000 {
|
||||
ER_IROM1 0x1C000 0x0064000 {
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
}
|
||||
RW_IRAM1 0x20002EF8 0x0000D108 {
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,443 @@
|
|||
;/* Copyright (c) 2012 ARM LIMITED
|
||||
;
|
||||
; All rights reserved.
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
; - 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.
|
||||
; - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
|
||||
; ---------------------------------------------------------------------------*/
|
||||
|
||||
__initial_sp EQU 0x20008000
|
||||
|
||||
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
|
||||
DCD NMI_Handler
|
||||
DCD HardFault_Handler
|
||||
DCD MemoryManagement_Handler
|
||||
DCD BusFault_Handler
|
||||
DCD UsageFault_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler
|
||||
DCD DebugMonitor_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler
|
||||
DCD SysTick_Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD POWER_CLOCK_IRQHandler
|
||||
DCD RADIO_IRQHandler
|
||||
DCD UARTE0_UART0_IRQHandler
|
||||
DCD SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
|
||||
DCD SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
|
||||
DCD NFCT_IRQHandler
|
||||
DCD GPIOTE_IRQHandler
|
||||
DCD SAADC_IRQHandler
|
||||
DCD TIMER0_IRQHandler
|
||||
DCD TIMER1_IRQHandler
|
||||
DCD TIMER2_IRQHandler
|
||||
DCD RTC0_IRQHandler
|
||||
DCD TEMP_IRQHandler
|
||||
DCD RNG_IRQHandler
|
||||
DCD ECB_IRQHandler
|
||||
DCD CCM_AAR_IRQHandler
|
||||
DCD WDT_IRQHandler
|
||||
DCD RTC1_IRQHandler
|
||||
DCD QDEC_IRQHandler
|
||||
DCD COMP_LPCOMP_IRQHandler
|
||||
DCD SWI0_EGU0_IRQHandler
|
||||
DCD SWI1_EGU1_IRQHandler
|
||||
DCD SWI2_EGU2_IRQHandler
|
||||
DCD SWI3_EGU3_IRQHandler
|
||||
DCD SWI4_EGU4_IRQHandler
|
||||
DCD SWI5_EGU5_IRQHandler
|
||||
DCD TIMER3_IRQHandler
|
||||
DCD TIMER4_IRQHandler
|
||||
DCD PWM0_IRQHandler
|
||||
DCD PDM_IRQHandler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD MWU_IRQHandler
|
||||
DCD PWM1_IRQHandler
|
||||
DCD PWM2_IRQHandler
|
||||
DCD SPIM2_SPIS2_SPI2_IRQHandler
|
||||
DCD RTC2_IRQHandler
|
||||
DCD I2S_IRQHandler
|
||||
DCD FPU_IRQHandler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset Handler
|
||||
|
||||
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
|
||||
|
||||
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
|
||||
MemoryManagement_Handler\
|
||||
PROC
|
||||
EXPORT MemoryManagement_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
|
||||
DebugMonitor_Handler\
|
||||
PROC
|
||||
EXPORT DebugMonitor_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 POWER_CLOCK_IRQHandler [WEAK]
|
||||
EXPORT RADIO_IRQHandler [WEAK]
|
||||
EXPORT UARTE0_UART0_IRQHandler [WEAK]
|
||||
EXPORT SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler [WEAK]
|
||||
EXPORT SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler [WEAK]
|
||||
EXPORT NFCT_IRQHandler [WEAK]
|
||||
EXPORT GPIOTE_IRQHandler [WEAK]
|
||||
EXPORT SAADC_IRQHandler [WEAK]
|
||||
EXPORT TIMER0_IRQHandler [WEAK]
|
||||
EXPORT TIMER1_IRQHandler [WEAK]
|
||||
EXPORT TIMER2_IRQHandler [WEAK]
|
||||
EXPORT RTC0_IRQHandler [WEAK]
|
||||
EXPORT TEMP_IRQHandler [WEAK]
|
||||
EXPORT RNG_IRQHandler [WEAK]
|
||||
EXPORT ECB_IRQHandler [WEAK]
|
||||
EXPORT CCM_AAR_IRQHandler [WEAK]
|
||||
EXPORT WDT_IRQHandler [WEAK]
|
||||
EXPORT RTC1_IRQHandler [WEAK]
|
||||
EXPORT QDEC_IRQHandler [WEAK]
|
||||
EXPORT COMP_LPCOMP_IRQHandler [WEAK]
|
||||
EXPORT SWI0_EGU0_IRQHandler [WEAK]
|
||||
EXPORT SWI1_EGU1_IRQHandler [WEAK]
|
||||
EXPORT SWI2_EGU2_IRQHandler [WEAK]
|
||||
EXPORT SWI3_EGU3_IRQHandler [WEAK]
|
||||
EXPORT SWI4_EGU4_IRQHandler [WEAK]
|
||||
EXPORT SWI5_EGU5_IRQHandler [WEAK]
|
||||
EXPORT TIMER3_IRQHandler [WEAK]
|
||||
EXPORT TIMER4_IRQHandler [WEAK]
|
||||
EXPORT PWM0_IRQHandler [WEAK]
|
||||
EXPORT PDM_IRQHandler [WEAK]
|
||||
EXPORT MWU_IRQHandler [WEAK]
|
||||
EXPORT PWM1_IRQHandler [WEAK]
|
||||
EXPORT PWM2_IRQHandler [WEAK]
|
||||
EXPORT SPIM2_SPIS2_SPI2_IRQHandler [WEAK]
|
||||
EXPORT RTC2_IRQHandler [WEAK]
|
||||
EXPORT I2S_IRQHandler [WEAK]
|
||||
EXPORT FPU_IRQHandler [WEAK]
|
||||
POWER_CLOCK_IRQHandler
|
||||
RADIO_IRQHandler
|
||||
UARTE0_UART0_IRQHandler
|
||||
SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
|
||||
SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
|
||||
NFCT_IRQHandler
|
||||
GPIOTE_IRQHandler
|
||||
SAADC_IRQHandler
|
||||
TIMER0_IRQHandler
|
||||
TIMER1_IRQHandler
|
||||
TIMER2_IRQHandler
|
||||
RTC0_IRQHandler
|
||||
TEMP_IRQHandler
|
||||
RNG_IRQHandler
|
||||
ECB_IRQHandler
|
||||
CCM_AAR_IRQHandler
|
||||
WDT_IRQHandler
|
||||
RTC1_IRQHandler
|
||||
QDEC_IRQHandler
|
||||
COMP_LPCOMP_IRQHandler
|
||||
SWI0_EGU0_IRQHandler
|
||||
SWI1_EGU1_IRQHandler
|
||||
SWI2_EGU2_IRQHandler
|
||||
SWI3_EGU3_IRQHandler
|
||||
SWI4_EGU4_IRQHandler
|
||||
SWI5_EGU5_IRQHandler
|
||||
TIMER3_IRQHandler
|
||||
TIMER4_IRQHandler
|
||||
PWM0_IRQHandler
|
||||
PDM_IRQHandler
|
||||
MWU_IRQHandler
|
||||
PWM1_IRQHandler
|
||||
PWM2_IRQHandler
|
||||
SPIM2_SPIS2_SPI2_IRQHandler
|
||||
RTC2_IRQHandler
|
||||
I2S_IRQHandler
|
||||
FPU_IRQHandler
|
||||
B .
|
||||
ENDP
|
||||
ALIGN
|
||||
END
|
|
@ -0,0 +1,31 @@
|
|||
/* mbed Microcontroller Library - stackheap
|
||||
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
|
||||
*
|
||||
* Setup a fixed single stack/heap memory model,
|
||||
* between the top of the RW/ZI region and the stackpointer
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rt_misc.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern char Image$$RW_IRAM1$$ZI$$Limit[];
|
||||
|
||||
extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) {
|
||||
uint32_t zi_limit = (uint32_t)Image$$RW_IRAM1$$ZI$$Limit;
|
||||
uint32_t sp_limit = __current_sp();
|
||||
|
||||
zi_limit = (zi_limit + 7) & ~0x7; // ensure zi_limit is 8-byte aligned
|
||||
|
||||
struct __initial_stackheap r;
|
||||
r.heap_base = zi_limit;
|
||||
r.heap_limit = sp_limit;
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
* Copyright (c) 2015 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.
|
||||
*/
|
||||
|
||||
/* Linker script to configure memory regions. */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x1C000, LENGTH = 0x64000
|
||||
RAM (rwx) : ORIGIN = 0x20002ef8, LENGTH = 0xd108
|
||||
}
|
||||
|
||||
|
||||
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with the other linker script that defines memory regions FLASH and RAM.
|
||||
* It references the following symbols that must be defined in code:
|
||||
* Reset_Handler : Entry of reset handler
|
||||
*
|
||||
* It defines the following symbols that the code can use without definition:
|
||||
* __exidx_start
|
||||
* __exidx_end
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __preinit_array_start
|
||||
* __preinit_array_end
|
||||
* __init_array_start
|
||||
* __init_array_end
|
||||
* __fini_array_start
|
||||
* __fini_array_end
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __end__
|
||||
* end
|
||||
* __HeapLimit
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
*/
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.Vectors))
|
||||
*(.text*)
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
. = ALIGN(4);
|
||||
} > FLASH
|
||||
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
. = ALIGN(4);
|
||||
} > FLASH
|
||||
__exidx_end = .;
|
||||
|
||||
__etext = .;
|
||||
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
*(.jcr)
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
|
||||
} > RAM
|
||||
|
||||
__edata = .;
|
||||
|
||||
.fs_data :
|
||||
{
|
||||
PROVIDE(__start_fs_data = .);
|
||||
KEEP(*(.fs_data))
|
||||
PROVIDE(__stop_fs_data = .);
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > RAM
|
||||
|
||||
.heap (NOLOAD):
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*);
|
||||
|
||||
/* Expand the heap to reach the stack boundary. */
|
||||
ASSERT(. <= (ORIGIN(RAM) + LENGTH(RAM) - 0x800), "heap region overflowed into stack");
|
||||
. += (ORIGIN(RAM) + LENGTH(RAM) - 0x800) - .;
|
||||
} > RAM
|
||||
PROVIDE(__heap_start = ADDR(.heap));
|
||||
PROVIDE(__heap_size = SIZEOF(.heap));
|
||||
PROVIDE(__mbed_sbrk_start = ADDR(.heap));
|
||||
PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap));
|
||||
|
||||
/* .stack_dummy section does not contain any symbols. It is only
|
||||
* used for the linker script to calculate the size of stack sections
|
||||
* and assign values to stack symbols later. */
|
||||
.stack (NOLOAD):
|
||||
{
|
||||
__StackLimit = .;
|
||||
*(.stack*)
|
||||
. += (ORIGIN(RAM) + LENGTH(RAM) - .);
|
||||
} > RAM
|
||||
|
||||
/* Set the stack top to the end of RAM and move down the stack limit by
|
||||
* the size of the stack_dummy section. */
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
__StackLimit = __StackTop - SIZEOF(.stack);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
}
|
|
@ -0,0 +1,467 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
NOTE: Template files (including this one) are application specific and therefore
|
||||
expected to be copied into the application project folder prior to its use!
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.arch armv7e-m
|
||||
|
||||
.section .Vectors
|
||||
.align 2
|
||||
.globl __Vectors
|
||||
__Vectors:
|
||||
.long __StackTop /* Top of Stack */
|
||||
.long Reset_Handler
|
||||
.long NMI_Handler
|
||||
.long HardFault_Handler
|
||||
.long MemoryManagement_Handler
|
||||
.long BusFault_Handler
|
||||
.long UsageFault_Handler
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long SVC_Handler
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long PendSV_Handler
|
||||
.long SysTick_Handler
|
||||
|
||||
/* External Interrupts */
|
||||
.long POWER_CLOCK_IRQHandler
|
||||
.long RADIO_IRQHandler
|
||||
.long UARTE0_UART0_IRQHandler
|
||||
.long SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
|
||||
.long SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
|
||||
.long NFCT_IRQHandler
|
||||
.long GPIOTE_IRQHandler
|
||||
.long SAADC_IRQHandler
|
||||
.long TIMER0_IRQHandler
|
||||
.long TIMER1_IRQHandler
|
||||
.long TIMER2_IRQHandler
|
||||
.long RTC0_IRQHandler
|
||||
.long TEMP_IRQHandler
|
||||
.long RNG_IRQHandler
|
||||
.long ECB_IRQHandler
|
||||
.long CCM_AAR_IRQHandler
|
||||
.long WDT_IRQHandler
|
||||
.long RTC1_IRQHandler
|
||||
.long QDEC_IRQHandler
|
||||
.long COMP_LPCOMP_IRQHandler
|
||||
.long SWI0_EGU0_IRQHandler
|
||||
.long SWI1_EGU1_IRQHandler
|
||||
.long SWI2_EGU2_IRQHandler
|
||||
.long SWI3_EGU3_IRQHandler
|
||||
.long SWI4_EGU4_IRQHandler
|
||||
.long SWI5_EGU5_IRQHandler
|
||||
.long TIMER3_IRQHandler
|
||||
.long TIMER4_IRQHandler
|
||||
.long PWM0_IRQHandler
|
||||
.long PDM_IRQHandler
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long MWU_IRQHandler
|
||||
.long PWM1_IRQHandler
|
||||
.long PWM2_IRQHandler
|
||||
.long SPIM2_SPIS2_SPI2_IRQHandler
|
||||
.long RTC2_IRQHandler
|
||||
.long I2S_IRQHandler
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
.long 0 /*Reserved */
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
/* Reset Handler */
|
||||
|
||||
.text
|
||||
.thumb
|
||||
.thumb_func
|
||||
.align 1
|
||||
.globl Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.fnstart
|
||||
|
||||
|
||||
/* Loop to copy data from read only memory to RAM. The ranges
|
||||
* of copy from/to are specified by following symbols evaluated in
|
||||
* linker script.
|
||||
* __etext: End of code section, i.e., begin of data sections to copy from.
|
||||
* __data_start__/__data_end__: RAM address range that data should be
|
||||
* copied to. Both must be aligned to 4 bytes boundary. */
|
||||
|
||||
ldr r1, =__etext
|
||||
ldr r2, =__data_start__
|
||||
ldr r3, =__data_end__
|
||||
|
||||
subs r3, r2
|
||||
ble .LC0
|
||||
|
||||
.LC1:
|
||||
subs r3, 4
|
||||
ldr r0, [r1,r3]
|
||||
str r0, [r2,r3]
|
||||
bgt .LC1
|
||||
.LC0:
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =_start
|
||||
BX R0
|
||||
|
||||
.pool
|
||||
.cantunwind
|
||||
.fnend
|
||||
.size Reset_Handler,.-Reset_Handler
|
||||
|
||||
.section ".text"
|
||||
|
||||
|
||||
/* Dummy Exception Handlers (infinite loops which can be modified) */
|
||||
|
||||
.weak NMI_Handler
|
||||
.type NMI_Handler, %function
|
||||
NMI_Handler:
|
||||
B .
|
||||
.size NMI_Handler, . - NMI_Handler
|
||||
|
||||
|
||||
.weak HardFault_Handler
|
||||
.type HardFault_Handler, %function
|
||||
HardFault_Handler:
|
||||
B .
|
||||
.size HardFault_Handler, . - HardFault_Handler
|
||||
|
||||
|
||||
.weak MemoryManagement_Handler
|
||||
.type MemoryManagement_Handler, %function
|
||||
MemoryManagement_Handler:
|
||||
B .
|
||||
.size MemoryManagement_Handler, . - MemoryManagement_Handler
|
||||
|
||||
|
||||
.weak BusFault_Handler
|
||||
.type BusFault_Handler, %function
|
||||
BusFault_Handler:
|
||||
B .
|
||||
.size BusFault_Handler, . - BusFault_Handler
|
||||
|
||||
|
||||
.weak UsageFault_Handler
|
||||
.type UsageFault_Handler, %function
|
||||
UsageFault_Handler:
|
||||
B .
|
||||
.size UsageFault_Handler, . - UsageFault_Handler
|
||||
|
||||
|
||||
.weak SVC_Handler
|
||||
.type SVC_Handler, %function
|
||||
SVC_Handler:
|
||||
B .
|
||||
.size SVC_Handler, . - SVC_Handler
|
||||
|
||||
|
||||
.weak PendSV_Handler
|
||||
.type PendSV_Handler, %function
|
||||
PendSV_Handler:
|
||||
B .
|
||||
.size PendSV_Handler, . - PendSV_Handler
|
||||
|
||||
|
||||
.weak SysTick_Handler
|
||||
.type SysTick_Handler, %function
|
||||
SysTick_Handler:
|
||||
B .
|
||||
.size SysTick_Handler, . - SysTick_Handler
|
||||
|
||||
|
||||
/* IRQ Handlers */
|
||||
|
||||
.globl Default_Handler
|
||||
.type Default_Handler, %function
|
||||
Default_Handler:
|
||||
B .
|
||||
.size Default_Handler, . - Default_Handler
|
||||
|
||||
.macro IRQ handler
|
||||
.weak \handler
|
||||
.set \handler, Default_Handler
|
||||
.endm
|
||||
|
||||
IRQ POWER_CLOCK_IRQHandler
|
||||
IRQ RADIO_IRQHandler
|
||||
IRQ UARTE0_UART0_IRQHandler
|
||||
IRQ SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
|
||||
IRQ SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
|
||||
IRQ NFCT_IRQHandler
|
||||
IRQ GPIOTE_IRQHandler
|
||||
IRQ SAADC_IRQHandler
|
||||
IRQ TIMER0_IRQHandler
|
||||
IRQ TIMER1_IRQHandler
|
||||
IRQ TIMER2_IRQHandler
|
||||
IRQ RTC0_IRQHandler
|
||||
IRQ TEMP_IRQHandler
|
||||
IRQ RNG_IRQHandler
|
||||
IRQ ECB_IRQHandler
|
||||
IRQ CCM_AAR_IRQHandler
|
||||
IRQ WDT_IRQHandler
|
||||
IRQ RTC1_IRQHandler
|
||||
IRQ QDEC_IRQHandler
|
||||
IRQ COMP_LPCOMP_IRQHandler
|
||||
IRQ SWI0_EGU0_IRQHandler
|
||||
IRQ SWI1_EGU1_IRQHandler
|
||||
IRQ SWI2_EGU2_IRQHandler
|
||||
IRQ SWI3_EGU3_IRQHandler
|
||||
IRQ SWI4_EGU4_IRQHandler
|
||||
IRQ SWI5_EGU5_IRQHandler
|
||||
IRQ TIMER3_IRQHandler
|
||||
IRQ TIMER4_IRQHandler
|
||||
IRQ PWM0_IRQHandler
|
||||
IRQ PDM_IRQHandler
|
||||
IRQ MWU_IRQHandler
|
||||
IRQ PWM1_IRQHandler
|
||||
IRQ PWM2_IRQHandler
|
||||
IRQ SPIM2_SPIS2_SPI2_IRQHandler
|
||||
IRQ RTC2_IRQHandler
|
||||
IRQ I2S_IRQHandler
|
||||
|
||||
.end
|
|
@ -0,0 +1,46 @@
|
|||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x1c000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x1c000;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x7ffff;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20002ef8;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000ffff;
|
||||
export symbol __ICFEDIT_region_RAM_start__;
|
||||
export symbol __ICFEDIT_region_RAM_end__;
|
||||
/*-Sizes-*/
|
||||
/*Heap 1/4 of ram and stack 1/8*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x800;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x1800;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
define symbol __code_start_soft_device__ = 0x0;
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
keep { section .intvec };
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
block HEAP,
|
||||
block CSTACK };
|
||||
|
||||
/*This is used for mbed applications build inside the Embedded workbench
|
||||
Applications build with the python scritps use a hex merge so need to merge it
|
||||
inside the linker. The linker can only use binary files so the hex merge is not possible
|
||||
through the linker. That is why a binary is used instead of a hex image for the embedded project.
|
||||
*/
|
||||
if(isdefinedsymbol(SOFT_DEVICE_BIN))
|
||||
{
|
||||
place at address mem:__code_start_soft_device__ { section .noinit_softdevice };
|
||||
}
|
|
@ -0,0 +1,578 @@
|
|||
;/* Copyright (c) 2012 ARM LIMITED
|
||||
;
|
||||
; All rights reserved.
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
; - 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.
|
||||
; - Neither the name of ARM 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 COPYRIGHT HOLDERS AND 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.
|
||||
; ---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
; The modules in this file are included in the libraries, and may be replaced
|
||||
; by any user-defined modules that define the PUBLIC symbol _program_start or
|
||||
; a user defined start symbol.
|
||||
; To override the cstartup defined in the library, simply add your modified
|
||||
; version to the workbench project.
|
||||
;
|
||||
; The vector table is normally located at address 0.
|
||||
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
|
||||
; The name "__vector_table" has special meaning for C-SPY:
|
||||
; it is where the SP start value is found, and the NVIC vector
|
||||
; table register (VTOR) is initialized to this address if != 0.
|
||||
|
||||
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
;; Stack size default : Defined in *.icf (linker file). Can be modified inside EW.
|
||||
;; Heap size default : Defined in *.icf (linker file). Can be modified inside EW.
|
||||
|
||||
;; Forward declaration of sections.
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
|
||||
SECTION .intvec:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
EXTERN SystemInit
|
||||
PUBLIC __vector_table
|
||||
PUBLIC __Vectors
|
||||
PUBLIC __Vectors_End
|
||||
PUBLIC __Vectors_Size
|
||||
|
||||
DATA
|
||||
|
||||
__vector_table
|
||||
DCD sfe(CSTACK)
|
||||
DCD Reset_Handler
|
||||
DCD NMI_Handler
|
||||
DCD HardFault_Handler
|
||||
DCD MemoryManagement_Handler
|
||||
DCD BusFault_Handler
|
||||
DCD UsageFault_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler
|
||||
DCD DebugMonitor_Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler
|
||||
DCD SysTick_Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD POWER_CLOCK_IRQHandler
|
||||
DCD RADIO_IRQHandler
|
||||
DCD UARTE0_UART0_IRQHandler
|
||||
DCD SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
|
||||
DCD SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
|
||||
DCD NFCT_IRQHandler
|
||||
DCD GPIOTE_IRQHandler
|
||||
DCD SAADC_IRQHandler
|
||||
DCD TIMER0_IRQHandler
|
||||
DCD TIMER1_IRQHandler
|
||||
DCD TIMER2_IRQHandler
|
||||
DCD RTC0_IRQHandler
|
||||
DCD TEMP_IRQHandler
|
||||
DCD RNG_IRQHandler
|
||||
DCD ECB_IRQHandler
|
||||
DCD CCM_AAR_IRQHandler
|
||||
DCD WDT_IRQHandler
|
||||
DCD RTC1_IRQHandler
|
||||
DCD QDEC_IRQHandler
|
||||
DCD COMP_LPCOMP_IRQHandler
|
||||
DCD SWI0_EGU0_IRQHandler
|
||||
DCD SWI1_EGU1_IRQHandler
|
||||
DCD SWI2_EGU2_IRQHandler
|
||||
DCD SWI3_EGU3_IRQHandler
|
||||
DCD SWI4_EGU4_IRQHandler
|
||||
DCD SWI5_EGU5_IRQHandler
|
||||
DCD TIMER3_IRQHandler
|
||||
DCD TIMER4_IRQHandler
|
||||
DCD PWM0_IRQHandler
|
||||
DCD PDM_IRQHandler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD MWU_IRQHandler
|
||||
DCD PWM1_IRQHandler
|
||||
DCD PWM2_IRQHandler
|
||||
DCD SPIM2_SPIS2_SPI2_IRQHandler
|
||||
DCD RTC2_IRQHandler
|
||||
DCD I2S_IRQHandler
|
||||
DCD FPU_IRQHandler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
|
||||
__Vectors_End
|
||||
__Vectors EQU __vector_table
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
|
||||
; Default handlers.
|
||||
THUMB
|
||||
|
||||
PUBWEAK Reset_Handler
|
||||
SECTION .text:CODE:NOROOT(2)
|
||||
Reset_Handler
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__iar_program_start
|
||||
BX R0
|
||||
|
||||
; Dummy exception handlers
|
||||
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
NMI_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK HardFault_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
HardFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK MemoryManagement_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
MemoryManagement_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK BusFault_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
BusFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK UsageFault_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
UsageFault_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SVC_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SVC_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK DebugMonitor_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
DebugMonitor_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK PendSV_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PendSV_Handler
|
||||
B .
|
||||
|
||||
PUBWEAK SysTick_Handler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SysTick_Handler
|
||||
B .
|
||||
|
||||
|
||||
; Dummy interrupt handlers
|
||||
|
||||
PUBWEAK POWER_CLOCK_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
POWER_CLOCK_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK RADIO_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RADIO_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK UARTE0_UART0_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
UARTE0_UART0_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK NFCT_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
NFCT_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK GPIOTE_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
GPIOTE_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SAADC_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SAADC_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER0_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER0_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER1_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER1_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER2_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER2_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK RTC0_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RTC0_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK TEMP_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TEMP_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK RNG_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RNG_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK ECB_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
ECB_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK CCM_AAR_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
CCM_AAR_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK WDT_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
WDT_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK RTC1_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RTC1_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK QDEC_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
QDEC_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK COMP_LPCOMP_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
COMP_LPCOMP_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SWI0_EGU0_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI0_EGU0_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SWI1_EGU1_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI1_EGU1_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SWI2_EGU2_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI2_EGU2_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SWI3_EGU3_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI3_EGU3_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SWI4_EGU4_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI4_EGU4_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SWI5_EGU5_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SWI5_EGU5_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER3_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER3_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK TIMER4_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
TIMER4_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK PWM0_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PWM0_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK PDM_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PDM_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK MWU_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
MWU_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK PWM1_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PWM1_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK PWM2_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
PWM2_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK SPIM2_SPIS2_SPI2_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
SPIM2_SPIS2_SPI2_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK RTC2_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
RTC2_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK I2S_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
I2S_IRQHandler
|
||||
B .
|
||||
|
||||
PUBWEAK FPU_IRQHandler
|
||||
SECTION .text:CODE:NOROOT(1)
|
||||
FPU_IRQHandler
|
||||
B .
|
||||
|
||||
|
||||
END
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* PackageLicenseDeclared: Apache-2.0
|
||||
* Copyright (c) 2016 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_CMSIS_H
|
||||
#define MBED_CMSIS_H
|
||||
|
||||
#include "nrf.h"
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,57 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2016 ARM Limited. All rights reserved.
|
||||
* 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 ARM Limited 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 "cmsis_nvic.h"
|
||||
|
||||
#define NVIC_RAM_VECTOR_ADDRESS (0x10000000) // Vectors positioned at start of SRAM2
|
||||
#define NVIC_FLASH_VECTOR_ADDRESS (0x0) // Initial vector position in flash
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
|
||||
{
|
||||
uint32_t *vectors = (uint32_t *) SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
/* Copy and switch to dynamic vectors if the first time called */
|
||||
if (SCB->VTOR != NVIC_RAM_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = (uint32_t *) NVIC_FLASH_VECTOR_ADDRESS;
|
||||
vectors = (uint32_t *) NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i = 0; i < NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t) NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
vectors[IRQn + NVIC_USER_IRQ_OFFSET] = vector;
|
||||
}
|
||||
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn)
|
||||
{
|
||||
uint32_t *vectors = (uint32_t *) SCB->VTOR;
|
||||
return vectors[IRQn + NVIC_USER_IRQ_OFFSET];
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2016 ARM Limited. All rights reserved.
|
||||
* 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 ARM Limited 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_CMSIS_NVIC_H
|
||||
#define MBED_CMSIS_NVIC_H
|
||||
|
||||
#define NVIC_NUM_VECTORS (16 + 38) // CORE + MCU Peripherals
|
||||
#define NVIC_USER_IRQ_OFFSET 16
|
||||
|
||||
#include "nrf52.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,321 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf.h"
|
||||
#include "system_nrf52.h"
|
||||
#include "nrf5x_lf_clk_helper.h"
|
||||
|
||||
/*lint ++flb "Enter library region" */
|
||||
|
||||
#define __SYSTEM_CLOCK_64M (64000000UL)
|
||||
|
||||
static bool errata_16(void);
|
||||
static bool errata_31(void);
|
||||
static bool errata_32(void);
|
||||
static bool errata_36(void);
|
||||
static bool errata_37(void);
|
||||
static bool errata_57(void);
|
||||
static bool errata_66(void);
|
||||
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M;
|
||||
#elif defined ( __ICCARM__ )
|
||||
__root uint32_t SystemCoreClock = __SYSTEM_CLOCK_64M;
|
||||
#elif defined ( __GNUC__ )
|
||||
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M;
|
||||
#endif
|
||||
|
||||
void SystemCoreClockUpdate(void)
|
||||
{
|
||||
SystemCoreClock = __SYSTEM_CLOCK_64M;
|
||||
}
|
||||
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU IDLE" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_16()){
|
||||
*(volatile uint32_t *)0x4007C074 = 3131961357ul;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 31 "CLOCK: Calibration values are not correctly loaded from FICR at reset" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_31()){
|
||||
*(volatile uint32_t *)0x4000053C = ((*(volatile uint32_t *)0x10000244) & 0x0000E000) >> 13;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 32 "DIF: Debug session automatically enables TracePort pins" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_32()){
|
||||
CoreDebug->DEMCR &= ~CoreDebug_DEMCR_TRCENA_Msk;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_36()){
|
||||
NRF_CLOCK->EVENTS_DONE = 0;
|
||||
NRF_CLOCK->EVENTS_CTTO = 0;
|
||||
NRF_CLOCK->CTIV = 0;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 37 "RADIO: Encryption engine is slow by default" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_37()){
|
||||
*(volatile uint32_t *)0x400005A0 = 0x3;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 57 "NFCT: NFC Modulation amplitude" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_57()){
|
||||
*(volatile uint32_t *)0x40005610 = 0x00000005;
|
||||
*(volatile uint32_t *)0x40005688 = 0x00000001;
|
||||
*(volatile uint32_t *)0x40005618 = 0x00000000;
|
||||
*(volatile uint32_t *)0x40005614 = 0x0000003F;
|
||||
}
|
||||
|
||||
/* Workaround for Errata 66 "TEMP: Linearity specification not met with default settings" found at the Errata document
|
||||
for your device located at https://infocenter.nordicsemi.com/ */
|
||||
if (errata_66()){
|
||||
NRF_TEMP->A0 = NRF_FICR->TEMP.A0;
|
||||
NRF_TEMP->A1 = NRF_FICR->TEMP.A1;
|
||||
NRF_TEMP->A2 = NRF_FICR->TEMP.A2;
|
||||
NRF_TEMP->A3 = NRF_FICR->TEMP.A3;
|
||||
NRF_TEMP->A4 = NRF_FICR->TEMP.A4;
|
||||
NRF_TEMP->A5 = NRF_FICR->TEMP.A5;
|
||||
NRF_TEMP->B0 = NRF_FICR->TEMP.B0;
|
||||
NRF_TEMP->B1 = NRF_FICR->TEMP.B1;
|
||||
NRF_TEMP->B2 = NRF_FICR->TEMP.B2;
|
||||
NRF_TEMP->B3 = NRF_FICR->TEMP.B3;
|
||||
NRF_TEMP->B4 = NRF_FICR->TEMP.B4;
|
||||
NRF_TEMP->B5 = NRF_FICR->TEMP.B5;
|
||||
NRF_TEMP->T0 = NRF_FICR->TEMP.T0;
|
||||
NRF_TEMP->T1 = NRF_FICR->TEMP.T1;
|
||||
NRF_TEMP->T2 = NRF_FICR->TEMP.T2;
|
||||
NRF_TEMP->T3 = NRF_FICR->TEMP.T3;
|
||||
NRF_TEMP->T4 = NRF_FICR->TEMP.T4;
|
||||
}
|
||||
|
||||
/* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the
|
||||
* compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit
|
||||
* operations are not used in your code. */
|
||||
#if (__FPU_USED == 1)
|
||||
SCB->CPACR |= (3UL << 20) | (3UL << 22);
|
||||
__DSB();
|
||||
__ISB();
|
||||
#endif
|
||||
|
||||
/* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined,
|
||||
two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as
|
||||
normal GPIOs. */
|
||||
#if defined (CONFIG_NFCT_PINS_AS_GPIOS)
|
||||
if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
|
||||
defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
|
||||
reserved for PinReset and not available as normal GPIO. */
|
||||
#if defined (CONFIG_GPIO_AS_PINRESET)
|
||||
if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) ||
|
||||
((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->PSELRESET[0] = 21;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_UICR->PSELRESET[1] = 21;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product
|
||||
Specification to see which one). */
|
||||
#if defined (ENABLE_SWO)
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos;
|
||||
NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
#endif
|
||||
|
||||
/* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product
|
||||
Specification to see which ones). */
|
||||
#if defined (ENABLE_TRACE)
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos;
|
||||
NRF_P0->PIN_CNF[14] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P0->PIN_CNF[15] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P0->PIN_CNF[16] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
NRF_P0->PIN_CNF[20] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||
#endif
|
||||
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
// Start the LF oscilator according to the mbed configuration (over the nrf5x_lf_clk_helper.h file)
|
||||
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_TO_USE << CLOCK_LFCLKSRC_SRC_Pos);
|
||||
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
|
||||
NRF_CLOCK->TASKS_LFCLKSTART = 1;
|
||||
|
||||
// Wait for the external oscillator to start up.
|
||||
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool errata_16(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_31(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_32(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_36(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_37(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_57(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool errata_66(void)
|
||||
{
|
||||
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
|
||||
{
|
||||
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*lint --flb "Leave library region" */
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 SYSTEM_NRF52_H
|
||||
#define SYSTEM_NRF52_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||
|
||||
/**
|
||||
* Initialize the system
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Setup the microcontroller system.
|
||||
* Initialize the System and update the SystemCoreClock variable.
|
||||
*/
|
||||
extern void SystemInit (void);
|
||||
|
||||
/**
|
||||
* Update SystemCoreClock variable
|
||||
*
|
||||
* @param none
|
||||
* @return none
|
||||
*
|
||||
* @brief Updates the SystemCoreClock with current core Clock
|
||||
* retrieved from cpu registers.
|
||||
*/
|
||||
extern void SystemCoreClockUpdate (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SYSTEM_NRF52_H */
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 __NRF5X_LF_CLK_HELPER_H_
|
||||
|
||||
#ifndef MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC
|
||||
#define MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC (NRF_LF_SRC_XTAL)
|
||||
#warning No configuration for LF clock source. Xtal source will be used as a default configuration.
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define NRF_LF_SRC_XTAL 2
|
||||
#define NRF_LF_SRC_SYNTH 3
|
||||
#define NRF_LF_SRC_RC 4
|
||||
|
||||
#if MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC == NRF_LF_SRC_SYNTH
|
||||
#define CLOCK_LFCLKSRC_SRC_TO_USE (CLOCK_LFCLKSRC_SRC_Synth)
|
||||
#elif MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC == NRF_LF_SRC_XTAL
|
||||
#define CLOCK_LFCLKSRC_SRC_TO_USE (CLOCK_LFCLKSRC_SRC_Xtal)
|
||||
#elif MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC == NRF_LF_SRC_RC
|
||||
#define CLOCK_LFCLKSRC_SRC_TO_USE (CLOCK_LFCLKSRC_SRC_RC)
|
||||
#else
|
||||
#error Bad LFCLK configuration. Declare proper source through mbed configuration.
|
||||
#endif
|
||||
|
||||
#undef NRF_LF_SRC_XTAL
|
||||
#undef NRF_LF_SRC_SYNTH
|
||||
#undef NRF_LF_SRC_RC
|
||||
|
||||
#endif
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 _COMPILER_ABSTRACTION_H
|
||||
#define _COMPILER_ABSTRACTION_H
|
||||
|
||||
/*lint ++flb "Enter library region" */
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
|
||||
#ifndef __INLINE
|
||||
#define __INLINE __inline
|
||||
#endif
|
||||
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __weak
|
||||
#endif
|
||||
|
||||
#ifndef __ALIGN
|
||||
#define __ALIGN(n) __align(n)
|
||||
#endif
|
||||
|
||||
#define GET_SP() __current_sp()
|
||||
|
||||
#elif defined ( __ICCARM__ )
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __weak
|
||||
#endif
|
||||
|
||||
/* Not defined for IAR since it requires a new line to work, and C preprocessor does not allow that. */
|
||||
#ifndef __ALIGN
|
||||
#define __ALIGN(n)
|
||||
#endif
|
||||
|
||||
#define GET_SP() __get_SP()
|
||||
|
||||
#elif defined ( __GNUC__ )
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
|
||||
#ifndef __ALIGN
|
||||
#define __ALIGN(n) __attribute__((aligned(n)))
|
||||
#endif
|
||||
|
||||
#define GET_SP() gcc_current_sp()
|
||||
|
||||
static inline unsigned int gcc_current_sp(void)
|
||||
{
|
||||
register unsigned sp __ASM("sp");
|
||||
return sp;
|
||||
}
|
||||
|
||||
#elif defined ( __TASKING__ )
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
|
||||
#ifndef __ALIGN
|
||||
#define __ALIGN(n) __align(n)
|
||||
#endif
|
||||
|
||||
#define GET_SP() __get_MSP()
|
||||
|
||||
#endif
|
||||
|
||||
/*lint --flb "Leave library region" */
|
||||
|
||||
#endif
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 NRF_H
|
||||
#define NRF_H
|
||||
|
||||
/* MDK version */
|
||||
#define MDK_MAJOR_VERSION 8
|
||||
#define MDK_MINOR_VERSION 5
|
||||
#define MDK_MICRO_VERSION 0
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* Do not include nrf51 specific files when building for PC host */
|
||||
#elif defined(__unix)
|
||||
/* Do not include nrf51 specific files when building for PC host */
|
||||
#elif defined(__APPLE__)
|
||||
/* Do not include nrf51 specific files when building for PC host */
|
||||
#else
|
||||
|
||||
/* Family selection for family includes. */
|
||||
#if defined (NRF51)
|
||||
#include "nrf51.h"
|
||||
#include "nrf51_bitfields.h"
|
||||
#include "nrf51_deprecated.h"
|
||||
#elif defined (NRF52)
|
||||
#include "nrf52.h"
|
||||
#include "nrf52_bitfields.h"
|
||||
#include "nrf51_to_nrf52.h"
|
||||
#include "nrf52_name_change.h"
|
||||
#else
|
||||
#error "Device family must be defined. See nrf.h."
|
||||
#endif /* NRF51, NRF52 */
|
||||
|
||||
#include "compiler_abstraction.h"
|
||||
|
||||
#endif /* _WIN32 || __unix || __APPLE__ */
|
||||
|
||||
#endif /* NRF_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,447 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 NRF51_DEPRECATED_H
|
||||
#define NRF51_DEPRECATED_H
|
||||
|
||||
/*lint ++flb "Enter library region */
|
||||
|
||||
/* This file is given to prevent your SW from not compiling with the updates made to nrf51.h and
|
||||
* nrf51_bitfields.h. The macros defined in this file were available previously. Do not use these
|
||||
* macros on purpose. Use the ones defined in nrf51.h and nrf51_bitfields.h instead.
|
||||
*/
|
||||
|
||||
/* NVMC */
|
||||
/* The register ERASEPROTECTEDPAGE is called ERASEPCR0 in the documentation. */
|
||||
#define ERASEPROTECTEDPAGE ERASEPCR0
|
||||
|
||||
|
||||
/* LPCOMP */
|
||||
/* The interrupt ISR was renamed. Adding old name to the macros. */
|
||||
#define LPCOMP_COMP_IRQHandler LPCOMP_IRQHandler
|
||||
#define LPCOMP_COMP_IRQn LPCOMP_IRQn
|
||||
|
||||
|
||||
/* MPU */
|
||||
/* The field MPU.PERR0.LPCOMP_COMP was renamed. Added into deprecated in case somebody was using the macros defined for it. */
|
||||
#define MPU_PERR0_LPCOMP_COMP_Pos MPU_PERR0_LPCOMP_Pos
|
||||
#define MPU_PERR0_LPCOMP_COMP_Msk MPU_PERR0_LPCOMP_Msk
|
||||
#define MPU_PERR0_LPCOMP_COMP_InRegion1 MPU_PERR0_LPCOMP_InRegion1
|
||||
#define MPU_PERR0_LPCOMP_COMP_InRegion0 MPU_PERR0_LPCOMP_InRegion0
|
||||
|
||||
|
||||
/* POWER */
|
||||
/* The field POWER.RAMON.OFFRAM3 was eliminated. Added into deprecated in case somebody was using the macros defined for it. */
|
||||
#define POWER_RAMON_OFFRAM3_Pos (19UL)
|
||||
#define POWER_RAMON_OFFRAM3_Msk (0x1UL << POWER_RAMON_OFFRAM3_Pos)
|
||||
#define POWER_RAMON_OFFRAM3_RAM3Off (0UL)
|
||||
#define POWER_RAMON_OFFRAM3_RAM3On (1UL)
|
||||
/* The field POWER.RAMON.OFFRAM2 was eliminated. Added into deprecated in case somebody was using the macros defined for it. */
|
||||
#define POWER_RAMON_OFFRAM2_Pos (18UL)
|
||||
#define POWER_RAMON_OFFRAM2_Msk (0x1UL << POWER_RAMON_OFFRAM2_Pos)
|
||||
#define POWER_RAMON_OFFRAM2_RAM2Off (0UL)
|
||||
#define POWER_RAMON_OFFRAM2_RAM2On (1UL)
|
||||
/* The field POWER.RAMON.ONRAM3 was eliminated. Added into deprecated in case somebody was using the macros defined for it. */
|
||||
#define POWER_RAMON_ONRAM3_Pos (3UL)
|
||||
#define POWER_RAMON_ONRAM3_Msk (0x1UL << POWER_RAMON_ONRAM3_Pos)
|
||||
#define POWER_RAMON_ONRAM3_RAM3Off (0UL)
|
||||
#define POWER_RAMON_ONRAM3_RAM3On (1UL)
|
||||
/* The field POWER.RAMON.ONRAM2 was eliminated. Added into deprecated in case somebody was using the macros defined for it. */
|
||||
#define POWER_RAMON_ONRAM2_Pos (2UL)
|
||||
#define POWER_RAMON_ONRAM2_Msk (0x1UL << POWER_RAMON_ONRAM2_Pos)
|
||||
#define POWER_RAMON_ONRAM2_RAM2Off (0UL)
|
||||
#define POWER_RAMON_ONRAM2_RAM2On (1UL)
|
||||
|
||||
|
||||
/* RADIO */
|
||||
/* The enumerated value RADIO.TXPOWER.TXPOWER.Neg40dBm was renamed. Added into deprecated with the new macro name. */
|
||||
#define RADIO_TXPOWER_TXPOWER_Neg40dBm RADIO_TXPOWER_TXPOWER_Neg30dBm
|
||||
/* The name of the field SKIPADDR was corrected. Old macros added for compatibility. */
|
||||
#define RADIO_CRCCNF_SKIP_ADDR_Pos RADIO_CRCCNF_SKIPADDR_Pos
|
||||
#define RADIO_CRCCNF_SKIP_ADDR_Msk RADIO_CRCCNF_SKIPADDR_Msk
|
||||
#define RADIO_CRCCNF_SKIP_ADDR_Include RADIO_CRCCNF_SKIPADDR_Include
|
||||
#define RADIO_CRCCNF_SKIP_ADDR_Skip RADIO_CRCCNF_SKIPADDR_Skip
|
||||
/* The name of the field PLLLOCK was corrected. Old macros added for compatibility. */
|
||||
#define RADIO_TEST_PLL_LOCK_Pos RADIO_TEST_PLLLOCK_Pos
|
||||
#define RADIO_TEST_PLL_LOCK_Msk RADIO_TEST_PLLLOCK_Msk
|
||||
#define RADIO_TEST_PLL_LOCK_Disabled RADIO_TEST_PLLLOCK_Disabled
|
||||
#define RADIO_TEST_PLL_LOCK_Enabled RADIO_TEST_PLLLOCK_Enabled
|
||||
/* The name of the field CONSTCARRIER was corrected. Old macros added for compatibility. */
|
||||
#define RADIO_TEST_CONST_CARRIER_Pos RADIO_TEST_CONSTCARRIER_Pos
|
||||
#define RADIO_TEST_CONST_CARRIER_Msk RADIO_TEST_CONSTCARRIER_Msk
|
||||
#define RADIO_TEST_CONST_CARRIER_Disabled RADIO_TEST_CONSTCARRIER_Disabled
|
||||
#define RADIO_TEST_CONST_CARRIER_Enabled RADIO_TEST_CONSTCARRIER_Enabled
|
||||
|
||||
|
||||
/* FICR */
|
||||
/* The registers FICR.SIZERAMBLOCK0, FICR.SIZERAMBLOCK1, FICR.SIZERAMBLOCK2 and FICR.SIZERAMBLOCK3 were renamed into an array. */
|
||||
#define SIZERAMBLOCK0 SIZERAMBLOCKS
|
||||
#define SIZERAMBLOCK1 SIZERAMBLOCKS
|
||||
#define SIZERAMBLOCK2 SIZERAMBLOCK[2] /*!< Note that this macro will disapear when SIZERAMBLOCK array is eliminated. SIZERAMBLOCK is a deprecated array. */
|
||||
#define SIZERAMBLOCK3 SIZERAMBLOCK[3] /*!< Note that this macro will disapear when SIZERAMBLOCK array is eliminated. SIZERAMBLOCK is a deprecated array. */
|
||||
/* The registers FICR.DEVICEID0 and FICR.DEVICEID1 were renamed into an array. */
|
||||
#define DEVICEID0 DEVICEID[0]
|
||||
#define DEVICEID1 DEVICEID[1]
|
||||
/* The registers FICR.ER0, FICR.ER1, FICR.ER2 and FICR.ER3 were renamed into an array. */
|
||||
#define ER0 ER[0]
|
||||
#define ER1 ER[1]
|
||||
#define ER2 ER[2]
|
||||
#define ER3 ER[3]
|
||||
/* The registers FICR.IR0, FICR.IR1, FICR.IR2 and FICR.IR3 were renamed into an array. */
|
||||
#define IR0 IR[0]
|
||||
#define IR1 IR[1]
|
||||
#define IR2 IR[2]
|
||||
#define IR3 IR[3]
|
||||
/* The registers FICR.DEVICEADDR0 and FICR.DEVICEADDR1 were renamed into an array. */
|
||||
#define DEVICEADDR0 DEVICEADDR[0]
|
||||
#define DEVICEADDR1 DEVICEADDR[1]
|
||||
|
||||
|
||||
/* PPI */
|
||||
/* The tasks PPI.TASKS_CHGxEN and PPI.TASKS_CHGxDIS were renamed into an array of structs. */
|
||||
#define TASKS_CHG0EN TASKS_CHG[0].EN
|
||||
#define TASKS_CHG0DIS TASKS_CHG[0].DIS
|
||||
#define TASKS_CHG1EN TASKS_CHG[1].EN
|
||||
#define TASKS_CHG1DIS TASKS_CHG[1].DIS
|
||||
#define TASKS_CHG2EN TASKS_CHG[2].EN
|
||||
#define TASKS_CHG2DIS TASKS_CHG[2].DIS
|
||||
#define TASKS_CHG3EN TASKS_CHG[3].EN
|
||||
#define TASKS_CHG3DIS TASKS_CHG[3].DIS
|
||||
/* The registers PPI.CHx_EEP and PPI.CHx_TEP were renamed into an array of structs. */
|
||||
#define CH0_EEP CH[0].EEP
|
||||
#define CH0_TEP CH[0].TEP
|
||||
#define CH1_EEP CH[1].EEP
|
||||
#define CH1_TEP CH[1].TEP
|
||||
#define CH2_EEP CH[2].EEP
|
||||
#define CH2_TEP CH[2].TEP
|
||||
#define CH3_EEP CH[3].EEP
|
||||
#define CH3_TEP CH[3].TEP
|
||||
#define CH4_EEP CH[4].EEP
|
||||
#define CH4_TEP CH[4].TEP
|
||||
#define CH5_EEP CH[5].EEP
|
||||
#define CH5_TEP CH[5].TEP
|
||||
#define CH6_EEP CH[6].EEP
|
||||
#define CH6_TEP CH[6].TEP
|
||||
#define CH7_EEP CH[7].EEP
|
||||
#define CH7_TEP CH[7].TEP
|
||||
#define CH8_EEP CH[8].EEP
|
||||
#define CH8_TEP CH[8].TEP
|
||||
#define CH9_EEP CH[9].EEP
|
||||
#define CH9_TEP CH[9].TEP
|
||||
#define CH10_EEP CH[10].EEP
|
||||
#define CH10_TEP CH[10].TEP
|
||||
#define CH11_EEP CH[11].EEP
|
||||
#define CH11_TEP CH[11].TEP
|
||||
#define CH12_EEP CH[12].EEP
|
||||
#define CH12_TEP CH[12].TEP
|
||||
#define CH13_EEP CH[13].EEP
|
||||
#define CH13_TEP CH[13].TEP
|
||||
#define CH14_EEP CH[14].EEP
|
||||
#define CH14_TEP CH[14].TEP
|
||||
#define CH15_EEP CH[15].EEP
|
||||
#define CH15_TEP CH[15].TEP
|
||||
/* The registers PPI.CHG0, PPI.CHG1, PPI.CHG2 and PPI.CHG3 were renamed into an array. */
|
||||
#define CHG0 CHG[0]
|
||||
#define CHG1 CHG[1]
|
||||
#define CHG2 CHG[2]
|
||||
#define CHG3 CHG[3]
|
||||
/* All bitfield macros for the CHGx registers therefore changed name. */
|
||||
#define PPI_CHG0_CH15_Pos PPI_CHG_CH15_Pos
|
||||
#define PPI_CHG0_CH15_Msk PPI_CHG_CH15_Msk
|
||||
#define PPI_CHG0_CH15_Excluded PPI_CHG_CH15_Excluded
|
||||
#define PPI_CHG0_CH15_Included PPI_CHG_CH15_Included
|
||||
#define PPI_CHG0_CH14_Pos PPI_CHG_CH14_Pos
|
||||
#define PPI_CHG0_CH14_Msk PPI_CHG_CH14_Msk
|
||||
#define PPI_CHG0_CH14_Excluded PPI_CHG_CH14_Excluded
|
||||
#define PPI_CHG0_CH14_Included PPI_CHG_CH14_Included
|
||||
#define PPI_CHG0_CH13_Pos PPI_CHG_CH13_Pos
|
||||
#define PPI_CHG0_CH13_Msk PPI_CHG_CH13_Msk
|
||||
#define PPI_CHG0_CH13_Excluded PPI_CHG_CH13_Excluded
|
||||
#define PPI_CHG0_CH13_Included PPI_CHG_CH13_Included
|
||||
#define PPI_CHG0_CH12_Pos PPI_CHG_CH12_Pos
|
||||
#define PPI_CHG0_CH12_Msk PPI_CHG_CH12_Msk
|
||||
#define PPI_CHG0_CH12_Excluded PPI_CHG_CH12_Excluded
|
||||
#define PPI_CHG0_CH12_Included PPI_CHG_CH12_Included
|
||||
#define PPI_CHG0_CH11_Pos PPI_CHG_CH11_Pos
|
||||
#define PPI_CHG0_CH11_Msk PPI_CHG_CH11_Msk
|
||||
#define PPI_CHG0_CH11_Excluded PPI_CHG_CH11_Excluded
|
||||
#define PPI_CHG0_CH11_Included PPI_CHG_CH11_Included
|
||||
#define PPI_CHG0_CH10_Pos PPI_CHG_CH10_Pos
|
||||
#define PPI_CHG0_CH10_Msk PPI_CHG_CH10_Msk
|
||||
#define PPI_CHG0_CH10_Excluded PPI_CHG_CH10_Excluded
|
||||
#define PPI_CHG0_CH10_Included PPI_CHG_CH10_Included
|
||||
#define PPI_CHG0_CH9_Pos PPI_CHG_CH9_Pos
|
||||
#define PPI_CHG0_CH9_Msk PPI_CHG_CH9_Msk
|
||||
#define PPI_CHG0_CH9_Excluded PPI_CHG_CH9_Excluded
|
||||
#define PPI_CHG0_CH9_Included PPI_CHG_CH9_Included
|
||||
#define PPI_CHG0_CH8_Pos PPI_CHG_CH8_Pos
|
||||
#define PPI_CHG0_CH8_Msk PPI_CHG_CH8_Msk
|
||||
#define PPI_CHG0_CH8_Excluded PPI_CHG_CH8_Excluded
|
||||
#define PPI_CHG0_CH8_Included PPI_CHG_CH8_Included
|
||||
#define PPI_CHG0_CH7_Pos PPI_CHG_CH7_Pos
|
||||
#define PPI_CHG0_CH7_Msk PPI_CHG_CH7_Msk
|
||||
#define PPI_CHG0_CH7_Excluded PPI_CHG_CH7_Excluded
|
||||
#define PPI_CHG0_CH7_Included PPI_CHG_CH7_Included
|
||||
#define PPI_CHG0_CH6_Pos PPI_CHG_CH6_Pos
|
||||
#define PPI_CHG0_CH6_Msk PPI_CHG_CH6_Msk
|
||||
#define PPI_CHG0_CH6_Excluded PPI_CHG_CH6_Excluded
|
||||
#define PPI_CHG0_CH6_Included PPI_CHG_CH6_Included
|
||||
#define PPI_CHG0_CH5_Pos PPI_CHG_CH5_Pos
|
||||
#define PPI_CHG0_CH5_Msk PPI_CHG_CH5_Msk
|
||||
#define PPI_CHG0_CH5_Excluded PPI_CHG_CH5_Excluded
|
||||
#define PPI_CHG0_CH5_Included PPI_CHG_CH5_Included
|
||||
#define PPI_CHG0_CH4_Pos PPI_CHG_CH4_Pos
|
||||
#define PPI_CHG0_CH4_Msk PPI_CHG_CH4_Msk
|
||||
#define PPI_CHG0_CH4_Excluded PPI_CHG_CH4_Excluded
|
||||
#define PPI_CHG0_CH4_Included PPI_CHG_CH4_Included
|
||||
#define PPI_CHG0_CH3_Pos PPI_CHG_CH3_Pos
|
||||
#define PPI_CHG0_CH3_Msk PPI_CHG_CH3_Msk
|
||||
#define PPI_CHG0_CH3_Excluded PPI_CHG_CH3_Excluded
|
||||
#define PPI_CHG0_CH3_Included PPI_CHG_CH3_Included
|
||||
#define PPI_CHG0_CH2_Pos PPI_CHG_CH2_Pos
|
||||
#define PPI_CHG0_CH2_Msk PPI_CHG_CH2_Msk
|
||||
#define PPI_CHG0_CH2_Excluded PPI_CHG_CH2_Excluded
|
||||
#define PPI_CHG0_CH2_Included PPI_CHG_CH2_Included
|
||||
#define PPI_CHG0_CH1_Pos PPI_CHG_CH1_Pos
|
||||
#define PPI_CHG0_CH1_Msk PPI_CHG_CH1_Msk
|
||||
#define PPI_CHG0_CH1_Excluded PPI_CHG_CH1_Excluded
|
||||
#define PPI_CHG0_CH1_Included PPI_CHG_CH1_Included
|
||||
#define PPI_CHG0_CH0_Pos PPI_CHG_CH0_Pos
|
||||
#define PPI_CHG0_CH0_Msk PPI_CHG_CH0_Msk
|
||||
#define PPI_CHG0_CH0_Excluded PPI_CHG_CH0_Excluded
|
||||
#define PPI_CHG0_CH0_Included PPI_CHG_CH0_Included
|
||||
#define PPI_CHG1_CH15_Pos PPI_CHG_CH15_Pos
|
||||
#define PPI_CHG1_CH15_Msk PPI_CHG_CH15_Msk
|
||||
#define PPI_CHG1_CH15_Excluded PPI_CHG_CH15_Excluded
|
||||
#define PPI_CHG1_CH15_Included PPI_CHG_CH15_Included
|
||||
#define PPI_CHG1_CH14_Pos PPI_CHG_CH14_Pos
|
||||
#define PPI_CHG1_CH14_Msk PPI_CHG_CH14_Msk
|
||||
#define PPI_CHG1_CH14_Excluded PPI_CHG_CH14_Excluded
|
||||
#define PPI_CHG1_CH14_Included PPI_CHG_CH14_Included
|
||||
#define PPI_CHG1_CH13_Pos PPI_CHG_CH13_Pos
|
||||
#define PPI_CHG1_CH13_Msk PPI_CHG_CH13_Msk
|
||||
#define PPI_CHG1_CH13_Excluded PPI_CHG_CH13_Excluded
|
||||
#define PPI_CHG1_CH13_Included PPI_CHG_CH13_Included
|
||||
#define PPI_CHG1_CH12_Pos PPI_CHG_CH12_Pos
|
||||
#define PPI_CHG1_CH12_Msk PPI_CHG_CH12_Msk
|
||||
#define PPI_CHG1_CH12_Excluded PPI_CHG_CH12_Excluded
|
||||
#define PPI_CHG1_CH12_Included PPI_CHG_CH12_Included
|
||||
#define PPI_CHG1_CH11_Pos PPI_CHG_CH11_Pos
|
||||
#define PPI_CHG1_CH11_Msk PPI_CHG_CH11_Msk
|
||||
#define PPI_CHG1_CH11_Excluded PPI_CHG_CH11_Excluded
|
||||
#define PPI_CHG1_CH11_Included PPI_CHG_CH11_Included
|
||||
#define PPI_CHG1_CH10_Pos PPI_CHG_CH10_Pos
|
||||
#define PPI_CHG1_CH10_Msk PPI_CHG_CH10_Msk
|
||||
#define PPI_CHG1_CH10_Excluded PPI_CHG_CH10_Excluded
|
||||
#define PPI_CHG1_CH10_Included PPI_CHG_CH10_Included
|
||||
#define PPI_CHG1_CH9_Pos PPI_CHG_CH9_Pos
|
||||
#define PPI_CHG1_CH9_Msk PPI_CHG_CH9_Msk
|
||||
#define PPI_CHG1_CH9_Excluded PPI_CHG_CH9_Excluded
|
||||
#define PPI_CHG1_CH9_Included PPI_CHG_CH9_Included
|
||||
#define PPI_CHG1_CH8_Pos PPI_CHG_CH8_Pos
|
||||
#define PPI_CHG1_CH8_Msk PPI_CHG_CH8_Msk
|
||||
#define PPI_CHG1_CH8_Excluded PPI_CHG_CH8_Excluded
|
||||
#define PPI_CHG1_CH8_Included PPI_CHG_CH8_Included
|
||||
#define PPI_CHG1_CH7_Pos PPI_CHG_CH7_Pos
|
||||
#define PPI_CHG1_CH7_Msk PPI_CHG_CH7_Msk
|
||||
#define PPI_CHG1_CH7_Excluded PPI_CHG_CH7_Excluded
|
||||
#define PPI_CHG1_CH7_Included PPI_CHG_CH7_Included
|
||||
#define PPI_CHG1_CH6_Pos PPI_CHG_CH6_Pos
|
||||
#define PPI_CHG1_CH6_Msk PPI_CHG_CH6_Msk
|
||||
#define PPI_CHG1_CH6_Excluded PPI_CHG_CH6_Excluded
|
||||
#define PPI_CHG1_CH6_Included PPI_CHG_CH6_Included
|
||||
#define PPI_CHG1_CH5_Pos PPI_CHG_CH5_Pos
|
||||
#define PPI_CHG1_CH5_Msk PPI_CHG_CH5_Msk
|
||||
#define PPI_CHG1_CH5_Excluded PPI_CHG_CH5_Excluded
|
||||
#define PPI_CHG1_CH5_Included PPI_CHG_CH5_Included
|
||||
#define PPI_CHG1_CH4_Pos PPI_CHG_CH4_Pos
|
||||
#define PPI_CHG1_CH4_Msk PPI_CHG_CH4_Msk
|
||||
#define PPI_CHG1_CH4_Excluded PPI_CHG_CH4_Excluded
|
||||
#define PPI_CHG1_CH4_Included PPI_CHG_CH4_Included
|
||||
#define PPI_CHG1_CH3_Pos PPI_CHG_CH3_Pos
|
||||
#define PPI_CHG1_CH3_Msk PPI_CHG_CH3_Msk
|
||||
#define PPI_CHG1_CH3_Excluded PPI_CHG_CH3_Excluded
|
||||
#define PPI_CHG1_CH3_Included PPI_CHG_CH3_Included
|
||||
#define PPI_CHG1_CH2_Pos PPI_CHG_CH2_Pos
|
||||
#define PPI_CHG1_CH2_Msk PPI_CHG_CH2_Msk
|
||||
#define PPI_CHG1_CH2_Excluded PPI_CHG_CH2_Excluded
|
||||
#define PPI_CHG1_CH2_Included PPI_CHG_CH2_Included
|
||||
#define PPI_CHG1_CH1_Pos PPI_CHG_CH1_Pos
|
||||
#define PPI_CHG1_CH1_Msk PPI_CHG_CH1_Msk
|
||||
#define PPI_CHG1_CH1_Excluded PPI_CHG_CH1_Excluded
|
||||
#define PPI_CHG1_CH1_Included PPI_CHG_CH1_Included
|
||||
#define PPI_CHG1_CH0_Pos PPI_CHG_CH0_Pos
|
||||
#define PPI_CHG1_CH0_Msk PPI_CHG_CH0_Msk
|
||||
#define PPI_CHG1_CH0_Excluded PPI_CHG_CH0_Excluded
|
||||
#define PPI_CHG1_CH0_Included PPI_CHG_CH0_Included
|
||||
#define PPI_CHG2_CH15_Pos PPI_CHG_CH15_Pos
|
||||
#define PPI_CHG2_CH15_Msk PPI_CHG_CH15_Msk
|
||||
#define PPI_CHG2_CH15_Excluded PPI_CHG_CH15_Excluded
|
||||
#define PPI_CHG2_CH15_Included PPI_CHG_CH15_Included
|
||||
#define PPI_CHG2_CH14_Pos PPI_CHG_CH14_Pos
|
||||
#define PPI_CHG2_CH14_Msk PPI_CHG_CH14_Msk
|
||||
#define PPI_CHG2_CH14_Excluded PPI_CHG_CH14_Excluded
|
||||
#define PPI_CHG2_CH14_Included PPI_CHG_CH14_Included
|
||||
#define PPI_CHG2_CH13_Pos PPI_CHG_CH13_Pos
|
||||
#define PPI_CHG2_CH13_Msk PPI_CHG_CH13_Msk
|
||||
#define PPI_CHG2_CH13_Excluded PPI_CHG_CH13_Excluded
|
||||
#define PPI_CHG2_CH13_Included PPI_CHG_CH13_Included
|
||||
#define PPI_CHG2_CH12_Pos PPI_CHG_CH12_Pos
|
||||
#define PPI_CHG2_CH12_Msk PPI_CHG_CH12_Msk
|
||||
#define PPI_CHG2_CH12_Excluded PPI_CHG_CH12_Excluded
|
||||
#define PPI_CHG2_CH12_Included PPI_CHG_CH12_Included
|
||||
#define PPI_CHG2_CH11_Pos PPI_CHG_CH11_Pos
|
||||
#define PPI_CHG2_CH11_Msk PPI_CHG_CH11_Msk
|
||||
#define PPI_CHG2_CH11_Excluded PPI_CHG_CH11_Excluded
|
||||
#define PPI_CHG2_CH11_Included PPI_CHG_CH11_Included
|
||||
#define PPI_CHG2_CH10_Pos PPI_CHG_CH10_Pos
|
||||
#define PPI_CHG2_CH10_Msk PPI_CHG_CH10_Msk
|
||||
#define PPI_CHG2_CH10_Excluded PPI_CHG_CH10_Excluded
|
||||
#define PPI_CHG2_CH10_Included PPI_CHG_CH10_Included
|
||||
#define PPI_CHG2_CH9_Pos PPI_CHG_CH9_Pos
|
||||
#define PPI_CHG2_CH9_Msk PPI_CHG_CH9_Msk
|
||||
#define PPI_CHG2_CH9_Excluded PPI_CHG_CH9_Excluded
|
||||
#define PPI_CHG2_CH9_Included PPI_CHG_CH9_Included
|
||||
#define PPI_CHG2_CH8_Pos PPI_CHG_CH8_Pos
|
||||
#define PPI_CHG2_CH8_Msk PPI_CHG_CH8_Msk
|
||||
#define PPI_CHG2_CH8_Excluded PPI_CHG_CH8_Excluded
|
||||
#define PPI_CHG2_CH8_Included PPI_CHG_CH8_Included
|
||||
#define PPI_CHG2_CH7_Pos PPI_CHG_CH7_Pos
|
||||
#define PPI_CHG2_CH7_Msk PPI_CHG_CH7_Msk
|
||||
#define PPI_CHG2_CH7_Excluded PPI_CHG_CH7_Excluded
|
||||
#define PPI_CHG2_CH7_Included PPI_CHG_CH7_Included
|
||||
#define PPI_CHG2_CH6_Pos PPI_CHG_CH6_Pos
|
||||
#define PPI_CHG2_CH6_Msk PPI_CHG_CH6_Msk
|
||||
#define PPI_CHG2_CH6_Excluded PPI_CHG_CH6_Excluded
|
||||
#define PPI_CHG2_CH6_Included PPI_CHG_CH6_Included
|
||||
#define PPI_CHG2_CH5_Pos PPI_CHG_CH5_Pos
|
||||
#define PPI_CHG2_CH5_Msk PPI_CHG_CH5_Msk
|
||||
#define PPI_CHG2_CH5_Excluded PPI_CHG_CH5_Excluded
|
||||
#define PPI_CHG2_CH5_Included PPI_CHG_CH5_Included
|
||||
#define PPI_CHG2_CH4_Pos PPI_CHG_CH4_Pos
|
||||
#define PPI_CHG2_CH4_Msk PPI_CHG_CH4_Msk
|
||||
#define PPI_CHG2_CH4_Excluded PPI_CHG_CH4_Excluded
|
||||
#define PPI_CHG2_CH4_Included PPI_CHG_CH4_Included
|
||||
#define PPI_CHG2_CH3_Pos PPI_CHG_CH3_Pos
|
||||
#define PPI_CHG2_CH3_Msk PPI_CHG_CH3_Msk
|
||||
#define PPI_CHG2_CH3_Excluded PPI_CHG_CH3_Excluded
|
||||
#define PPI_CHG2_CH3_Included PPI_CHG_CH3_Included
|
||||
#define PPI_CHG2_CH2_Pos PPI_CHG_CH2_Pos
|
||||
#define PPI_CHG2_CH2_Msk PPI_CHG_CH2_Msk
|
||||
#define PPI_CHG2_CH2_Excluded PPI_CHG_CH2_Excluded
|
||||
#define PPI_CHG2_CH2_Included PPI_CHG_CH2_Included
|
||||
#define PPI_CHG2_CH1_Pos PPI_CHG_CH1_Pos
|
||||
#define PPI_CHG2_CH1_Msk PPI_CHG_CH1_Msk
|
||||
#define PPI_CHG2_CH1_Excluded PPI_CHG_CH1_Excluded
|
||||
#define PPI_CHG2_CH1_Included PPI_CHG_CH1_Included
|
||||
#define PPI_CHG2_CH0_Pos PPI_CHG_CH0_Pos
|
||||
#define PPI_CHG2_CH0_Msk PPI_CHG_CH0_Msk
|
||||
#define PPI_CHG2_CH0_Excluded PPI_CHG_CH0_Excluded
|
||||
#define PPI_CHG2_CH0_Included PPI_CHG_CH0_Included
|
||||
#define PPI_CHG3_CH15_Pos PPI_CHG_CH15_Pos
|
||||
#define PPI_CHG3_CH15_Msk PPI_CHG_CH15_Msk
|
||||
#define PPI_CHG3_CH15_Excluded PPI_CHG_CH15_Excluded
|
||||
#define PPI_CHG3_CH15_Included PPI_CHG_CH15_Included
|
||||
#define PPI_CHG3_CH14_Pos PPI_CHG_CH14_Pos
|
||||
#define PPI_CHG3_CH14_Msk PPI_CHG_CH14_Msk
|
||||
#define PPI_CHG3_CH14_Excluded PPI_CHG_CH14_Excluded
|
||||
#define PPI_CHG3_CH14_Included PPI_CHG_CH14_Included
|
||||
#define PPI_CHG3_CH13_Pos PPI_CHG_CH13_Pos
|
||||
#define PPI_CHG3_CH13_Msk PPI_CHG_CH13_Msk
|
||||
#define PPI_CHG3_CH13_Excluded PPI_CHG_CH13_Excluded
|
||||
#define PPI_CHG3_CH13_Included PPI_CHG_CH13_Included
|
||||
#define PPI_CHG3_CH12_Pos PPI_CHG_CH12_Pos
|
||||
#define PPI_CHG3_CH12_Msk PPI_CHG_CH12_Msk
|
||||
#define PPI_CHG3_CH12_Excluded PPI_CHG_CH12_Excluded
|
||||
#define PPI_CHG3_CH12_Included PPI_CHG_CH12_Included
|
||||
#define PPI_CHG3_CH11_Pos PPI_CHG_CH11_Pos
|
||||
#define PPI_CHG3_CH11_Msk PPI_CHG_CH11_Msk
|
||||
#define PPI_CHG3_CH11_Excluded PPI_CHG_CH11_Excluded
|
||||
#define PPI_CHG3_CH11_Included PPI_CHG_CH11_Included
|
||||
#define PPI_CHG3_CH10_Pos PPI_CHG_CH10_Pos
|
||||
#define PPI_CHG3_CH10_Msk PPI_CHG_CH10_Msk
|
||||
#define PPI_CHG3_CH10_Excluded PPI_CHG_CH10_Excluded
|
||||
#define PPI_CHG3_CH10_Included PPI_CHG_CH10_Included
|
||||
#define PPI_CHG3_CH9_Pos PPI_CHG_CH9_Pos
|
||||
#define PPI_CHG3_CH9_Msk PPI_CHG_CH9_Msk
|
||||
#define PPI_CHG3_CH9_Excluded PPI_CHG_CH9_Excluded
|
||||
#define PPI_CHG3_CH9_Included PPI_CHG_CH9_Included
|
||||
#define PPI_CHG3_CH8_Pos PPI_CHG_CH8_Pos
|
||||
#define PPI_CHG3_CH8_Msk PPI_CHG_CH8_Msk
|
||||
#define PPI_CHG3_CH8_Excluded PPI_CHG_CH8_Excluded
|
||||
#define PPI_CHG3_CH8_Included PPI_CHG_CH8_Included
|
||||
#define PPI_CHG3_CH7_Pos PPI_CHG_CH7_Pos
|
||||
#define PPI_CHG3_CH7_Msk PPI_CHG_CH7_Msk
|
||||
#define PPI_CHG3_CH7_Excluded PPI_CHG_CH7_Excluded
|
||||
#define PPI_CHG3_CH7_Included PPI_CHG_CH7_Included
|
||||
#define PPI_CHG3_CH6_Pos PPI_CHG_CH6_Pos
|
||||
#define PPI_CHG3_CH6_Msk PPI_CHG_CH6_Msk
|
||||
#define PPI_CHG3_CH6_Excluded PPI_CHG_CH6_Excluded
|
||||
#define PPI_CHG3_CH6_Included PPI_CHG_CH6_Included
|
||||
#define PPI_CHG3_CH5_Pos PPI_CHG_CH5_Pos
|
||||
#define PPI_CHG3_CH5_Msk PPI_CHG_CH5_Msk
|
||||
#define PPI_CHG3_CH5_Excluded PPI_CHG_CH5_Excluded
|
||||
#define PPI_CHG3_CH5_Included PPI_CHG_CH5_Included
|
||||
#define PPI_CHG3_CH4_Pos PPI_CHG_CH4_Pos
|
||||
#define PPI_CHG3_CH4_Msk PPI_CHG_CH4_Msk
|
||||
#define PPI_CHG3_CH4_Excluded PPI_CHG_CH4_Excluded
|
||||
#define PPI_CHG3_CH4_Included PPI_CHG_CH4_Included
|
||||
#define PPI_CHG3_CH3_Pos PPI_CHG_CH3_Pos
|
||||
#define PPI_CHG3_CH3_Msk PPI_CHG_CH3_Msk
|
||||
#define PPI_CHG3_CH3_Excluded PPI_CHG_CH3_Excluded
|
||||
#define PPI_CHG3_CH3_Included PPI_CHG_CH3_Included
|
||||
#define PPI_CHG3_CH2_Pos PPI_CHG_CH2_Pos
|
||||
#define PPI_CHG3_CH2_Msk PPI_CHG_CH2_Msk
|
||||
#define PPI_CHG3_CH2_Excluded PPI_CHG_CH2_Excluded
|
||||
#define PPI_CHG3_CH2_Included PPI_CHG_CH2_Included
|
||||
#define PPI_CHG3_CH1_Pos PPI_CHG_CH1_Pos
|
||||
#define PPI_CHG3_CH1_Msk PPI_CHG_CH1_Msk
|
||||
#define PPI_CHG3_CH1_Excluded PPI_CHG_CH1_Excluded
|
||||
#define PPI_CHG3_CH1_Included PPI_CHG_CH1_Included
|
||||
#define PPI_CHG3_CH0_Pos PPI_CHG_CH0_Pos
|
||||
#define PPI_CHG3_CH0_Msk PPI_CHG_CH0_Msk
|
||||
#define PPI_CHG3_CH0_Excluded PPI_CHG_CH0_Excluded
|
||||
#define PPI_CHG3_CH0_Included PPI_CHG_CH0_Included
|
||||
|
||||
|
||||
|
||||
/*lint --flb "Leave library region" */
|
||||
|
||||
#endif /* NRF51_DEPRECATED_H */
|
||||
|
|
@ -0,0 +1,944 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 NRF51_TO_NRF52_H
|
||||
#define NRF51_TO_NRF52_H
|
||||
|
||||
/*lint ++flb "Enter library region */
|
||||
|
||||
/* This file is given to prevent your SW from not compiling with the name changes between nRF51 and nRF52 devices.
|
||||
* It redefines the old nRF51 names into the new ones as long as the functionality is still supported. If the
|
||||
* functionality is gone, there old names are not define, so compilation will fail. Note that also includes macros
|
||||
* from the nrf51_deprecated.h file. */
|
||||
|
||||
|
||||
/* IRQ */
|
||||
/* Several peripherals have been added to several indexes. Names of IRQ handlers and IRQ numbers have changed. */
|
||||
#define UART0_IRQHandler UARTE0_UART0_IRQHandler
|
||||
#define SPI0_TWI0_IRQHandler SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
|
||||
#define SPI1_TWI1_IRQHandler SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
|
||||
#define ADC_IRQHandler SAADC_IRQHandler
|
||||
#define LPCOMP_IRQHandler COMP_LPCOMP_IRQHandler
|
||||
#define SWI0_IRQHandler SWI0_EGU0_IRQHandler
|
||||
#define SWI1_IRQHandler SWI1_EGU1_IRQHandler
|
||||
#define SWI2_IRQHandler SWI2_EGU2_IRQHandler
|
||||
#define SWI3_IRQHandler SWI3_EGU3_IRQHandler
|
||||
#define SWI4_IRQHandler SWI4_EGU4_IRQHandler
|
||||
#define SWI5_IRQHandler SWI5_EGU5_IRQHandler
|
||||
|
||||
#define UART0_IRQn UARTE0_UART0_IRQn
|
||||
#define SPI0_TWI0_IRQn SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn
|
||||
#define SPI1_TWI1_IRQn SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn
|
||||
#define ADC_IRQn SAADC_IRQn
|
||||
#define LPCOMP_IRQn COMP_LPCOMP_IRQn
|
||||
#define SWI0_IRQn SWI0_EGU0_IRQn
|
||||
#define SWI1_IRQn SWI1_EGU1_IRQn
|
||||
#define SWI2_IRQn SWI2_EGU2_IRQn
|
||||
#define SWI3_IRQn SWI3_EGU3_IRQn
|
||||
#define SWI4_IRQn SWI4_EGU4_IRQn
|
||||
#define SWI5_IRQn SWI5_EGU5_IRQn
|
||||
|
||||
|
||||
/* UICR */
|
||||
/* Register RBPCONF was renamed to APPROTECT. */
|
||||
#define RBPCONF APPROTECT
|
||||
|
||||
#define UICR_RBPCONF_PALL_Pos UICR_APPROTECT_PALL_Pos
|
||||
#define UICR_RBPCONF_PALL_Msk UICR_APPROTECT_PALL_Msk
|
||||
#define UICR_RBPCONF_PALL_Enabled UICR_APPROTECT_PALL_Enabled
|
||||
#define UICR_RBPCONF_PALL_Disabled UICR_APPROTECT_PALL_Disabled
|
||||
|
||||
|
||||
/* GPIO */
|
||||
/* GPIO port was renamed to P0. */
|
||||
#define NRF_GPIO NRF_P0
|
||||
#define NRF_GPIO_BASE NRF_P0_BASE
|
||||
|
||||
|
||||
/* SPIS */
|
||||
/* The registers PSELSCK, PSELMISO, PSELMOSI, PSELCSN were restructured into a struct. */
|
||||
#define PSELSCK PSEL.SCK
|
||||
#define PSELMISO PSEL.MISO
|
||||
#define PSELMOSI PSEL.MOSI
|
||||
#define PSELCSN PSEL.CSN
|
||||
|
||||
/* The registers RXDPTR, MAXRX, AMOUNTRX were restructured into a struct */
|
||||
#define RXDPTR RXD.PTR
|
||||
#define MAXRX RXD.MAXCNT
|
||||
#define AMOUNTRX RXD.AMOUNT
|
||||
|
||||
#define SPIS_MAXRX_MAXRX_Pos SPIS_RXD_MAXCNT_MAXCNT_Pos
|
||||
#define SPIS_MAXRX_MAXRX_Msk SPIS_RXD_MAXCNT_MAXCNT_Msk
|
||||
|
||||
#define SPIS_AMOUNTRX_AMOUNTRX_Pos SPIS_RXD_AMOUNT_AMOUNT_Pos
|
||||
#define SPIS_AMOUNTRX_AMOUNTRX_Msk SPIS_RXD_AMOUNT_AMOUNT_Msk
|
||||
|
||||
/* The registers TXDPTR, MAXTX, AMOUNTTX were restructured into a struct */
|
||||
#define TXDPTR TXD.PTR
|
||||
#define MAXTX TXD.MAXCNT
|
||||
#define AMOUNTTX TXD.AMOUNT
|
||||
|
||||
#define SPIS_MAXTX_MAXTX_Pos SPIS_TXD_MAXCNT_MAXCNT_Pos
|
||||
#define SPIS_MAXTX_MAXTX_Msk SPIS_TXD_MAXCNT_MAXCNT_Msk
|
||||
|
||||
#define SPIS_AMOUNTTX_AMOUNTTX_Pos SPIS_TXD_AMOUNT_AMOUNT_Pos
|
||||
#define SPIS_AMOUNTTX_AMOUNTTX_Msk SPIS_TXD_AMOUNT_AMOUNT_Msk
|
||||
|
||||
|
||||
/* MPU */
|
||||
/* Part of MPU module was renamed BPROT, while the rest was eliminated. */
|
||||
#define NRF_MPU NRF_BPROT
|
||||
|
||||
/* Register DISABLEINDEBUG macros were affected. */
|
||||
#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Pos
|
||||
#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Msk BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Msk
|
||||
#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Enabled BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Enabled
|
||||
#define MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled BPROT_DISABLEINDEBUG_DISABLEINDEBUG_Disabled
|
||||
|
||||
/* Registers PROTENSET0 and PROTENSET1 were affected and renamed as CONFIG0 and CONFIG1. */
|
||||
#define PROTENSET0 CONFIG0
|
||||
#define PROTENSET1 CONFIG1
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG63_Pos BPROT_CONFIG1_REGION63_Pos
|
||||
#define MPU_PROTENSET1_PROTREG63_Msk BPROT_CONFIG1_REGION63_Msk
|
||||
#define MPU_PROTENSET1_PROTREG63_Disabled BPROT_CONFIG1_REGION63_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG63_Enabled BPROT_CONFIG1_REGION63_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG63_Set BPROT_CONFIG1_REGION63_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG62_Pos BPROT_CONFIG1_REGION62_Pos
|
||||
#define MPU_PROTENSET1_PROTREG62_Msk BPROT_CONFIG1_REGION62_Msk
|
||||
#define MPU_PROTENSET1_PROTREG62_Disabled BPROT_CONFIG1_REGION62_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG62_Enabled BPROT_CONFIG1_REGION62_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG62_Set BPROT_CONFIG1_REGION62_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG61_Pos BPROT_CONFIG1_REGION61_Pos
|
||||
#define MPU_PROTENSET1_PROTREG61_Msk BPROT_CONFIG1_REGION61_Msk
|
||||
#define MPU_PROTENSET1_PROTREG61_Disabled BPROT_CONFIG1_REGION61_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG61_Enabled BPROT_CONFIG1_REGION61_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG61_Set BPROT_CONFIG1_REGION61_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG60_Pos BPROT_CONFIG1_REGION60_Pos
|
||||
#define MPU_PROTENSET1_PROTREG60_Msk BPROT_CONFIG1_REGION60_Msk
|
||||
#define MPU_PROTENSET1_PROTREG60_Disabled BPROT_CONFIG1_REGION60_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG60_Enabled BPROT_CONFIG1_REGION60_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG60_Set BPROT_CONFIG1_REGION60_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG59_Pos BPROT_CONFIG1_REGION59_Pos
|
||||
#define MPU_PROTENSET1_PROTREG59_Msk BPROT_CONFIG1_REGION59_Msk
|
||||
#define MPU_PROTENSET1_PROTREG59_Disabled BPROT_CONFIG1_REGION59_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG59_Enabled BPROT_CONFIG1_REGION59_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG59_Set BPROT_CONFIG1_REGION59_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG58_Pos BPROT_CONFIG1_REGION58_Pos
|
||||
#define MPU_PROTENSET1_PROTREG58_Msk BPROT_CONFIG1_REGION58_Msk
|
||||
#define MPU_PROTENSET1_PROTREG58_Disabled BPROT_CONFIG1_REGION58_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG58_Enabled BPROT_CONFIG1_REGION58_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG58_Set BPROT_CONFIG1_REGION58_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG57_Pos BPROT_CONFIG1_REGION57_Pos
|
||||
#define MPU_PROTENSET1_PROTREG57_Msk BPROT_CONFIG1_REGION57_Msk
|
||||
#define MPU_PROTENSET1_PROTREG57_Disabled BPROT_CONFIG1_REGION57_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG57_Enabled BPROT_CONFIG1_REGION57_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG57_Set BPROT_CONFIG1_REGION57_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG56_Pos BPROT_CONFIG1_REGION56_Pos
|
||||
#define MPU_PROTENSET1_PROTREG56_Msk BPROT_CONFIG1_REGION56_Msk
|
||||
#define MPU_PROTENSET1_PROTREG56_Disabled BPROT_CONFIG1_REGION56_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG56_Enabled BPROT_CONFIG1_REGION56_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG56_Set BPROT_CONFIG1_REGION56_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG55_Pos BPROT_CONFIG1_REGION55_Pos
|
||||
#define MPU_PROTENSET1_PROTREG55_Msk BPROT_CONFIG1_REGION55_Msk
|
||||
#define MPU_PROTENSET1_PROTREG55_Disabled BPROT_CONFIG1_REGION55_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG55_Enabled BPROT_CONFIG1_REGION55_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG55_Set BPROT_CONFIG1_REGION55_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG54_Pos BPROT_CONFIG1_REGION54_Pos
|
||||
#define MPU_PROTENSET1_PROTREG54_Msk BPROT_CONFIG1_REGION54_Msk
|
||||
#define MPU_PROTENSET1_PROTREG54_Disabled BPROT_CONFIG1_REGION54_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG54_Enabled BPROT_CONFIG1_REGION54_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG54_Set BPROT_CONFIG1_REGION54_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG53_Pos BPROT_CONFIG1_REGION53_Pos
|
||||
#define MPU_PROTENSET1_PROTREG53_Msk BPROT_CONFIG1_REGION53_Msk
|
||||
#define MPU_PROTENSET1_PROTREG53_Disabled BPROT_CONFIG1_REGION53_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG53_Enabled BPROT_CONFIG1_REGION53_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG53_Set BPROT_CONFIG1_REGION53_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG52_Pos BPROT_CONFIG1_REGION52_Pos
|
||||
#define MPU_PROTENSET1_PROTREG52_Msk BPROT_CONFIG1_REGION52_Msk
|
||||
#define MPU_PROTENSET1_PROTREG52_Disabled BPROT_CONFIG1_REGION52_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG52_Enabled BPROT_CONFIG1_REGION52_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG52_Set BPROT_CONFIG1_REGION52_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG51_Pos BPROT_CONFIG1_REGION51_Pos
|
||||
#define MPU_PROTENSET1_PROTREG51_Msk BPROT_CONFIG1_REGION51_Msk
|
||||
#define MPU_PROTENSET1_PROTREG51_Disabled BPROT_CONFIG1_REGION51_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG51_Enabled BPROT_CONFIG1_REGION51_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG51_Set BPROT_CONFIG1_REGION51_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG50_Pos BPROT_CONFIG1_REGION50_Pos
|
||||
#define MPU_PROTENSET1_PROTREG50_Msk BPROT_CONFIG1_REGION50_Msk
|
||||
#define MPU_PROTENSET1_PROTREG50_Disabled BPROT_CONFIG1_REGION50_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG50_Enabled BPROT_CONFIG1_REGION50_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG50_Set BPROT_CONFIG1_REGION50_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG49_Pos BPROT_CONFIG1_REGION49_Pos
|
||||
#define MPU_PROTENSET1_PROTREG49_Msk BPROT_CONFIG1_REGION49_Msk
|
||||
#define MPU_PROTENSET1_PROTREG49_Disabled BPROT_CONFIG1_REGION49_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG49_Enabled BPROT_CONFIG1_REGION49_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG49_Set BPROT_CONFIG1_REGION49_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG48_Pos BPROT_CONFIG1_REGION48_Pos
|
||||
#define MPU_PROTENSET1_PROTREG48_Msk BPROT_CONFIG1_REGION48_Msk
|
||||
#define MPU_PROTENSET1_PROTREG48_Disabled BPROT_CONFIG1_REGION48_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG48_Enabled BPROT_CONFIG1_REGION48_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG48_Set BPROT_CONFIG1_REGION48_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG47_Pos BPROT_CONFIG1_REGION47_Pos
|
||||
#define MPU_PROTENSET1_PROTREG47_Msk BPROT_CONFIG1_REGION47_Msk
|
||||
#define MPU_PROTENSET1_PROTREG47_Disabled BPROT_CONFIG1_REGION47_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG47_Enabled BPROT_CONFIG1_REGION47_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG47_Set BPROT_CONFIG1_REGION47_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG46_Pos BPROT_CONFIG1_REGION46_Pos
|
||||
#define MPU_PROTENSET1_PROTREG46_Msk BPROT_CONFIG1_REGION46_Msk
|
||||
#define MPU_PROTENSET1_PROTREG46_Disabled BPROT_CONFIG1_REGION46_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG46_Enabled BPROT_CONFIG1_REGION46_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG46_Set BPROT_CONFIG1_REGION46_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG45_Pos BPROT_CONFIG1_REGION45_Pos
|
||||
#define MPU_PROTENSET1_PROTREG45_Msk BPROT_CONFIG1_REGION45_Msk
|
||||
#define MPU_PROTENSET1_PROTREG45_Disabled BPROT_CONFIG1_REGION45_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG45_Enabled BPROT_CONFIG1_REGION45_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG45_Set BPROT_CONFIG1_REGION45_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG44_Pos BPROT_CONFIG1_REGION44_Pos
|
||||
#define MPU_PROTENSET1_PROTREG44_Msk BPROT_CONFIG1_REGION44_Msk
|
||||
#define MPU_PROTENSET1_PROTREG44_Disabled BPROT_CONFIG1_REGION44_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG44_Enabled BPROT_CONFIG1_REGION44_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG44_Set BPROT_CONFIG1_REGION44_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG43_Pos BPROT_CONFIG1_REGION43_Pos
|
||||
#define MPU_PROTENSET1_PROTREG43_Msk BPROT_CONFIG1_REGION43_Msk
|
||||
#define MPU_PROTENSET1_PROTREG43_Disabled BPROT_CONFIG1_REGION43_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG43_Enabled BPROT_CONFIG1_REGION43_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG43_Set BPROT_CONFIG1_REGION43_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG42_Pos BPROT_CONFIG1_REGION42_Pos
|
||||
#define MPU_PROTENSET1_PROTREG42_Msk BPROT_CONFIG1_REGION42_Msk
|
||||
#define MPU_PROTENSET1_PROTREG42_Disabled BPROT_CONFIG1_REGION42_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG42_Enabled BPROT_CONFIG1_REGION42_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG42_Set BPROT_CONFIG1_REGION42_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG41_Pos BPROT_CONFIG1_REGION41_Pos
|
||||
#define MPU_PROTENSET1_PROTREG41_Msk BPROT_CONFIG1_REGION41_Msk
|
||||
#define MPU_PROTENSET1_PROTREG41_Disabled BPROT_CONFIG1_REGION41_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG41_Enabled BPROT_CONFIG1_REGION41_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG41_Set BPROT_CONFIG1_REGION41_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG40_Pos BPROT_CONFIG1_REGION40_Pos
|
||||
#define MPU_PROTENSET1_PROTREG40_Msk BPROT_CONFIG1_REGION40_Msk
|
||||
#define MPU_PROTENSET1_PROTREG40_Disabled BPROT_CONFIG1_REGION40_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG40_Enabled BPROT_CONFIG1_REGION40_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG40_Set BPROT_CONFIG1_REGION40_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG39_Pos BPROT_CONFIG1_REGION39_Pos
|
||||
#define MPU_PROTENSET1_PROTREG39_Msk BPROT_CONFIG1_REGION39_Msk
|
||||
#define MPU_PROTENSET1_PROTREG39_Disabled BPROT_CONFIG1_REGION39_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG39_Enabled BPROT_CONFIG1_REGION39_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG39_Set BPROT_CONFIG1_REGION39_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG38_Pos BPROT_CONFIG1_REGION38_Pos
|
||||
#define MPU_PROTENSET1_PROTREG38_Msk BPROT_CONFIG1_REGION38_Msk
|
||||
#define MPU_PROTENSET1_PROTREG38_Disabled BPROT_CONFIG1_REGION38_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG38_Enabled BPROT_CONFIG1_REGION38_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG38_Set BPROT_CONFIG1_REGION38_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG37_Pos BPROT_CONFIG1_REGION37_Pos
|
||||
#define MPU_PROTENSET1_PROTREG37_Msk BPROT_CONFIG1_REGION37_Msk
|
||||
#define MPU_PROTENSET1_PROTREG37_Disabled BPROT_CONFIG1_REGION37_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG37_Enabled BPROT_CONFIG1_REGION37_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG37_Set BPROT_CONFIG1_REGION37_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG36_Pos BPROT_CONFIG1_REGION36_Pos
|
||||
#define MPU_PROTENSET1_PROTREG36_Msk BPROT_CONFIG1_REGION36_Msk
|
||||
#define MPU_PROTENSET1_PROTREG36_Disabled BPROT_CONFIG1_REGION36_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG36_Enabled BPROT_CONFIG1_REGION36_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG36_Set BPROT_CONFIG1_REGION36_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG35_Pos BPROT_CONFIG1_REGION35_Pos
|
||||
#define MPU_PROTENSET1_PROTREG35_Msk BPROT_CONFIG1_REGION35_Msk
|
||||
#define MPU_PROTENSET1_PROTREG35_Disabled BPROT_CONFIG1_REGION35_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG35_Enabled BPROT_CONFIG1_REGION35_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG35_Set BPROT_CONFIG1_REGION35_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG34_Pos BPROT_CONFIG1_REGION34_Pos
|
||||
#define MPU_PROTENSET1_PROTREG34_Msk BPROT_CONFIG1_REGION34_Msk
|
||||
#define MPU_PROTENSET1_PROTREG34_Disabled BPROT_CONFIG1_REGION34_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG34_Enabled BPROT_CONFIG1_REGION34_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG34_Set BPROT_CONFIG1_REGION34_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG33_Pos BPROT_CONFIG1_REGION33_Pos
|
||||
#define MPU_PROTENSET1_PROTREG33_Msk BPROT_CONFIG1_REGION33_Msk
|
||||
#define MPU_PROTENSET1_PROTREG33_Disabled BPROT_CONFIG1_REGION33_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG33_Enabled BPROT_CONFIG1_REGION33_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG33_Set BPROT_CONFIG1_REGION33_Enabled
|
||||
|
||||
#define MPU_PROTENSET1_PROTREG32_Pos BPROT_CONFIG1_REGION32_Pos
|
||||
#define MPU_PROTENSET1_PROTREG32_Msk BPROT_CONFIG1_REGION32_Msk
|
||||
#define MPU_PROTENSET1_PROTREG32_Disabled BPROT_CONFIG1_REGION32_Disabled
|
||||
#define MPU_PROTENSET1_PROTREG32_Enabled BPROT_CONFIG1_REGION32_Enabled
|
||||
#define MPU_PROTENSET1_PROTREG32_Set BPROT_CONFIG1_REGION32_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG31_Pos BPROT_CONFIG0_REGION31_Pos
|
||||
#define MPU_PROTENSET0_PROTREG31_Msk BPROT_CONFIG0_REGION31_Msk
|
||||
#define MPU_PROTENSET0_PROTREG31_Disabled BPROT_CONFIG0_REGION31_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG31_Enabled BPROT_CONFIG0_REGION31_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG31_Set BPROT_CONFIG0_REGION31_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG30_Pos BPROT_CONFIG0_REGION30_Pos
|
||||
#define MPU_PROTENSET0_PROTREG30_Msk BPROT_CONFIG0_REGION30_Msk
|
||||
#define MPU_PROTENSET0_PROTREG30_Disabled BPROT_CONFIG0_REGION30_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG30_Enabled BPROT_CONFIG0_REGION30_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG30_Set BPROT_CONFIG0_REGION30_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG29_Pos BPROT_CONFIG0_REGION29_Pos
|
||||
#define MPU_PROTENSET0_PROTREG29_Msk BPROT_CONFIG0_REGION29_Msk
|
||||
#define MPU_PROTENSET0_PROTREG29_Disabled BPROT_CONFIG0_REGION29_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG29_Enabled BPROT_CONFIG0_REGION29_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG29_Set BPROT_CONFIG0_REGION29_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG28_Pos BPROT_CONFIG0_REGION28_Pos
|
||||
#define MPU_PROTENSET0_PROTREG28_Msk BPROT_CONFIG0_REGION28_Msk
|
||||
#define MPU_PROTENSET0_PROTREG28_Disabled BPROT_CONFIG0_REGION28_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG28_Enabled BPROT_CONFIG0_REGION28_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG28_Set BPROT_CONFIG0_REGION28_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG27_Pos BPROT_CONFIG0_REGION27_Pos
|
||||
#define MPU_PROTENSET0_PROTREG27_Msk BPROT_CONFIG0_REGION27_Msk
|
||||
#define MPU_PROTENSET0_PROTREG27_Disabled BPROT_CONFIG0_REGION27_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG27_Enabled BPROT_CONFIG0_REGION27_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG27_Set BPROT_CONFIG0_REGION27_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG26_Pos BPROT_CONFIG0_REGION26_Pos
|
||||
#define MPU_PROTENSET0_PROTREG26_Msk BPROT_CONFIG0_REGION26_Msk
|
||||
#define MPU_PROTENSET0_PROTREG26_Disabled BPROT_CONFIG0_REGION26_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG26_Enabled BPROT_CONFIG0_REGION26_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG26_Set BPROT_CONFIG0_REGION26_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG25_Pos BPROT_CONFIG0_REGION25_Pos
|
||||
#define MPU_PROTENSET0_PROTREG25_Msk BPROT_CONFIG0_REGION25_Msk
|
||||
#define MPU_PROTENSET0_PROTREG25_Disabled BPROT_CONFIG0_REGION25_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG25_Enabled BPROT_CONFIG0_REGION25_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG25_Set BPROT_CONFIG0_REGION25_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG24_Pos BPROT_CONFIG0_REGION24_Pos
|
||||
#define MPU_PROTENSET0_PROTREG24_Msk BPROT_CONFIG0_REGION24_Msk
|
||||
#define MPU_PROTENSET0_PROTREG24_Disabled BPROT_CONFIG0_REGION24_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG24_Enabled BPROT_CONFIG0_REGION24_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG24_Set BPROT_CONFIG0_REGION24_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG23_Pos BPROT_CONFIG0_REGION23_Pos
|
||||
#define MPU_PROTENSET0_PROTREG23_Msk BPROT_CONFIG0_REGION23_Msk
|
||||
#define MPU_PROTENSET0_PROTREG23_Disabled BPROT_CONFIG0_REGION23_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG23_Enabled BPROT_CONFIG0_REGION23_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG23_Set BPROT_CONFIG0_REGION23_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG22_Pos BPROT_CONFIG0_REGION22_Pos
|
||||
#define MPU_PROTENSET0_PROTREG22_Msk BPROT_CONFIG0_REGION22_Msk
|
||||
#define MPU_PROTENSET0_PROTREG22_Disabled BPROT_CONFIG0_REGION22_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG22_Enabled BPROT_CONFIG0_REGION22_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG22_Set BPROT_CONFIG0_REGION22_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG21_Pos BPROT_CONFIG0_REGION21_Pos
|
||||
#define MPU_PROTENSET0_PROTREG21_Msk BPROT_CONFIG0_REGION21_Msk
|
||||
#define MPU_PROTENSET0_PROTREG21_Disabled BPROT_CONFIG0_REGION21_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG21_Enabled BPROT_CONFIG0_REGION21_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG21_Set BPROT_CONFIG0_REGION21_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG20_Pos BPROT_CONFIG0_REGION20_Pos
|
||||
#define MPU_PROTENSET0_PROTREG20_Msk BPROT_CONFIG0_REGION20_Msk
|
||||
#define MPU_PROTENSET0_PROTREG20_Disabled BPROT_CONFIG0_REGION20_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG20_Enabled BPROT_CONFIG0_REGION20_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG20_Set BPROT_CONFIG0_REGION20_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG19_Pos BPROT_CONFIG0_REGION19_Pos
|
||||
#define MPU_PROTENSET0_PROTREG19_Msk BPROT_CONFIG0_REGION19_Msk
|
||||
#define MPU_PROTENSET0_PROTREG19_Disabled BPROT_CONFIG0_REGION19_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG19_Enabled BPROT_CONFIG0_REGION19_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG19_Set BPROT_CONFIG0_REGION19_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG18_Pos BPROT_CONFIG0_REGION18_Pos
|
||||
#define MPU_PROTENSET0_PROTREG18_Msk BPROT_CONFIG0_REGION18_Msk
|
||||
#define MPU_PROTENSET0_PROTREG18_Disabled BPROT_CONFIG0_REGION18_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG18_Enabled BPROT_CONFIG0_REGION18_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG18_Set BPROT_CONFIG0_REGION18_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG17_Pos BPROT_CONFIG0_REGION17_Pos
|
||||
#define MPU_PROTENSET0_PROTREG17_Msk BPROT_CONFIG0_REGION17_Msk
|
||||
#define MPU_PROTENSET0_PROTREG17_Disabled BPROT_CONFIG0_REGION17_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG17_Enabled BPROT_CONFIG0_REGION17_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG17_Set BPROT_CONFIG0_REGION17_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG16_Pos BPROT_CONFIG0_REGION16_Pos
|
||||
#define MPU_PROTENSET0_PROTREG16_Msk BPROT_CONFIG0_REGION16_Msk
|
||||
#define MPU_PROTENSET0_PROTREG16_Disabled BPROT_CONFIG0_REGION16_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG16_Enabled BPROT_CONFIG0_REGION16_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG16_Set BPROT_CONFIG0_REGION16_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG15_Pos BPROT_CONFIG0_REGION15_Pos
|
||||
#define MPU_PROTENSET0_PROTREG15_Msk BPROT_CONFIG0_REGION15_Msk
|
||||
#define MPU_PROTENSET0_PROTREG15_Disabled BPROT_CONFIG0_REGION15_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG15_Enabled BPROT_CONFIG0_REGION15_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG15_Set BPROT_CONFIG0_REGION15_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG14_Pos BPROT_CONFIG0_REGION14_Pos
|
||||
#define MPU_PROTENSET0_PROTREG14_Msk BPROT_CONFIG0_REGION14_Msk
|
||||
#define MPU_PROTENSET0_PROTREG14_Disabled BPROT_CONFIG0_REGION14_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG14_Enabled BPROT_CONFIG0_REGION14_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG14_Set BPROT_CONFIG0_REGION14_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG13_Pos BPROT_CONFIG0_REGION13_Pos
|
||||
#define MPU_PROTENSET0_PROTREG13_Msk BPROT_CONFIG0_REGION13_Msk
|
||||
#define MPU_PROTENSET0_PROTREG13_Disabled BPROT_CONFIG0_REGION13_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG13_Enabled BPROT_CONFIG0_REGION13_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG13_Set BPROT_CONFIG0_REGION13_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG12_Pos BPROT_CONFIG0_REGION12_Pos
|
||||
#define MPU_PROTENSET0_PROTREG12_Msk BPROT_CONFIG0_REGION12_Msk
|
||||
#define MPU_PROTENSET0_PROTREG12_Disabled BPROT_CONFIG0_REGION12_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG12_Enabled BPROT_CONFIG0_REGION12_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG12_Set BPROT_CONFIG0_REGION12_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG11_Pos BPROT_CONFIG0_REGION11_Pos
|
||||
#define MPU_PROTENSET0_PROTREG11_Msk BPROT_CONFIG0_REGION11_Msk
|
||||
#define MPU_PROTENSET0_PROTREG11_Disabled BPROT_CONFIG0_REGION11_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG11_Enabled BPROT_CONFIG0_REGION11_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG11_Set BPROT_CONFIG0_REGION11_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG10_Pos BPROT_CONFIG0_REGION10_Pos
|
||||
#define MPU_PROTENSET0_PROTREG10_Msk BPROT_CONFIG0_REGION10_Msk
|
||||
#define MPU_PROTENSET0_PROTREG10_Disabled BPROT_CONFIG0_REGION10_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG10_Enabled BPROT_CONFIG0_REGION10_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG10_Set BPROT_CONFIG0_REGION10_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG9_Pos BPROT_CONFIG0_REGION9_Pos
|
||||
#define MPU_PROTENSET0_PROTREG9_Msk BPROT_CONFIG0_REGION9_Msk
|
||||
#define MPU_PROTENSET0_PROTREG9_Disabled BPROT_CONFIG0_REGION9_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG9_Enabled BPROT_CONFIG0_REGION9_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG9_Set BPROT_CONFIG0_REGION9_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG8_Pos BPROT_CONFIG0_REGION8_Pos
|
||||
#define MPU_PROTENSET0_PROTREG8_Msk BPROT_CONFIG0_REGION8_Msk
|
||||
#define MPU_PROTENSET0_PROTREG8_Disabled BPROT_CONFIG0_REGION8_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG8_Enabled BPROT_CONFIG0_REGION8_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG8_Set BPROT_CONFIG0_REGION8_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG7_Pos BPROT_CONFIG0_REGION7_Pos
|
||||
#define MPU_PROTENSET0_PROTREG7_Msk BPROT_CONFIG0_REGION7_Msk
|
||||
#define MPU_PROTENSET0_PROTREG7_Disabled BPROT_CONFIG0_REGION7_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG7_Enabled BPROT_CONFIG0_REGION7_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG7_Set BPROT_CONFIG0_REGION7_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG6_Pos BPROT_CONFIG0_REGION6_Pos
|
||||
#define MPU_PROTENSET0_PROTREG6_Msk BPROT_CONFIG0_REGION6_Msk
|
||||
#define MPU_PROTENSET0_PROTREG6_Disabled BPROT_CONFIG0_REGION6_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG6_Enabled BPROT_CONFIG0_REGION6_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG6_Set BPROT_CONFIG0_REGION6_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG5_Pos BPROT_CONFIG0_REGION5_Pos
|
||||
#define MPU_PROTENSET0_PROTREG5_Msk BPROT_CONFIG0_REGION5_Msk
|
||||
#define MPU_PROTENSET0_PROTREG5_Disabled BPROT_CONFIG0_REGION5_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG5_Enabled BPROT_CONFIG0_REGION5_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG5_Set BPROT_CONFIG0_REGION5_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG4_Pos BPROT_CONFIG0_REGION4_Pos
|
||||
#define MPU_PROTENSET0_PROTREG4_Msk BPROT_CONFIG0_REGION4_Msk
|
||||
#define MPU_PROTENSET0_PROTREG4_Disabled BPROT_CONFIG0_REGION4_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG4_Enabled BPROT_CONFIG0_REGION4_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG4_Set BPROT_CONFIG0_REGION4_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG3_Pos BPROT_CONFIG0_REGION3_Pos
|
||||
#define MPU_PROTENSET0_PROTREG3_Msk BPROT_CONFIG0_REGION3_Msk
|
||||
#define MPU_PROTENSET0_PROTREG3_Disabled BPROT_CONFIG0_REGION3_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG3_Enabled BPROT_CONFIG0_REGION3_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG3_Set BPROT_CONFIG0_REGION3_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG2_Pos BPROT_CONFIG0_REGION2_Pos
|
||||
#define MPU_PROTENSET0_PROTREG2_Msk BPROT_CONFIG0_REGION2_Msk
|
||||
#define MPU_PROTENSET0_PROTREG2_Disabled BPROT_CONFIG0_REGION2_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG2_Enabled BPROT_CONFIG0_REGION2_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG2_Set BPROT_CONFIG0_REGION2_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG1_Pos BPROT_CONFIG0_REGION1_Pos
|
||||
#define MPU_PROTENSET0_PROTREG1_Msk BPROT_CONFIG0_REGION1_Msk
|
||||
#define MPU_PROTENSET0_PROTREG1_Disabled BPROT_CONFIG0_REGION1_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG1_Enabled BPROT_CONFIG0_REGION1_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG1_Set BPROT_CONFIG0_REGION1_Enabled
|
||||
|
||||
#define MPU_PROTENSET0_PROTREG0_Pos BPROT_CONFIG0_REGION0_Pos
|
||||
#define MPU_PROTENSET0_PROTREG0_Msk BPROT_CONFIG0_REGION0_Msk
|
||||
#define MPU_PROTENSET0_PROTREG0_Disabled BPROT_CONFIG0_REGION0_Disabled
|
||||
#define MPU_PROTENSET0_PROTREG0_Enabled BPROT_CONFIG0_REGION0_Enabled
|
||||
#define MPU_PROTENSET0_PROTREG0_Set BPROT_CONFIG0_REGION0_Enabled
|
||||
|
||||
|
||||
/* From nrf51_deprecated.h */
|
||||
|
||||
/* NVMC */
|
||||
/* The register ERASEPROTECTEDPAGE changed name to ERASEPCR0 in the documentation. */
|
||||
#define ERASEPROTECTEDPAGE ERASEPCR0
|
||||
|
||||
|
||||
/* IRQ */
|
||||
/* COMP module was eliminated. Adapted to nrf52 headers. */
|
||||
#define LPCOMP_COMP_IRQHandler COMP_LPCOMP_IRQHandler
|
||||
#define LPCOMP_COMP_IRQn COMP_LPCOMP_IRQn
|
||||
|
||||
|
||||
/* RADIO */
|
||||
/* The name of the field SKIPADDR was corrected. Old macros added for compatibility. */
|
||||
#define RADIO_CRCCNF_SKIP_ADDR_Pos RADIO_CRCCNF_SKIPADDR_Pos
|
||||
#define RADIO_CRCCNF_SKIP_ADDR_Msk RADIO_CRCCNF_SKIPADDR_Msk
|
||||
#define RADIO_CRCCNF_SKIP_ADDR_Include RADIO_CRCCNF_SKIPADDR_Include
|
||||
#define RADIO_CRCCNF_SKIP_ADDR_Skip RADIO_CRCCNF_SKIPADDR_Skip
|
||||
|
||||
|
||||
/* FICR */
|
||||
/* The registers FICR.DEVICEID0 and FICR.DEVICEID1 were renamed into an array. */
|
||||
#define DEVICEID0 DEVICEID[0]
|
||||
#define DEVICEID1 DEVICEID[1]
|
||||
|
||||
/* The registers FICR.ER0, FICR.ER1, FICR.ER2 and FICR.ER3 were renamed into an array. */
|
||||
#define ER0 ER[0]
|
||||
#define ER1 ER[1]
|
||||
#define ER2 ER[2]
|
||||
#define ER3 ER[3]
|
||||
|
||||
/* The registers FICR.IR0, FICR.IR1, FICR.IR2 and FICR.IR3 were renamed into an array. */
|
||||
#define IR0 IR[0]
|
||||
#define IR1 IR[1]
|
||||
#define IR2 IR[2]
|
||||
#define IR3 IR[3]
|
||||
|
||||
/* The registers FICR.DEVICEADDR0 and FICR.DEVICEADDR1 were renamed into an array. */
|
||||
#define DEVICEADDR0 DEVICEADDR[0]
|
||||
#define DEVICEADDR1 DEVICEADDR[1]
|
||||
|
||||
|
||||
/* PPI */
|
||||
/* The tasks PPI.TASKS_CHGxEN and PPI.TASKS_CHGxDIS were renamed into an array of structs. */
|
||||
#define TASKS_CHG0EN TASKS_CHG[0].EN
|
||||
#define TASKS_CHG0DIS TASKS_CHG[0].DIS
|
||||
#define TASKS_CHG1EN TASKS_CHG[1].EN
|
||||
#define TASKS_CHG1DIS TASKS_CHG[1].DIS
|
||||
#define TASKS_CHG2EN TASKS_CHG[2].EN
|
||||
#define TASKS_CHG2DIS TASKS_CHG[2].DIS
|
||||
#define TASKS_CHG3EN TASKS_CHG[3].EN
|
||||
#define TASKS_CHG3DIS TASKS_CHG[3].DIS
|
||||
|
||||
/* The registers PPI.CHx_EEP and PPI.CHx_TEP were renamed into an array of structs. */
|
||||
#define CH0_EEP CH[0].EEP
|
||||
#define CH0_TEP CH[0].TEP
|
||||
#define CH1_EEP CH[1].EEP
|
||||
#define CH1_TEP CH[1].TEP
|
||||
#define CH2_EEP CH[2].EEP
|
||||
#define CH2_TEP CH[2].TEP
|
||||
#define CH3_EEP CH[3].EEP
|
||||
#define CH3_TEP CH[3].TEP
|
||||
#define CH4_EEP CH[4].EEP
|
||||
#define CH4_TEP CH[4].TEP
|
||||
#define CH5_EEP CH[5].EEP
|
||||
#define CH5_TEP CH[5].TEP
|
||||
#define CH6_EEP CH[6].EEP
|
||||
#define CH6_TEP CH[6].TEP
|
||||
#define CH7_EEP CH[7].EEP
|
||||
#define CH7_TEP CH[7].TEP
|
||||
#define CH8_EEP CH[8].EEP
|
||||
#define CH8_TEP CH[8].TEP
|
||||
#define CH9_EEP CH[9].EEP
|
||||
#define CH9_TEP CH[9].TEP
|
||||
#define CH10_EEP CH[10].EEP
|
||||
#define CH10_TEP CH[10].TEP
|
||||
#define CH11_EEP CH[11].EEP
|
||||
#define CH11_TEP CH[11].TEP
|
||||
#define CH12_EEP CH[12].EEP
|
||||
#define CH12_TEP CH[12].TEP
|
||||
#define CH13_EEP CH[13].EEP
|
||||
#define CH13_TEP CH[13].TEP
|
||||
#define CH14_EEP CH[14].EEP
|
||||
#define CH14_TEP CH[14].TEP
|
||||
#define CH15_EEP CH[15].EEP
|
||||
#define CH15_TEP CH[15].TEP
|
||||
|
||||
/* The registers PPI.CHG0, PPI.CHG1, PPI.CHG2 and PPI.CHG3 were renamed into an array. */
|
||||
#define CHG0 CHG[0]
|
||||
#define CHG1 CHG[1]
|
||||
#define CHG2 CHG[2]
|
||||
#define CHG3 CHG[3]
|
||||
|
||||
/* All bitfield macros for the CHGx registers therefore changed name. */
|
||||
#define PPI_CHG0_CH15_Pos PPI_CHG_CH15_Pos
|
||||
#define PPI_CHG0_CH15_Msk PPI_CHG_CH15_Msk
|
||||
#define PPI_CHG0_CH15_Excluded PPI_CHG_CH15_Excluded
|
||||
#define PPI_CHG0_CH15_Included PPI_CHG_CH15_Included
|
||||
|
||||
#define PPI_CHG0_CH14_Pos PPI_CHG_CH14_Pos
|
||||
#define PPI_CHG0_CH14_Msk PPI_CHG_CH14_Msk
|
||||
#define PPI_CHG0_CH14_Excluded PPI_CHG_CH14_Excluded
|
||||
#define PPI_CHG0_CH14_Included PPI_CHG_CH14_Included
|
||||
|
||||
#define PPI_CHG0_CH13_Pos PPI_CHG_CH13_Pos
|
||||
#define PPI_CHG0_CH13_Msk PPI_CHG_CH13_Msk
|
||||
#define PPI_CHG0_CH13_Excluded PPI_CHG_CH13_Excluded
|
||||
#define PPI_CHG0_CH13_Included PPI_CHG_CH13_Included
|
||||
|
||||
#define PPI_CHG0_CH12_Pos PPI_CHG_CH12_Pos
|
||||
#define PPI_CHG0_CH12_Msk PPI_CHG_CH12_Msk
|
||||
#define PPI_CHG0_CH12_Excluded PPI_CHG_CH12_Excluded
|
||||
#define PPI_CHG0_CH12_Included PPI_CHG_CH12_Included
|
||||
|
||||
#define PPI_CHG0_CH11_Pos PPI_CHG_CH11_Pos
|
||||
#define PPI_CHG0_CH11_Msk PPI_CHG_CH11_Msk
|
||||
#define PPI_CHG0_CH11_Excluded PPI_CHG_CH11_Excluded
|
||||
#define PPI_CHG0_CH11_Included PPI_CHG_CH11_Included
|
||||
|
||||
#define PPI_CHG0_CH10_Pos PPI_CHG_CH10_Pos
|
||||
#define PPI_CHG0_CH10_Msk PPI_CHG_CH10_Msk
|
||||
#define PPI_CHG0_CH10_Excluded PPI_CHG_CH10_Excluded
|
||||
#define PPI_CHG0_CH10_Included PPI_CHG_CH10_Included
|
||||
|
||||
#define PPI_CHG0_CH9_Pos PPI_CHG_CH9_Pos
|
||||
#define PPI_CHG0_CH9_Msk PPI_CHG_CH9_Msk
|
||||
#define PPI_CHG0_CH9_Excluded PPI_CHG_CH9_Excluded
|
||||
#define PPI_CHG0_CH9_Included PPI_CHG_CH9_Included
|
||||
|
||||
#define PPI_CHG0_CH8_Pos PPI_CHG_CH8_Pos
|
||||
#define PPI_CHG0_CH8_Msk PPI_CHG_CH8_Msk
|
||||
#define PPI_CHG0_CH8_Excluded PPI_CHG_CH8_Excluded
|
||||
#define PPI_CHG0_CH8_Included PPI_CHG_CH8_Included
|
||||
|
||||
#define PPI_CHG0_CH7_Pos PPI_CHG_CH7_Pos
|
||||
#define PPI_CHG0_CH7_Msk PPI_CHG_CH7_Msk
|
||||
#define PPI_CHG0_CH7_Excluded PPI_CHG_CH7_Excluded
|
||||
#define PPI_CHG0_CH7_Included PPI_CHG_CH7_Included
|
||||
|
||||
#define PPI_CHG0_CH6_Pos PPI_CHG_CH6_Pos
|
||||
#define PPI_CHG0_CH6_Msk PPI_CHG_CH6_Msk
|
||||
#define PPI_CHG0_CH6_Excluded PPI_CHG_CH6_Excluded
|
||||
#define PPI_CHG0_CH6_Included PPI_CHG_CH6_Included
|
||||
|
||||
#define PPI_CHG0_CH5_Pos PPI_CHG_CH5_Pos
|
||||
#define PPI_CHG0_CH5_Msk PPI_CHG_CH5_Msk
|
||||
#define PPI_CHG0_CH5_Excluded PPI_CHG_CH5_Excluded
|
||||
#define PPI_CHG0_CH5_Included PPI_CHG_CH5_Included
|
||||
|
||||
#define PPI_CHG0_CH4_Pos PPI_CHG_CH4_Pos
|
||||
#define PPI_CHG0_CH4_Msk PPI_CHG_CH4_Msk
|
||||
#define PPI_CHG0_CH4_Excluded PPI_CHG_CH4_Excluded
|
||||
#define PPI_CHG0_CH4_Included PPI_CHG_CH4_Included
|
||||
|
||||
#define PPI_CHG0_CH3_Pos PPI_CHG_CH3_Pos
|
||||
#define PPI_CHG0_CH3_Msk PPI_CHG_CH3_Msk
|
||||
#define PPI_CHG0_CH3_Excluded PPI_CHG_CH3_Excluded
|
||||
#define PPI_CHG0_CH3_Included PPI_CHG_CH3_Included
|
||||
|
||||
#define PPI_CHG0_CH2_Pos PPI_CHG_CH2_Pos
|
||||
#define PPI_CHG0_CH2_Msk PPI_CHG_CH2_Msk
|
||||
#define PPI_CHG0_CH2_Excluded PPI_CHG_CH2_Excluded
|
||||
#define PPI_CHG0_CH2_Included PPI_CHG_CH2_Included
|
||||
|
||||
#define PPI_CHG0_CH1_Pos PPI_CHG_CH1_Pos
|
||||
#define PPI_CHG0_CH1_Msk PPI_CHG_CH1_Msk
|
||||
#define PPI_CHG0_CH1_Excluded PPI_CHG_CH1_Excluded
|
||||
#define PPI_CHG0_CH1_Included PPI_CHG_CH1_Included
|
||||
|
||||
#define PPI_CHG0_CH0_Pos PPI_CHG_CH0_Pos
|
||||
#define PPI_CHG0_CH0_Msk PPI_CHG_CH0_Msk
|
||||
#define PPI_CHG0_CH0_Excluded PPI_CHG_CH0_Excluded
|
||||
#define PPI_CHG0_CH0_Included PPI_CHG_CH0_Included
|
||||
|
||||
#define PPI_CHG1_CH15_Pos PPI_CHG_CH15_Pos
|
||||
#define PPI_CHG1_CH15_Msk PPI_CHG_CH15_Msk
|
||||
#define PPI_CHG1_CH15_Excluded PPI_CHG_CH15_Excluded
|
||||
#define PPI_CHG1_CH15_Included PPI_CHG_CH15_Included
|
||||
|
||||
#define PPI_CHG1_CH14_Pos PPI_CHG_CH14_Pos
|
||||
#define PPI_CHG1_CH14_Msk PPI_CHG_CH14_Msk
|
||||
#define PPI_CHG1_CH14_Excluded PPI_CHG_CH14_Excluded
|
||||
#define PPI_CHG1_CH14_Included PPI_CHG_CH14_Included
|
||||
|
||||
#define PPI_CHG1_CH13_Pos PPI_CHG_CH13_Pos
|
||||
#define PPI_CHG1_CH13_Msk PPI_CHG_CH13_Msk
|
||||
#define PPI_CHG1_CH13_Excluded PPI_CHG_CH13_Excluded
|
||||
#define PPI_CHG1_CH13_Included PPI_CHG_CH13_Included
|
||||
|
||||
#define PPI_CHG1_CH12_Pos PPI_CHG_CH12_Pos
|
||||
#define PPI_CHG1_CH12_Msk PPI_CHG_CH12_Msk
|
||||
#define PPI_CHG1_CH12_Excluded PPI_CHG_CH12_Excluded
|
||||
#define PPI_CHG1_CH12_Included PPI_CHG_CH12_Included
|
||||
|
||||
#define PPI_CHG1_CH11_Pos PPI_CHG_CH11_Pos
|
||||
#define PPI_CHG1_CH11_Msk PPI_CHG_CH11_Msk
|
||||
#define PPI_CHG1_CH11_Excluded PPI_CHG_CH11_Excluded
|
||||
#define PPI_CHG1_CH11_Included PPI_CHG_CH11_Included
|
||||
|
||||
#define PPI_CHG1_CH10_Pos PPI_CHG_CH10_Pos
|
||||
#define PPI_CHG1_CH10_Msk PPI_CHG_CH10_Msk
|
||||
#define PPI_CHG1_CH10_Excluded PPI_CHG_CH10_Excluded
|
||||
#define PPI_CHG1_CH10_Included PPI_CHG_CH10_Included
|
||||
|
||||
#define PPI_CHG1_CH9_Pos PPI_CHG_CH9_Pos
|
||||
#define PPI_CHG1_CH9_Msk PPI_CHG_CH9_Msk
|
||||
#define PPI_CHG1_CH9_Excluded PPI_CHG_CH9_Excluded
|
||||
#define PPI_CHG1_CH9_Included PPI_CHG_CH9_Included
|
||||
|
||||
#define PPI_CHG1_CH8_Pos PPI_CHG_CH8_Pos
|
||||
#define PPI_CHG1_CH8_Msk PPI_CHG_CH8_Msk
|
||||
#define PPI_CHG1_CH8_Excluded PPI_CHG_CH8_Excluded
|
||||
#define PPI_CHG1_CH8_Included PPI_CHG_CH8_Included
|
||||
|
||||
#define PPI_CHG1_CH7_Pos PPI_CHG_CH7_Pos
|
||||
#define PPI_CHG1_CH7_Msk PPI_CHG_CH7_Msk
|
||||
#define PPI_CHG1_CH7_Excluded PPI_CHG_CH7_Excluded
|
||||
#define PPI_CHG1_CH7_Included PPI_CHG_CH7_Included
|
||||
|
||||
#define PPI_CHG1_CH6_Pos PPI_CHG_CH6_Pos
|
||||
#define PPI_CHG1_CH6_Msk PPI_CHG_CH6_Msk
|
||||
#define PPI_CHG1_CH6_Excluded PPI_CHG_CH6_Excluded
|
||||
#define PPI_CHG1_CH6_Included PPI_CHG_CH6_Included
|
||||
|
||||
#define PPI_CHG1_CH5_Pos PPI_CHG_CH5_Pos
|
||||
#define PPI_CHG1_CH5_Msk PPI_CHG_CH5_Msk
|
||||
#define PPI_CHG1_CH5_Excluded PPI_CHG_CH5_Excluded
|
||||
#define PPI_CHG1_CH5_Included PPI_CHG_CH5_Included
|
||||
|
||||
#define PPI_CHG1_CH4_Pos PPI_CHG_CH4_Pos
|
||||
#define PPI_CHG1_CH4_Msk PPI_CHG_CH4_Msk
|
||||
#define PPI_CHG1_CH4_Excluded PPI_CHG_CH4_Excluded
|
||||
#define PPI_CHG1_CH4_Included PPI_CHG_CH4_Included
|
||||
|
||||
#define PPI_CHG1_CH3_Pos PPI_CHG_CH3_Pos
|
||||
#define PPI_CHG1_CH3_Msk PPI_CHG_CH3_Msk
|
||||
#define PPI_CHG1_CH3_Excluded PPI_CHG_CH3_Excluded
|
||||
#define PPI_CHG1_CH3_Included PPI_CHG_CH3_Included
|
||||
|
||||
#define PPI_CHG1_CH2_Pos PPI_CHG_CH2_Pos
|
||||
#define PPI_CHG1_CH2_Msk PPI_CHG_CH2_Msk
|
||||
#define PPI_CHG1_CH2_Excluded PPI_CHG_CH2_Excluded
|
||||
#define PPI_CHG1_CH2_Included PPI_CHG_CH2_Included
|
||||
|
||||
#define PPI_CHG1_CH1_Pos PPI_CHG_CH1_Pos
|
||||
#define PPI_CHG1_CH1_Msk PPI_CHG_CH1_Msk
|
||||
#define PPI_CHG1_CH1_Excluded PPI_CHG_CH1_Excluded
|
||||
#define PPI_CHG1_CH1_Included PPI_CHG_CH1_Included
|
||||
|
||||
#define PPI_CHG1_CH0_Pos PPI_CHG_CH0_Pos
|
||||
#define PPI_CHG1_CH0_Msk PPI_CHG_CH0_Msk
|
||||
#define PPI_CHG1_CH0_Excluded PPI_CHG_CH0_Excluded
|
||||
#define PPI_CHG1_CH0_Included PPI_CHG_CH0_Included
|
||||
|
||||
#define PPI_CHG2_CH15_Pos PPI_CHG_CH15_Pos
|
||||
#define PPI_CHG2_CH15_Msk PPI_CHG_CH15_Msk
|
||||
#define PPI_CHG2_CH15_Excluded PPI_CHG_CH15_Excluded
|
||||
#define PPI_CHG2_CH15_Included PPI_CHG_CH15_Included
|
||||
|
||||
#define PPI_CHG2_CH14_Pos PPI_CHG_CH14_Pos
|
||||
#define PPI_CHG2_CH14_Msk PPI_CHG_CH14_Msk
|
||||
#define PPI_CHG2_CH14_Excluded PPI_CHG_CH14_Excluded
|
||||
#define PPI_CHG2_CH14_Included PPI_CHG_CH14_Included
|
||||
|
||||
#define PPI_CHG2_CH13_Pos PPI_CHG_CH13_Pos
|
||||
#define PPI_CHG2_CH13_Msk PPI_CHG_CH13_Msk
|
||||
#define PPI_CHG2_CH13_Excluded PPI_CHG_CH13_Excluded
|
||||
#define PPI_CHG2_CH13_Included PPI_CHG_CH13_Included
|
||||
|
||||
#define PPI_CHG2_CH12_Pos PPI_CHG_CH12_Pos
|
||||
#define PPI_CHG2_CH12_Msk PPI_CHG_CH12_Msk
|
||||
#define PPI_CHG2_CH12_Excluded PPI_CHG_CH12_Excluded
|
||||
#define PPI_CHG2_CH12_Included PPI_CHG_CH12_Included
|
||||
|
||||
#define PPI_CHG2_CH11_Pos PPI_CHG_CH11_Pos
|
||||
#define PPI_CHG2_CH11_Msk PPI_CHG_CH11_Msk
|
||||
#define PPI_CHG2_CH11_Excluded PPI_CHG_CH11_Excluded
|
||||
#define PPI_CHG2_CH11_Included PPI_CHG_CH11_Included
|
||||
|
||||
#define PPI_CHG2_CH10_Pos PPI_CHG_CH10_Pos
|
||||
#define PPI_CHG2_CH10_Msk PPI_CHG_CH10_Msk
|
||||
#define PPI_CHG2_CH10_Excluded PPI_CHG_CH10_Excluded
|
||||
#define PPI_CHG2_CH10_Included PPI_CHG_CH10_Included
|
||||
|
||||
#define PPI_CHG2_CH9_Pos PPI_CHG_CH9_Pos
|
||||
#define PPI_CHG2_CH9_Msk PPI_CHG_CH9_Msk
|
||||
#define PPI_CHG2_CH9_Excluded PPI_CHG_CH9_Excluded
|
||||
#define PPI_CHG2_CH9_Included PPI_CHG_CH9_Included
|
||||
|
||||
#define PPI_CHG2_CH8_Pos PPI_CHG_CH8_Pos
|
||||
#define PPI_CHG2_CH8_Msk PPI_CHG_CH8_Msk
|
||||
#define PPI_CHG2_CH8_Excluded PPI_CHG_CH8_Excluded
|
||||
#define PPI_CHG2_CH8_Included PPI_CHG_CH8_Included
|
||||
|
||||
#define PPI_CHG2_CH7_Pos PPI_CHG_CH7_Pos
|
||||
#define PPI_CHG2_CH7_Msk PPI_CHG_CH7_Msk
|
||||
#define PPI_CHG2_CH7_Excluded PPI_CHG_CH7_Excluded
|
||||
#define PPI_CHG2_CH7_Included PPI_CHG_CH7_Included
|
||||
|
||||
#define PPI_CHG2_CH6_Pos PPI_CHG_CH6_Pos
|
||||
#define PPI_CHG2_CH6_Msk PPI_CHG_CH6_Msk
|
||||
#define PPI_CHG2_CH6_Excluded PPI_CHG_CH6_Excluded
|
||||
#define PPI_CHG2_CH6_Included PPI_CHG_CH6_Included
|
||||
|
||||
#define PPI_CHG2_CH5_Pos PPI_CHG_CH5_Pos
|
||||
#define PPI_CHG2_CH5_Msk PPI_CHG_CH5_Msk
|
||||
#define PPI_CHG2_CH5_Excluded PPI_CHG_CH5_Excluded
|
||||
#define PPI_CHG2_CH5_Included PPI_CHG_CH5_Included
|
||||
|
||||
#define PPI_CHG2_CH4_Pos PPI_CHG_CH4_Pos
|
||||
#define PPI_CHG2_CH4_Msk PPI_CHG_CH4_Msk
|
||||
#define PPI_CHG2_CH4_Excluded PPI_CHG_CH4_Excluded
|
||||
#define PPI_CHG2_CH4_Included PPI_CHG_CH4_Included
|
||||
|
||||
#define PPI_CHG2_CH3_Pos PPI_CHG_CH3_Pos
|
||||
#define PPI_CHG2_CH3_Msk PPI_CHG_CH3_Msk
|
||||
#define PPI_CHG2_CH3_Excluded PPI_CHG_CH3_Excluded
|
||||
#define PPI_CHG2_CH3_Included PPI_CHG_CH3_Included
|
||||
|
||||
#define PPI_CHG2_CH2_Pos PPI_CHG_CH2_Pos
|
||||
#define PPI_CHG2_CH2_Msk PPI_CHG_CH2_Msk
|
||||
#define PPI_CHG2_CH2_Excluded PPI_CHG_CH2_Excluded
|
||||
#define PPI_CHG2_CH2_Included PPI_CHG_CH2_Included
|
||||
|
||||
#define PPI_CHG2_CH1_Pos PPI_CHG_CH1_Pos
|
||||
#define PPI_CHG2_CH1_Msk PPI_CHG_CH1_Msk
|
||||
#define PPI_CHG2_CH1_Excluded PPI_CHG_CH1_Excluded
|
||||
#define PPI_CHG2_CH1_Included PPI_CHG_CH1_Included
|
||||
|
||||
#define PPI_CHG2_CH0_Pos PPI_CHG_CH0_Pos
|
||||
#define PPI_CHG2_CH0_Msk PPI_CHG_CH0_Msk
|
||||
#define PPI_CHG2_CH0_Excluded PPI_CHG_CH0_Excluded
|
||||
#define PPI_CHG2_CH0_Included PPI_CHG_CH0_Included
|
||||
|
||||
#define PPI_CHG3_CH15_Pos PPI_CHG_CH15_Pos
|
||||
#define PPI_CHG3_CH15_Msk PPI_CHG_CH15_Msk
|
||||
#define PPI_CHG3_CH15_Excluded PPI_CHG_CH15_Excluded
|
||||
#define PPI_CHG3_CH15_Included PPI_CHG_CH15_Included
|
||||
|
||||
#define PPI_CHG3_CH14_Pos PPI_CHG_CH14_Pos
|
||||
#define PPI_CHG3_CH14_Msk PPI_CHG_CH14_Msk
|
||||
#define PPI_CHG3_CH14_Excluded PPI_CHG_CH14_Excluded
|
||||
#define PPI_CHG3_CH14_Included PPI_CHG_CH14_Included
|
||||
|
||||
#define PPI_CHG3_CH13_Pos PPI_CHG_CH13_Pos
|
||||
#define PPI_CHG3_CH13_Msk PPI_CHG_CH13_Msk
|
||||
#define PPI_CHG3_CH13_Excluded PPI_CHG_CH13_Excluded
|
||||
#define PPI_CHG3_CH13_Included PPI_CHG_CH13_Included
|
||||
|
||||
#define PPI_CHG3_CH12_Pos PPI_CHG_CH12_Pos
|
||||
#define PPI_CHG3_CH12_Msk PPI_CHG_CH12_Msk
|
||||
#define PPI_CHG3_CH12_Excluded PPI_CHG_CH12_Excluded
|
||||
#define PPI_CHG3_CH12_Included PPI_CHG_CH12_Included
|
||||
|
||||
#define PPI_CHG3_CH11_Pos PPI_CHG_CH11_Pos
|
||||
#define PPI_CHG3_CH11_Msk PPI_CHG_CH11_Msk
|
||||
#define PPI_CHG3_CH11_Excluded PPI_CHG_CH11_Excluded
|
||||
#define PPI_CHG3_CH11_Included PPI_CHG_CH11_Included
|
||||
|
||||
#define PPI_CHG3_CH10_Pos PPI_CHG_CH10_Pos
|
||||
#define PPI_CHG3_CH10_Msk PPI_CHG_CH10_Msk
|
||||
#define PPI_CHG3_CH10_Excluded PPI_CHG_CH10_Excluded
|
||||
#define PPI_CHG3_CH10_Included PPI_CHG_CH10_Included
|
||||
|
||||
#define PPI_CHG3_CH9_Pos PPI_CHG_CH9_Pos
|
||||
#define PPI_CHG3_CH9_Msk PPI_CHG_CH9_Msk
|
||||
#define PPI_CHG3_CH9_Excluded PPI_CHG_CH9_Excluded
|
||||
#define PPI_CHG3_CH9_Included PPI_CHG_CH9_Included
|
||||
|
||||
#define PPI_CHG3_CH8_Pos PPI_CHG_CH8_Pos
|
||||
#define PPI_CHG3_CH8_Msk PPI_CHG_CH8_Msk
|
||||
#define PPI_CHG3_CH8_Excluded PPI_CHG_CH8_Excluded
|
||||
#define PPI_CHG3_CH8_Included PPI_CHG_CH8_Included
|
||||
|
||||
#define PPI_CHG3_CH7_Pos PPI_CHG_CH7_Pos
|
||||
#define PPI_CHG3_CH7_Msk PPI_CHG_CH7_Msk
|
||||
#define PPI_CHG3_CH7_Excluded PPI_CHG_CH7_Excluded
|
||||
#define PPI_CHG3_CH7_Included PPI_CHG_CH7_Included
|
||||
|
||||
#define PPI_CHG3_CH6_Pos PPI_CHG_CH6_Pos
|
||||
#define PPI_CHG3_CH6_Msk PPI_CHG_CH6_Msk
|
||||
#define PPI_CHG3_CH6_Excluded PPI_CHG_CH6_Excluded
|
||||
#define PPI_CHG3_CH6_Included PPI_CHG_CH6_Included
|
||||
|
||||
#define PPI_CHG3_CH5_Pos PPI_CHG_CH5_Pos
|
||||
#define PPI_CHG3_CH5_Msk PPI_CHG_CH5_Msk
|
||||
#define PPI_CHG3_CH5_Excluded PPI_CHG_CH5_Excluded
|
||||
#define PPI_CHG3_CH5_Included PPI_CHG_CH5_Included
|
||||
|
||||
#define PPI_CHG3_CH4_Pos PPI_CHG_CH4_Pos
|
||||
#define PPI_CHG3_CH4_Msk PPI_CHG_CH4_Msk
|
||||
#define PPI_CHG3_CH4_Excluded PPI_CHG_CH4_Excluded
|
||||
#define PPI_CHG3_CH4_Included PPI_CHG_CH4_Included
|
||||
|
||||
#define PPI_CHG3_CH3_Pos PPI_CHG_CH3_Pos
|
||||
#define PPI_CHG3_CH3_Msk PPI_CHG_CH3_Msk
|
||||
#define PPI_CHG3_CH3_Excluded PPI_CHG_CH3_Excluded
|
||||
#define PPI_CHG3_CH3_Included PPI_CHG_CH3_Included
|
||||
|
||||
#define PPI_CHG3_CH2_Pos PPI_CHG_CH2_Pos
|
||||
#define PPI_CHG3_CH2_Msk PPI_CHG_CH2_Msk
|
||||
#define PPI_CHG3_CH2_Excluded PPI_CHG_CH2_Excluded
|
||||
#define PPI_CHG3_CH2_Included PPI_CHG_CH2_Included
|
||||
|
||||
#define PPI_CHG3_CH1_Pos PPI_CHG_CH1_Pos
|
||||
#define PPI_CHG3_CH1_Msk PPI_CHG_CH1_Msk
|
||||
#define PPI_CHG3_CH1_Excluded PPI_CHG_CH1_Excluded
|
||||
#define PPI_CHG3_CH1_Included PPI_CHG_CH1_Included
|
||||
|
||||
#define PPI_CHG3_CH0_Pos PPI_CHG_CH0_Pos
|
||||
#define PPI_CHG3_CH0_Msk PPI_CHG_CH0_Msk
|
||||
#define PPI_CHG3_CH0_Excluded PPI_CHG_CH0_Excluded
|
||||
#define PPI_CHG3_CH0_Included PPI_CHG_CH0_Included
|
||||
|
||||
|
||||
|
||||
|
||||
/*lint --flb "Leave library region" */
|
||||
|
||||
#endif /* NRF51_TO_NRF52_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 NRF52_NAME_CHANGE_H
|
||||
#define NRF52_NAME_CHANGE_H
|
||||
|
||||
/*lint ++flb "Enter library region */
|
||||
|
||||
/* This file is given to prevent your SW from not compiling with the updates made to nrf52.h and
|
||||
* nrf52_bitfields.h. The macros defined in this file were available previously. Do not use these
|
||||
* macros on purpose. Use the ones defined in nrf52.h and nrf52_bitfields.h instead.
|
||||
*/
|
||||
|
||||
/* I2S */
|
||||
/* Several enumerations changed case. Adding old macros to keep compilation compatibility. */
|
||||
#define I2S_ENABLE_ENABLE_DISABLE I2S_ENABLE_ENABLE_Disabled
|
||||
#define I2S_ENABLE_ENABLE_ENABLE I2S_ENABLE_ENABLE_Enabled
|
||||
#define I2S_CONFIG_MODE_MODE_MASTER I2S_CONFIG_MODE_MODE_Master
|
||||
#define I2S_CONFIG_MODE_MODE_SLAVE I2S_CONFIG_MODE_MODE_Slave
|
||||
#define I2S_CONFIG_RXEN_RXEN_DISABLE I2S_CONFIG_RXEN_RXEN_Disabled
|
||||
#define I2S_CONFIG_RXEN_RXEN_ENABLE I2S_CONFIG_RXEN_RXEN_Enabled
|
||||
#define I2S_CONFIG_TXEN_TXEN_DISABLE I2S_CONFIG_TXEN_TXEN_Disabled
|
||||
#define I2S_CONFIG_TXEN_TXEN_ENABLE I2S_CONFIG_TXEN_TXEN_Enabled
|
||||
#define I2S_CONFIG_MCKEN_MCKEN_DISABLE I2S_CONFIG_MCKEN_MCKEN_Disabled
|
||||
#define I2S_CONFIG_MCKEN_MCKEN_ENABLE I2S_CONFIG_MCKEN_MCKEN_Enabled
|
||||
#define I2S_CONFIG_SWIDTH_SWIDTH_8BIT I2S_CONFIG_SWIDTH_SWIDTH_8Bit
|
||||
#define I2S_CONFIG_SWIDTH_SWIDTH_16BIT I2S_CONFIG_SWIDTH_SWIDTH_16Bit
|
||||
#define I2S_CONFIG_SWIDTH_SWIDTH_24BIT I2S_CONFIG_SWIDTH_SWIDTH_24Bit
|
||||
#define I2S_CONFIG_ALIGN_ALIGN_LEFT I2S_CONFIG_ALIGN_ALIGN_Left
|
||||
#define I2S_CONFIG_ALIGN_ALIGN_RIGHT I2S_CONFIG_ALIGN_ALIGN_Right
|
||||
#define I2S_CONFIG_FORMAT_FORMAT_ALIGNED I2S_CONFIG_FORMAT_FORMAT_Aligned
|
||||
#define I2S_CONFIG_CHANNELS_CHANNELS_STEREO I2S_CONFIG_CHANNELS_CHANNELS_Stereo
|
||||
#define I2S_CONFIG_CHANNELS_CHANNELS_LEFT I2S_CONFIG_CHANNELS_CHANNELS_Left
|
||||
#define I2S_CONFIG_CHANNELS_CHANNELS_RIGHT I2S_CONFIG_CHANNELS_CHANNELS_Right
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*lint --flb "Leave library region" */
|
||||
|
||||
#endif /* NRF52_NAME_CHANGE_H */
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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
|
||||
|
||||
#define STDIO_UART_TX TX_PIN_NUMBER
|
||||
#define STDIO_UART_RX RX_PIN_NUMBER
|
||||
#define STDIO_UART UART_0
|
||||
|
||||
typedef enum {
|
||||
UART_0 = (int)NRF_UART0_BASE
|
||||
} UARTName;
|
||||
|
||||
|
||||
typedef enum {
|
||||
SPI_0 = (int)NRF_SPI0_BASE,
|
||||
SPI_1 = (int)NRF_SPI1_BASE,
|
||||
SPIS = (int)NRF_SPIS1_BASE
|
||||
} SPIName;
|
||||
|
||||
typedef enum {
|
||||
PWM_1 = 0,
|
||||
PWM_2
|
||||
} PWMName;
|
||||
|
||||
typedef enum {
|
||||
I2C_0 = (int)NRF_TWI0_BASE,
|
||||
I2C_1 = (int)NRF_TWI1_BASE
|
||||
} I2CName;
|
||||
|
||||
typedef enum {
|
||||
ADC0_0 = (int)NRF_ADC_BASE
|
||||
} ADCName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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_PORTNAMES_H
|
||||
#define MBED_PORTNAMES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
Port0 = 0 //GPIO pins 0-31
|
||||
} PortName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
#define PORT_SHIFT 3
|
||||
|
||||
typedef enum {
|
||||
p0 = 0,
|
||||
p1 = 1,
|
||||
p2 = 2,
|
||||
p3 = 3,
|
||||
p4 = 4,
|
||||
p5 = 5,
|
||||
p6 = 6,
|
||||
p7 = 7,
|
||||
p8 = 8,
|
||||
p9 = 9,
|
||||
p10 = 10,
|
||||
p11 = 11,
|
||||
p12 = 12,
|
||||
p13 = 13,
|
||||
p14 = 14,
|
||||
p15 = 15,
|
||||
p16 = 16,
|
||||
p17 = 17,
|
||||
p18 = 18,
|
||||
p19 = 19,
|
||||
p20 = 20,
|
||||
p21 = 21,
|
||||
p22 = 22,
|
||||
p23 = 23,
|
||||
p24 = 24,
|
||||
p25 = 25,
|
||||
p26 = 26,
|
||||
p27 = 27,
|
||||
p28 = 28,
|
||||
p29 = 29,
|
||||
p30 = 30,
|
||||
|
||||
P0_0 = p0,
|
||||
P0_1 = p1,
|
||||
P0_2 = p2,
|
||||
P0_3 = p3,
|
||||
P0_4 = p4,
|
||||
P0_5 = p5,
|
||||
P0_6 = p6,
|
||||
P0_7 = p7,
|
||||
|
||||
P0_8 = p8,
|
||||
P0_9 = p9,
|
||||
P0_10 = p10,
|
||||
P0_11 = p11,
|
||||
P0_12 = p12,
|
||||
P0_13 = p13,
|
||||
P0_14 = p14,
|
||||
P0_15 = p15,
|
||||
|
||||
P0_16 = p16,
|
||||
P0_17 = p17,
|
||||
P0_18 = p18,
|
||||
P0_19 = p19,
|
||||
P0_20 = p20,
|
||||
P0_21 = p21,
|
||||
P0_22 = p22,
|
||||
P0_23 = p23,
|
||||
|
||||
P0_24 = p24,
|
||||
P0_25 = p25,
|
||||
P0_26 = p26,
|
||||
P0_27 = p27,
|
||||
P0_28 = p28,
|
||||
P0_29 = p29,
|
||||
P0_30 = p30,
|
||||
|
||||
LED1 = p21,
|
||||
LED2 = p22,
|
||||
LED3 = p23,
|
||||
LED4 = p24,
|
||||
|
||||
BUTTON1 = p17,
|
||||
BUTTON2 = p18,
|
||||
BUTTON3 = p19,
|
||||
BUTTON4 = p20,
|
||||
|
||||
RX_PIN_NUMBER = p11,
|
||||
TX_PIN_NUMBER = p9,
|
||||
CTS_PIN_NUMBER = p10,
|
||||
RTS_PIN_NUMBER = p8,
|
||||
|
||||
// mBed interface Pins
|
||||
USBTX = TX_PIN_NUMBER,
|
||||
USBRX = RX_PIN_NUMBER,
|
||||
|
||||
SPI_PSELMOSI0 = p25,
|
||||
SPI_PSELMISO0 = p28,
|
||||
SPI_PSELSS0 = p24,
|
||||
SPI_PSELSCK0 = p29,
|
||||
|
||||
SPI_PSELMOSI1 = p13,
|
||||
SPI_PSELMISO1 = p14,
|
||||
SPI_PSELSS1 = p12,
|
||||
SPI_PSELSCK1 = p15,
|
||||
|
||||
SPIS_PSELMOSI = p13,
|
||||
SPIS_PSELMISO = p14,
|
||||
SPIS_PSELSS = p12,
|
||||
SPIS_PSELSCK = p15,
|
||||
|
||||
I2C_SDA0 = p30,
|
||||
I2C_SCL0 = p7,
|
||||
|
||||
D0 = p12,
|
||||
D1 = p13,
|
||||
D2 = p14,
|
||||
D3 = p15,
|
||||
D4 = p16,
|
||||
D5 = p17,
|
||||
D6 = p18,
|
||||
D7 = p19,
|
||||
|
||||
D8 = p20,
|
||||
D9 = p23,
|
||||
D10 = p24,
|
||||
D11 = p25,
|
||||
D12 = p28,
|
||||
D13 = p29,
|
||||
|
||||
D14 = p30,
|
||||
D15 = p7,
|
||||
|
||||
A0 = p1,
|
||||
A1 = p2,
|
||||
A2 = p3,
|
||||
A3 = p4,
|
||||
A4 = p5,
|
||||
A5 = p6,
|
||||
|
||||
// Not connected
|
||||
NC = (int)0xFFFFFFFF
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullDown = 1,
|
||||
PullUp = 3,
|
||||
PullDefault = PullUp
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,38 @@
|
|||
// The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches.
|
||||
// Check the 'features' section of the target description in 'targets.json' for more details.
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,88 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 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 "mbed_assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
#include "nrf_drv_adc.h"
|
||||
|
||||
#ifdef DEVICE_ANALOGIN
|
||||
|
||||
|
||||
#define ADC_10BIT_RANGE 0x3FF
|
||||
#define ADC_RANGE ADC_10BIT_RANGE
|
||||
|
||||
static const PinMap PinMap_ADC[] = {
|
||||
{p1, ADC0_0, 4},
|
||||
{p2, ADC0_0, 8},
|
||||
{p3, ADC0_0, 16},
|
||||
{p4, ADC0_0, 32},
|
||||
{p5, ADC0_0, 64},
|
||||
{p6, ADC0_0, 128},
|
||||
#ifndef TARGET_NRF51_DONGLE
|
||||
{p26, ADC0_0, 1},
|
||||
{p27, ADC0_0, 2},
|
||||
#endif
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
|
||||
void analogin_init(analogin_t *obj, PinName pin)
|
||||
{
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
uint32_t pinFunc = pinmap_function(pin, PinMap_ADC);
|
||||
MBED_ASSERT(pinFunc != (uint32_t)NC);
|
||||
|
||||
obj->adc_pin = pinFunc;
|
||||
|
||||
ret_code_t ret_code;
|
||||
// p_config, event_handler
|
||||
ret_code = nrf_drv_adc_init(NULL , NULL); // select blocking mode
|
||||
MBED_ASSERT((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_INVALID_STATE)); //NRF_ERROR_INVALID_STATE expected for multiple channels used.
|
||||
}
|
||||
|
||||
uint16_t analogin_read_u16(analogin_t *obj)
|
||||
{
|
||||
nrf_adc_value_t adc_value;
|
||||
|
||||
nrf_drv_adc_channel_t adc_channel;
|
||||
|
||||
// initialization by assigment because IAR dosen't support variable initializer in declaration statement.
|
||||
adc_channel.config.config.resolution = NRF_ADC_CONFIG_RES_10BIT;
|
||||
adc_channel.config.config.input = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE;
|
||||
adc_channel.config.config.reference = NRF_ADC_CONFIG_REF_VBG;
|
||||
adc_channel.config.config.ain = (obj->adc_pin);
|
||||
adc_channel.p_next = NULL;
|
||||
|
||||
|
||||
ret_code_t ret_code;
|
||||
|
||||
ret_code = nrf_drv_adc_sample_convert( &adc_channel, &adc_value);
|
||||
MBED_ASSERT(ret_code == NRF_SUCCESS);
|
||||
|
||||
return adc_value;
|
||||
}
|
||||
|
||||
float analogin_read(analogin_t *obj)
|
||||
{
|
||||
uint16_t value = analogin_read_u16(obj);
|
||||
|
||||
return (float)value * (1.0f / (float)ADC_RANGE);
|
||||
}
|
||||
|
||||
#endif // DEVICE_ANALOGIN
|
|
@ -0,0 +1,237 @@
|
|||
/*
|
||||
* Copyright (c) 2013 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 "mbed_assert.h"
|
||||
#include "mbed_error.h"
|
||||
#include "pwmout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#if DEVICE_PWMOUT
|
||||
|
||||
#include "nrf.h"
|
||||
#include "nrf_drv_timer.h"
|
||||
#include "app_pwm.h"
|
||||
|
||||
#define PWM_INSTANCE_COUNT 2
|
||||
#define PWM_CHANNELS_PER_INSTANCE 2
|
||||
#define PWM_DEFAULT_PERIOD_US 20000
|
||||
#define PWM_PERIOD_MIN 3
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const app_pwm_t * const instance;
|
||||
NRF_TIMER_Type * const timer_reg;
|
||||
uint8_t channels_allocated;
|
||||
uint32_t pins[PWM_CHANNELS_PER_INSTANCE];
|
||||
uint16_t period_us;
|
||||
uint16_t duty_ticks[PWM_CHANNELS_PER_INSTANCE];
|
||||
} pwm_t;
|
||||
|
||||
|
||||
APP_PWM_INSTANCE(m_pwm_instance_0, 1); //PWM0: Timer 1
|
||||
APP_PWM_INSTANCE(m_pwm_instance_1, 2); //PWM1: Timer 2
|
||||
|
||||
|
||||
static pwm_t m_pwm[] = {
|
||||
{.instance = &m_pwm_instance_0, .timer_reg = NRF_TIMER1, .channels_allocated = 0},
|
||||
{.instance = &m_pwm_instance_1, .timer_reg = NRF_TIMER2, .channels_allocated = 0}
|
||||
};
|
||||
|
||||
static inline void pwm_ticks_set(pwm_t* pwm, uint8_t channel, uint16_t ticks)
|
||||
{
|
||||
pwm->duty_ticks[channel] = ticks;
|
||||
while (app_pwm_channel_duty_ticks_set(pwm->instance, channel, ticks) != NRF_SUCCESS);
|
||||
}
|
||||
|
||||
static void pwm_reinit(pwm_t * pwm)
|
||||
{
|
||||
app_pwm_uninit(pwm->instance);
|
||||
app_pwm_config_t pwm_cfg = APP_PWM_DEFAULT_CONFIG_2CH(pwm->period_us,
|
||||
pwm->pins[0],
|
||||
pwm->pins[1]);
|
||||
app_pwm_init(pwm->instance, &pwm_cfg, NULL);
|
||||
app_pwm_enable(pwm->instance);
|
||||
|
||||
for (uint8_t channel = 0; channel < PWM_CHANNELS_PER_INSTANCE; ++channel) {
|
||||
if ((pwm->channels_allocated & (1 << channel)) && (pwm->pins[channel] != APP_PWM_NOPIN)) {
|
||||
app_pwm_channel_duty_ticks_set(pwm->instance, channel, pwm->duty_ticks[channel]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pwmout_init(pwmout_t *obj, PinName pin)
|
||||
{
|
||||
if (pin == NC) {
|
||||
error("PwmOut init failed. Invalid pin name.");
|
||||
}
|
||||
|
||||
// Check if pin is already initialized and find the next free channel.
|
||||
uint8_t free_instance = 0xFF;
|
||||
uint8_t free_channel = 0xFF;
|
||||
|
||||
for (uint8_t inst = 0; inst < PWM_INSTANCE_COUNT; ++inst) {
|
||||
if (m_pwm[inst].channels_allocated) {
|
||||
for (uint8_t channel = 0; channel < PWM_CHANNELS_PER_INSTANCE; ++channel) {
|
||||
if (m_pwm[inst].channels_allocated & (1 << channel)) {
|
||||
if (m_pwm[inst].pins[channel] == (uint32_t)pin) {
|
||||
error("PwmOut init failed. Pin is already in use.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (free_instance == 0xFF) {
|
||||
free_instance = inst;
|
||||
free_channel = channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (free_instance == 0xFF) {
|
||||
free_instance = inst;
|
||||
free_channel = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (free_instance == 0xFF)
|
||||
{
|
||||
error("PwmOut init failed. All available PWM channels are in use.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Init / reinit PWM instance.
|
||||
m_pwm[free_instance].pins[free_channel] = (uint32_t) pin;
|
||||
m_pwm[free_instance].duty_ticks[free_channel] = 0;
|
||||
if (!m_pwm[free_instance].channels_allocated) {
|
||||
m_pwm[free_instance].period_us = PWM_DEFAULT_PERIOD_US;
|
||||
for (uint8_t channel = 1; channel < PWM_CHANNELS_PER_INSTANCE; ++channel) {
|
||||
m_pwm[free_instance].pins[channel] = APP_PWM_NOPIN;
|
||||
m_pwm[free_instance].duty_ticks[channel] = 0;
|
||||
}
|
||||
app_pwm_config_t pwm_cfg = APP_PWM_DEFAULT_CONFIG_1CH(PWM_DEFAULT_PERIOD_US, pin);
|
||||
app_pwm_init(m_pwm[free_instance].instance, &pwm_cfg, NULL);
|
||||
app_pwm_enable(m_pwm[free_instance].instance);
|
||||
}
|
||||
else {
|
||||
pwm_reinit(&m_pwm[free_instance]);
|
||||
}
|
||||
m_pwm[free_instance].channels_allocated |= (1 << free_channel);
|
||||
|
||||
obj->pin = pin;
|
||||
obj->pwm_struct = (void *) &m_pwm[free_instance];
|
||||
obj->pwm_channel = free_channel;
|
||||
}
|
||||
|
||||
void pwmout_free(pwmout_t *obj)
|
||||
{
|
||||
MBED_ASSERT(obj->pwm_name != (PWMName)NC);
|
||||
MBED_ASSERT(obj->pwm_channel < PWM_CHANNELS_PER_INSTANCE);
|
||||
|
||||
pwm_t * pwm = (pwm_t *) obj->pwm_struct;
|
||||
pwm->channels_allocated &= ~(1 << obj->pwm_channel);
|
||||
pwm->pins[obj->pwm_channel] = APP_PWM_NOPIN;
|
||||
pwm->duty_ticks[obj->pwm_channel] = 0;
|
||||
|
||||
app_pwm_uninit(pwm->instance);
|
||||
if (pwm->channels_allocated) {
|
||||
pwm_reinit(pwm);
|
||||
}
|
||||
|
||||
obj->pwm_struct = NULL;
|
||||
}
|
||||
|
||||
void pwmout_write(pwmout_t *obj, float value)
|
||||
{
|
||||
pwm_t * pwm = (pwm_t *) obj->pwm_struct;
|
||||
if (value > 1.0f) {
|
||||
value = 1.0f;
|
||||
}
|
||||
|
||||
app_pwm_channel_duty_set(pwm->instance, obj->pwm_channel, (app_pwm_duty_t)(value * 100.0f) );
|
||||
}
|
||||
|
||||
float pwmout_read(pwmout_t *obj)
|
||||
{
|
||||
pwm_t * pwm = (pwm_t *) obj->pwm_struct;
|
||||
MBED_ASSERT(pwm != NULL);
|
||||
return ((float)pwm->duty_ticks[obj->pwm_channel] / (float)app_pwm_cycle_ticks_get(pwm->instance));
|
||||
}
|
||||
|
||||
void pwmout_period(pwmout_t *obj, float seconds)
|
||||
{
|
||||
pwmout_period_us(obj, seconds * 1000000.0f);
|
||||
}
|
||||
|
||||
void pwmout_period_ms(pwmout_t *obj, int ms)
|
||||
{
|
||||
pwmout_period_us(obj, ms * 1000);
|
||||
}
|
||||
|
||||
void pwmout_period_us(pwmout_t *obj, int us)
|
||||
{
|
||||
pwm_t * pwm = (pwm_t *) obj->pwm_struct;
|
||||
MBED_ASSERT(pwm != NULL);
|
||||
if (us < PWM_PERIOD_MIN) {
|
||||
us = PWM_PERIOD_MIN;
|
||||
}
|
||||
pwm->period_us = (uint32_t)us;
|
||||
pwm_reinit(pwm);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth(pwmout_t *obj, float seconds)
|
||||
{
|
||||
pwmout_pulsewidth_us(obj, seconds * 1000000.0f);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth_ms(pwmout_t *obj, int ms)
|
||||
{
|
||||
pwmout_pulsewidth_us(obj, ms * 1000);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth_us(pwmout_t *obj, int us)
|
||||
{
|
||||
pwm_t * pwm = (pwm_t *) obj->pwm_struct;
|
||||
MBED_ASSERT(pwm);
|
||||
|
||||
uint16_t ticks = nrf_timer_us_to_ticks((uint32_t)us, nrf_timer_frequency_get(pwm->timer_reg));
|
||||
pwm_ticks_set(pwm, obj->pwm_channel, ticks);
|
||||
}
|
||||
|
||||
#endif // DEVICE_PWMOUT
|
|
@ -0,0 +1,280 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 "nrf_drv_adc.h"
|
||||
#include "nrf_drv_common.h"
|
||||
#include "nrf_assert.h"
|
||||
#include "app_util_platform.h"
|
||||
#include "app_util.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
nrf_drv_adc_event_handler_t event_handler;
|
||||
nrf_drv_adc_channel_t * p_head;
|
||||
nrf_drv_adc_channel_t * p_current_conv;
|
||||
nrf_adc_value_t * p_buffer;
|
||||
uint8_t size;
|
||||
uint8_t idx;
|
||||
nrf_drv_state_t state;
|
||||
} adc_cb_t;
|
||||
|
||||
static adc_cb_t m_cb;
|
||||
static const nrf_drv_adc_config_t m_default_config = NRF_DRV_ADC_DEFAULT_CONFIG;
|
||||
|
||||
ret_code_t nrf_drv_adc_init(nrf_drv_adc_config_t const * p_config,
|
||||
nrf_drv_adc_event_handler_t event_handler)
|
||||
{
|
||||
if (m_cb.state != NRF_DRV_STATE_UNINITIALIZED)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
nrf_adc_event_clear(NRF_ADC_EVENT_END);
|
||||
if (event_handler)
|
||||
{
|
||||
if (!p_config)
|
||||
{
|
||||
p_config = (nrf_drv_adc_config_t *)&m_default_config;
|
||||
}
|
||||
nrf_drv_common_irq_enable(ADC_IRQn, p_config->interrupt_priority);
|
||||
}
|
||||
m_cb.event_handler = event_handler;
|
||||
m_cb.state = NRF_DRV_STATE_INITIALIZED;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
void nrf_drv_adc_uninit(void)
|
||||
{
|
||||
m_cb.p_head = NULL;
|
||||
nrf_drv_common_irq_disable(ADC_IRQn);
|
||||
nrf_adc_int_disable(NRF_ADC_INT_END_MASK);
|
||||
nrf_adc_task_trigger(NRF_ADC_TASK_STOP);
|
||||
|
||||
m_cb.state = NRF_DRV_STATE_UNINITIALIZED;
|
||||
}
|
||||
|
||||
void nrf_drv_adc_channel_enable(nrf_drv_adc_channel_t * const p_channel)
|
||||
{
|
||||
ASSERT(mp_state == NRF_DRV_STATE_INITIALIZED);
|
||||
ASSERT(!is_address_from_stack(p_channel));
|
||||
|
||||
p_channel->p_next = NULL;
|
||||
if (m_cb.p_head == NULL)
|
||||
{
|
||||
m_cb.p_head = p_channel;
|
||||
}
|
||||
else
|
||||
{
|
||||
nrf_drv_adc_channel_t * p_curr_channel = m_cb.p_head;
|
||||
while (p_curr_channel->p_next != NULL)
|
||||
{
|
||||
ASSERT(p_channel != p_curr_channel);
|
||||
p_curr_channel = p_curr_channel->p_next;
|
||||
}
|
||||
p_curr_channel->p_next = p_channel;
|
||||
}
|
||||
}
|
||||
|
||||
void nrf_drv_adc_channel_disable(nrf_drv_adc_channel_t * const p_channel)
|
||||
{
|
||||
ASSERT(mp_state == NRF_DRV_STATE_INITIALIZED);
|
||||
ASSERT(m_cb.p_head);
|
||||
|
||||
nrf_drv_adc_channel_t * p_curr_channel = m_cb.p_head;
|
||||
nrf_drv_adc_channel_t * p_prev_channel = NULL;
|
||||
while(p_curr_channel != p_channel)
|
||||
{
|
||||
p_prev_channel = p_curr_channel;
|
||||
p_curr_channel = p_curr_channel->p_next;
|
||||
ASSERT(p_curr_channel == NULL);
|
||||
}
|
||||
if (p_prev_channel)
|
||||
{
|
||||
p_prev_channel->p_next = p_curr_channel->p_next;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cb.p_head = p_curr_channel->p_next;
|
||||
}
|
||||
}
|
||||
|
||||
void nrf_drv_adc_sample(void)
|
||||
{
|
||||
ASSERT(mp_state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
ASSERT(!nrf_adc_is_busy());
|
||||
nrf_adc_start();
|
||||
}
|
||||
|
||||
ret_code_t nrf_drv_adc_sample_convert(nrf_drv_adc_channel_t const * const p_channel,
|
||||
nrf_adc_value_t * p_value)
|
||||
{
|
||||
ASSERT(mp_state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
if(m_cb.state == NRF_DRV_STATE_POWERED_ON)
|
||||
{
|
||||
return NRF_ERROR_BUSY;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cb.state = NRF_DRV_STATE_POWERED_ON;
|
||||
|
||||
nrf_adc_config_set(p_channel->config.data);
|
||||
nrf_adc_enable();
|
||||
nrf_adc_int_disable(NRF_ADC_INT_END_MASK);
|
||||
nrf_adc_start();
|
||||
if (p_value)
|
||||
{
|
||||
while(!nrf_adc_event_check(NRF_ADC_EVENT_END)) {}
|
||||
nrf_adc_event_clear(NRF_ADC_EVENT_END);
|
||||
*p_value = (nrf_adc_value_t)nrf_adc_result_get();
|
||||
nrf_adc_disable();
|
||||
|
||||
m_cb.state = NRF_DRV_STATE_INITIALIZED;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(m_cb.event_handler);
|
||||
m_cb.p_buffer = NULL;
|
||||
nrf_adc_int_enable(NRF_ADC_INT_END_MASK);
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static bool adc_sample_process()
|
||||
{
|
||||
nrf_adc_event_clear(NRF_ADC_EVENT_END);
|
||||
nrf_adc_disable();
|
||||
m_cb.p_buffer[m_cb.idx] = (nrf_adc_value_t)nrf_adc_result_get();
|
||||
m_cb.idx++;
|
||||
if (m_cb.idx < m_cb.size)
|
||||
{
|
||||
bool task_trigger = false;
|
||||
if (m_cb.p_current_conv->p_next == NULL)
|
||||
{
|
||||
m_cb.p_current_conv = m_cb.p_head;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cb.p_current_conv = m_cb.p_current_conv->p_next;
|
||||
task_trigger = true;
|
||||
}
|
||||
nrf_adc_config_set(m_cb.p_current_conv->config.data);
|
||||
nrf_adc_enable();
|
||||
if (task_trigger)
|
||||
{
|
||||
//nrf_adc_start();
|
||||
nrf_adc_task_trigger(NRF_ADC_TASK_START);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ret_code_t nrf_drv_adc_buffer_convert(nrf_adc_value_t * buffer, uint16_t size)
|
||||
{
|
||||
ASSERT(mp_state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
if(m_cb.state == NRF_DRV_STATE_POWERED_ON)
|
||||
{
|
||||
return NRF_ERROR_BUSY;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cb.state = NRF_DRV_STATE_POWERED_ON;
|
||||
m_cb.p_current_conv = m_cb.p_head;
|
||||
m_cb.size = size;
|
||||
m_cb.idx = 0;
|
||||
m_cb.p_buffer = buffer;
|
||||
nrf_adc_config_set(m_cb.p_current_conv->config.data);
|
||||
nrf_adc_event_clear(NRF_ADC_EVENT_END);
|
||||
nrf_adc_enable();
|
||||
if (m_cb.event_handler)
|
||||
{
|
||||
nrf_adc_int_enable(NRF_ADC_INT_END_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
while(!nrf_adc_event_check(NRF_ADC_EVENT_END)){}
|
||||
|
||||
if (adc_sample_process())
|
||||
{
|
||||
m_cb.state = NRF_DRV_STATE_INITIALIZED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
bool nrf_drv_adc_is_busy(void)
|
||||
{
|
||||
ASSERT(mp_state != NRF_DRV_STATE_UNINITIALIZED);
|
||||
return (m_cb.state == NRF_DRV_STATE_POWERED_ON) ? true : false;
|
||||
}
|
||||
|
||||
void ADC_IRQHandler(void)
|
||||
{
|
||||
if (m_cb.p_buffer == NULL)
|
||||
{
|
||||
nrf_adc_event_clear(NRF_ADC_EVENT_END);
|
||||
nrf_adc_int_disable(NRF_ADC_INT_END_MASK);
|
||||
nrf_adc_disable();
|
||||
nrf_drv_adc_evt_t evt;
|
||||
evt.type = NRF_DRV_ADC_EVT_SAMPLE;
|
||||
evt.data.sample.sample = (nrf_adc_value_t)nrf_adc_result_get();
|
||||
m_cb.state = NRF_DRV_STATE_INITIALIZED;
|
||||
m_cb.event_handler(&evt);
|
||||
}
|
||||
else if (adc_sample_process())
|
||||
{
|
||||
nrf_adc_int_disable(NRF_ADC_INT_END_MASK);
|
||||
nrf_drv_adc_evt_t evt;
|
||||
evt.type = NRF_DRV_ADC_EVT_DONE;
|
||||
evt.data.done.p_buffer = m_cb.p_buffer;
|
||||
evt.data.done.size = m_cb.size;
|
||||
m_cb.state = NRF_DRV_STATE_INITIALIZED;
|
||||
m_cb.event_handler(&evt);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,324 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 "nrf_adc.h"
|
||||
#include "nrf_drv_config.h"
|
||||
#include "sdk_errors.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup nrf_adc ADC HAL and driver
|
||||
* @ingroup nrf_drivers
|
||||
* @brief Analog-to-digital converter (ADC) APIs.
|
||||
* @details The ADC HAL provides basic APIs for accessing the registers of the analog-to-digital converter.
|
||||
* The ADC driver provides APIs on a higher level.
|
||||
*
|
||||
* @defgroup nrf_adc_drv ADC driver
|
||||
* @{
|
||||
* @ingroup nrf_adc
|
||||
* @brief Analog-to-digital converter (ADC) driver.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Driver event types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NRF_DRV_ADC_EVT_DONE, ///< Event generated when the buffer is filled with samples.
|
||||
NRF_DRV_ADC_EVT_SAMPLE, ///< Event generated when the requested channel is sampled.
|
||||
} nrf_drv_adc_evt_type_t;
|
||||
|
||||
typedef int16_t nrf_adc_value_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver DONE event.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_adc_value_t * p_buffer; ///< Pointer to buffer with converted samples.
|
||||
uint16_t size; ///< Number of samples in the buffer.
|
||||
} nrf_drv_adc_done_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver SAMPLE event.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_adc_value_t sample; ///< Converted sample.
|
||||
} nrf_drv_adc_sample_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Analog-to-digital converter driver event.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
nrf_drv_adc_evt_type_t type; ///< Event type.
|
||||
union
|
||||
{
|
||||
nrf_drv_adc_done_evt_t done; ///< Data for DONE event.
|
||||
nrf_drv_adc_sample_evt_t sample; ///< Data for SAMPLE event.
|
||||
} data;
|
||||
} nrf_drv_adc_evt_t;
|
||||
|
||||
/**@brief Macro for initializing the ADC channel with the default configuration. */
|
||||
#define NRF_DRV_ADC_DEFAULT_CHANNEL(analog_input) \
|
||||
{{{ \
|
||||
.resolution = NRF_ADC_CONFIG_RES_10BIT, \
|
||||
.input = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE, \
|
||||
.reference = NRF_ADC_CONFIG_REF_VBG, \
|
||||
.ain = (analog_input) \
|
||||
}}, NULL}
|
||||
|
||||
/**
|
||||
* @brief ADC channel configuration.
|
||||
*
|
||||
* @note The bit fields reflect bit fields in the ADC CONFIG register.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t resolution :2; ///< 8-10 bit resolution.
|
||||
uint32_t input :3; ///< Input selection and scaling.
|
||||
uint32_t reference :2; ///< Reference source.
|
||||
uint32_t reserved :1; ///< Unused bit fields.
|
||||
uint32_t ain :8; ///< Analog input.
|
||||
uint32_t external_reference:2; ///< Eternal reference source.
|
||||
}nrf_drv_adc_channel_config_t;
|
||||
|
||||
// Forward declaration of the nrf_drv_adc_channel_t type.
|
||||
typedef struct nrf_drv_adc_channel_s nrf_drv_adc_channel_t;
|
||||
|
||||
/**
|
||||
* @brief ADC channel.
|
||||
*
|
||||
* This structure is defined by the user and used by the driver. Therefore, it should
|
||||
* not be defined on the stack as a local variable.
|
||||
*/
|
||||
struct nrf_drv_adc_channel_s
|
||||
{
|
||||
union
|
||||
{
|
||||
nrf_drv_adc_channel_config_t config; ///< Channel configuration.
|
||||
uint32_t data; ///< Raw value.
|
||||
} config;
|
||||
nrf_drv_adc_channel_t * p_next; ///< Pointer to the next enabled channel (for internal use).
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief ADC configuration.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t interrupt_priority; ///< Priority of ADC interrupt.
|
||||
} nrf_drv_adc_config_t;
|
||||
|
||||
/** @brief ADC default configuration. */
|
||||
#define NRF_DRV_ADC_DEFAULT_CONFIG \
|
||||
{ \
|
||||
.interrupt_priority = ADC_CONFIG_IRQ_PRIORITY \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief User event handler prototype.
|
||||
*
|
||||
* This function is called when the requested number of samples has been processed.
|
||||
*
|
||||
* @param p_event Event.
|
||||
*/
|
||||
typedef void (*nrf_drv_adc_event_handler_t)(nrf_drv_adc_evt_t const * p_event);
|
||||
|
||||
/**
|
||||
* @brief Function for initializing the ADC.
|
||||
*
|
||||
* If a valid event handler is provided, the driver is initialized in non-blocking mode.
|
||||
* If event_handler is NULL, the driver works in blocking mode.
|
||||
*
|
||||
* @param[in] p_config Driver configuration.
|
||||
* @param[in] event_handler Event handler provided by the user.
|
||||
*
|
||||
* @retval NRF_SUCCESS If initialization was successful.
|
||||
* @retval NRF_ERROR_INVALID_STATE If the driver is already initialized.
|
||||
*/
|
||||
ret_code_t nrf_drv_adc_init(nrf_drv_adc_config_t const * p_config,
|
||||
nrf_drv_adc_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Function for uninitializing the ADC.
|
||||
*
|
||||
* This function stops all ongoing conversions and disables all channels.
|
||||
*/
|
||||
void nrf_drv_adc_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Function for enabling an ADC channel.
|
||||
*
|
||||
* This function configures and enables the channel. When @ref nrf_drv_adc_buffer_convert is
|
||||
* called, all channels that have been enabled with this function are sampled.
|
||||
*
|
||||
* @note The channel instance variable @p p_channel is used by the driver as an item
|
||||
* in a list. Therefore, it cannot be an automatic variable, and an assertion fails if it is
|
||||
* an automatic variable (if asserts are enabled).
|
||||
*/
|
||||
void nrf_drv_adc_channel_enable(nrf_drv_adc_channel_t * const p_channel);
|
||||
|
||||
/**
|
||||
* @brief Function for disabling an ADC channel.
|
||||
*/
|
||||
void nrf_drv_adc_channel_disable(nrf_drv_adc_channel_t * const p_channel);
|
||||
|
||||
/**
|
||||
* @brief Function for starting ADC sampling.
|
||||
*
|
||||
* This function triggers single ADC sampling. If more than one channel is enabled, the driver
|
||||
* emulates scanning and all channels are sampled in the order they were enabled.
|
||||
*/
|
||||
void nrf_drv_adc_sample(void);
|
||||
|
||||
/**
|
||||
* @brief Function for executing a single ADC conversion.
|
||||
*
|
||||
* This function selects the desired input and starts a single conversion. If a valid pointer
|
||||
* is provided for the result, the function blocks until the conversion is completed. Otherwise, the
|
||||
* function returns when the conversion is started, and the result is provided in an event (driver
|
||||
* must be initialized in non-blocking mode otherwise an assertion will fail). The function will fail if
|
||||
* ADC is busy. The channel does not need to be enabled to perform a single conversion.
|
||||
*
|
||||
* @param[in] p_channel Channel.
|
||||
* @param[out] p_value Pointer to the location where the result should be placed. Unless NULL is
|
||||
* provided, the function is blocking.
|
||||
*
|
||||
* @retval NRF_SUCCESS If conversion was successful.
|
||||
* @retval NRF_ERROR_BUSY If the ADC driver is busy.
|
||||
*/
|
||||
ret_code_t nrf_drv_adc_sample_convert(nrf_drv_adc_channel_t const * const p_channel,
|
||||
nrf_adc_value_t * p_value);
|
||||
|
||||
/**
|
||||
* @brief Function for converting data to the buffer.
|
||||
*
|
||||
* If the driver is initialized in non-blocking mode, this function returns when the first conversion
|
||||
* is set up. When the buffer is filled, the application is notified by the event handler. If the
|
||||
* driver is initialized in blocking mode, the function returns when the buffer is filled.
|
||||
*
|
||||
* Conversion is done on all enabled channels, but it is not triggered by this
|
||||
* function. This function will prepare the ADC for sampling and then
|
||||
* wait for the SAMPLE task. Sampling can be triggered manually by the @ref
|
||||
* nrf_drv_adc_sample function or by PPI using the @ref NRF_ADC_TASK_START task.
|
||||
*
|
||||
* @note If more than one channel is enabled, the function emulates scanning, and
|
||||
* a single START task will trigger conversion on all enabled channels. For example:
|
||||
* If 3 channels are enabled and the user requests 6 samples, the completion event
|
||||
* handler will be called after 2 START tasks.
|
||||
* @note The application must adjust the sampling frequency. The maximum frequency
|
||||
* depends on the sampling timer and the maximum latency of the ADC interrupt. If
|
||||
* an interrupt is not handled before the next sampling is triggered, the sample
|
||||
* will be lost.
|
||||
*
|
||||
* @param[in] buffer Result buffer.
|
||||
* @param[in] size Buffer size in samples.
|
||||
*
|
||||
* @retval NRF_SUCCESS If conversion was successful.
|
||||
* @retval NRF_ERROR_BUSY If the driver is busy.
|
||||
*/
|
||||
ret_code_t nrf_drv_adc_buffer_convert(nrf_adc_value_t * buffer, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the ADC state.
|
||||
*
|
||||
* @retval true If the ADC is busy.
|
||||
* @retval false If the ADC is ready.
|
||||
*/
|
||||
bool nrf_drv_adc_is_busy(void);
|
||||
|
||||
/**
|
||||
* @brief Function for getting the address of the ADC START task.
|
||||
*
|
||||
* This function is used to get the address of the START task, which can be used to trigger ADC
|
||||
* conversion.
|
||||
*
|
||||
* @return Start task address.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t nrf_drv_adc_start_task_get(void);
|
||||
|
||||
/**
|
||||
* @brief Function for converting a GPIO pin number to an analog input pin mask to be used in
|
||||
* the ADC channel configuration.
|
||||
*
|
||||
* @param[in] pin GPIO pin.
|
||||
*
|
||||
* @return Analog input pin mask. The function returns @ref NRF_ADC_CONFIG_INPUT_DISABLED
|
||||
* if the specified pin is not an analog input.
|
||||
*/
|
||||
__STATIC_INLINE nrf_adc_config_input_t nrf_drv_adc_gpio_to_ain(uint32_t pin);
|
||||
|
||||
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
|
||||
|
||||
__STATIC_INLINE uint32_t nrf_drv_adc_start_task_get(void)
|
||||
{
|
||||
return nrf_adc_task_address_get(NRF_ADC_TASK_START);
|
||||
}
|
||||
|
||||
__STATIC_INLINE nrf_adc_config_input_t nrf_drv_adc_gpio_to_ain(uint32_t pin)
|
||||
{
|
||||
// AIN2 - AIN7
|
||||
if (pin >= 1 && pin <= 6)
|
||||
{
|
||||
return (nrf_adc_config_input_t)(1 << (pin+1));
|
||||
}
|
||||
// AIN0 - AIN1
|
||||
else if (pin >= 26 && pin <= 27)
|
||||
{
|
||||
return (nrf_adc_config_input_t)(1 <<(pin - 26));
|
||||
}
|
||||
else
|
||||
{
|
||||
return NRF_ADC_CONFIG_INPUT_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/** @} */
|
|
@ -0,0 +1,495 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 NRF_DRV_CONFIG_H
|
||||
#define NRF_DRV_CONFIG_H
|
||||
|
||||
/**
|
||||
* Provide a non-zero value here in applications that need to use several
|
||||
* peripherals with the same ID that are sharing certain resources
|
||||
* (for example, SPI0 and TWI0). Obviously, such peripherals cannot be used
|
||||
* simultaneously. Therefore, this definition allows to initialize the driver
|
||||
* for another peripheral from a given group only after the previously used one
|
||||
* is uninitialized. Normally, this is not possible, because interrupt handlers
|
||||
* are implemented in individual drivers.
|
||||
* This functionality requires a more complicated interrupt handling and driver
|
||||
* initialization, hence it is not always desirable to use it.
|
||||
*/
|
||||
#define PERIPHERAL_RESOURCE_SHARING_ENABLED 1
|
||||
|
||||
/* CLOCK */
|
||||
#define CLOCK_ENABLED 1
|
||||
|
||||
#if (CLOCK_ENABLED == 1)
|
||||
#define CLOCK_CONFIG_XTAL_FREQ NRF_CLOCK_XTALFREQ_Default
|
||||
#define CLOCK_CONFIG_LF_SRC NRF_CLOCK_LFCLK_Xtal
|
||||
#define CLOCK_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#endif
|
||||
|
||||
/* GPIOTE */
|
||||
#define GPIOTE_ENABLED 1
|
||||
|
||||
#if (GPIOTE_ENABLED == 1)
|
||||
#define GPIOTE_CONFIG_USE_SWI_EGU false
|
||||
#define GPIOTE_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 8
|
||||
#endif
|
||||
|
||||
/* TIMER */
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#define TIMER0_ENABLED 0
|
||||
#else
|
||||
#define TIMER0_ENABLED 1
|
||||
#endif
|
||||
|
||||
#if (TIMER0_ENABLED == 1)
|
||||
#define TIMER0_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
|
||||
#define TIMER0_CONFIG_MODE TIMER_MODE_MODE_Timer
|
||||
#define TIMER0_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_32Bit
|
||||
#define TIMER0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define TIMER0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define TIMER1_ENABLED 1
|
||||
|
||||
#if (TIMER1_ENABLED == 1)
|
||||
#define TIMER1_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
|
||||
#define TIMER1_CONFIG_MODE TIMER_MODE_MODE_Timer
|
||||
#define TIMER1_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
|
||||
#define TIMER1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define TIMER1_INSTANCE_INDEX (TIMER0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define TIMER2_ENABLED 1
|
||||
|
||||
#if (TIMER2_ENABLED == 1)
|
||||
#define TIMER2_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
|
||||
#define TIMER2_CONFIG_MODE TIMER_MODE_MODE_Timer
|
||||
#define TIMER2_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
|
||||
#define TIMER2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define TIMER2_INSTANCE_INDEX (TIMER1_ENABLED+TIMER0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define TIMER3_ENABLED 0
|
||||
|
||||
#if (TIMER3_ENABLED == 1)
|
||||
#define TIMER3_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
|
||||
#define TIMER3_CONFIG_MODE TIMER_MODE_MODE_Timer
|
||||
#define TIMER3_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
|
||||
#define TIMER3_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define TIMER3_INSTANCE_INDEX (TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define TIMER4_ENABLED 0
|
||||
|
||||
#if (TIMER4_ENABLED == 1)
|
||||
#define TIMER4_CONFIG_FREQUENCY NRF_TIMER_FREQ_16MHz
|
||||
#define TIMER4_CONFIG_MODE TIMER_MODE_MODE_Timer
|
||||
#define TIMER4_CONFIG_BIT_WIDTH TIMER_BITMODE_BITMODE_16Bit
|
||||
#define TIMER4_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define TIMER4_INSTANCE_INDEX (TIMER3_ENABLED+TIMER2_ENABLED+TIMER1_ENABLED+TIMER0_ENABLED)
|
||||
#endif
|
||||
|
||||
|
||||
#define TIMER_COUNT (TIMER0_ENABLED + TIMER1_ENABLED + TIMER2_ENABLED + TIMER3_ENABLED + TIMER4_ENABLED)
|
||||
|
||||
/* RTC */
|
||||
#define RTC0_ENABLED 0
|
||||
|
||||
#if (RTC0_ENABLED == 1)
|
||||
#define RTC0_CONFIG_FREQUENCY 32678
|
||||
#define RTC0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#define RTC0_CONFIG_RELIABLE false
|
||||
|
||||
#define RTC0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define RTC1_ENABLED 0
|
||||
|
||||
#if (RTC1_ENABLED == 1)
|
||||
#define RTC1_CONFIG_FREQUENCY 32768
|
||||
#define RTC1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#define RTC1_CONFIG_RELIABLE false
|
||||
|
||||
#define RTC1_INSTANCE_INDEX (RTC0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define RTC2_ENABLED 0
|
||||
|
||||
#if (RTC2_ENABLED == 1)
|
||||
#define RTC2_CONFIG_FREQUENCY 32768
|
||||
#define RTC2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#define RTC2_CONFIG_RELIABLE false
|
||||
|
||||
#define RTC2_INSTANCE_INDEX (RTC0_ENABLED+RTC1_ENABLED)
|
||||
#endif
|
||||
|
||||
|
||||
#define RTC_COUNT (RTC0_ENABLED+RTC1_ENABLED+RTC2_ENABLED)
|
||||
|
||||
#define NRF_MAXIMUM_LATENCY_US 2000
|
||||
|
||||
/* RNG */
|
||||
#define RNG_ENABLED 0
|
||||
|
||||
#if (RNG_ENABLED == 1)
|
||||
#define RNG_CONFIG_ERROR_CORRECTION true
|
||||
#define RNG_CONFIG_POOL_SIZE 8
|
||||
#define RNG_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#endif
|
||||
|
||||
/* PWM */
|
||||
|
||||
#define PWM0_ENABLED 0
|
||||
|
||||
#if (PWM0_ENABLED == 1)
|
||||
#define PWM0_CONFIG_OUT0_PIN 2
|
||||
#define PWM0_CONFIG_OUT1_PIN 3
|
||||
#define PWM0_CONFIG_OUT2_PIN 4
|
||||
#define PWM0_CONFIG_OUT3_PIN 5
|
||||
#define PWM0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#define PWM0_CONFIG_BASE_CLOCK NRF_PWM_CLK_1MHz
|
||||
#define PWM0_CONFIG_COUNT_MODE NRF_PWM_MODE_UP
|
||||
#define PWM0_CONFIG_TOP_VALUE 1000
|
||||
#define PWM0_CONFIG_LOAD_MODE NRF_PWM_LOAD_COMMON
|
||||
#define PWM0_CONFIG_STEP_MODE NRF_PWM_STEP_AUTO
|
||||
|
||||
#define PWM0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define PWM1_ENABLED 0
|
||||
|
||||
#if (PWM1_ENABLED == 1)
|
||||
#define PWM1_CONFIG_OUT0_PIN 2
|
||||
#define PWM1_CONFIG_OUT1_PIN 3
|
||||
#define PWM1_CONFIG_OUT2_PIN 4
|
||||
#define PWM1_CONFIG_OUT3_PIN 5
|
||||
#define PWM1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#define PWM1_CONFIG_BASE_CLOCK NRF_PWM_CLK_1MHz
|
||||
#define PWM1_CONFIG_COUNT_MODE NRF_PWM_MODE_UP
|
||||
#define PWM1_CONFIG_TOP_VALUE 1000
|
||||
#define PWM1_CONFIG_LOAD_MODE NRF_PWM_LOAD_COMMON
|
||||
#define PWM1_CONFIG_STEP_MODE NRF_PWM_STEP_AUTO
|
||||
|
||||
#define PWM1_INSTANCE_INDEX (PWM0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define PWM2_ENABLED 0
|
||||
|
||||
#if (PWM2_ENABLED == 1)
|
||||
#define PWM2_CONFIG_OUT0_PIN 2
|
||||
#define PWM2_CONFIG_OUT1_PIN 3
|
||||
#define PWM2_CONFIG_OUT2_PIN 4
|
||||
#define PWM2_CONFIG_OUT3_PIN 5
|
||||
#define PWM2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#define PWM2_CONFIG_BASE_CLOCK NRF_PWM_CLK_1MHz
|
||||
#define PWM2_CONFIG_COUNT_MODE NRF_PWM_MODE_UP
|
||||
#define PWM2_CONFIG_TOP_VALUE 1000
|
||||
#define PWM2_CONFIG_LOAD_MODE NRF_PWM_LOAD_COMMON
|
||||
#define PWM2_CONFIG_STEP_MODE NRF_PWM_STEP_AUTO
|
||||
|
||||
#define PWM2_INSTANCE_INDEX (PWM0_ENABLED + PWM1_ENABLED)
|
||||
#endif
|
||||
|
||||
#define PWM_COUNT (PWM0_ENABLED + PWM1_ENABLED + PWM2_ENABLED)
|
||||
|
||||
/* SPI */
|
||||
#define SPI0_ENABLED 0
|
||||
|
||||
#if (SPI0_ENABLED == 1)
|
||||
#define SPI0_USE_EASY_DMA 0
|
||||
|
||||
#define SPI0_CONFIG_SCK_PIN 2
|
||||
#define SPI0_CONFIG_MOSI_PIN 3
|
||||
#define SPI0_CONFIG_MISO_PIN 4
|
||||
#define SPI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define SPI0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define SPI1_ENABLED 1
|
||||
|
||||
#if (SPI1_ENABLED == 1)
|
||||
#define SPI1_USE_EASY_DMA 0
|
||||
|
||||
#define SPI1_CONFIG_SCK_PIN 2
|
||||
#define SPI1_CONFIG_MOSI_PIN 3
|
||||
#define SPI1_CONFIG_MISO_PIN 4
|
||||
#define SPI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define SPI1_INSTANCE_INDEX (SPI0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define SPI2_ENABLED 0
|
||||
|
||||
#if (SPI2_ENABLED == 1)
|
||||
#define SPI2_USE_EASY_DMA 0
|
||||
|
||||
#define SPI2_CONFIG_SCK_PIN 2
|
||||
#define SPI2_CONFIG_MOSI_PIN 3
|
||||
#define SPI2_CONFIG_MISO_PIN 4
|
||||
#define SPI2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define SPI2_INSTANCE_INDEX (SPI0_ENABLED + SPI1_ENABLED)
|
||||
#endif
|
||||
|
||||
#define SPI_COUNT (SPI0_ENABLED + SPI1_ENABLED + SPI2_ENABLED)
|
||||
|
||||
/* SPIS */
|
||||
#define SPIS0_ENABLED 0
|
||||
|
||||
#if (SPIS0_ENABLED == 1)
|
||||
#define SPIS0_CONFIG_SCK_PIN 2
|
||||
#define SPIS0_CONFIG_MOSI_PIN 3
|
||||
#define SPIS0_CONFIG_MISO_PIN 4
|
||||
#define SPIS0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define SPIS0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define SPIS1_ENABLED 1
|
||||
|
||||
#if (SPIS1_ENABLED == 1)
|
||||
#define SPIS1_CONFIG_SCK_PIN 2
|
||||
#define SPIS1_CONFIG_MOSI_PIN 3
|
||||
#define SPIS1_CONFIG_MISO_PIN 4
|
||||
#define SPIS1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define SPIS1_INSTANCE_INDEX SPIS0_ENABLED
|
||||
#endif
|
||||
|
||||
#define SPIS2_ENABLED 0
|
||||
|
||||
#if (SPIS2_ENABLED == 1)
|
||||
#define SPIS2_CONFIG_SCK_PIN 2
|
||||
#define SPIS2_CONFIG_MOSI_PIN 3
|
||||
#define SPIS2_CONFIG_MISO_PIN 4
|
||||
#define SPIS2_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define SPIS2_INSTANCE_INDEX (SPIS0_ENABLED + SPIS1_ENABLED)
|
||||
#endif
|
||||
|
||||
#define SPIS_COUNT (SPIS0_ENABLED + SPIS1_ENABLED + SPIS2_ENABLED)
|
||||
|
||||
/* UART */
|
||||
#define UART0_ENABLED 1
|
||||
|
||||
#if (UART0_ENABLED == 1)
|
||||
#define UART0_CONFIG_HWFC NRF_UART_HWFC_ENABLED
|
||||
#define UART0_CONFIG_PARITY NRF_UART_PARITY_EXCLUDED
|
||||
#define UART0_CONFIG_BAUDRATE NRF_UART_BAUDRATE_9600
|
||||
#define UART0_CONFIG_PSEL_TXD 9
|
||||
#define UART0_CONFIG_PSEL_RXD 11
|
||||
#define UART0_CONFIG_PSEL_CTS 10
|
||||
#define UART0_CONFIG_PSEL_RTS 8
|
||||
#define UART0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
|
||||
#ifdef NRF52
|
||||
#define UART0_CONFIG_USE_EASY_DMA false
|
||||
//Compile time flag
|
||||
#define UART_EASY_DMA_SUPPORT 1
|
||||
#define UART_LEGACY_SUPPORT 1
|
||||
#endif //NRF52
|
||||
#endif
|
||||
|
||||
#define TWI0_ENABLED 1
|
||||
|
||||
#if (TWI0_ENABLED == 1)
|
||||
#define TWI0_USE_EASY_DMA 0
|
||||
|
||||
#define TWI0_CONFIG_FREQUENCY NRF_TWI_FREQ_100K
|
||||
#define TWI0_CONFIG_SCL 0
|
||||
#define TWI0_CONFIG_SDA 1
|
||||
#define TWI0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define TWI0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define TWI1_ENABLED 1
|
||||
|
||||
#if (TWI1_ENABLED == 1)
|
||||
#define TWI1_USE_EASY_DMA 0
|
||||
|
||||
#define TWI1_CONFIG_FREQUENCY NRF_TWI_FREQ_100K
|
||||
#define TWI1_CONFIG_SCL 0
|
||||
#define TWI1_CONFIG_SDA 1
|
||||
#define TWI1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define TWI1_INSTANCE_INDEX (TWI0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define TWI_COUNT (TWI0_ENABLED + TWI1_ENABLED)
|
||||
|
||||
/* TWIS */
|
||||
#define TWIS0_ENABLED 0
|
||||
|
||||
#if (TWIS0_ENABLED == 1)
|
||||
#define TWIS0_CONFIG_ADDR0 0
|
||||
#define TWIS0_CONFIG_ADDR1 0 /* 0: Disabled */
|
||||
#define TWIS0_CONFIG_SCL 0
|
||||
#define TWIS0_CONFIG_SDA 1
|
||||
#define TWIS0_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define TWIS0_INSTANCE_INDEX 0
|
||||
#endif
|
||||
|
||||
#define TWIS1_ENABLED 0
|
||||
|
||||
#if (TWIS1_ENABLED == 1)
|
||||
#define TWIS1_CONFIG_ADDR0 0
|
||||
#define TWIS1_CONFIG_ADDR1 0 /* 0: Disabled */
|
||||
#define TWIS1_CONFIG_SCL 0
|
||||
#define TWIS1_CONFIG_SDA 1
|
||||
#define TWIS1_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
|
||||
#define TWIS1_INSTANCE_INDEX (TWIS0_ENABLED)
|
||||
#endif
|
||||
|
||||
#define TWIS_COUNT (TWIS0_ENABLED + TWIS1_ENABLED)
|
||||
/* For more documentation see nrf_drv_twis.h file */
|
||||
#define TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0
|
||||
/* For more documentation see nrf_drv_twis.h file */
|
||||
#define TWIS_NO_SYNC_MODE 0
|
||||
|
||||
/* QDEC */
|
||||
#define QDEC_ENABLED 0
|
||||
|
||||
#if (QDEC_ENABLED == 1)
|
||||
#define QDEC_CONFIG_REPORTPER NRF_QDEC_REPORTPER_10
|
||||
#define QDEC_CONFIG_SAMPLEPER NRF_QDEC_SAMPLEPER_16384us
|
||||
#define QDEC_CONFIG_PIO_A 1
|
||||
#define QDEC_CONFIG_PIO_B 2
|
||||
#define QDEC_CONFIG_PIO_LED 3
|
||||
#define QDEC_CONFIG_LEDPRE 511
|
||||
#define QDEC_CONFIG_LEDPOL NRF_QDEC_LEPOL_ACTIVE_HIGH
|
||||
#define QDEC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#define QDEC_CONFIG_DBFEN false
|
||||
#define QDEC_CONFIG_SAMPLE_INTEN false
|
||||
#endif
|
||||
|
||||
/* ADC */
|
||||
#define ADC_ENABLED 1
|
||||
|
||||
#if (ADC_ENABLED == 1)
|
||||
#define ADC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#endif
|
||||
|
||||
|
||||
/* SAADC */
|
||||
#define SAADC_ENABLED 0
|
||||
|
||||
#if (SAADC_ENABLED == 1)
|
||||
#define SAADC_CONFIG_RESOLUTION NRF_SAADC_RESOLUTION_10BIT
|
||||
#define SAADC_CONFIG_OVERSAMPLE NRF_SAADC_OVERSAMPLE_DISABLED
|
||||
#define SAADC_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#endif
|
||||
|
||||
/* PDM */
|
||||
#define PDM_ENABLED 0
|
||||
|
||||
#if (PDM_ENABLED == 1)
|
||||
#define PDM_CONFIG_MODE NRF_PDM_MODE_MONO
|
||||
#define PDM_CONFIG_EDGE NRF_PDM_EDGE_LEFTFALLING
|
||||
#define PDM_CONFIG_CLOCK_FREQ NRF_PDM_FREQ_1032K
|
||||
#define PDM_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#endif
|
||||
|
||||
/* COMP */
|
||||
#define COMP_ENABLED 0
|
||||
|
||||
#if (COMP_ENABLED == 1)
|
||||
#define COMP_CONFIG_REF NRF_COMP_REF_Int1V8
|
||||
#define COMP_CONFIG_MAIN_MODE NRF_COMP_MAIN_MODE_SE
|
||||
#define COMP_CONFIG_SPEED_MODE NRF_COMP_SP_MODE_High
|
||||
#define COMP_CONFIG_HYST NRF_COMP_HYST_NoHyst
|
||||
#define COMP_CONFIG_ISOURCE NRF_COMP_ISOURCE_Off
|
||||
#define COMP_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#define COMP_CONFIG_INPUT NRF_COMP_INPUT_0
|
||||
#endif
|
||||
|
||||
/* LPCOMP */
|
||||
#define LPCOMP_ENABLED 0
|
||||
|
||||
#if (LPCOMP_ENABLED == 1)
|
||||
#define LPCOMP_CONFIG_REFERENCE NRF_LPCOMP_REF_SUPPLY_4_8
|
||||
#define LPCOMP_CONFIG_DETECTION NRF_LPCOMP_DETECT_DOWN
|
||||
#define LPCOMP_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_LOW
|
||||
#define LPCOMP_CONFIG_INPUT NRF_LPCOMP_INPUT_0
|
||||
#endif
|
||||
|
||||
/* WDT */
|
||||
#define WDT_ENABLED 0
|
||||
|
||||
#if (WDT_ENABLED == 1)
|
||||
#define WDT_CONFIG_BEHAVIOUR NRF_WDT_BEHAVIOUR_RUN_SLEEP
|
||||
#define WDT_CONFIG_RELOAD_VALUE 2000
|
||||
#define WDT_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
|
||||
#endif
|
||||
|
||||
/* SWI EGU */
|
||||
#ifdef NRF52
|
||||
#define EGU_ENABLED 0
|
||||
#endif
|
||||
|
||||
/* I2S */
|
||||
#define I2S_ENABLED 0
|
||||
|
||||
#if (I2S_ENABLED == 1)
|
||||
#define I2S_CONFIG_SCK_PIN 22
|
||||
#define I2S_CONFIG_LRCK_PIN 23
|
||||
#define I2S_CONFIG_MCK_PIN NRF_DRV_I2S_PIN_NOT_USED
|
||||
#define I2S_CONFIG_SDOUT_PIN 24
|
||||
#define I2S_CONFIG_SDIN_PIN 25
|
||||
#define I2S_CONFIG_IRQ_PRIORITY APP_IRQ_PRIORITY_HIGH
|
||||
#define I2S_CONFIG_MASTER NRF_I2S_MODE_MASTER
|
||||
#define I2S_CONFIG_FORMAT NRF_I2S_FORMAT_I2S
|
||||
#define I2S_CONFIG_ALIGN NRF_I2S_ALIGN_LEFT
|
||||
#define I2S_CONFIG_SWIDTH NRF_I2S_SWIDTH_16BIT
|
||||
#define I2S_CONFIG_CHANNELS NRF_I2S_CHANNELS_STEREO
|
||||
#define I2S_CONFIG_MCK_SETUP NRF_I2S_MCK_32MDIV8
|
||||
#define I2S_CONFIG_RATIO NRF_I2S_RATIO_256X
|
||||
#endif
|
||||
|
||||
#include "nrf_drv_config_validation.h"
|
||||
|
||||
#endif // NRF_DRV_CONFIG_H
|
|
@ -0,0 +1,202 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@defgroup nrf_mbr_api Master Boot Record API
|
||||
@{
|
||||
|
||||
@brief APIs for updating SoftDevice and BootLoader
|
||||
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_MBR_H__
|
||||
#define NRF_MBR_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef NRF51
|
||||
#error "This header file shall only be included for nRF51 projects"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup NRF_MBR_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief MBR SVC Base number. */
|
||||
#define MBR_SVC_BASE (0x18)
|
||||
|
||||
/**@brief Page size in words. */
|
||||
#define PAGE_SIZE_IN_WORDS 256
|
||||
/** @} */
|
||||
|
||||
/** @brief The size that must be reserved for the MBR when a softdevice is written to flash.
|
||||
This is the offset where the first byte of the softdevice hex file is written.*/
|
||||
#define MBR_SIZE (0x1000)
|
||||
|
||||
/** @addtogroup NRF_MBR_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF Master Boot Record API SVC numbers. */
|
||||
enum NRF_MBR_SVCS
|
||||
{
|
||||
SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
|
||||
};
|
||||
|
||||
/**@brief Possible values for ::sd_mbr_command_t.command */
|
||||
enum NRF_MBR_COMMANDS
|
||||
{
|
||||
SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see sd_mbr_command_copy_bl_t */
|
||||
SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
|
||||
SD_MBR_COMMAND_INIT_SD, /**< Init forwarding interrupts to SD, and run reset function in SD*/
|
||||
SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
|
||||
SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Start forwarding all exception to this address @see ::sd_mbr_command_vector_table_base_set_t*/
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief This command copies part of a new SoftDevice
|
||||
* The destination area is erased before copying.
|
||||
* If dst is in the middle of a flash page, that whole flash page will be erased.
|
||||
* If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* The user of this function is responsible for setting the PROTENSET registers.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *src; /**< Pointer to the source of data to be copied.*/
|
||||
uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/
|
||||
uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref PAGE_SIZE_IN_WORDS words.*/
|
||||
} sd_mbr_command_copy_sd_t;
|
||||
|
||||
|
||||
/**@brief This command works like memcmp, but takes the length in words.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
|
||||
* @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *ptr1; /**< Pointer to block of memory. */
|
||||
uint32_t *ptr2; /**< Pointer to block of memory. */
|
||||
uint32_t len; /**< Number of 32 bit words to compare.*/
|
||||
} sd_mbr_command_compare_t;
|
||||
|
||||
|
||||
/**@brief This command copies a new BootLoader.
|
||||
* With this command, destination of BootLoader is always the address written in NRF_UICR->BOOTADDR.
|
||||
*
|
||||
* Destination is erased by this function.
|
||||
* If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* This function will use PROTENSET to protect the flash that is not intended to be written.
|
||||
*
|
||||
* On Success, this function will not return. It will start the new BootLoader from reset-vector as normal.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN if NRF_UICR->BOOTADDR is not set.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *bl_src; /**< Pointer to the source of the Bootloader to be be copied.*/
|
||||
uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */
|
||||
} sd_mbr_command_copy_bl_t;
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
|
||||
*
|
||||
* Once this function has been called, this address is where the MBR will start to forward interrupts to after a reset.
|
||||
*
|
||||
* To restore default forwarding this function should be called with @param address set to 0.
|
||||
* The MBR will then start forwarding to interrupts to the address in NFR_UICR->BOOTADDR or to the SoftDevice if the BOOTADDR is not set.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
} sd_mbr_command_vector_table_base_set_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t command; /**< type of command to be issued see @ref NRF_MBR_COMMANDS. */
|
||||
union
|
||||
{
|
||||
sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/
|
||||
sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader.*/
|
||||
sd_mbr_command_compare_t compare; /**< Parameters for verify.*/
|
||||
sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set.*/
|
||||
} params;
|
||||
} sd_mbr_command_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Issue Master Boot Record commands
|
||||
*
|
||||
* Commands used when updating a SoftDevice and bootloader.
|
||||
*
|
||||
* @param[in] param Pointer to a struct describing the command.
|
||||
*
|
||||
*@note for retvals see ::sd_mbr_command_copy_sd_t ::sd_mbr_command_copy_bl_t ::sd_mbr_command_compare_t
|
||||
|
||||
*/
|
||||
SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
|
||||
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_MBR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
|
@ -0,0 +1,635 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 BLE_COMMON BLE SoftDevice Common
|
||||
@{
|
||||
@defgroup ble_api Events, type definitions and API calls
|
||||
@{
|
||||
|
||||
@brief Module independent events, type definitions and API calls for the BLE SoftDevice.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NRF_BLE_H__
|
||||
#define NRF_BLE_H__
|
||||
|
||||
#include "nrf_ble_ranges.h"
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_gap.h"
|
||||
#include "nrf_ble_l2cap.h"
|
||||
#include "nrf_ble_gatt.h"
|
||||
#include "nrf_ble_gattc.h"
|
||||
#include "nrf_ble_gatts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_COMMON_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief Common API SVC numbers.
|
||||
*/
|
||||
enum BLE_COMMON_SVCS
|
||||
{
|
||||
SD_BLE_ENABLE = BLE_SVC_BASE, /**< Enable and initialize the BLE stack */
|
||||
SD_BLE_EVT_GET, /**< Get an event from the pending events queue. */
|
||||
SD_BLE_TX_PACKET_COUNT_GET, /**< Get the total number of available application transmission packets for a particular connection. */
|
||||
SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific UUID. */
|
||||
SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */
|
||||
SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */
|
||||
SD_BLE_VERSION_GET, /**< Get the local version information (company id, Link Layer Version, Link Layer Subversion). */
|
||||
SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */
|
||||
SD_BLE_OPT_SET, /**< Set a BLE option. */
|
||||
SD_BLE_OPT_GET, /**< Get a BLE option. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief BLE Module Independent Event IDs.
|
||||
*/
|
||||
enum BLE_COMMON_EVTS
|
||||
{
|
||||
BLE_EVT_TX_COMPLETE = BLE_EVT_BASE, /**< Transmission Complete. @ref ble_evt_tx_complete_t */
|
||||
BLE_EVT_USER_MEM_REQUEST, /**< User Memory request. @ref ble_evt_user_mem_request_t */
|
||||
BLE_EVT_USER_MEM_RELEASE /**< User Memory release. @ref ble_evt_user_mem_release_t */
|
||||
};
|
||||
|
||||
/**@brief BLE connection bandwidth types.
|
||||
* Bandwidth types supported by the SoftDevice in packets per connection interval.
|
||||
*/
|
||||
enum BLE_CONN_BWS
|
||||
{
|
||||
BLE_CONN_BW_NONE = 0,
|
||||
BLE_CONN_BW_LOW,
|
||||
BLE_CONN_BW_MID,
|
||||
BLE_CONN_BW_HIGH
|
||||
};
|
||||
|
||||
/**@brief Common Option IDs.
|
||||
* IDs that uniquely identify a common option.
|
||||
*/
|
||||
enum BLE_COMMON_OPTS
|
||||
{
|
||||
BLE_COMMON_OPT_CONN_BW = BLE_OPT_BASE, /**< Bandwidth configuration @ref ble_common_opt_conn_bw_t */
|
||||
BLE_COMMON_OPT_PA_LNA /**< PA and LNA options */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @brief Required pointer alignment for BLE Events.
|
||||
*/
|
||||
#define BLE_EVTS_PTR_ALIGNMENT 4
|
||||
|
||||
/** @defgroup BLE_USER_MEM_TYPES User Memory Types
|
||||
* @{ */
|
||||
#define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */
|
||||
#define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_UUID_VS_COUNTS Vendor Specific UUID counts
|
||||
* @{
|
||||
*/
|
||||
#define BLE_UUID_VS_COUNT_MIN 1 /**< Minimum VS UUID count. */
|
||||
#define BLE_UUID_VS_COUNT_DEFAULT 0 /**< Use the default VS UUID count (10 for this version of the SoftDevice). */
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief User Memory Block. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *p_mem; /**< Pointer to the start of the user memory block. */
|
||||
uint16_t len; /**< Length in bytes of the user memory block. */
|
||||
} ble_user_mem_block_t;
|
||||
|
||||
/**
|
||||
* @brief Event structure for @ref BLE_EVT_TX_COMPLETE.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t count; /**< Number of packets transmitted. */
|
||||
} ble_evt_tx_complete_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_EVT_USER_MEM_REQUEST. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
|
||||
} ble_evt_user_mem_request_t;
|
||||
|
||||
/**@brief Event structure for @ref BLE_EVT_USER_MEM_RELEASE. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
|
||||
ble_user_mem_block_t mem_block; /**< User memory block */
|
||||
} ble_evt_user_mem_release_t;
|
||||
|
||||
|
||||
/**@brief Event structure for events not associated with a specific function module. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which this event occurred. */
|
||||
union
|
||||
{
|
||||
ble_evt_tx_complete_t tx_complete; /**< Transmission Complete. */
|
||||
ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */
|
||||
ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */
|
||||
} params;
|
||||
} ble_common_evt_t;
|
||||
|
||||
/**@brief BLE Event header. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t evt_id; /**< Value from a BLE_<module>_EVT series. */
|
||||
uint16_t evt_len; /**< Length in octets including this header. */
|
||||
} ble_evt_hdr_t;
|
||||
|
||||
/**@brief Common BLE Event type, wrapping the module specific event reports. */
|
||||
typedef struct
|
||||
{
|
||||
ble_evt_hdr_t header; /**< Event header. */
|
||||
union
|
||||
{
|
||||
ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */
|
||||
ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */
|
||||
ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */
|
||||
ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */
|
||||
ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */
|
||||
} evt;
|
||||
} ble_evt_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Version Information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t version_number; /**< Link Layer Version number for BT 4.1 spec is 7 (https://www.bluetooth.org/en-us/specification/assigned-numbers/link-layer). */
|
||||
uint16_t company_id; /**< Company ID, Nordic Semiconductor's company ID is 89 (0x0059) (https://www.bluetooth.org/apps/content/Default.aspx?doc_id=49708). */
|
||||
uint16_t subversion_number; /**< Link Layer Sub Version number, corresponds to the SoftDevice Config ID or Firmware ID (FWID). */
|
||||
} ble_version_t;
|
||||
|
||||
/* @brief: Configuration parameters for the PA and LNA. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t enable :1; /**< Enable toggling for this amplifier */
|
||||
uint8_t active_high :1; /**< Set the pin to be active high */
|
||||
uint8_t gpio_pin :6; /**< The GPIO pin to toggle for this amplifier */
|
||||
} ble_pa_lna_cfg_t;
|
||||
|
||||
/*
|
||||
* @brief PA & LNA GPIO toggle configuration
|
||||
*
|
||||
* This option configures the SoftDevice to toggle pins when the radio is active for use with a power amplifier and/or
|
||||
* a low noise amplifier.
|
||||
*
|
||||
* Toggling the pins is achieved by using two PPI channels and a GPIOTE channel. The hardware channel IDs are provided
|
||||
* by the application and should be regarded as reserved as long as any PA/LNA toggling is enabled.
|
||||
*
|
||||
* @note @ref sd_ble_opt_get is not supported for this option.
|
||||
* @note This feature is only supported for nRF52, on nRF51 @ref NRF_ERROR_NOT_SUPPORTED will always be returned.
|
||||
* @note Setting this option while the radio is in use (i.e. any of the roles are active) may have undefined consequences
|
||||
* and must be avoided by the application.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_pa_lna_cfg_t pa_cfg; /**< Power Amplifier configuration */
|
||||
ble_pa_lna_cfg_t lna_cfg; /**< Low Noise Amplifier configuration */
|
||||
|
||||
uint8_t ppi_ch_id_set; /**< PPI channel used for radio pin setting */
|
||||
uint8_t ppi_ch_id_clr; /**< PPI channel used for radio pin clearing */
|
||||
uint8_t gpiote_ch_id; /**< GPIOTE channel used for radio pin toggling */
|
||||
} ble_common_opt_pa_lna_t;
|
||||
|
||||
/**
|
||||
* @brief BLE connection bandwidth configuration parameters
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t conn_bw_tx; /**< Connection bandwidth configuration for transmission, see @ref BLE_CONN_BWS.*/
|
||||
uint8_t conn_bw_rx; /**< Connection bandwidth configuration for reception, see @ref BLE_CONN_BWS.*/
|
||||
} ble_conn_bw_t;
|
||||
|
||||
/**@brief BLE connection specific bandwidth configuration parameters.
|
||||
*
|
||||
* This can be used with @ref sd_ble_opt_set to set the bandwidth configuration to be used when creating connections.
|
||||
*
|
||||
* Call @ref sd_ble_opt_set with this option prior to calling @ref sd_ble_gap_adv_start or @ref sd_ble_gap_connect.
|
||||
*
|
||||
* The bandwidth configurations set via @ref sd_ble_opt_set are maintained separately for central and peripheral
|
||||
* connections. The given configurations are used for all future connections of the role indicated in this structure
|
||||
* unless they are changed by subsequent @ref sd_ble_opt_set calls.
|
||||
*
|
||||
* @note When this option is not used, the SoftDevice will use the default options:
|
||||
* - @ref BLE_CONN_BW_HIGH for @ref BLE_GAP_ROLE_PERIPH connections (both transmission and reception).
|
||||
* - @ref BLE_CONN_BW_MID for @ref BLE_GAP_ROLE_CENTRAL connections (both transmisison and reception).
|
||||
* This option allows the application to selectively override these defaults for each role.
|
||||
*
|
||||
* @note The global memory pool configuration can be set with the @ref ble_conn_bw_counts_t configuration parameter, which
|
||||
* is provided to @ref sd_ble_enable.
|
||||
*
|
||||
* @note Please refer to SoftDevice Specification for more information on bandwidth configuration.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_CONF_BW}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Set successfully.
|
||||
* @retval ::BLE_ERROR_INVALID_ROLE The role is invalid.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid bandwidth configuration parameters.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED If the combination of role and bandwidth configuration is not supported.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t role; /**< BLE role of the connection, see @ref BLE_GAP_ROLES. */
|
||||
ble_conn_bw_t conn_bw; /**< Bandwidth configuration parameters. */
|
||||
} ble_common_opt_conn_bw_t;
|
||||
|
||||
/**@brief Option structure for common options. */
|
||||
typedef union
|
||||
{
|
||||
ble_common_opt_conn_bw_t conn_bw; /**< Parameters for the connection bandwidth option. */
|
||||
ble_common_opt_pa_lna_t pa_lna; /**< Parameters for controlling PA and LNA pin toggling. */
|
||||
} ble_common_opt_t;
|
||||
|
||||
/**@brief Common BLE Option type, wrapping the module specific options. */
|
||||
typedef union
|
||||
{
|
||||
ble_common_opt_t common_opt; /**< COMMON options, opt_id in @ref BLE_COMMON_OPTS series. */
|
||||
ble_gap_opt_t gap_opt; /**< GAP option, opt_id in @ref BLE_GAP_OPTS series. */
|
||||
} ble_opt_t;
|
||||
|
||||
/**
|
||||
* @brief BLE bandwidth count parameters
|
||||
*
|
||||
* These parameters are used to configure the memory pools allocated within the SoftDevice for application packets
|
||||
* (both transmission and reception) for all connections.
|
||||
*
|
||||
* @note The sum of all three counts must add up to the sum of @ref ble_gap_enable_params_t::central_conn_count and
|
||||
* @ref ble_gap_enable_params_t::periph_conn_count in @ref ble_gap_enable_params_t.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t high_count; /**< Total number of high bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
|
||||
uint8_t mid_count; /**< Total number of medium bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
|
||||
uint8_t low_count; /**< Total number of low bandwidth TX or RX memory pools available to the application at runtime for all active connections. */
|
||||
} ble_conn_bw_count_t;
|
||||
|
||||
/**
|
||||
* @brief BLE bandwidth global memory pool configuration parameters
|
||||
*
|
||||
* These configuration parameters are used to set the amount of memory dedicated to application packets for
|
||||
* all connections. The application should specify the most demanding configuration for the intended use.
|
||||
*
|
||||
* Please refer to the SoftDevice Specification for more information on bandwidth configuration.
|
||||
*
|
||||
* @note Each connection created at runtime requires both a TX and an RX memory pool. By the use of these configuration
|
||||
* parameters, the application can decide the size and total number of the global memory pools that will be later
|
||||
* available for connection creation.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_CONF_BW}
|
||||
* @endmscs
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
ble_conn_bw_count_t tx_counts; /**< Global memory pool configuration for transmission.*/
|
||||
ble_conn_bw_count_t rx_counts; /**< Global memory pool configuration for reception.*/
|
||||
} ble_conn_bw_counts_t;
|
||||
|
||||
/**
|
||||
* @brief BLE Common Initialization parameters.
|
||||
*
|
||||
* @note If @ref p_conn_bw_counts is NULL the SoftDevice will assume default bandwidth configuration for all connections.
|
||||
* To fit a custom bandwidth configuration requirement, the application developer may have to specify a custom memory
|
||||
* pool configuration here. See @ref ble_common_opt_conn_bw_t for bandwidth configuration of individual connections.
|
||||
* Please refer to the SoftDevice Specification for more information on bandwidth configuration.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t vs_uuid_count; /**< Maximum number of 128-bit, Vendor Specific UUID bases to allocate. */
|
||||
ble_conn_bw_counts_t *p_conn_bw_counts; /**< Bandwidth configuration parameters or NULL for defaults. */
|
||||
} ble_common_enable_params_t;
|
||||
|
||||
/**
|
||||
* @brief BLE Initialization parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_common_enable_params_t common_enable_params; /**< Common init parameters @ref ble_common_enable_params_t. */
|
||||
ble_gap_enable_params_t gap_enable_params; /**< GAP init parameters @ref ble_gap_enable_params_t. */
|
||||
ble_gatts_enable_params_t gatts_enable_params; /**< GATTS init parameters @ref ble_gatts_enable_params_t. */
|
||||
} ble_enable_params_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Enable the BLE stack
|
||||
*
|
||||
* @param[in, out] p_ble_enable_params Pointer to ble_enable_params_t
|
||||
* @param[in, out] p_app_ram_base Pointer to a variable containing the start address of the application RAM region
|
||||
* (APP_RAM_BASE). On return, this will contain the minimum start address of the application RAM region required by the
|
||||
* SoftDevice for this configuration. Calling @ref sd_ble_enable() with *p_app_ram_base set to 0 can be used during
|
||||
* development to find out how much memory a specific configuration will need.
|
||||
*
|
||||
* @note The memory requirement for a specific configuration will not increase between SoftDevices with the same major
|
||||
* version number.
|
||||
*
|
||||
* @note At runtime the IC's RAM is split into 2 regions: The SoftDevice RAM region is located between 0x20000000 and
|
||||
* APP_RAM_BASE-1 and the application's RAM region is located between APP_RAM_BASE and the start of the call stack.
|
||||
*
|
||||
* @details This call initializes the BLE stack, no other BLE related function can be called before this one.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_ENABLE}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The BLE stack has been initialized successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized and cannot be reinitialized.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH The specified Attribute Table size is either too small or not a multiple of 4.
|
||||
* The minimum acceptable size is defined by @ref BLE_GATTS_ATTR_TAB_SIZE_MIN.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Incorrectly configured VS UUID count or connection count parameters.
|
||||
* @retval ::NRF_ERROR_NO_MEM The amount of memory assigned to the SoftDevice by *p_app_ram_base is not
|
||||
* large enough to fit this configuration's memory requirement. Check *p_app_ram_base
|
||||
* and set the start address of the application RAM region accordingly.
|
||||
* @retval ::NRF_ERROR_CONN_COUNT The requested number of connections exceeds the maximum supported by the SoftDevice.
|
||||
* Please refer to the SoftDevice Specification for more information on role configuration.
|
||||
*/
|
||||
SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(ble_enable_params_t * p_ble_enable_params, uint32_t * p_app_ram_base));
|
||||
|
||||
/**@brief Get an event from the pending events queue.
|
||||
*
|
||||
* @param[out] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length.
|
||||
* This buffer <b>must be 4-byte aligned in memory</b>.
|
||||
* @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length.
|
||||
*
|
||||
* @details This call allows the application to pull a BLE event from the BLE stack. The application is signaled that
|
||||
* an event is available from the BLE stack by the triggering of the SD_EVT_IRQn interrupt.
|
||||
* The application is free to choose whether to call this function from thread mode (main context) or directly from the
|
||||
* Interrupt Service Routine that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher
|
||||
* priority than the application, this function should be called in a loop (until @ref NRF_ERROR_NOT_FOUND is returned)
|
||||
* every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the BLE stack. Failure to do so
|
||||
* could potentially leave events in the internal queue without the application being aware of this fact. Sizing the
|
||||
* p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to
|
||||
* be copied into application memory. If the buffer provided is not large enough to fit the entire contents of the event,
|
||||
* @ref NRF_ERROR_DATA_SIZE will be returned and the application can then call again with a larger buffer size.
|
||||
* Please note that because of the variable length nature of some events, sizeof(ble_evt_t) will not always be large
|
||||
* enough to fit certain events, and so it is the application's responsibility to provide an amount of memory large
|
||||
* enough so that the relevant event is copied in full. The application may "peek" the event length by providing p_dest
|
||||
* as a NULL pointer and inspecting the value of *p_len upon return:
|
||||
*
|
||||
* \code
|
||||
* uint16_t len;
|
||||
* errcode = sd_ble_evt_get(NULL, &len);
|
||||
* \endcode
|
||||
*
|
||||
* @note The pointer supplied must be aligned to the extend defined by @ref BLE_EVTS_PTR_ALIGNMENT
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_IRQ_EVT_MSC}
|
||||
* @mmsc{@ref BLE_COMMON_THREAD_EVT_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Event pulled and stored into the supplied buffer.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND No events ready to be pulled.
|
||||
* @retval ::NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer.
|
||||
*/
|
||||
SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len));
|
||||
|
||||
|
||||
/**@brief Get the total number of available guaranteed application transmission packets for a particular connection.
|
||||
*
|
||||
* @details This call allows the application to obtain the total number of guaranteed application transmission packets
|
||||
* available for a connection. Please note that this does not return the number of free packets, but rather the total
|
||||
* amount of them for that particular connection. The application has two options to handle transmitting application packets:
|
||||
* - Use a simple arithmetic calculation: after connection creation time the application should use this function to
|
||||
* find out the total amount of guaranteed packets available to it and store it in a variable.
|
||||
* Every time a packet is successfully queued for a transmission on this connection using any of the exposed functions in
|
||||
* this BLE API, the application should decrement that variable. Conversely, whenever a @ref BLE_EVT_TX_COMPLETE event
|
||||
* with the conn_handle matching the particular connection is received by the application, it should retrieve the count
|
||||
* field in such event and add that number to the same variable storing the number of available guaranteed packets. This
|
||||
* mechanism allows the application to be aware at any time of the number of guaranteed application packets available for
|
||||
* each of the active connections, and therefore it can know with certainty whether it is possible to send more data or
|
||||
* it has to wait for a @ref BLE_EVT_TX_COMPLETE event before it proceeds.
|
||||
* The application can still pursue transmissions when the number of guaranteed application packets available is smaller
|
||||
* than or equal to zero, but successful queuing of the tranmsission is not guaranteed.
|
||||
* - Choose to simply not keep track of available packets at all, and instead handle the @ref BLE_ERROR_NO_TX_PACKETS error
|
||||
* by queueing the packet to be transmitted and try again as soon as a @ref BLE_EVT_TX_COMPLETE event arrives.
|
||||
*
|
||||
* The API functions that <b>may</b> consume an application packet depending on the parameters supplied to them can be found below:
|
||||
* - @ref sd_ble_gattc_write (write without response only)
|
||||
* - @ref sd_ble_gatts_hvx (notifications only)
|
||||
* - @ref sd_ble_l2cap_tx (all packets)
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[out] p_count Pointer to a uint8_t which will contain the number of application transmission packets upon
|
||||
* successful return.
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_COMMON_APP_BUFF_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Number of application transmission packets retrieved successfully.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
*/
|
||||
SVCALL(SD_BLE_TX_PACKET_COUNT_GET, uint32_t, sd_ble_tx_packet_count_get(uint16_t conn_handle, uint8_t *p_count));
|
||||
|
||||
|
||||
/**@brief Add a Vendor Specific UUID.
|
||||
*
|
||||
* @details This call enables the application to add a vendor specific UUID to the BLE stack's table, for later use
|
||||
* all other modules and APIs. This then allows the application to use the shorter, 24-bit @ref ble_uuid_t format
|
||||
* when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code paths.
|
||||
* The way that this is accomplished is by extending the grouping mechanism that the Bluetooth SIG standard base
|
||||
* UUID uses for all other 128-bit UUIDs. The type field in the @ref ble_uuid_t structure is an index (relative to
|
||||
* @ref BLE_UUID_TYPE_VENDOR_BEGIN) to the table populated by multiple calls to this function, and the uuid field
|
||||
* in the same structure contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to
|
||||
* the application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536,
|
||||
* although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.
|
||||
*
|
||||
* @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by
|
||||
* the 16-bit uuid field in @ref ble_uuid_t.
|
||||
*
|
||||
* @note If a UUID is already present in the BLE stack's internal table, the corresponding index will be returned in
|
||||
* p_uuid_type along with an NRF_SUCCESS error code.
|
||||
*
|
||||
* @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding
|
||||
* bytes 12 and 13.
|
||||
* @param[out] p_uuid_type Pointer to a uint8_t where the type field in @ref ble_uuid_t corresponding to this UUID will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully added the Vendor Specific UUID.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid.
|
||||
* @retval ::NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type));
|
||||
|
||||
|
||||
/** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure.
|
||||
*
|
||||
* @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared
|
||||
* to the corresponding ones in each entry of the table of vendor specific UUIDs populated with @ref sd_ble_uuid_vs_add
|
||||
* to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index
|
||||
* relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
|
||||
*
|
||||
* @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE.
|
||||
*
|
||||
* @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes).
|
||||
* @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes.
|
||||
* @param[out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH Invalid UUID length.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const *p_uuid_le, ble_uuid_t *p_uuid));
|
||||
|
||||
|
||||
/** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit).
|
||||
*
|
||||
* @note The pointer to the destination buffer p_uuid_le may be NULL, in which case only the validity and size of p_uuid is computed.
|
||||
*
|
||||
* @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes.
|
||||
* @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes).
|
||||
* @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully encoded into the buffer.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid UUID type.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const *p_uuid, uint8_t *p_uuid_le_len, uint8_t *p_uuid_le));
|
||||
|
||||
|
||||
/**@brief Get Version Information.
|
||||
*
|
||||
* @details This call allows the application to get the BLE stack version information.
|
||||
*
|
||||
* @param[out] p_version Pointer to a ble_version_t structure to be filled in.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Version information stored successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy (typically doing a locally-initiated disconnection procedure).
|
||||
*/
|
||||
SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t *p_version));
|
||||
|
||||
|
||||
/**@brief Provide a user memory block.
|
||||
*
|
||||
* @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in,out] p_block Pointer to a user memory block structure.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_PEER_CANCEL_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_NOAUTH_MSC}
|
||||
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
|
||||
* @endmscs
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Successfully queued a response to the peer.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection state or no execute write request pending.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time.
|
||||
*/
|
||||
SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block));
|
||||
|
||||
/**@brief Set a BLE option.
|
||||
*
|
||||
* @details This call allows the application to set the value of an option.
|
||||
*
|
||||
* @mscs
|
||||
* @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
|
||||
* @mmsc{@ref BLE_COMMON_CONF_BW}
|
||||
* @endmscs
|
||||
*
|
||||
* @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
|
||||
* @param[in] p_opt Pointer to a ble_opt_t structure containing the option value.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Option set successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Unable to set the parameter at this time.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed.
|
||||
*/
|
||||
SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt));
|
||||
|
||||
|
||||
/**@brief Get a BLE option.
|
||||
*
|
||||
* @details This call allows the application to retrieve the value of an option.
|
||||
*
|
||||
* @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
|
||||
* @param[out] p_opt Pointer to a ble_opt_t structure to be filled in.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Option retrieved successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Unable to retrieve the parameter at this time.
|
||||
* @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED This option is not supported.
|
||||
*
|
||||
*/
|
||||
SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt));
|
||||
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* NRF_BLE_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 BLE_COMMON
|
||||
@{
|
||||
@addtogroup nrf_error
|
||||
@{
|
||||
@ingroup BLE_COMMON
|
||||
@}
|
||||
|
||||
@defgroup ble_err General error codes
|
||||
@{
|
||||
|
||||
@brief General error code definitions for the BLE API.
|
||||
|
||||
@ingroup BLE_COMMON
|
||||
*/
|
||||
#ifndef NRF_BLE_ERR_H__
|
||||
#define NRF_BLE_ERR_H__
|
||||
|
||||
#include "nrf_error.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* @defgroup BLE_ERRORS Error Codes
|
||||
* @{ */
|
||||
#define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */
|
||||
#define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */
|
||||
#define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */
|
||||
#define BLE_ERROR_NO_TX_PACKETS (NRF_ERROR_STK_BASE_NUM+0x004) /**< Not enough application packets available on this connection. */
|
||||
#define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x005) /**< Invalid role. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges
|
||||
* @brief Assignment of subranges for module specific error codes.
|
||||
* @note For specific error codes, see ble_<module>.h or ble_error_<module>.h.
|
||||
* @{ */
|
||||
#define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */
|
||||
#define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */
|
||||
#define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */
|
||||
#define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,215 @@
|
|||
/*
|
||||
* Copyright (c) 2000 Nordic Semiconductor ASA
|
||||
* 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, except as embedded into a Nordic Semiconductor ASA
|
||||
* integrated circuit in a product or a software update for such product, 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 Nordic Semiconductor ASA nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary or object form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* 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 BLE_GATT Generic Attribute Profile (GATT) Common
|
||||
@{
|
||||
@brief Common definitions and prototypes for the GATT interfaces.
|
||||
*/
|
||||
|
||||
#ifndef NRF_BLE_GATT_H__
|
||||
#define NRF_BLE_GATT_H__
|
||||
|
||||
#include "nrf_ble_types.h"
|
||||
#include "nrf_ble_ranges.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup BLE_GATT_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @brief Default MTU size. */
|
||||
#define GATT_MTU_SIZE_DEFAULT 23
|
||||
|
||||
/** @brief Only the default MTU size of 23 is currently supported. */
|
||||
#define GATT_RX_MTU 23
|
||||
|
||||
|
||||
/**@brief Invalid Attribute Handle. */
|
||||
#define BLE_GATT_HANDLE_INVALID 0x0000
|
||||
|
||||
/**@brief First Attribute Handle. */
|
||||
#define BLE_GATT_HANDLE_START 0x0001
|
||||
|
||||
/**@brief Last Attribute Handle. */
|
||||
#define BLE_GATT_HANDLE_END 0xFFFF
|
||||
|
||||
/** @defgroup BLE_GATT_TIMEOUT_SOURCES GATT Timeout sources
|
||||
* @{ */
|
||||
#define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00 /**< ATT Protocol timeout. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_WRITE_OPS GATT Write operations
|
||||
* @{ */
|
||||
#define BLE_GATT_OP_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATT_OP_WRITE_REQ 0x01 /**< Write Request. */
|
||||
#define BLE_GATT_OP_WRITE_CMD 0x02 /**< Write Command. */
|
||||
#define BLE_GATT_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
|
||||
#define BLE_GATT_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
|
||||
#define BLE_GATT_OP_EXEC_WRITE_REQ 0x05 /**< Execute Write Request. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_EXEC_WRITE_FLAGS GATT Execute Write flags
|
||||
* @{ */
|
||||
#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00
|
||||
#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_HVX_TYPES GATT Handle Value operations
|
||||
* @{ */
|
||||
#define BLE_GATT_HVX_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATT_HVX_NOTIFICATION 0x01 /**< Handle Value Notification. */
|
||||
#define BLE_GATT_HVX_INDICATION 0x02 /**< Handle Value Indication. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_STATUS_CODES GATT Status Codes
|
||||
* @{ */
|
||||
#define BLE_GATT_STATUS_SUCCESS 0x0000 /**< Success. */
|
||||
#define BLE_GATT_STATUS_UNKNOWN 0x0001 /**< Unknown or not applicable status. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID 0x0100 /**< ATT Error: Invalid Error Code. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101 /**< ATT Error: Invalid Attribute Handle. */
|
||||
#define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102 /**< ATT Error: Read not permitted. */
|
||||
#define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103 /**< ATT Error: Write not permitted. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104 /**< ATT Error: Used in ATT as Invalid PDU. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105 /**< ATT Error: Authenticated link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106 /**< ATT Error: Used in ATT as Request Not Supported. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107 /**< ATT Error: Offset specified was past the end of the attribute. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108 /**< ATT Error: Used in ATT as Insufficient Authorisation. */
|
||||
#define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109 /**< ATT Error: Used in ATT as Prepare Queue Full. */
|
||||
#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A /**< ATT Error: Used in ATT as Attribute not found. */
|
||||
#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B /**< ATT Error: Attribute cannot be read or written using read/write blob requests. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C /**< ATT Error: Encryption key size used is insufficient. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D /**< ATT Error: Invalid value size. */
|
||||
#define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Encrypted link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_APP_END 0x019F /**< ATT Error: Application range end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0 /**< ATT Error: Reserved for Future Use range #2 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GATT_CPF_FORMATS Characteristic Presentation Formats
|
||||
* @note Found at http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
|
||||
* @{ */
|
||||
#define BLE_GATT_CPF_FORMAT_RFU 0x00 /**< Reserved For Future Use. */
|
||||
#define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01 /**< Boolean. */
|
||||
#define BLE_GATT_CPF_FORMAT_2BIT 0x02 /**< Unsigned 2-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_NIBBLE 0x03 /**< Unsigned 4-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT8 0x04 /**< Unsigned 8-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT12 0x05 /**< Unsigned 12-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT16 0x06 /**< Unsigned 16-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT24 0x07 /**< Unsigned 24-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT32 0x08 /**< Unsigned 32-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT48 0x09 /**< Unsigned 48-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT64 0x0A /**< Unsigned 64-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT128 0x0B /**< Unsigned 128-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT8 0x0C /**< Signed 2-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT12 0x0D /**< Signed 12-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT16 0x0E /**< Signed 16-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT24 0x0F /**< Signed 24-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT32 0x10 /**< Signed 32-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT48 0x11 /**< Signed 48-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT64 0x12 /**< Signed 64-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT128 0x13 /**< Signed 128-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT32 0x14 /**< IEEE-754 32-bit floating point. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT64 0x15 /**< IEEE-754 64-bit floating point. */
|
||||
#define BLE_GATT_CPF_FORMAT_SFLOAT 0x16 /**< IEEE-11073 16-bit SFLOAT. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT 0x17 /**< IEEE-11073 32-bit FLOAT. */
|
||||
#define BLE_GATT_CPF_FORMAT_DUINT16 0x18 /**< IEEE-20601 format. */
|
||||
#define BLE_GATT_CPF_FORMAT_UTF8S 0x19 /**< UTF-8 string. */
|
||||
#define BLE_GATT_CPF_FORMAT_UTF16S 0x1A /**< UTF-16 string. */
|
||||
#define BLE_GATT_CPF_FORMAT_STRUCT 0x1B /**< Opaque Structure. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_CPF_NAMESPACES GATT Bluetooth Namespaces
|
||||
* @{
|
||||
*/
|
||||
#define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01 /**< Bluetooth SIG defined Namespace. */
|
||||
#define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000 /**< Namespace Description Unknown. */
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATT_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief GATT Characteristic Properties. */
|
||||
typedef struct
|
||||
{
|
||||
/* Standard properties */
|
||||
uint8_t broadcast :1; /**< Broadcasting of the value permitted. */
|
||||
uint8_t read :1; /**< Reading the value permitted. */
|
||||
uint8_t write_wo_resp :1; /**< Writing the value with Write Command permitted. */
|
||||
uint8_t write :1; /**< Writing the value with Write Request permitted. */
|
||||
uint8_t notify :1; /**< Notications of the value permitted. */
|
||||
uint8_t indicate :1; /**< Indications of the value permitted. */
|
||||
uint8_t auth_signed_wr :1; /**< Writing the value with Signed Write Command permitted. */
|
||||
} ble_gatt_char_props_t;
|
||||
|
||||
/**@brief GATT Characteristic Extended Properties. */
|
||||
typedef struct
|
||||
{
|
||||
/* Extended properties */
|
||||
uint8_t reliable_wr :1; /**< Writing the value with Queued Write operations permitted. */
|
||||
uint8_t wr_aux :1; /**< Writing the Characteristic User Description descriptor permitted. */
|
||||
} ble_gatt_char_ext_props_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // NRF_BLE_GATT_H__
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue