Apply shorthand Assembler macros
This commit is contained in:
@ -23,6 +23,8 @@
|
||||
#ifndef _MATH_AVR_H_
|
||||
#define _MATH_AVR_H_
|
||||
|
||||
#define a(CODE) " " CODE "\n\t"
|
||||
|
||||
/**
|
||||
* Optimized math functions for AVR
|
||||
*/
|
||||
@ -39,41 +41,41 @@
|
||||
//
|
||||
#define MultiU24X32toH16(intRes, longIn1, longIn2) \
|
||||
asm volatile ( \
|
||||
"clr r26 \n\t" \
|
||||
"mul %A1, %B2 \n\t" \
|
||||
"mov r27, r1 \n\t" \
|
||||
"mul %B1, %C2 \n\t" \
|
||||
"movw %A0, r0 \n\t" \
|
||||
"mul %C1, %C2 \n\t" \
|
||||
"add %B0, r0 \n\t" \
|
||||
"mul %C1, %B2 \n\t" \
|
||||
"add %A0, r0 \n\t" \
|
||||
"adc %B0, r1 \n\t" \
|
||||
"mul %A1, %C2 \n\t" \
|
||||
"add r27, r0 \n\t" \
|
||||
"adc %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %B1, %B2 \n\t" \
|
||||
"add r27, r0 \n\t" \
|
||||
"adc %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %C1, %A2 \n\t" \
|
||||
"add r27, r0 \n\t" \
|
||||
"adc %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %B1, %A2 \n\t" \
|
||||
"add r27, r1 \n\t" \
|
||||
"adc %A0, r26 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"lsr r27 \n\t" \
|
||||
"adc %A0, r26 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"mul %D2, %A1 \n\t" \
|
||||
"add %A0, r0 \n\t" \
|
||||
"adc %B0, r1 \n\t" \
|
||||
"mul %D2, %B1 \n\t" \
|
||||
"add %B0, r0 \n\t" \
|
||||
"clr r1 \n\t" \
|
||||
A("clr r26") \
|
||||
A("mul %A1, %B2") \
|
||||
A("mov r27, r1") \
|
||||
A("mul %B1, %C2") \
|
||||
A("movw %A0, r0") \
|
||||
A("mul %C1, %C2") \
|
||||
A("add %B0, r0") \
|
||||
A("mul %C1, %B2") \
|
||||
A("add %A0, r0") \
|
||||
A("adc %B0, r1") \
|
||||
A("mul %A1, %C2") \
|
||||
A("add r27, r0") \
|
||||
A("adc %A0, r1") \
|
||||
A("adc %B0, r26") \
|
||||
A("mul %B1, %B2") \
|
||||
A("add r27, r0") \
|
||||
A("adc %A0, r1") \
|
||||
A("adc %B0, r26") \
|
||||
A("mul %C1, %A2") \
|
||||
A("add r27, r0") \
|
||||
A("adc %A0, r1") \
|
||||
A("adc %B0, r26") \
|
||||
A("mul %B1, %A2") \
|
||||
A("add r27, r1") \
|
||||
A("adc %A0, r26") \
|
||||
A("adc %B0, r26") \
|
||||
A("lsr r27") \
|
||||
A("adc %A0, r26") \
|
||||
A("adc %B0, r26") \
|
||||
A("mul %D2, %A1") \
|
||||
A("add %A0, r0") \
|
||||
A("adc %B0, r1") \
|
||||
A("mul %D2, %B1") \
|
||||
A("add %B0, r0") \
|
||||
A("clr r1") \
|
||||
: \
|
||||
"=&r" (intRes) \
|
||||
: \
|
||||
@ -89,16 +91,16 @@
|
||||
// r27 to store the byte 1 of the 24 bit result
|
||||
#define MultiU16X8toH16(intRes, charIn1, intIn2) \
|
||||
asm volatile ( \
|
||||
"clr r26 \n\t" \
|
||||
"mul %A1, %B2 \n\t" \
|
||||
"movw %A0, r0 \n\t" \
|
||||
"mul %A1, %A2 \n\t" \
|
||||
"add %A0, r1 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"lsr r0 \n\t" \
|
||||
"adc %A0, r26 \n\t" \
|
||||
"adc %B0, r26 \n\t" \
|
||||
"clr r1 \n\t" \
|
||||
A("clr r26") \
|
||||
A("mul %A1, %B2") \
|
||||
A("movw %A0, r0") \
|
||||
A("mul %A1, %A2") \
|
||||
A("add %A0, r1") \
|
||||
A("adc %B0, r26") \
|
||||
A("lsr r0") \
|
||||
A("adc %A0, r26") \
|
||||
A("adc %B0, r26") \
|
||||
A("clr r1") \
|
||||
: \
|
||||
"=&r" (intRes) \
|
||||
: \
|
||||
|
@ -36,7 +36,7 @@
|
||||
// state we are when running them
|
||||
|
||||
// A SW memory barrier, to ensure GCC does not overoptimize loops
|
||||
#define sw_barrier() asm volatile("": : :"memory");
|
||||
#define sw_barrier() __asm__ volatile("": : :"memory");
|
||||
|
||||
// (re)initialize UART0 as a monitor output to 250000,n,8,1
|
||||
static void TXBegin(void) {
|
||||
@ -230,106 +230,106 @@ void HardFault_HandlerC(unsigned long *sp, unsigned long lr, unsigned long cause
|
||||
|
||||
__attribute__((naked)) void NMI_Handler(void) {
|
||||
__asm__ __volatile__ (
|
||||
".syntax unified \n"
|
||||
" tst lr, #4 \n"
|
||||
" ite eq \n"
|
||||
" mrseq r0, msp \n"
|
||||
" mrsne r0, psp \n"
|
||||
" mov r1,lr \n"
|
||||
" mov r2,#0 \n"
|
||||
" b HardFault_HandlerC \n"
|
||||
".syntax unified" "\n\t"
|
||||
A("tst lr, #4")
|
||||
A("ite eq")
|
||||
A("mrseq r0, msp")
|
||||
A("mrsne r0, psp")
|
||||
A("mov r1,lr")
|
||||
A("mov r2,#0")
|
||||
A("b HardFault_HandlerC")
|
||||
);
|
||||
}
|
||||
|
||||
__attribute__((naked)) void HardFault_Handler(void) {
|
||||
__asm__ __volatile__ (
|
||||
".syntax unified \n"
|
||||
" tst lr, #4 \n"
|
||||
" ite eq \n"
|
||||
" mrseq r0, msp \n"
|
||||
" mrsne r0, psp \n"
|
||||
" mov r1,lr \n"
|
||||
" mov r2,#1 \n"
|
||||
" b HardFault_HandlerC \n"
|
||||
".syntax unified" "\n\t"
|
||||
A("tst lr, #4")
|
||||
A("ite eq")
|
||||
A("mrseq r0, msp")
|
||||
A("mrsne r0, psp")
|
||||
A("mov r1,lr")
|
||||
A("mov r2,#1")
|
||||
A("b HardFault_HandlerC")
|
||||
);
|
||||
}
|
||||
|
||||
__attribute__((naked)) void MemManage_Handler(void) {
|
||||
__asm__ __volatile__ (
|
||||
".syntax unified \n"
|
||||
" tst lr, #4 \n"
|
||||
" ite eq \n"
|
||||
" mrseq r0, msp \n"
|
||||
" mrsne r0, psp \n"
|
||||
" mov r1,lr \n"
|
||||
" mov r2,#2 \n"
|
||||
" b HardFault_HandlerC \n"
|
||||
".syntax unified" "\n\t"
|
||||
A("tst lr, #4")
|
||||
A("ite eq")
|
||||
A("mrseq r0, msp")
|
||||
A("mrsne r0, psp")
|
||||
A("mov r1,lr")
|
||||
A("mov r2,#2")
|
||||
A("b HardFault_HandlerC")
|
||||
);
|
||||
}
|
||||
|
||||
__attribute__((naked)) void BusFault_Handler(void) {
|
||||
__asm__ __volatile__ (
|
||||
".syntax unified \n"
|
||||
" tst lr, #4 \n"
|
||||
" ite eq \n"
|
||||
" mrseq r0, msp \n"
|
||||
" mrsne r0, psp \n"
|
||||
" mov r1,lr \n"
|
||||
" mov r2,#3 \n"
|
||||
" b HardFault_HandlerC \n"
|
||||
".syntax unified" "\n\t"
|
||||
A("tst lr, #4")
|
||||
A("ite eq")
|
||||
A("mrseq r0, msp")
|
||||
A("mrsne r0, psp")
|
||||
A("mov r1,lr")
|
||||
A("mov r2,#3")
|
||||
A("b HardFault_HandlerC")
|
||||
);
|
||||
}
|
||||
|
||||
__attribute__((naked)) void UsageFault_Handler(void) {
|
||||
__asm__ __volatile__ (
|
||||
".syntax unified \n"
|
||||
" tst lr, #4 \n"
|
||||
" ite eq \n"
|
||||
" mrseq r0, msp \n"
|
||||
" mrsne r0, psp \n"
|
||||
" mov r1,lr \n"
|
||||
" mov r2,#4 \n"
|
||||
" b HardFault_HandlerC \n"
|
||||
".syntax unified" "\n\t"
|
||||
A("tst lr, #4")
|
||||
A("ite eq")
|
||||
A("mrseq r0, msp")
|
||||
A("mrsne r0, psp")
|
||||
A("mov r1,lr")
|
||||
A("mov r2,#4")
|
||||
A("b HardFault_HandlerC")
|
||||
);
|
||||
}
|
||||
|
||||
__attribute__((naked)) void DebugMon_Handler(void) {
|
||||
__asm__ __volatile__ (
|
||||
".syntax unified \n"
|
||||
" tst lr, #4 \n"
|
||||
" ite eq \n"
|
||||
" mrseq r0, msp \n"
|
||||
" mrsne r0, psp \n"
|
||||
" mov r1,lr \n"
|
||||
" mov r2,#5 \n"
|
||||
" b HardFault_HandlerC \n"
|
||||
".syntax unified" "\n\t"
|
||||
A("tst lr, #4")
|
||||
A("ite eq")
|
||||
A("mrseq r0, msp")
|
||||
A("mrsne r0, psp")
|
||||
A("mov r1,lr")
|
||||
A("mov r2,#5")
|
||||
A("b HardFault_HandlerC")
|
||||
);
|
||||
}
|
||||
|
||||
/* This is NOT an exception, it is an interrupt handler - Nevertheless, the framing is the same */
|
||||
__attribute__((naked)) void WDT_Handler(void) {
|
||||
__asm__ __volatile__ (
|
||||
".syntax unified \n"
|
||||
" tst lr, #4 \n"
|
||||
" ite eq \n"
|
||||
" mrseq r0, msp \n"
|
||||
" mrsne r0, psp \n"
|
||||
" mov r1,lr \n"
|
||||
" mov r2,#6 \n"
|
||||
" b HardFault_HandlerC \n"
|
||||
".syntax unified" "\n\t"
|
||||
A("tst lr, #4")
|
||||
A("ite eq")
|
||||
A("mrseq r0, msp")
|
||||
A("mrsne r0, psp")
|
||||
A("mov r1,lr")
|
||||
A("mov r2,#6")
|
||||
A("b HardFault_HandlerC")
|
||||
);
|
||||
}
|
||||
|
||||
__attribute__((naked)) void RSTC_Handler(void) {
|
||||
__asm__ __volatile__ (
|
||||
".syntax unified \n"
|
||||
" tst lr, #4 \n"
|
||||
" ite eq \n"
|
||||
" mrseq r0, msp \n"
|
||||
" mrsne r0, psp \n"
|
||||
" mov r1,lr \n"
|
||||
" mov r2,#7 \n"
|
||||
" b HardFault_HandlerC \n"
|
||||
".syntax unified" "\n\t"
|
||||
A("tst lr, #4")
|
||||
A("ite eq")
|
||||
A("mrseq r0, msp")
|
||||
A("mrsne r0, psp")
|
||||
A("mov r1,lr")
|
||||
A("mov r2,#7")
|
||||
A("b HardFault_HandlerC")
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -77,10 +77,10 @@
|
||||
__asm__ __volatile__(
|
||||
".syntax unified" "\n\t" // is to prevent CM0,CM1 non-unified syntax
|
||||
|
||||
"loop%=:" "\n\t"
|
||||
" subs %[cnt],#1" "\n\t"
|
||||
EXTRA_NOP_CYCLES "\n\t"
|
||||
" bne loop%=" "\n\t"
|
||||
L("loop%=")
|
||||
A("subs %[cnt],#1")
|
||||
A(EXTRA_NOP_CYCLES)
|
||||
A("bne loop%=")
|
||||
: [cnt]"+r"(cy) // output: +r means input+output
|
||||
: // input:
|
||||
: "cc" // clobbers:
|
||||
@ -141,54 +141,54 @@
|
||||
".syntax unified" "\n\t" // is to prevent CM0,CM1 non-unified syntax
|
||||
|
||||
/* Bit 7 */
|
||||
" ubfx %[idx],%[txval],#7,#1" "\n\t" /* Place bit 7 in bit 0 of idx*/
|
||||
A("ubfx %[idx],%[txval],#7,#1") /* Place bit 7 in bit 0 of idx*/
|
||||
|
||||
" str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[idx],%[txval],#6,#1" "\n\t" /* Place bit 6 in bit 0 of idx*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[idx],%[txval],#6,#1") /* Place bit 6 in bit 0 of idx*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 6 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[idx],%[txval],#5,#1" "\n\t" /* Place bit 5 in bit 0 of idx*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[idx],%[txval],#5,#1") /* Place bit 5 in bit 0 of idx*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 5 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[idx],%[txval],#4,#1" "\n\t" /* Place bit 4 in bit 0 of idx*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[idx],%[txval],#4,#1") /* Place bit 4 in bit 0 of idx*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 4 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[idx],%[txval],#3,#1" "\n\t" /* Place bit 3 in bit 0 of idx*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[idx],%[txval],#3,#1") /* Place bit 3 in bit 0 of idx*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 3 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[idx],%[txval],#2,#1" "\n\t" /* Place bit 2 in bit 0 of idx*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[idx],%[txval],#2,#1") /* Place bit 2 in bit 0 of idx*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 2 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[idx],%[txval],#1,#1" "\n\t" /* Place bit 1 in bit 0 of idx*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[idx],%[txval],#1,#1") /* Place bit 1 in bit 0 of idx*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 1 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[idx],%[txval],#0,#1" "\n\t" /* Place bit 0 in bit 0 of idx*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[idx],%[txval],#0,#1") /* Place bit 0 in bit 0 of idx*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 0 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" nop" "\n\t" /* Result will be 0 */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[idx],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("nop") /* Result will be 0 */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
: [idx]"+r"( idx )
|
||||
: [txval]"r"( bout ) ,
|
||||
@ -222,52 +222,52 @@
|
||||
".syntax unified" "\n\t" // is to prevent CM0,CM1 non-unified syntax
|
||||
|
||||
/* bit 7 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#7,#1" "\n\t" /* Store read bit as the bit 7 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#7,#1") /* Store read bit as the bit 7 */
|
||||
|
||||
/* bit 6 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#6,#1" "\n\t" /* Store read bit as the bit 6 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#6,#1") /* Store read bit as the bit 6 */
|
||||
|
||||
/* bit 5 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#5,#1" "\n\t" /* Store read bit as the bit 5 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#5,#1") /* Store read bit as the bit 5 */
|
||||
|
||||
/* bit 4 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#4,#1" "\n\t" /* Store read bit as the bit 4 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#4,#1") /* Store read bit as the bit 4 */
|
||||
|
||||
/* bit 3 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#3,#1" "\n\t" /* Store read bit as the bit 3 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#3,#1") /* Store read bit as the bit 3 */
|
||||
|
||||
/* bit 2 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#2,#1" "\n\t" /* Store read bit as the bit 2 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#2,#1") /* Store read bit as the bit 2 */
|
||||
|
||||
/* bit 1 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#1,#1" "\n\t" /* Store read bit as the bit 1 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#1,#1") /* Store read bit as the bit 1 */
|
||||
|
||||
/* bit 0 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#0,#1" "\n\t" /* Store read bit as the bit 0 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#0,#1") /* Store read bit as the bit 0 */
|
||||
|
||||
: [bin]"+r"(bin),
|
||||
[work]"+r"(work)
|
||||
@ -335,60 +335,60 @@
|
||||
__asm__ __volatile__(
|
||||
".syntax unified" "\n\t" // is to prevent CM0,CM1 non-unified syntax
|
||||
|
||||
" loop%=:" "\n\t"
|
||||
" ldrb.w %[txval], [%[ptr]], #1" "\n\t" /* Load value to send, increment buffer */
|
||||
" mvn %[txval],%[txval]" "\n\t" /* Negate value */
|
||||
L("loop%=")
|
||||
A("ldrb.w %[txval], [%[ptr]], #1") /* Load value to send, increment buffer */
|
||||
A("mvn %[txval],%[txval]") /* Negate value */
|
||||
|
||||
/* Bit 7 */
|
||||
" ubfx %[work],%[txval],#7,#1" "\n\t" /* Place bit 7 in bit 0 of work*/
|
||||
A("ubfx %[work],%[txval],#7,#1") /* Place bit 7 in bit 0 of work*/
|
||||
|
||||
" str %[mosi_mask],[%[mosi_port], %[work],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[work],%[txval],#6,#1" "\n\t" /* Place bit 6 in bit 0 of work*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[work],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[work],%[txval],#6,#1") /* Place bit 6 in bit 0 of work*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 6 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[work],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[work],%[txval],#5,#1" "\n\t" /* Place bit 5 in bit 0 of work*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[work],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[work],%[txval],#5,#1") /* Place bit 5 in bit 0 of work*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 5 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[work],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[work],%[txval],#4,#1" "\n\t" /* Place bit 4 in bit 0 of work*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[work],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[work],%[txval],#4,#1") /* Place bit 4 in bit 0 of work*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 4 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[work],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[work],%[txval],#3,#1" "\n\t" /* Place bit 3 in bit 0 of work*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[work],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[work],%[txval],#3,#1") /* Place bit 3 in bit 0 of work*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 3 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[work],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[work],%[txval],#2,#1" "\n\t" /* Place bit 2 in bit 0 of work*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[work],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[work],%[txval],#2,#1") /* Place bit 2 in bit 0 of work*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 2 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[work],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[work],%[txval],#1,#1" "\n\t" /* Place bit 1 in bit 0 of work*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[work],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[work],%[txval],#1,#1") /* Place bit 1 in bit 0 of work*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 1 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[work],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ubfx %[work],%[txval],#0,#1" "\n\t" /* Place bit 0 in bit 0 of work*/
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[work],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ubfx %[work],%[txval],#0,#1") /* Place bit 0 in bit 0 of work*/
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
|
||||
/* Bit 0 */
|
||||
" str %[mosi_mask],[%[mosi_port], %[work],LSL #2]" "\n\t" /* Access the proper SODR or CODR registers based on that bit */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" subs %[todo],#1" "\n\t" /* Decrement count of pending words to send, update status */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bne.n loop%=" "\n\t" /* Repeat until done */
|
||||
A("str %[mosi_mask],[%[mosi_port], %[work],LSL #2]") /* Access the proper SODR or CODR registers based on that bit */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("subs %[todo],#1") /* Decrement count of pending words to send, update status */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bne.n loop%=") /* Repeat until done */
|
||||
|
||||
: [ptr]"+r" ( ptr ) ,
|
||||
[todo]"+r" ( todo ) ,
|
||||
@ -413,59 +413,59 @@
|
||||
__asm__ __volatile__(
|
||||
".syntax unified" "\n\t" // is to prevent CM0,CM1 non-unified syntax
|
||||
|
||||
" loop%=:" "\n\t"
|
||||
L("loop%=")
|
||||
|
||||
/* bit 7 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#7,#1" "\n\t" /* Store read bit as the bit 7 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#7,#1") /* Store read bit as the bit 7 */
|
||||
|
||||
/* bit 6 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#6,#1" "\n\t" /* Store read bit as the bit 6 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#6,#1") /* Store read bit as the bit 6 */
|
||||
|
||||
/* bit 5 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#5,#1" "\n\t" /* Store read bit as the bit 5 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#5,#1") /* Store read bit as the bit 5 */
|
||||
|
||||
/* bit 4 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#4,#1" "\n\t" /* Store read bit as the bit 4 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#4,#1") /* Store read bit as the bit 4 */
|
||||
|
||||
/* bit 3 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#3,#1" "\n\t" /* Store read bit as the bit 3 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#3,#1") /* Store read bit as the bit 3 */
|
||||
|
||||
/* bit 2 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#2,#1" "\n\t" /* Store read bit as the bit 2 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#2,#1") /* Store read bit as the bit 2 */
|
||||
|
||||
/* bit 1 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#1,#1" "\n\t" /* Store read bit as the bit 1 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#1,#1") /* Store read bit as the bit 1 */
|
||||
|
||||
/* bit 0 */
|
||||
" str %[sck_mask],[%[sck_port]]" "\n\t" /* SODR */
|
||||
" ldr %[work],[%[bitband_miso_port]]" "\n\t" /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
" str %[sck_mask],[%[sck_port],#0x4]" "\n\t" /* CODR */
|
||||
" bfi %[bin],%[work],#0,#1" "\n\t" /* Store read bit as the bit 0 */
|
||||
A("str %[sck_mask],[%[sck_port]]") /* SODR */
|
||||
A("ldr %[work],[%[bitband_miso_port]]") /* PDSR on bitband area for required bit: work will be 1 or 0 based on port */
|
||||
A("str %[sck_mask],[%[sck_port],#0x4]") /* CODR */
|
||||
A("bfi %[bin],%[work],#0,#1") /* Store read bit as the bit 0 */
|
||||
|
||||
" subs %[todo],#1" "\n\t" /* Decrement count of pending words to send, update status */
|
||||
" strb.w %[bin], [%[ptr]], #1" "\n\t" /* Store read value into buffer, increment buffer pointer */
|
||||
" bne.n loop%=" "\n\t" /* Repeat until done */
|
||||
A("subs %[todo],#1") /* Decrement count of pending words to send, update status */
|
||||
A("strb.w %[bin], [%[ptr]], #1") /* Store read value into buffer, increment buffer pointer */
|
||||
A("bne.n loop%=") /* Repeat until done */
|
||||
|
||||
: [ptr]"+r"(ptr),
|
||||
[todo]"+r"(todo),
|
||||
|
@ -71,8 +71,6 @@ void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
|
||||
else port->PIO_CODR = mask;
|
||||
}
|
||||
|
||||
#define nop() __asm__ __volatile__("nop;\n\t":::)
|
||||
|
||||
void __delay_4cycles(uint32_t cy) __attribute__ ((weak));
|
||||
|
||||
FORCE_INLINE void __delay_4cycles(uint32_t cy) { // +1 cycle
|
||||
@ -85,10 +83,10 @@ FORCE_INLINE void __delay_4cycles(uint32_t cy) { // +1 cycle
|
||||
__asm__ __volatile__(
|
||||
".syntax unified" "\n\t" // is to prevent CM0,CM1 non-unified syntax
|
||||
|
||||
"loop%=:" "\n\t"
|
||||
" subs %[cnt],#1" "\n\t"
|
||||
EXTRA_NOP_CYCLES "\n\t"
|
||||
" bne loop%=" "\n\t"
|
||||
L("loop%=")
|
||||
A("subs %[cnt],#1")
|
||||
A(EXTRA_NOP_CYCLES)
|
||||
A("bne loop%=")
|
||||
: [cnt]"+r"(cy) // output: +r means input+output
|
||||
: // input:
|
||||
: "cc" // clobbers:
|
||||
|
Reference in New Issue
Block a user