setup-loop.cpp 571 B

12345678910111213141516171819202122
  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. }
  9. void loop (void) {
  10. // Drive PTD7 high --> led is on
  11. GPIOD_PSOR = 1 << 7 ;
  12. // Wait...
  13. for (volatile uint32_t i=0 ; i< 10 * 2000 * 1000 ; i++) {}
  14. // Drive PTD7 low --> led is off
  15. GPIOD_PCOR = 1 << 7 ;
  16. // Wait...
  17. for (volatile uint32_t i=0 ; i< 10 * 500 * 1000 ; i++) {}
  18. }