setup-loop.cpp 522 B

1234567891011121314151617181920212223242526
  1. #include "all-headers.h"
  2. // Led L2 is connected to PORTD:7 (active high)
  3. void setup (USER_MODE) {
  4. // Configure PTD7 as digital port (input or output)
  5. PORTD_PCR (7) = PORT_PCR_MUX (1) ;
  6. // Configure PTD7 as digital output port (output level is low --> led is off)
  7. GPIOD_PDDR |= (1 << 7) ;
  8. }
  9. void loop (USER_MODE) {
  10. // Drive PTD7 high --> led is on
  11. GPIOD_PSOR = 1 << 7 ;
  12. // Wait...
  13. busyWaitDuring(MODE_ 500);
  14. // Drive PTD7 low --> led is off
  15. GPIOD_PCOR = 1 << 7 ;
  16. // Wait...
  17. busyWaitDuring(MODE_ 500);
  18. }