Bläddra i källkod

Tweaks to HAL format and order

Scott Lahteine 6 år sedan
förälder
incheckning
ad21a4f07b
3 ändrade filer med 61 tillägg och 52 borttagningar
  1. 35
    43
      Marlin/src/HAL/HAL_DUE/HAL.h
  2. 24
    7
      Marlin/src/HAL/HAL_LPC1768/HAL.h
  3. 2
    2
      Marlin/src/HAL/HAL_STM32F1/HAL.h

+ 35
- 43
Marlin/src/HAL/HAL_DUE/HAL.h Visa fil

41
 #include "watchdog_Due.h"
41
 #include "watchdog_Due.h"
42
 #include "HAL_timers_Due.h"
42
 #include "HAL_timers_Due.h"
43
 
43
 
44
-//
45
-// Defines
46
-//
47
 #define NUM_SERIAL 1
44
 #define NUM_SERIAL 1
45
+// Required before the include or compilation fails
48
 #define MYSERIAL0 customizedSerial
46
 #define MYSERIAL0 customizedSerial
49
 
47
 
50
-// We need the previous define before the include, or compilation bombs...
51
 #include "MarlinSerial_Due.h"
48
 #include "MarlinSerial_Due.h"
52
 #include "MarlinSerialUSB_Due.h"
49
 #include "MarlinSerialUSB_Due.h"
53
 
50
 
54
-#ifndef analogInputToDigitalPin
55
-  #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
56
-#endif
57
-
58
-#define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq()
59
-#define CRITICAL_SECTION_END    if (!primask) __enable_irq()
60
-#define ISRS_ENABLED() (!__get_PRIMASK())
61
-#define ENABLE_ISRS()  __enable_irq()
62
-#define DISABLE_ISRS() __disable_irq()
63
-
64
 // On AVR this is in math.h?
51
 // On AVR this is in math.h?
65
 #define square(x) ((x)*(x))
52
 #define square(x) ((x)*(x))
66
 
53
 
86
 #define RST_SOFTWARE   32
73
 #define RST_SOFTWARE   32
87
 #define RST_BACKUP     64
74
 #define RST_BACKUP     64
88
 
75
 
89
-// --------------------------------------------------------------------------
90
-// Types
91
-// --------------------------------------------------------------------------
92
-
93
 typedef int8_t pin_t;
76
 typedef int8_t pin_t;
94
 
77
 
95
 #define HAL_SERVO_LIB Servo
78
 #define HAL_SERVO_LIB Servo
96
 
79
 
97
-// --------------------------------------------------------------------------
98
-// Public Variables
99
-// --------------------------------------------------------------------------
100
-
101
-extern uint16_t HAL_adc_result;     // result of last ADC conversion
80
+//
81
+// Interrupts
82
+//
83
+#define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq()
84
+#define CRITICAL_SECTION_END    if (!primask) __enable_irq()
85
+#define ISRS_ENABLED() (!__get_PRIMASK())
86
+#define ENABLE_ISRS()  __enable_irq()
87
+#define DISABLE_ISRS() __disable_irq()
102
 
88
 
103
 void cli(void);                     // Disable interrupts
89
 void cli(void);                     // Disable interrupts
104
 void sei(void);                     // Enable interrupts
90
 void sei(void);                     // Enable interrupts
106
 void HAL_clear_reset_source(void);  // clear reset reason
92
 void HAL_clear_reset_source(void);  // clear reset reason
107
 uint8_t HAL_get_reset_source(void); // get reset reason
93
 uint8_t HAL_get_reset_source(void); // get reset reason
108
 
94
 
109
-void _delay_ms(const int delay);
110
-
111
-int freeMemory(void);
112
-
113
-/**
114
- * SPI: Extended functions taking a channel number (hardware SPI only)
115
- */
95
+//
96
+// SPI: Extended functions taking a channel number (Hardware SPI only)
97
+//
116
 
98
 
117
 // Write single byte to specified SPI channel
99
 // Write single byte to specified SPI channel
