main.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <LPC8xx.h>
  2. #include <syscon.h>
  3. #include <gpio.h>
  4. #include <delay.h>
  5. /*=======================================================================*/
  6. /* Configuration */
  7. #define SYS_TICK_PERIOD_IN_MS 100
  8. /*=======================================================================*/
  9. /* system procedures and sys tick master task */
  10. volatile uint32_t sys_tick_irq_cnt=0;
  11. void __attribute__ ((interrupt)) SysTick_Handler(void)
  12. {
  13. sys_tick_irq_cnt++;
  14. }
  15. /*=======================================================================*/
  16. /*
  17. setup the hardware and start interrupts.
  18. called by "Reset_Handler"
  19. */
  20. int __attribute__ ((noinline)) main(void)
  21. {
  22. /* call to the lpc lib setup procedure. This will set the IRC as clk src and main clk to 24 MHz */
  23. SystemInit();
  24. /* if the clock or PLL has been changed, also update the global variable SystemCoreClock */
  25. SystemCoreClockUpdate();
  26. /* set systick and start systick interrupt */
  27. SysTick_Config(main_clk/1000UL*(unsigned long)SYS_TICK_PERIOD_IN_MS);
  28. /* */
  29. GPIOInit();
  30. /* enable clock for several subsystems */
  31. Enable_Periph_Clock(CLK_IOCON);
  32. Enable_Periph_Clock(CLK_SWM);
  33. GPIOSetDir( PORT0, 15, OUTPUT);
  34. for(;;)
  35. {
  36. GPIOSetBitValue(PORT0, 15, 1);
  37. delay_micro_seconds(1000000);
  38. GPIOSetBitValue(PORT0, 15, 0);
  39. delay_micro_seconds(1000000);
  40. }
  41. }