RelaisLEDs.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. //==============================================================================
  2. // Purpose: DigitalOutput-Ansteuerung
  3. //
  4. // Created on: 21.09.2012 by IPE
  5. //
  6. // History
  7. // 21.09.2012 neu, T.Maurer
  8. //==============================================================================
  9. #include "BMS_Master.h"
  10. static void switch_allRelais(uint8_t isON);
  11. static void switch_allLEDs(uint8_t isON);
  12. static void switch_allHsSwitches(uint8_t isON);
  13. void RelaisLEDs_init()
  14. {
  15. //Init ISOMETER
  16. SIU.PCR[PIN_REGNR_MHS].R = 0x0100; //Input
  17. SIU.PCR[PIN_REGNR_OKHS].R = 0x0100; //Input
  18. //Init LEDs
  19. SIU.PCR[PIN_REGNR_LED1].R = 0x0200; //Output
  20. SIU.PCR[PIN_REGNR_LED2].R = 0x0200; //Output
  21. SIU.PCR[PIN_REGNR_LED3].R = 0x0200; //Output
  22. SIU.PCR[PIN_REGNR_LED4].R = 0x0200; //Output
  23. //Init HS-Switches
  24. SIU.PCR[PIN_REGNR_HS1].R = 0x0302; // HS_IN_test1; PF[0] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  25. SIU.PCR[PIN_REGNR_HS2].R = 0x0302; // HS_IN_test2; PF[1] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  26. SIU.PCR[PIN_REGNR_HS3].R = 0x0302; // HS_IN_test3; PF[2] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  27. SIU.PCR[PIN_REGNR_HS4].R = 0x0302; // HS_IN_test4; PF[3] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  28. SIU.PCR[PIN_REGNR_HS5].R = 0x0302; // HS_IN_test5; PF[4] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  29. SIU.PCR[PIN_REGNR_HS6].R = 0x0302; // HS_IN_test6; PF[5] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  30. SIU.PCR[PIN_REGNR_HS7].R = 0x0302; // HS_IN_test7; PF[6] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  31. SIU.PCR[PIN_REGNR_HS8].R = 0x0302; // HS_IN_test8; PF[7] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  32. //Init RelaisSwitches
  33. SIU.PCR[PIN_REGNR_RELAIS_PLUS].R = 0x0302; // HS_IN_test1; PF[0] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  34. SIU.PCR[PIN_REGNR_RELAIS_PRECHA].R = 0x0302; // HS_IN_test2; PF[1] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  35. SIU.PCR[PIN_REGNR_RELAIS_SLAVE].R = 0x0302; // HS_IN_test3; PF[2] Output enable, input enable, Weak PU/PD enable, Weak PD selected
  36. //Init PWR SUpply relais
  37. SIU.PCR[PIN_REGNR_PWR_SUPPLY].R = 0x0302;
  38. switch_allLEDs(0);
  39. }
  40. uint8_t RelaisLEDs_TM_update(uint8_t tick) //TestMode
  41. {
  42. static uint8_t state = 0;
  43. static uint16_t msek = 0;
  44. if (tick)
  45. {
  46. msek+=1;
  47. if (state == 0) {
  48. switch_allRelais(1);
  49. switch_allLEDs(1);
  50. switch_allHsSwitches(1);
  51. if (msek > 3000) {
  52. state = 1;
  53. }
  54. }
  55. else {
  56. // switch_allRelais(0);
  57. switch_allLEDs(0);
  58. switch_allHsSwitches(0);
  59. return 1;
  60. }
  61. }
  62. return 0;
  63. }
  64. //--------------------------------------------------------------
  65. static void switch_allRelais(uint8_t isON)
  66. {
  67. if ( isON == 0 ) {
  68. CLEAR_OUTPIN(PIN_REGNR_RELAIS_PLUS);
  69. CLEAR_OUTPIN(PIN_REGNR_RELAIS_PRECHA);
  70. CLEAR_OUTPIN(PIN_REGNR_RELAIS_SLAVE);
  71. }
  72. else {
  73. SET_OUTPIN(PIN_REGNR_RELAIS_PLUS);
  74. SET_OUTPIN(PIN_REGNR_RELAIS_PRECHA);
  75. SET_OUTPIN(PIN_REGNR_RELAIS_SLAVE);
  76. }
  77. }
  78. static void switch_allLEDs(uint8_t isON)
  79. {
  80. if ( isON == 0 ) {
  81. CLEAR_OUTPIN(PIN_REGNR_LED1);
  82. CLEAR_OUTPIN(PIN_REGNR_LED2);
  83. CLEAR_OUTPIN(PIN_REGNR_LED3);
  84. CLEAR_OUTPIN(PIN_REGNR_LED4);
  85. }
  86. else {
  87. SET_OUTPIN(PIN_REGNR_LED1);
  88. SET_OUTPIN(PIN_REGNR_LED2);
  89. SET_OUTPIN(PIN_REGNR_LED3);
  90. SET_OUTPIN(PIN_REGNR_LED4);
  91. }
  92. }
  93. static void switch_allHsSwitches(uint8_t isON)
  94. {
  95. if ( isON == 0 ) {
  96. CLEAR_OUTPIN(PIN_REGNR_HS1);
  97. CLEAR_OUTPIN(PIN_REGNR_HS2);
  98. CLEAR_OUTPIN(PIN_REGNR_HS3);
  99. CLEAR_OUTPIN(PIN_REGNR_HS4);
  100. CLEAR_OUTPIN(PIN_REGNR_HS5);
  101. CLEAR_OUTPIN(PIN_REGNR_HS6);
  102. CLEAR_OUTPIN(PIN_REGNR_HS7);
  103. CLEAR_OUTPIN(PIN_REGNR_HS8);
  104. }
  105. else {
  106. SET_OUTPIN(PIN_REGNR_HS1);
  107. SET_OUTPIN(PIN_REGNR_HS2);
  108. SET_OUTPIN(PIN_REGNR_HS3);
  109. SET_OUTPIN(PIN_REGNR_HS4);
  110. SET_OUTPIN(PIN_REGNR_HS5);
  111. SET_OUTPIN(PIN_REGNR_HS6);
  112. SET_OUTPIN(PIN_REGNR_HS7);
  113. SET_OUTPIN(PIN_REGNR_HS8);
  114. }
  115. }