118
 void spiSend(uint32_t chan, byte b);
100
 void spiSend(uint32_t chan, byte b);
123
 // Read single byte from specified SPI channel
105
 // Read single byte from specified SPI channel
124
 uint8_t spiRec(uint32_t chan);
106
 uint8_t spiRec(uint32_t chan);
125
 
107
 
126
-/**
127
- * EEPROM
128
- */
129
-
108
+//
109
+// EEPROM
110
+//
130
 void eeprom_write_byte(unsigned char *pos, unsigned char value);
111
 void eeprom_write_byte(unsigned char *pos, unsigned char value);
131
 unsigned char eeprom_read_byte(unsigned char *pos);
112
 unsigned char eeprom_read_byte(unsigned char *pos);
132
 void eeprom_read_block (void *__dst, const void *__src, size_t __n);
113
 void eeprom_read_block (void *__dst, const void *__src, size_t __n);
133
 void eeprom_update_block (const void *__src, void *__dst, size_t __n);
114
 void eeprom_update_block (const void *__src, void *__dst, size_t __n);
134
 
115
 
135
-/**
136
- * ADC
137
- */
116
+//
117
+// ADC
118
+//
119
+extern uint16_t HAL_adc_result;     // result of last ADC conversion
120
+
121
+#ifndef analogInputToDigitalPin
122
+  #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
123
+#endif
138
 
124
 
139
 #define HAL_ANALOG_SELECT(pin)
125
 #define HAL_ANALOG_SELECT(pin)
140
 
126
 
154
 void HAL_enable_AdcFreerun(void);
140
 void HAL_enable_AdcFreerun(void);
155
 //void HAL_disable_AdcFreerun(uint8_t chan);
141
 //void HAL_disable_AdcFreerun(uint8_t chan);
156
 
142
 
157
-/**
158
- * Pin Map
159
- */
143
+//
144
+// Pin Map
145
+//
160
 #define GET_PIN_MAP_PIN(index) index
146
 #define GET_PIN_MAP_PIN(index) index
161
 #define GET_PIN_MAP_INDEX(pin) pin
147
 #define GET_PIN_MAP_INDEX(pin) pin
162
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
148
 #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
163
 
149
 
164
-/**
165
- * Tone
166
- */
150
+//
151
+// Tone
152
+//
167
 void toneInit();
153
 void toneInit();
168
 void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
154
 void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
169
 void noTone(const pin_t _pin);
155
 void noTone(const pin_t _pin);
174
 void HAL_idletask(void);
160
 void HAL_idletask(void);
175
 void HAL_init(void);
161
 void HAL_init(void);
176
 
162
 
163
+//
164
+// Utility functions
165
+//
166
+void _delay_ms(const int delay);
167
+int freeMemory(void);
168
+
177
 #ifdef __cplusplus
169
 #ifdef __cplusplus
