Skip to content

Core cleaning #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 4 additions & 47 deletions cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,21 @@
#ifndef Arduino_h
#define Arduino_h

#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>

#include "binary.h"
#include "itoa.h"

#ifdef __cplusplus
extern "C"{
#endif // __cplusplus

// Includes CMSIS
#include <chip.h>

#include "wiring_constants.h"

#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )

void yield(void);
#include "wiring.h"

/* sketch */
extern void setup( void ) ;
extern void loop( void ) ;

/* Define attribute */
#if defined ( __CC_ARM ) /* Keil uVision 4 */
#define WEAK (__attribute__ ((weak)))
#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
#define WEAK __weak
#elif defined ( __GNUC__ ) /* GCC CS */
#define WEAK __attribute__ ((weak))
#endif

#ifdef __cplusplus
} // extern "C"
extern "C"{
#endif // __cplusplus

void yield(void);
#ifdef __cplusplus
#include "WCharacter.h"
#include "WString.h"
#include "Tone.h"
#include "WMath.h"
#include "HardwareSerial.h"
#include "wiring_pulse.h"
} // extern "C"
#endif // __cplusplus


// Include board variant
#include "pins_arduino.h"

#include "wiring.h"
#include "wiring_digital.h"
#include "wiring_analog.h"
#include "wiring_shift.h"
#include "WInterrupts.h"

#endif // Arduino_h
5 changes: 0 additions & 5 deletions cores/arduino/Tone.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
#define _WIRING_TONE_

#ifdef __cplusplus
extern "C" {
#endif

/*
* \brief Generate a tone to a pin.
*
Expand All @@ -39,8 +36,6 @@ extern void tone(uint8_t _pin, unsigned int frequency, unsigned long duration =
*/
extern void noTone(uint8_t _pin);

#ifdef __cplusplus
}
#endif

#endif /* _WIRING_TONE_ */
16 changes: 16 additions & 0 deletions cores/arduino/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "board.h"

#ifdef __cplusplus
extern "C" {
#endif

void __libc_init_array(void);

WEAK void init( void )
{
hw_config_init();
}

#ifdef __cplusplus
}
#endif
40 changes: 40 additions & 0 deletions cores/arduino/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef _BOARD_H_
#define _BOARD_H_

/*
* Core and peripherals registers definitions
*/
#include "analog.h"
#include "clock.h"
#include "digital_io.h"
#include "ethernet.h"
#include "hal_uart_emul.h"
#include "hw_config.h"
#include "interrupt.h"
#include "spi_com.h"
#include "stm32_eeprom.h"
#include "timer.h"
#include "twi.h"
#include "uart.h"
#include "uart_emul.h"
#ifdef USBCON
#include "usb_interface.h"
#endif //USBCON

/* Define attribute */
#if defined ( __GNUC__ ) /* GCC CS3 */
#define WEAK __attribute__ ((weak))
#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
#define WEAK __weak
#endif

/* Define NO_INIT attribute */
#if defined ( __GNUC__ )
#define NO_INIT
#elif defined ( __ICCARM__ )
#define NO_INIT __no_init
#endif

void init( void ) ;

#endif /* _BOARD_H_ */
62 changes: 0 additions & 62 deletions cores/arduino/chip.h

This file was deleted.

7 changes: 0 additions & 7 deletions cores/arduino/pins_arduino.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
extern "C" {
#endif

void __libc_init_array(void);

WEAK uint32_t pinNametoDigitalPin(PinName p)
{
uint32_t i = NC;
Expand All @@ -36,11 +34,6 @@ WEAK uint32_t pinNametoDigitalPin(PinName p)
return i;
}

WEAK void init( void )
{
hw_config_init();
}

#ifdef __cplusplus
}
#endif
84 changes: 34 additions & 50 deletions cores/arduino/wiring.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,46 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef _WIRING_
#define _WIRING_
#ifndef _WIRING_H_
#define _WIRING_H_

#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>

/**
*
*/
extern void initVariant( void ) ;
extern void init( void ) ;
#include "binary.h"
#include "itoa.h"

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

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

/**
* \brief Pauses the program for the amount of time (in miliseconds) specified as parameter.
* (There are 1000 milliseconds in a second.)
*
* \param dwMs the number of milliseconds to pause (uint32_t)
*/
extern void delay( uint32_t dwMs ) ;
#ifdef __cplusplus
#include "HardwareSerial.h"
#include "Tone.h"
#include "WCharacter.h"
#include "WMath.h"
#include "WString.h"
#endif // __cplusplus

/**
* \brief Pauses the program for the amount of time (in microseconds) specified as parameter.
*
* \param dwUs the number of microseconds to pause (uint32_t)
*/
static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused));
static inline void delayMicroseconds(uint32_t usec){
uint32_t start = GetCurrentMicro();
#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L )
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) )
#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) )

while((start+usec) > GetCurrentMicro());
}

#ifdef __cplusplus
}
#endif

#endif /* _WIRING_ */
#endif /* _WIRING_H_ */
20 changes: 0 additions & 20 deletions cores/arduino/wiring_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,4 @@
#ifndef WiringPrivate_h
#define WiringPrivate_h

#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>

#ifdef __cplusplus
extern "C"{
#endif

// Includes ST CMSIS
#include <chip.h>

#include "wiring_constants.h"

#ifdef __cplusplus
} // extern "C"

#include "HardwareSerial.h"

#endif

#endif
10 changes: 0 additions & 10 deletions cores/arduino/wiring_pulse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

#include "Arduino.h"
#include "wiring_private.h"

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

#ifdef __cplusplus
extern "C" {
#endif


uint32_t pulseIn( uint32_t pin, uint32_t state, uint32_t timeout )
{
uint32_t startMicros = micros();
Expand Down Expand Up @@ -78,7 +72,3 @@ uint32_t pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout)
{
return pulseIn(pin, state, timeout);
}

#ifdef __cplusplus
}
#endif
6 changes: 0 additions & 6 deletions cores/arduino/wiring_pulse.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
#define _WIRING_PULSE_

#ifdef __cplusplus
extern "C" {
#endif

unsigned long countPulseASM(const volatile uint32_t *port, uint32_t bit, uint32_t stateMask, unsigned long maxloops);
/*
* \brief Measures the length (in microseconds) of a pulse on the pin; state is HIGH
Expand All @@ -32,9 +29,6 @@ unsigned long countPulseASM(const volatile uint32_t *port, uint32_t bit, uint32_
*/
extern uint32_t pulseIn( uint32_t ulPin, uint32_t ulState, uint32_t ulTimeout = 1000000L ) ;
extern uint32_t pulseInLong( uint8_t pin, uint8_t state, unsigned long timeout = 1000000L ) ;

#ifdef __cplusplus
}
#endif

#endif /* _WIRING_PULSE_ */
Loading