1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
| void SYS_UART0_Init(void) { NVIC_ClearPendingIRQ(UART_0_INST_INT_IRQN); NVIC_EnableIRQ(UART_0_INST_INT_IRQN); DL_UART_clearInterruptStatus(UART_0_INST,DL_UART_INTERRUPT_RX); }
void SOC_UART1_Init(void) { NVIC_ClearPendingIRQ(UART_SOC_INST_INT_IRQN); NVIC_EnableIRQ(UART_SOC_INST_INT_IRQN); DL_UART_clearInterruptStatus(UART_SOC_INST,DL_UART_INTERRUPT_RX); }
void SOC_SendString(char *str) { while(*str != '\0') { DL_UART_Main_transmitDataBlocking(UART_SOC_INST, *str++); } }
void Screen_UART2_Init(void) { NVIC_ClearPendingIRQ(UART_Screen_INST_INT_IRQN); NVIC_EnableIRQ(UART_Screen_INST_INT_IRQN); DL_UART_clearInterruptStatus(UART_Screen_INST,DL_UART_INTERRUPT_RX); }
void Screen_SendString(char *str) { while(*str != '\0') { DL_UART_Main_transmitDataBlocking(UART_Screen_INST, *str++); } }
void int_to_binary_string(uint32_t value, char *binary_str, int max_bits) { for (int i = max_bits - 1; i >= 0; --i) { binary_str[i] = (value & (1U << i)) ? '1' : '0'; } binary_str[max_bits] = '\0'; }
void float_to_string(float value, char *str, size_t size) { snprintf(str, size, "%.2f", value); }
void HMI_send_string(char *name, char *showdata) { char buffer[BUFFER_SIZE]; int length;
length = snprintf(buffer, sizeof(buffer), "%s=\"%s\"\xff\xff\xff", name, showdata);
if (length >= sizeof(buffer)) { buffer[sizeof(buffer) - 1] = '\0'; }
Screen_SendString(buffer); }
void HMI_send_number(char* name, int num) { char buffer[BUFFER_SIZE]; int length = snprintf(buffer, sizeof(buffer), "%s=%d\xff\xff\xff", name, num); if (length >= BUFFER_SIZE) { } Screen_SendString(buffer); }
void HMI_send_float(char* name, float num) { char buffer[BUFFER_SIZE]; int num_int = (int)(num * 100); int length = snprintf(buffer, sizeof(buffer), "%s=%d\xff\xff\xff", name, num_int); if (length >= BUFFER_SIZE) { } Screen_SendString(buffer); }
void HMI_Wave(char* name, int ch, int val) { char buffer[BUFFER_SIZE]; int length = snprintf(buffer, sizeof(buffer), "add %s,%d,%d\xff\xff\xff", name, ch, val); if (length >= BUFFER_SIZE) { } Screen_SendString(buffer); }
void HMI_Wave_Fast(char* name, int ch, int count, int* show_data) { char buffer[BUFFER_SIZE]; int length = snprintf(buffer, sizeof(buffer), "addt %s,%d,%d\xff\xff\xff", name, ch, count); if (length >= BUFFER_SIZE) { } Screen_SendString(buffer);
delay_ms(100);
for (int i = 0; i < count; i++) { DL_UART_Main_transmitDataBlocking(UART_Screen_INST, (char)show_data[i]); } Screen_SendString("\xff\xff\xff"); }
void HMI_Wave_Clear(char* name, int ch) { char buffer[BUFFER_SIZE]; int length = snprintf(buffer, sizeof(buffer), "cle %s,%d\xff\xff\xff", name, ch); if (length >= BUFFER_SIZE) { } Screen_SendString(buffer); }
|