소스 검색

Tweak some HAL Due code

Scott Lahteine 5 년 전
부모
커밋
48a581ba2e
1개의 변경된 파일5개의 추가작업 그리고 17개의 파일을 삭제
  1. 5
    17
      Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_st7920_sw_spi.cpp

+ 5
- 17
Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_st7920_sw_spi.cpp 파일 보기

@@ -64,15 +64,14 @@
64 64
 #include "../shared/Delay.h"
65 65
 
66 66
 void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index) {
67
-   PIO_Configure(g_APinDescription[u8g->pin_list[pin_index]].pPort, PIO_OUTPUT_1,
68
-     g_APinDescription[u8g->pin_list[pin_index]].ulPin, g_APinDescription[u8g->pin_list[pin_index]].ulPinConfiguration);  // OUTPUT
67
+  PIO_Configure(g_APinDescription[u8g->pin_list[pin_index]].pPort, PIO_OUTPUT_1,
68
+    g_APinDescription[u8g->pin_list[pin_index]].ulPin, g_APinDescription[u8g->pin_list[pin_index]].ulPinConfiguration);  // OUTPUT
69 69
 }
70 70
 
71 71
 void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
72 72
   volatile Pio* port = g_APinDescription[u8g->pin_list[pin_index]].pPort;
73 73
   uint32_t mask = g_APinDescription[u8g->pin_list[pin_index]].ulPin;
74
-  if (level) port->PIO_SODR = mask;
75
-  else port->PIO_CODR = mask;
74
+  if (level) port->PIO_SODR = mask; else port->PIO_CODR = mask;
76 75
 }
77 76
 
78 77
 Pio *SCK_pPio, *MOSI_pPio;
@@ -95,26 +94,15 @@ static void spiSend_sw_DUE(uint8_t val) { // 800KHz
95 94
 static uint8_t rs_last_state = 255;
96 95
 
97 96
 static void u8g_com_DUE_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) {
98
-  uint8_t i;
99
-
100
-  if ( rs != rs_last_state) {  // time to send a command/data byte
97
+  if (rs != rs_last_state) {  // time to send a command/data byte
101 98
     rs_last_state = rs;
102
-
103
-    if ( rs == 0 )
104
-      /* command */
105
-      spiSend_sw_DUE(0x0F8);
106
-    else
107
-       /* data */
108
-      spiSend_sw_DUE(0x0FA);
109
-
99
+    spiSend_sw_DUE(rs ? 0x0FA : 0x0F8); // Command or Data
110 100
     DELAY_US(40); // give the controller some time to process the data: 20 is bad, 30 is OK, 40 is safe
111 101
   }
112
-
113 102
   spiSend_sw_DUE(val & 0x0F0);
114 103
   spiSend_sw_DUE(val << 4);
115 104
 }
116 105
 
117
-
118 106
 uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
119 107
   switch (msg) {
120 108
     case U8G_COM_MSG_INIT:

Loading…
취소
저장