setup-loop.cpp 533 B

1234567891011121314151617181920212223242526272829
  1. #include "all-headers.h"
  2. // Led L2 is connected to PORTD:7 (active high)
  3. void setup (void) {
  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. // Init clock
  9. startSystick();
  10. }
  11. void loop (void) {
  12. // Drive PTD7 high --> led is on
  13. GPIOD_PSOR = 1 << 7 ;
  14. // Wait...
  15. busyWaitDuring(500);
  16. // Drive PTD7 low --> led is off
  17. GPIOD_PCOR = 1 << 7 ;
  18. // Wait...
  19. busyWaitDuring(500);
  20. }