Skip to content

Commit f36dc5c

Browse files
committed
Core cleaning
Review naming of core files and include. Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 0692177 commit f36dc5c

12 files changed

+167
-222
lines changed

cores/arduino/Arduino.h

+4-47
Original file line numberDiff line numberDiff line change
@@ -20,64 +20,21 @@
2020
#ifndef Arduino_h
2121
#define Arduino_h
2222

23-
#include <stdint.h>
24-
#include <stdlib.h>
25-
#include <stdbool.h>
26-
#include <string.h>
27-
#include <math.h>
28-
29-
#include "binary.h"
30-
#include "itoa.h"
31-
32-
#ifdef __cplusplus
33-
extern "C"{
34-
#endif // __cplusplus
35-
36-
// Includes CMSIS
37-
#include <chip.h>
38-
39-
#include "wiring_constants.h"
40-
41-
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
42-
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
43-
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )
44-
45-
void yield(void);
23+
#include "wiring.h"
4624

4725
/* sketch */
4826
extern void setup( void ) ;
4927
extern void loop( void ) ;
5028

51-
/* Define attribute */
52-
#if defined ( __CC_ARM ) /* Keil uVision 4 */
53-
#define WEAK (__attribute__ ((weak)))
54-
#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
55-
#define WEAK __weak
56-
#elif defined ( __GNUC__ ) /* GCC CS */
57-
#define WEAK __attribute__ ((weak))
58-
#endif
59-
6029
#ifdef __cplusplus
61-
} // extern "C"
30+
extern "C"{
6231
#endif // __cplusplus
63-
32+
void yield(void);
6433
#ifdef __cplusplus
65-
#include "WCharacter.h"
66-
#include "WString.h"
67-
#include "Tone.h"
68-
#include "WMath.h"
69-
#include "HardwareSerial.h"
70-
#include "wiring_pulse.h"
34+
} // extern "C"
7135
#endif // __cplusplus
7236

73-
7437
// Include board variant
7538
#include "pins_arduino.h"
7639

77-
#include "wiring.h"
78-
#include "wiring_digital.h"
79-
#include "wiring_analog.h"
80-
#include "wiring_shift.h"
81-
#include "WInterrupts.h"
82-
8340
#endif // Arduino_h

cores/arduino/Tone.h

-5
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
#define _WIRING_TONE_
2121

2222
#ifdef __cplusplus
23-
extern "C" {
24-
#endif
25-
2623
/*
2724
* \brief Generate a tone to a pin.
2825
*
@@ -39,8 +36,6 @@ extern void tone(uint8_t _pin, unsigned int frequency, unsigned long duration =
3936
*/
4037
extern void noTone(uint8_t _pin);
4138

42-
#ifdef __cplusplus
43-
}
4439
#endif
4540

4641
#endif /* _WIRING_TONE_ */

cores/arduino/board.c

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "board.h"
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
void __libc_init_array(void);
8+
9+
WEAK void init( void )
10+
{
11+
hw_config_init();
12+
}
13+
14+
#ifdef __cplusplus
15+
}
16+
#endif

cores/arduino/board.h

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef _BOARD_H_
2+
#define _BOARD_H_
3+
4+
/*
5+
* Core and peripherals registers definitions
6+
*/
7+
#include "analog.h"
8+
#include "clock.h"
9+
#include "digital_io.h"
10+
#include "ethernet.h"
11+
#include "hal_uart_emul.h"
12+
#include "hw_config.h"
13+
#include "interrupt.h"
14+
#include "spi_com.h"
15+
#include "stm32_eeprom.h"
16+
#include "timer.h"
17+
#include "twi.h"
18+
#include "uart.h"
19+
#include "uart_emul.h"
20+
#ifdef USBCON
21+
#include "usb_interface.h"
22+
#endif //USBCON
23+
24+
/* Define attribute */
25+
#if defined ( __GNUC__ ) /* GCC CS3 */
26+
#define WEAK __attribute__ ((weak))
27+
#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
28+
#define WEAK __weak
29+
#endif
30+
31+
/* Define NO_INIT attribute */
32+
#if defined ( __GNUC__ )
33+
#define NO_INIT
34+
#elif defined ( __ICCARM__ )
35+
#define NO_INIT __no_init
36+
#endif
37+
38+
void init( void ) ;
39+
40+
#endif /* _BOARD_H_ */

cores/arduino/chip.h

-62
This file was deleted.

cores/arduino/pins_arduino.c

-7
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
extern "C" {
2323
#endif
2424

25-
void __libc_init_array(void);
26-
2725
WEAK uint32_t pinNametoDigitalPin(PinName p)
2826
{
2927
uint32_t i = NC;
@@ -36,11 +34,6 @@ WEAK uint32_t pinNametoDigitalPin(PinName p)
3634
return i;
3735
}
3836

39-
WEAK void init( void )
40-
{
41-
hw_config_init();
42-
}
43-
4437
#ifdef __cplusplus
4538
}
4639
#endif

cores/arduino/wiring.h

+34-50
Original file line numberDiff line numberDiff line change
@@ -17,62 +17,46 @@
1717
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20-
#ifndef _WIRING_
21-
#define _WIRING_
20+
#ifndef _WIRING_H_
21+
#define _WIRING_H_
2222

