main.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include <chip.h>
  2. #include <delay.h>
  3. /*=======================================================================*/
  4. /* Configuration */
  5. #define SYS_TICK_PERIOD_IN_MS 100
  6. /*=======================================================================*/
  7. /* system procedures and sys tick master task */
  8. volatile uint32_t sys_tick_irq_cnt=0;
  9. void __attribute__ ((interrupt)) SysTick_Handler(void)
  10. {
  11. sys_tick_irq_cnt++;
  12. }
  13. /*=======================================================================*/
  14. /*
  15. setup the hardware and start interrupts.
  16. called by "Reset_Handler"
  17. */
  18. int __attribute__ ((noinline)) main(void)
  19. {
  20. /* call to the lpc lib setup procedure. This will set the IRC as clk src and main clk to 24 MHz */
  21. Chip_SystemInit();
  22. /* if the clock or PLL has been changed, also update the global variable SystemCoreClock */
  23. SystemCoreClockUpdate();
  24. /* set systick and start systick interrupt */
  25. SysTick_Config(SystemCoreClock/1000UL*(unsigned long)SYS_TICK_PERIOD_IN_MS);
  26. /* enable clock for several subsystems */
  27. Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON | SYSCTL_CLOCK_GPIO | SYSCTL_CLOCK_SWM);
  28. /* turn on GPIO */
  29. Chip_GPIO_Init(LPC_GPIO_PORT); /* Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_GPIO); */
  30. //Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 15, IOCON_FUNC1); /* RxD */
  31. Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, 15);
  32. for(;;)
  33. {
  34. Chip_GPIO_SetPinOutHigh(LPC_GPIO_PORT, 0, 15);
  35. delay_micro_seconds(1000000);
  36. Chip_GPIO_SetPinOutLow(LPC_GPIO_PORT, 0, 15);
  37. delay_micro_seconds(1000000);
  38. }
  39. }