STR71xF_Example.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*********************************************************************
  2. * SEGGER MICROCONTROLLER SYSTEME GmbH *
  3. * Solutions for real time microcontroller applications *
  4. **********************************************************************
  5. * *
  6. * (c) 1996-2005 SEGGER Microcontroller Systeme GmbH *
  7. * *
  8. * Internet: www.segger.com Support: support@segger.com *
  9. * *
  10. **********************************************************************
  11. ----------------------------------------------------------------------
  12. File : STR71xF_Example.c
  13. Purpose : Test / demonstration of J-Link with STR71xF
  14. ---------------------------END-OF-HEADER------------------------------
  15. */
  16. #include <iostr710.h>
  17. #include <inarm.h>
  18. #define LED_12 (1UL << 11)
  19. #define LED_13 (1UL << 12)
  20. #define LED_14 (1UL << 13)
  21. #define LED_15 (1UL << 14)
  22. #define LED_MASK_P2 (LED_12 | LED_13 | LED_14 | LED_15)
  23. #define TIMING (0x1000)
  24. /*********************************************************************
  25. *
  26. * T1_INT_Handler
  27. */
  28. __arm __irq void T1_INT_Handler( void ) {
  29. if (TIM1_SR_bit.OCFA && TIM1_CR2_bit.OCAIE) {
  30. TIM1_OCAR += TIMING; /* set next compare time */
  31. TIM1_SR_bit.OCFA = 0; /* clear flag */
  32. IOPORT2_PD ^= (LED_MASK_P2); /* toggle led display */
  33. }
  34. EIC_IPR0 |= (1UL << T1_INT);
  35. }
  36. /*********************************************************************
  37. *
  38. * main
  39. */
  40. int main(void) {
  41. /* general preparations */
  42. EIC_ICR = 0 ;
  43. EIC_FIR = 0 ;
  44. EIC_IER0 = 0 ; /* reset all irqs */
  45. EIC_IPR0 = 0xFFFFFFFF ;
  46. /* start timer */
  47. TIM1_CR1 = 0; /* reset */
  48. TIM1_CR2 = 0x3F; /* prescaler */
  49. TIM1_CR1_bit.EN = 1;
  50. EIC_SIR19_bit.SIV = (unsigned long)T1_INT_Handler;
  51. EIC_SIR19_bit.SIPL = 1; /* proi 1 */
  52. EIC_IER0 |= (1UL << T1_INT);
  53. /* prepare output */
  54. IOPORT2_PC0 |= (LED_MASK_P2); /* push pull output */
  55. IOPORT2_PC1 &= ~(LED_MASK_P2);
  56. IOPORT2_PC2 |= (LED_MASK_P2);
  57. IOPORT2_PD &= ~(LED_MASK_P2); /* clear all */
  58. IOPORT2_PD |= (LED_13 | LED_14); /* initial pattern */
  59. /* enable global interrupts */
  60. EIC_ICR_bit.IRQ_EN = 1; /* enable irq line */
  61. __enable_interrupt();
  62. /* set the timeout compare interrupt */
  63. TIM1_OCAR = TIM1_CNTR + TIMING;
  64. TIM1_SR_bit.OCFA = 0; /* clear flag */
  65. TIM1_CR2_bit.OCAIE = 1; /* enable interrupt */
  66. while( 1 ) {
  67. }
  68. }
  69. /*************************** end of file ****************************/