Selaa lähdekoodia

SAMD51 LCD support (#15113)

Giuliano Zaro 5 vuotta sitten
vanhempi
commit
12c595c61f

+ 8
- 0
Marlin/src/HAL/HAL_SAMD51/HAL.h Näytä tiedosto

@@ -146,3 +146,11 @@ FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
146 146
 #pragma GCC diagnostic ignored "-Wunused-function"
147 147
 int freeMemory(void);
148 148
 #pragma GCC diagnostic pop
149
+
150
+#ifdef __cplusplus
151
+  extern "C" {
152
+#endif
153
+char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
154
+#ifdef __cplusplus
155
+  }
156
+#endif

+ 40
- 35
Marlin/src/lcd/dogm/HAL_LCD_com_defines.h Näytä tiedosto

@@ -35,78 +35,83 @@
35 35
 
36 36
   #ifdef __SAM3X8E__
37 37
     uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
38
-    #define U8G_COM_HAL_SW_SPI_FN  u8g_com_HAL_DUE_sw_spi_fn
38
+    #define U8G_COM_HAL_SW_SPI_FN       u8g_com_HAL_DUE_sw_spi_fn
39 39
     uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
40
-    #define U8G_COM_HAL_HW_SPI_FN u8g_com_HAL_DUE_shared_hw_spi_fn
40
+    #define U8G_COM_HAL_HW_SPI_FN       u8g_com_HAL_DUE_shared_hw_spi_fn
41 41
     uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
42
-    #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_HAL_DUE_ST7920_sw_spi_fn
43
-    #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_arduino_st7920_hw_spi_fn
42
+    #define U8G_COM_ST7920_HAL_SW_SPI   u8g_com_HAL_DUE_ST7920_sw_spi_fn
43
+    #define U8G_COM_ST7920_HAL_HW_SPI   u8g_com_arduino_st7920_hw_spi_fn
44 44
   #elif defined(__STM32F1__)
45 45
     uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
46
-    #define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_STM32F1_sw_spi_fn
46
+    #define U8G_COM_HAL_SW_SPI_FN       u8g_com_HAL_STM32F1_sw_spi_fn
47 47
     uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
48
-    #define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn
49
-    #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_std_sw_spi_fn
50
-    #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_stm32duino_hw_spi_fn
48
+    #define U8G_COM_HAL_HW_SPI_FN       u8g_com_stm32duino_hw_spi_fn
49
+    #define U8G_COM_ST7920_HAL_SW_SPI   u8g_com_std_sw_spi_fn
50
+    #define U8G_COM_ST7920_HAL_HW_SPI   u8g_com_stm32duino_hw_spi_fn
51 51
   #elif defined(ARDUINO_ARCH_STM32)
52
-    #define U8G_COM_HAL_SW_SPI_FN u8g_com_arduino_std_sw_spi_fn
52
+    #define U8G_COM_HAL_SW_SPI_FN       u8g_com_arduino_std_sw_spi_fn
53 53
     uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
54
-    #define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn
55
-    #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_arduino_st7920_spi_fn
56
-    #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_arduino_st7920_hw_spi_fn
54
+    #define U8G_COM_HAL_HW_SPI_FN       u8g_com_stm32duino_hw_spi_fn
55
+    #define U8G_COM_ST7920_HAL_SW_SPI   u8g_com_arduino_st7920_spi_fn
56
+    #define U8G_COM_ST7920_HAL_HW_SPI   u8g_com_arduino_st7920_hw_spi_fn
57 57
   #elif defined(__AVR__)
58 58
     uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
59
-    #define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_AVR_sw_sp_fn
60
-    #define U8G_COM_HAL_HW_SPI_FN u8g_com_arduino_hw_spi_fn
61
-    #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_arduino_st7920_spi_fn
62
-    #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_arduino_st7920_hw_spi_fn
59
+    #define U8G_COM_HAL_SW_SPI_FN       u8g_com_HAL_AVR_sw_sp_fn
60
+    #define U8G_COM_HAL_HW_SPI_FN       u8g_com_arduino_hw_spi_fn
61
+    #define U8G_COM_ST7920_HAL_SW_SPI   u8g_com_arduino_st7920_spi_fn
62
+    #define U8G_COM_ST7920_HAL_HW_SPI   u8g_com_arduino_st7920_hw_spi_fn
63
+  #elif defined(__SAMD51__)
64
+    #define U8G_COM_HAL_SW_SPI_FN       u8g_com_arduino_std_sw_spi_fn
65
+    #define U8G_COM_HAL_HW_SPI_FN       u8g_com_samd51_hw_spi_fn
66
+    #define U8G_COM_ST7920_HAL_SW_SPI   u8g_com_arduino_st7920_spi_fn
67
+    #define U8G_COM_ST7920_HAL_HW_SPI   u8g_com_samd51_st7920_hw_spi_fn
63 68
   #else
64
-    #define U8G_COM_HAL_SW_SPI_FN u8g_com_arduino_std_sw_spi_fn
65
-    #define U8G_COM_HAL_HW_SPI_FN u8g_com_arduino_hw_spi_fn
66
-    #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_arduino_st7920_spi_fn
67
-    #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_arduino_st7920_hw_spi_fn
69
+    #define U8G_COM_HAL_SW_SPI_FN       u8g_com_arduino_std_sw_spi_fn
70
+    #define U8G_COM_HAL_HW_SPI_FN       u8g_com_arduino_hw_spi_fn
71
+    #define U8G_COM_ST7920_HAL_SW_SPI   u8g_com_arduino_st7920_spi_fn
72
+    #define U8G_COM_ST7920_HAL_HW_SPI   u8g_com_arduino_st7920_hw_spi_fn
68 73
   #endif
69 74
 
70 75
   #ifdef TARGET_LPC1768
71 76
     uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
72 77
   #endif
73 78
 
74
-  #define U8G_COM_SSD_I2C_HAL u8g_com_arduino_ssd_i2c_fn
79
+  #define U8G_COM_SSD_I2C_HAL     u8g_com_arduino_ssd_i2c_fn
75 80
 
76 81
   #if PIN_EXISTS(FSMC_CS)
77 82
     uint8_t u8g_com_stm32duino_fsmc_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
78
-    #define U8G_COM_HAL_FSMC_FN u8g_com_stm32duino_fsmc_fn
83
+    #define U8G_COM_HAL_FSMC_FN   u8g_com_stm32duino_fsmc_fn
79 84
   #else
80
-    #define U8G_COM_HAL_FSMC_FN u8g_com_null_fn
85
+    #define U8G_COM_HAL_FSMC_FN   u8g_com_null_fn
81 86
   #endif
82 87
 
83 88
 #elif defined(TARGET_LPC1768)
84 89
 
85 90
   uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
86
-  #define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_LPC1768_sw_spi_fn
91
+  #define U8G_COM_HAL_SW_SPI_FN       u8g_com_HAL_LPC1768_sw_spi_fn
87 92
 
88 93
   uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
89
-  #define U8G_COM_HAL_HW_SPI_FN u8g_com_HAL_LPC1768_hw_spi_fn
94
+  #define U8G_COM_HAL_HW_SPI_FN       u8g_com_HAL_LPC1768_hw_spi_fn
90 95
 
91 96
   uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
92
-  #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_HAL_LPC1768_ST7920_sw_spi_fn
97
+  #define U8G_COM_ST7920_HAL_SW_SPI   u8g_com_HAL_LPC1768_ST7920_sw_spi_fn
93 98
 
94 99
   uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
95
-  #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_HAL_LPC1768_ST7920_hw_spi_fn
100
+  #define U8G_COM_ST7920_HAL_HW_SPI   u8g_com_HAL_LPC1768_ST7920_hw_spi_fn
96 101
 
97 102
   uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
98
-  #define U8G_COM_SSD_I2C_HAL u8g_com_HAL_LPC1768_ssd_hw_i2c_fn
103
+  #define U8G_COM_SSD_I2C_HAL         u8g_com_HAL_LPC1768_ssd_hw_i2c_fn
99 104
 
100
-  #define U8G_COM_HAL_FSMC_FN u8g_com_null_fn
105
+  #define U8G_COM_HAL_FSMC_FN         u8g_com_null_fn
101 106
 
102 107
 #else  // need to give them some definition or else get compiler errors
103 108
 
104 109
   uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
105
-  #define U8G_COM_HAL_SW_SPI_FN u8g_com_null_fn
106
-  #define U8G_COM_HAL_HW_SPI_FN u8g_com_null_fn
107
-  #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_null_fn
108
-  #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_null_fn
109
-  #define U8G_COM_SSD_I2C_HAL u8g_com_null_fn
110
-  #define U8G_COM_HAL_FSMC_FN u8g_com_null_fn
110
+  #define U8G_COM_HAL_SW_SPI_FN       u8g_com_null_fn
111
+  #define U8G_COM_HAL_HW_SPI_FN       u8g_com_null_fn
112
+  #define U8G_COM_ST7920_HAL_SW_SPI   u8g_com_null_fn
113
+  #define U8G_COM_ST7920_HAL_HW_SPI   u8g_com_null_fn
114
+  #define U8G_COM_SSD_I2C_HAL         u8g_com_null_fn
115
+  #define U8G_COM_HAL_FSMC_FN         u8g_com_null_fn
111 116
 
112 117
 #endif

+ 1
- 1
Marlin/src/lcd/dogm/u8g_dev_st7920_128x64_HAL.cpp Näytä tiedosto

@@ -202,7 +202,7 @@ u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_sw_spi = { u8g_dev_st7920_128x64_HAL_4x_f
202 202
 U8G_PB_DEV(u8g_dev_st7920_128x64_HAL_hw_spi, LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_HAL_fn, U8G_COM_ST7920_HAL_HW_SPI);
203 203
 u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi = { u8g_dev_st7920_128x64_HAL_4x_fn, &u8g_dev_st7920_128x64_HAL_4x_pb, U8G_COM_ST7920_HAL_HW_SPI };
204 204
 
205
-#if defined(U8G_HAL_LINKS) || defined(__SAM3X8E__)
205
+#if !defined(__AVR__) || defined(U8G_HAL_LINKS)
206 206
   // Also use this device for HAL version of rrd class. This results in the same device being used
207 207
   // for the ST7920 for HAL systems no matter what is selected in ultralcd_impl_DOGM.h.
208 208
   u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = { u8g_dev_st7920_128x64_HAL_4x_fn, &u8g_dev_st7920_128x64_HAL_4x_pb, U8G_COM_ST7920_HAL_SW_SPI };

+ 7
- 4
Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp Näytä tiedosto

@@ -23,9 +23,11 @@
23 23
 // NOTE - the HAL version of the rrd device uses a generic ST7920 device.  See the
24 24
 // file u8g_dev_st7920_128x64_HAL.cpp for the HAL version.
25 25
 
26
+#if defined(__AVR__) && !defined(U8G_HAL_LINKS)
27
+
26 28
 #include "../../inc/MarlinConfig.h"
27 29
 
28
-#if ENABLED(U8GLIB_ST7920) && !defined(U8G_HAL_LINKS) && !defined(__SAM3X8E__)
30
+#if ENABLED(U8GLIB_ST7920)
29 31
 
30 32
 #include "ultralcd_st7920_u8glib_rrd_AVR.h"
31 33
 
@@ -135,8 +137,8 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
135 137
 }
136 138
 
137 139
 uint8_t   u8g_dev_st7920_128x64_rrd_buf[(LCD_PIXEL_WIDTH) * (PAGE_HEIGHT) / 8] U8G_NOCOMMON;
138
-u8g_pb_t  u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0}, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf};
139
-u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn};
140
+u8g_pb_t  u8g_dev_st7920_128x64_rrd_pb = { { PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0 }, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf };
141
+u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = { u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn };
140 142
 
