Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more
OneWire_Masters/GPIO/owlink.s@46:afe466c96069, 2016-04-06 (annotated)
- Committer:
- IanBenzMaxim
- Date:
- Wed Apr 06 10:06:06 2016 -0500
- Revision:
- 46:afe466c96069
- Parent:
- 40:590791ecac1c
- Child:
- 52:4cba20c21941
Begin formalizing macros to write code for assemblers with different syntax.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IanBenzMaxim | 40:590791ecac1c | 1 | #define PROC_CLOCK_MHZ (__SYSTEM_HFX / 1000000) // Processor clock in MHz |
IanBenzMaxim | 31:7c684e49fa8f | 2 | #define OVERHEAD_TUNING 21 // Fraction where OverheadTime(us) = OVERHEAD_TUNING / PROC_CLOCK_MHZ |
IanBenzMaxim | 31:7c684e49fa8f | 3 | // Make PROC_CLOCK_MHZ and OVERHEAD_TUNING divisible by PROC_CYCLES_PER_LOOP for best results |
IanBenzMaxim | 28:057bb14d3cee | 4 | |
IanBenzMaxim | 31:7c684e49fa8f | 5 | #define PIPELINE_REFILL_PROC_CYCLES 1 // ARM specifies 1-3 cycles for pipeline refill following a branch |
IanBenzMaxim | 31:7c684e49fa8f | 6 | #define PROC_CYCLES_PER_LOOP (2 + PIPELINE_REFILL_PROC_CYCLES) |
IanBenzMaxim | 31:7c684e49fa8f | 7 | #define LOOPS_PER_US (PROC_CLOCK_MHZ / PROC_CYCLES_PER_LOOP) // Number of loop passes for a 1 us delay |
IanBenzMaxim | 31:7c684e49fa8f | 8 | #define LOOPS_REMOVED_TUNING (OVERHEAD_TUNING / PROC_CYCLES_PER_LOOP) |
IanBenzMaxim | 46:afe466c96069 | 9 | |
IanBenzMaxim | 46:afe466c96069 | 10 | // LABEL macro |
IanBenzMaxim | 46:afe466c96069 | 11 | #ifdef TOOLCHAIN_GCC_ARM |
IanBenzMaxim | 46:afe466c96069 | 12 | #define LABEL(x) x: |
IanBenzMaxim | 46:afe466c96069 | 13 | #else // TOOLCHAIN_IAR or TOOLCHAIN_ARM_STD |
IanBenzMaxim | 46:afe466c96069 | 14 | #define LABEL(x) x |
IanBenzMaxim | 46:afe466c96069 | 15 | #endif |
IanBenzMaxim | 46:afe466c96069 | 16 | |
IanBenzMaxim | 46:afe466c96069 | 17 | // EXPORT_LABEL macro |
IanBenzMaxim | 46:afe466c96069 | 18 | #ifdef TOOLCHAIN_GCC_ARM |
IanBenzMaxim | 46:afe466c96069 | 19 | #define EXPORT_LABEL(x) .global x |
IanBenzMaxim | 46:afe466c96069 | 20 | #else // TOOLCHAIN_IAR or TOOLCHAIN_ARM_STD |
IanBenzMaxim | 46:afe466c96069 | 21 | #define EXPORT_LABEL(x) EXPORT x |
IanBenzMaxim | 46:afe466c96069 | 22 | #endif |
IanBenzMaxim | 46:afe466c96069 | 23 | |
IanBenzMaxim | 46:afe466c96069 | 24 | // THUMB_FUNC macro |
IanBenzMaxim | 46:afe466c96069 | 25 | #ifdef TOOLCHAIN_GCC_ARM |
IanBenzMaxim | 46:afe466c96069 | 26 | #define THUMB_FUNC .thumb_func |
IanBenzMaxim | 46:afe466c96069 | 27 | #else // TOOLCHAIN_IAR or TOOLCHAIN_ARM_STD |
IanBenzMaxim | 46:afe466c96069 | 28 | #define THUMB_FUNC |
IanBenzMaxim | 46:afe466c96069 | 29 | #endif |
IanBenzMaxim | 30:fdd7a0f82f2f | 30 | |
IanBenzMaxim | 31:7c684e49fa8f | 31 | #if defined TOOLCHAIN_IAR |
IanBenzMaxim | 30:fdd7a0f82f2f | 32 | SECTION owlink : CODE |
IanBenzMaxim | 31:7c684e49fa8f | 33 | #elif defined TOOLCHAIN_ARM_STD |
IanBenzMaxim | 29:5c51a17cfbf5 | 34 | AREA owlink, CODE |
IanBenzMaxim | 31:7c684e49fa8f | 35 | #else // TOOLCHAIN_GCC_ARM |
IanBenzMaxim | 31:7c684e49fa8f | 36 | .syntax unified |
IanBenzMaxim | 31:7c684e49fa8f | 37 | .section .text |
IanBenzMaxim | 30:fdd7a0f82f2f | 38 | #endif |
IanBenzMaxim | 28:057bb14d3cee | 39 | |
IanBenzMaxim | 31:7c684e49fa8f | 40 | // void ow_usdelay(unsigned int time_us) |
IanBenzMaxim | 46:afe466c96069 | 41 | THUMB_FUNC |
IanBenzMaxim | 46:afe466c96069 | 42 | EXPORT_LABEL(ow_usdelay) |
IanBenzMaxim | 46:afe466c96069 | 43 | LABEL(ow_usdelay) |
IanBenzMaxim | 40:590791ecac1c | 44 | cmp R0, #0 // Return if time_us equals zero |
IanBenzMaxim | 40:590791ecac1c | 45 | beq return |
IanBenzMaxim | 28:057bb14d3cee | 46 | mov R1, #LOOPS_PER_US |
IanBenzMaxim | 28:057bb14d3cee | 47 | mul R0, R0, R1 |
IanBenzMaxim | 28:057bb14d3cee | 48 | sub R0, R0, #LOOPS_REMOVED_TUNING |
IanBenzMaxim | 46:afe466c96069 | 49 | LABEL(loop) |
IanBenzMaxim | 28:057bb14d3cee | 50 | subs R0, R0, #1 |
IanBenzMaxim | 28:057bb14d3cee | 51 | bne loop |
IanBenzMaxim | 46:afe466c96069 | 52 | LABEL(return) |
IanBenzMaxim | 28:057bb14d3cee | 53 | bx R14 |
IanBenzMaxim | 28:057bb14d3cee | 54 | |
IanBenzMaxim | 31:7c684e49fa8f | 55 | #ifdef TOOLCHAIN_GCC_ARM |
IanBenzMaxim | 31:7c684e49fa8f | 56 | .end |
IanBenzMaxim | 31:7c684e49fa8f | 57 | #else // TOOLCHAIN_IAR or TOOLCHAIN_ARM_STD |
IanBenzMaxim | 31:7c684e49fa8f | 58 | END |
IanBenzMaxim | 40:590791ecac1c | 59 | #endif |