| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- /*********************************************************************************************************
- * Module : R_Led.c
- * Abstract : R_Led module displays the relay status!
- * Version : 1.0.0
- * Author : Leopul(COPYRIGHT 2025 - 2027 Leopul. All rights reserved.)
- * Complete : 2025-02-16
- * Content : None
- * Note : None
- *********************************************************************************************************/
- #include "R_Led.h"
- #include "gd32f30x_libopt.h"
- #include "Sn74lvc573.h"
- #include "main.h"
- #define POWER_R2_Y GPIO_PIN_12
- #define POWER_R2_G GPIO_PIN_11
- #define POWER_R2_R GPIO_PIN_10
- #define POWER_R1_Y GPIO_PIN_9
- #define POWER_R1_G GPIO_PIN_8
- #define POWER_R1_R GPIO_PIN_7
- #define POWER_OUT_R GPIO_PIN_2
- #define POWER_OUT_G GPIO_PIN_3
- #define POWER_OUT_Y GPIO_PIN_4
- uint16_t led_status = 0;
- void r_led_init(void)
- {
- rcu_periph_clock_enable(RCU_GPIOC);
- gpio_init(GPIOC,GPIO_MODE_OUT_PP,GPIO_OSPEED_50MHZ,POWER_R2_Y |POWER_R2_G| POWER_R2_R | POWER_R1_Y | POWER_R1_G | POWER_R1_R | POWER_OUT_R | POWER_OUT_G | POWER_OUT_Y);
- gpio_bit_reset(GPIOC, POWER_R2_Y |POWER_R2_G| POWER_R2_R | POWER_R1_Y | POWER_R1_G | POWER_R1_R | POWER_OUT_R | POWER_OUT_G | POWER_OUT_Y);
-
- }
- void in_r_led_on_off(unsigned char channel)
- {
- // if(channel == 0)
- // {
- // gpio_bit_set(GPIOB, GPIO_PIN_2);
- // gpio_bit_reset(GPIOB, GPIO_PIN_10);
- // }else
- // {
- // gpio_bit_reset(GPIOB, GPIO_PIN_2);
- // gpio_bit_set(GPIOB, GPIO_PIN_10);
- // }
- }
- void out_r_led(unsigned char status)
- {
- // if(status == 0)
- // {
- // gpio_bit_set(GPIOB, GPIO_PIN_11);
- // }else
- // {
- // gpio_bit_reset(GPIOB, GPIO_PIN_11);
- // }
- }
- void show_wanning_led(void)
- {
- sts_data_t *data = get_sts();
- if(data)
- {
- uint16_t value = 0;
- if(data->m_data.input_status.input_status[0] && data->m_data.input_status.input_status[1])
- {
- if(data->m_data.input_wanning.waning[0] == 0 && data->m_data.input_wanning.waning[1] == 0)
- {
- if(data->m_data.md_choise.choise_ch == INPUT_CHANNEL_1)
- {
- value |= POWER_R1_G;
- }else
- {
- value |= POWER_R2_G;
- }
- }else
- {
- if(data->m_data.input_wanning.waning[0] != 0)
- {
- value |= POWER_R1_Y;
- //value |= POWER_R2_G;
- }else
- {
- value |= POWER_R1_G;
- }
- if(data->m_data.input_wanning.waning[1] != 0)
- {
- value |= POWER_R2_Y;
- //value |= POWER_R1_G;
- }else
- {
- value |= POWER_R2_G;
- }
- }
- }else
- {
- if(data->m_data.input_status.input_status[0] == 0)
- {
- value |=POWER_R1_R;
- if(data->m_data.input_status.input_status[1] == 1)
- {
- if(data->m_data.input_wanning.waning[1] != 0)
- {
- value |= POWER_R2_Y;
- }else
- value |=POWER_R2_G;
-
- }
- if(data->m_data.input_wanning.waning[0] != 0)
- {
- value |= POWER_R1_Y;
- }
- }
- if(data->m_data.input_status.input_status[1] == 0)
- {
- value |=POWER_R2_R;
- if(data->m_data.input_status.input_status[0] == 1)
- {
- if(data->m_data.input_wanning.waning[0] != 0)
- {
- value |= POWER_R1_Y;
- }else
- value |=POWER_R1_G;
- }
- if(data->m_data.input_wanning.waning[1] != 0)
- {
- value |= POWER_R2_Y;
- }
- }
- }
- if(data->m_data.out_status == 1)
- {
- if(data->m_data.output_waning.waning != 0)
- value |= POWER_OUT_Y;
- else
- value |= POWER_OUT_G;
- }else
- {
- if(data->m_data.output_waning.waning != 0)
- value |= POWER_OUT_Y;
- value |= POWER_OUT_R;
- }
-
- if(value != led_status)
- {
- led_status = value;
- gpio_bit_reset(GPIOC, POWER_R2_Y |POWER_R2_G| POWER_R2_R | POWER_R1_Y | POWER_R1_G | POWER_R1_R | POWER_OUT_R | POWER_OUT_G | POWER_OUT_Y);
- gpio_bit_set(GPIOC,led_status);
- unlock();
- lock();
- }
- }
- }
|