141 143
 #pragma GCC reset_options
142 144
 
@@ -149,4 +151,5 @@ u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g
149 151
   void ST7920_write_byte(const uint8_t val) { ST7920_WRITE_BYTE(val); }
150 152
 #endif
151 153
 
152
-#endif // U8GLIB_ST7920 && !U8G_HAL_LINKS && !__SAM3X8E__
154
+#endif // U8GLIB_ST7920
155
+#endif // __AVR__ && !U8G_HAL_LINKS

+ 0
- 5
Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.h Näytä tiedosto

@@ -25,9 +25,6 @@
25 25
 // file u8g_dev_st7920_128x64_HAL.cpp for the HAL version.
26 26
 
27 27
 #include "../../inc/MarlinConfig.h"
28
-
29
-#if ENABLED(U8GLIB_ST7920) && !defined(U8G_HAL_LINKS) && !defined(__SAM3X8E__)
30
-
31 28
 #include "../../HAL/shared/Delay.h"
32 29
 
33 30
 #define ST7920_CLK_PIN  LCD_PINS_D4
@@ -94,5 +91,3 @@ void ST7920_SWSPI_SND_8BIT(uint8_t val);
94 91
 #define ST7920_SET_DAT()         { ST7920_SWSPI_SND_8BIT(0xFA); U8G_DELAY(); }
95 92
 #define ST7920_WRITE_BYTE(a)     { ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xF0u)); ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u)); U8G_DELAY(); }
96 93
 #define ST7920_WRITE_BYTES(p,l)  { for (uint8_t i = l + 1; --i;) { ST7920_SWSPI_SND_8BIT(*p&0xF0); ST7920_SWSPI_SND_8BIT(*p<<4); p++; } U8G_DELAY(); }
97
-
98
-#endif // U8GLIB_ST7920 && !U8G_HAL_LINKS && !__SAM3X8E__

Loading…
Peruuta
Tallenna