Browse Source

Tweak some HAL Due code

Scott Lahteine 6 years ago
parent
commit
48a581ba2e
1 changed files with 5 additions and 17 deletions
  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 View File

64
 #include "../shared/Delay.h"
64
 #include "../shared/Delay.h"
65
 
65
 
66
 void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index) {
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
 void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
71
 void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
72
   volatile Pio* port = g_APinDescription[u8g->pin_list[pin_index]].pPort;
72
   volatile Pio* port = g_APinDescription[u8g->pin_list[pin_index]].pPort;
73
   uint32_t mask = g_APinDescription[u8g->pin_list[pin_index]].ulPin;
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
 Pio *SCK_pPio, *MOSI_pPio;
77
 Pio *SCK_pPio, *MOSI_pPio;
95
 static uint8_t rs_last_state = 255;
94
 static uint8_t rs_last_state = 255;
96
 
95
 
97
 static void u8g_com_DUE_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) {
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
     rs_last_state = rs;
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
     DELAY_US(40); // give the controller some time to process the data: 20 is bad, 30 is OK, 40 is safe
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
   spiSend_sw_DUE(val & 0x0F0);
102
   spiSend_sw_DUE(val & 0x0F0);
114
   spiSend_sw_DUE(val << 4);
103
   spiSend_sw_DUE(val << 4);
115
 }
104
 }
116
 
105
 
117
-
118
 uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
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
   switch (msg) {
107
   switch (msg) {
120
     case U8G_COM_MSG_INIT:
108
     case U8G_COM_MSG_INIT:

Loading…
Cancel
Save