23-
#ifdef __cplusplus
24-
extern "C" {
25-
#endif
23+
#include <stdint.h>
24+
#include <stdlib.h>
25+
#include <stdbool.h>
26+
#include <string.h>
27+
#include <math.h>
2628

27-
/**
28-
*
29-
*/
30-
extern void initVariant( void ) ;
31-
extern void init( void ) ;
29+
#include "binary.h"
30+
#include "itoa.h"
3231

33-
/**
34-
* \brief Returns the number of milliseconds since the Arduino board began running the current program.
35-
*
36-
* This number will overflow (go back to zero), after approximately 50 days.
37-
*
38-
* \return Number of milliseconds since the program started (uint32_t)
39-
*/
40-
extern uint32_t millis( void ) ;
32+
#ifdef __cplusplus
33+
extern "C"{
34+
#endif // __cplusplus
35+
#include <board.h>
36+
#ifdef __cplusplus
37+
}
38+
#endif
4139

42-
/**
43-
* \brief Returns the number of microseconds since the Arduino board began running the current program.
44-
*
45-
* This number will overflow (go back to zero), after approximately 70 minutes. On 16 MHz Arduino boards
46-
* (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is
47-
* always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution
48-
* of eight microseconds.
49-
*
50-
* \note There are 1,000 microseconds in a millisecond and 1,000,000 microseconds in a second.
51-
*/
52-
extern uint32_t micros( void ) ;
40+
#include "wiring_analog.h"
41+
#include "wiring_constants.h"
42+
#include "wiring_digital.h"
43+
#include "wiring_pulse.h"
44+
#include "wiring_shift.h"
45+
#include "wiring_time.h"
46+
#include "WInterrupts.h"
5347

54-
/**
55-
* \brief Pauses the program for the amount of time (in miliseconds) specified as parameter.
56-
* (There are 1000 milliseconds in a second.)
57-
*
58-
* \param dwMs the number of milliseconds to pause (uint32_t)
59-
*/
60-
extern void delay( uint32_t dwMs ) ;
48+
#ifdef __cplusplus
49+
#include "HardwareSerial.h"
50+
#include "Tone.h"
51+
#include "WCharacter.h"
52+
#include "WMath.h"
53+
#include "WString.h"
54+
#endif // __cplusplus
6155

62-
/**
63-
* \brief Pauses the program for the amount of time (in microseconds) specified as parameter.
64-
*
65-
* \param dwUs the number of microseconds to pause (uint32_t)
66-
*/
67-
static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
68-
static inline void delayMicroseconds(uint32_t usec){
69-
uint32_t start = GetCurrentMicro();
56+
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
57+
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
58+
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )
7059

71-
while((start+usec) > GetCurrentMicro());
72-
}
7360

74-
#ifdef __cplusplus
75-
}
76-
#endif
7761

78-
#endif /* _WIRING_ */
62+
#endif /* _WIRING_H_ */

cores/arduino/wiring_private.h

-20
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,4 @@
1919
#ifndef WiringPrivate_h
2020
#define WiringPrivate_h
2121

22-
#include <stdint.h>
23-
#include <stdio.h>
24-
#include <stdarg.h>
25-
26-
#ifdef __cplusplus
27-
extern "C"{
28-
#endif
29-
30-
// Includes ST CMSIS
31-
#include <chip.h>
32-
33-
#include "wiring_constants.h"
34-
35-
#ifdef __cplusplus
36-
} // extern "C"
37-
38-
#include "HardwareSerial.h"
39-
40-
#endif
41-
4222
#endif

cores/arduino/wiring_pulse.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818

1919
#include "Arduino.h"
20-
#include "wiring_private.h"
2120

2221
/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
2322
* or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
@@ -28,11 +27,6 @@
2827
* This function performs better with short pulses in noInterrupt() context
2928
*/
3029

31-
#ifdef __cplusplus
32-
extern "C" {
33-
#endif
34-
35-
3630
uint32_t pulseIn( uint32_t pin, uint32_t state, uint32_t timeout )
3731
{
3832
uint32_t startMicros = micros();
@@ -78,7 +72,3 @@ uint32_t pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout)
7872
{
7973
return pulseIn(pin, state, timeout);
8074
}
81-
82-
#ifdef __cplusplus
83-
}
84-
#endif

cores/arduino/wiring_pulse.h

-6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
#define _WIRING_PULSE_
2121

2222
#ifdef __cplusplus
23-
extern "C" {
24-
#endif
25-
2623
unsigned long countPulseASM(const volatile uint32_t *port, uint32_t bit, uint32_t stateMask, unsigned long maxloops);
2724
/*
2825
* \brief Measures the length (in microseconds) of a pulse on the pin; state is HIGH
@@ -32,9 +29,6 @@ unsigned long countPulseASM(const volatile uint32_t *port, uint32_t bit, uint32_
3229
*/
3330
extern uint32_t pulseIn( uint32_t ulPin, uint32_t ulState, uint32_t ulTimeout = 1000000L ) ;
3431
extern uint32_t pulseInLong( uint8_t pin, uint8_t state, unsigned long timeout = 1000000L ) ;
35-
36-
#ifdef __cplusplus
37-
}
3832
#endif
3933

4034
#endif /* _WIRING_PULSE_ */

0 commit comments

Comments
 (0)