178
   extern "C" {
170
   extern "C" {
179
 #endif
171
 #endif

+ 24
- 7
Marlin/src/HAL/HAL_LPC1768/HAL.h Visa fil

64
 #include "../shared/HAL_SPI.h"
64
 #include "../shared/HAL_SPI.h"
65
 #include "fastio.h"
65
 #include "fastio.h"
66
 #include "watchdog.h"
66
 #include "watchdog.h"
67
-#include "serial.h"
68
 #include "HAL_timers.h"
67
 #include "HAL_timers.h"
69
-#include "HardwareSerial.h"
70
 
68
 
69
+//
70
+// Default graphical display delays
71
+//
71
 #ifndef ST7920_DELAY_1
72
 #ifndef ST7920_DELAY_1
72
   #define ST7920_DELAY_1 DELAY_NS(600)
73
   #define ST7920_DELAY_1 DELAY_NS(600)
73
 #endif
74
 #endif
78
   #define ST7920_DELAY_3 DELAY_NS(750)
79
   #define ST7920_DELAY_3 DELAY_NS(750)
79
 #endif
80
 #endif
80
 
81
 
82
+//
83
+// Arduino-style serial ports
84
+//
85
+#include "serial.h"
86
+#include "HardwareSerial.h"
87
+
81
 extern HalSerial usb_serial;
88
 extern HalSerial usb_serial;
82
 
89
 
83
 #if !WITHIN(SERIAL_PORT, -1, 3)
90
 #if !WITHIN(SERIAL_PORT, -1, 3)
126
   #define NUM_SERIAL 1
133
   #define NUM_SERIAL 1
127
 #endif
134
 #endif
128
 
135
 
136
+//
137
+// Interrupts
138
+//
129
 #define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq()
139
 #define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq()
130
 #define CRITICAL_SECTION_END    if (!primask) __enable_irq()
140
 #define CRITICAL_SECTION_END    if (!primask) __enable_irq()
131
 #define ISRS_ENABLED() (!__get_PRIMASK())
141
 #define ISRS_ENABLED() (!__get_PRIMASK())
132
 #define ENABLE_ISRS()  __enable_irq()
142
 #define ENABLE_ISRS()  __enable_irq()
133
 #define DISABLE_ISRS() __disable_irq()
143
 #define DISABLE_ISRS() __disable_irq()
134
 
144
 
135
-//Utility functions
145
+//
146
+// Utility functions
147
+//
136
 int freeMemory(void);
148
 int freeMemory(void);
137
 
149
 
138
-// SPI: Extended functions which take a channel number (hardware SPI only)
139
-/** Write single byte to specified SPI channel */
150
+//
151
+// SPI: Extended functions taking a channel number (Hardware SPI only)
152
+//
153
+
154
+// Write single byte to specified SPI channel
140
 void spiSend(uint32_t chan, byte b);
155
 void spiSend(uint32_t chan, byte b);
141
-/** Write buffer to specified SPI channel */
156
+// Write buffer to specified SPI channel
142
 void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
157
 void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
143
-/** Read single byte from specified SPI channel */
158
+// Read single byte from specified SPI channel
144
 uint8_t spiRec(uint32_t chan);
159
 uint8_t spiRec(uint32_t chan);
145
 
160
 
161
+//
146
 // ADC
162
 // ADC
163
+//
147
 #define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin)
164
 #define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin)
148
 #define HAL_START_ADC(pin)     HAL_adc_start_conversion(pin)
165
 #define HAL_START_ADC(pin)     HAL_adc_start_conversion(pin)
149
 #define HAL_READ_ADC()         HAL_adc_get_result()
166
 #define HAL_READ_ADC()         HAL_adc_get_result()

+ 2
- 2
Marlin/src/HAL/HAL_STM32F1/HAL.h Visa fil

73
   #error "SERIAL_PORT must be from -1 to 3"
73
   #error "SERIAL_PORT must be from -1 to 3"
74
 #endif
74
 #endif
75
 #if SERIAL_PORT == -1
75
 #if SERIAL_PORT == -1
76
-extern USBSerial SerialUSB;
76
+  extern USBSerial SerialUSB;
77
   #define MYSERIAL0 SerialUSB
77
   #define MYSERIAL0 SerialUSB
78
 #elif SERIAL_PORT == 0
78
 #elif SERIAL_PORT == 0
79
   #define MYSERIAL0 Serial
79
   #define MYSERIAL0 Serial
93
   #endif
93
   #endif
94
   #define NUM_SERIAL 2
94
   #define NUM_SERIAL 2
95
   #if SERIAL_PORT_2 == -1
95
   #if SERIAL_PORT_2 == -1
96
-  extern USBSerial SerialUSB;
96
+    extern USBSerial SerialUSB;
97
     #define MYSERIAL1 SerialUSB
97
     #define MYSERIAL1 SerialUSB
98
   #elif SERIAL_PORT_2 == 0
98
   #elif SERIAL_PORT_2 == 0
99
     #define MYSERIAL1 Serial
99
     #define MYSERIAL1 Serial

Laddar…
Avbryt
Spara