Browse Source

Merge pull request #19 from filcab/master

Use the proper way to refer to gcc's asm extension so we can compile this in C standard mode.
main
Paul Stoffregen 10 years ago
parent
commit
91a3138350
4 changed files with 10 additions and 10 deletions
  1. +1
    -1
      teensy3/core_pins.h
  2. +6
    -6
      teensy3/mk20dx128.c
  3. +2
    -2
      teensy3/mk20dx128.h
  4. +1
    -1
      teensy3/usb_dev.c

+ 1
- 1
teensy3/core_pins.h View File

uint32_t n = usec >> 1; uint32_t n = usec >> 1;
#endif #endif
if (usec == 0) return; if (usec == 0) return;
asm volatile(
__asm__ volatile(
"L_%=_delayMicroseconds:" "\n\t" "L_%=_delayMicroseconds:" "\n\t"
#if F_CPU < 10000000 #if F_CPU < 10000000
"nop" "\n\t" "nop" "\n\t"

+ 6
- 6
teensy3/mk20dx128.c View File



WDOG_UNLOCK = WDOG_UNLOCK_SEQ1; WDOG_UNLOCK = WDOG_UNLOCK_SEQ1;
WDOG_UNLOCK = WDOG_UNLOCK_SEQ2; WDOG_UNLOCK = WDOG_UNLOCK_SEQ2;
asm volatile ("nop");
asm volatile ("nop");
__asm__ volatile ("nop");
__asm__ volatile ("nop");
// programs using the watchdog timer or needing to initialize hardware as // programs using the watchdog timer or needing to initialize hardware as
// early as possible can implement startup_early_hook() // early as possible can implement startup_early_hook()
startup_early_hook(); startup_early_hook();


// full algorithm in ARM DDI0403D, page B1-639 // full algorithm in ARM DDI0403D, page B1-639
// this isn't quite complete, but hopefully good enough // this isn't quite complete, but hopefully good enough
asm volatile("mrs %0, faultmask\n" : "=r" (faultmask)::);
__asm__ volatile("mrs %0, faultmask\n" : "=r" (faultmask)::);
if (faultmask) return -1; if (faultmask) return -1;
asm volatile("mrs %0, primask\n" : "=r" (primask)::);
__asm__ volatile("mrs %0, primask\n" : "=r" (primask)::);
if (primask) return 0; if (primask) return 0;
asm volatile("mrs %0, ipsr\n" : "=r" (ipsr)::);
__asm__ volatile("mrs %0, ipsr\n" : "=r" (ipsr)::);
if (ipsr) { if (ipsr) {
if (ipsr < 16) priority = 0; // could be non-zero if (ipsr < 16) priority = 0; // could be non-zero
else priority = NVIC_GET_PRIORITY(ipsr - 16); else priority = NVIC_GET_PRIORITY(ipsr - 16);
} }
asm volatile("mrs %0, basepri\n" : "=r" (basepri)::);
__asm__ volatile("mrs %0, basepri\n" : "=r" (basepri)::);
if (basepri > 0 && basepri < priority) priority = basepri; if (basepri > 0 && basepri < priority) priority = basepri;
return priority; return priority;
} }

+ 2
- 2
teensy3/mk20dx128.h View File







#define __disable_irq() asm volatile("CPSID i");
#define __enable_irq() asm volatile("CPSIE i");
#define __disable_irq() __asm__ volatile("CPSID i");
#define __enable_irq() __asm__ volatile("CPSIE i");


// System Control Space (SCS), ARMv7 ref manual, B3.2, page 708 // System Control Space (SCS), ARMv7 ref manual, B3.2, page 708
#define SCB_CPUID *(const uint32_t *)0xE000ED00 // CPUID Base Register #define SCB_CPUID *(const uint32_t *)0xE000ED00 // CPUID Base Register

+ 1
- 1
teensy3/usb_dev.c View File

void _reboot_Teensyduino_(void) void _reboot_Teensyduino_(void)
{ {
// TODO: initialize R0 with a code.... // TODO: initialize R0 with a code....
asm volatile("bkpt");
__asm__ volatile("bkpt");
} }





Loading…
Cancel
Save