mirror of
https://github.com/esp8266/Arduino.git
synced 2025-12-01 17:57:53 +03:00
[sam] UART/USART write(char) working and cmsis update
This commit is contained in:
@@ -28,6 +28,7 @@ extern "C"{
|
||||
#include "wiring_digital.h"
|
||||
#include "wiring_analog.h"
|
||||
#include "wiring_shift.h"
|
||||
#include "WInterrupts.h"
|
||||
|
||||
/* sketch */
|
||||
extern void setup( void ) ;
|
||||
@@ -52,6 +53,19 @@ extern void loop( void ) ;
|
||||
#define NOT_ON_TIMER 0
|
||||
#define TIMER0 1
|
||||
|
||||
typedef enum _EExt_Interrupts
|
||||
{
|
||||
EXTERNAL_INT_0=0,
|
||||
EXTERNAL_INT_1=1,
|
||||
EXTERNAL_INT_2=2,
|
||||
EXTERNAL_INT_3=3,
|
||||
EXTERNAL_INT_4=4,
|
||||
EXTERNAL_INT_5=5,
|
||||
EXTERNAL_INT_6=6,
|
||||
EXTERNAL_INT_7=7,
|
||||
EXTERNAL_NUM_INTERRUPTS
|
||||
} EExt_Interrupts ;
|
||||
|
||||
typedef void (*voidFuncPtr)( void ) ;
|
||||
|
||||
/* Define attribute */
|
||||
|
||||
@@ -24,9 +24,9 @@ class HardwareSerial : public Stream
|
||||
virtual void flush( void ) =0 ;
|
||||
virtual void write( const uint8_t c ) =0 ;
|
||||
|
||||
virtual void write( const char *str ) ;
|
||||
virtual void write( const uint8_t *buffer, size_t size ) ;
|
||||
// using Print::write ; // pull in write(str) and write(buf, size) from Print
|
||||
// virtual void write( const char *str ) ;
|
||||
// virtual void write( const uint8_t *buffer, size_t size ) ;
|
||||
using Print::write ; // pull in write(str) and write(buf, size) from Print
|
||||
} ;
|
||||
|
||||
#endif // HardwareSerial_h
|
||||
|
||||
@@ -1,6 +1,42 @@
|
||||
//#include <inttypes.h>
|
||||
//#include <stdio.h>
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
#include "WInterrupts.h"
|
||||
|
||||
#include "wiring_private.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** PIO interrupt handlers array */
|
||||
/*volatile*/ static voidFuncPtr g_apfn_IntFunc[EXTERNAL_NUM_INTERRUPTS]={ 0 } ;
|
||||
|
||||
void attachInterrupt( uint32_t ulInterrupt, void (*pfn_UserFunc)(void), uint32_t ulMode )
|
||||
{
|
||||
if ( ulInterrupt < EXTERNAL_NUM_INTERRUPTS )
|
||||
{
|
||||
g_apfn_IntFunc[ulInterrupt] = pfn_UserFunc ;
|
||||
|
||||
// Configure the interrupt mode (trigger on low input, any change, rising
|
||||
// edge, or falling edge). The mode constants were chosen to correspond
|
||||
// to the configuration bits in the hardware register, so we simply shift
|
||||
// the mode into place.
|
||||
|
||||
// Enable the interrupt.
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void detachInterrupt( uint32_t ulInterrupt )
|
||||
{
|
||||
if ( ulInterrupt < EXTERNAL_NUM_INTERRUPTS )
|
||||
{
|
||||
/* Disable the interrupt. */
|
||||
|
||||
|
||||
g_apfn_IntFunc[ulInterrupt] = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
68
hardware/sam/cores/sam/WInterrupts.h
Normal file
68
hardware/sam/cores/sam/WInterrupts.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
|
||||
#ifndef _WIRING_INTERRUPTS_
|
||||
#define _WIRING_INTERRUPTS_
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//typedef struct _InterruptSource
|
||||
//{
|
||||
// /* Pointer to the source pin instance. */
|
||||
// PinDescription *pPin ;
|
||||
//
|
||||
// /* Interrupt handler. */
|
||||
// void (*handler)( const PinDescription *pPin ) ;
|
||||
//} InterruptSource ;
|
||||
|
||||
|
||||
/*
|
||||
* \brief Specifies a function to call when an external interrupt occurs.
|
||||
* Replaces any previous function that was attached to the interrupt.
|
||||
* All Arduino SAM3 based boards pins can be switched into INPUT mode and have
|
||||
* an interrupt user function attached to an event.
|
||||
*
|
||||
* \param ulInterrupt
|
||||
* \param pfn_UserFunc
|
||||
* \param ulMode
|
||||
*
|
||||
PIO_IT_RE_OR_HL = Interrupt High Level/Rising Edge detection is active
|
||||
PIO_IT_EDGE = Interrupt Edge detection is active
|
||||
PIO_IT_LOW_LEVEL = Low level interrupt is active
|
||||
PIO_IT_HIGH_LEVEL = High level interrupt is active
|
||||
PIO_IT_FALL_EDGE = Falling edge interrupt is active
|
||||
PIO_IT_RISE_EDGE = Rising edge interrupt is active
|
||||
|
||||
interrupt: the number of the interrupt (int)
|
||||
|
||||
function: the function to call when the interrupt occurs; this function must take no parameters and return nothing. This function is sometimes referred to as an interrupt service routine.
|
||||
|
||||
mode defines when the interrupt should be triggered. Four contstants are predefined as valid values:
|
||||
|
||||
LOW to trigger the interrupt whenever the pin is low,
|
||||
CHANGE to trigger the interrupt whenever the pin changes value
|
||||
RISING to trigger when the pin goes from low to high,
|
||||
FALLING for when the pin goes from high to low.
|
||||
*/
|
||||
extern void attachInterrupt( uint32_t ulInterrupt, void (*pfn_UserFunc)(void), uint32_t ulMode ) ;
|
||||
|
||||
/*
|
||||
Turns off the given interrupt.
|
||||
|
||||
Parameters
|
||||
|
||||
interrupt: the number of interrupt to disable (0 or 1).
|
||||
*/
|
||||
extern void detachInterrupt( uint32_t ulInterrupt ) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _WIRING_INTERRUPTS_ */
|
||||
@@ -6,6 +6,7 @@ extern "C" {
|
||||
#include "stdlib.h"
|
||||
#include "stdint.h"
|
||||
}
|
||||
#include "WMath.h"
|
||||
|
||||
extern void randomSeed( uint32_t dwSeed )
|
||||
{
|
||||
@@ -42,7 +43,7 @@ extern long map(long x, long in_min, long in_max, long out_min, long out_max)
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
extern uint16_t makeWord( uint32_t w )
|
||||
extern uint16_t makeWord( uint16_t w )
|
||||
{
|
||||
return w ;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ extern void randomSeed( uint32_t dwSeed ) ;
|
||||
extern long map( long, long, long, long, long ) ;
|
||||
|
||||
extern uint16_t makeWord( uint16_t w ) ;
|
||||
extern uint16_t makeWord( byte h, byte l ) ;
|
||||
extern uint16_t makeWord( uint8_t h, uint8_t l ) ;
|
||||
|
||||
#define word(...) makeWord(__VA_ARGS__)
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "WString.h"
|
||||
#include "itoa.h"
|
||||
|
||||
|
||||
/*********************************************/
|
||||
@@ -64,7 +65,7 @@ String::String(unsigned char value, unsigned char base)
|
||||
{
|
||||
init();
|
||||
char buf[9];
|
||||
// utoa(value, buf, base);
|
||||
utoa(value, buf, base);
|
||||
*this = buf;
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ String::String(int value, unsigned char base)
|
||||
{
|
||||
init();
|
||||
char buf[18];
|
||||
// itoa(value, buf, base);
|
||||
itoa(value, buf, base);
|
||||
*this = buf;
|
||||
}
|
||||
|
||||
@@ -80,7 +81,7 @@ String::String(unsigned int value, unsigned char base)
|
||||
{
|
||||
init();
|
||||
char buf[17];
|
||||
// utoa(value, buf, base);
|
||||
utoa(value, buf, base);
|
||||
*this = buf;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ String::String(long value, unsigned char base)
|
||||
{
|
||||
init();
|
||||
char buf[34];
|
||||
// ltoa(value, buf, base);
|
||||
ltoa(value, buf, base);
|
||||
*this = buf;
|
||||
}
|
||||
|
||||
@@ -96,7 +97,7 @@ String::String(unsigned long value, unsigned char base)
|
||||
{
|
||||
init();
|
||||
char buf[33];
|
||||
// ultoa(value, buf, base);
|
||||
ultoa(value, buf, base);
|
||||
*this = buf;
|
||||
}
|
||||
|
||||
@@ -258,28 +259,28 @@ unsigned char String::concat(unsigned char num)
|
||||
unsigned char String::concat(int num)
|
||||
{
|
||||
char buf[7];
|
||||
// itoa(num, buf, 10);
|
||||
itoa(num, buf, 10);
|
||||
return concat(buf, strlen(buf));
|
||||
}
|
||||
|
||||
unsigned char String::concat(unsigned int num)
|
||||
{
|
||||
char buf[6];
|
||||
// utoa(num, buf, 10);
|
||||
utoa(num, buf, 10);
|
||||
return concat(buf, strlen(buf));
|
||||
}
|
||||
|
||||
unsigned char String::concat(long num)
|
||||
{
|
||||
char buf[12];
|
||||
// ltoa(num, buf, 10);
|
||||
ltoa(num, buf, 10);
|
||||
return concat(buf, strlen(buf));
|
||||
}
|
||||
|
||||
unsigned char String::concat(unsigned long num)
|
||||
{
|
||||
char buf[11];
|
||||
// ultoa(num, buf, 10);
|
||||
ultoa(num, buf, 10);
|
||||
return concat(buf, strlen(buf));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
ifeq ("$(VARIANTS)", "")
|
||||
#VARIANTS = sam3s_ek sam3u_ek arduino_due
|
||||
VARIANTS = arduino_due
|
||||
VARIANTS = sam3u_ek
|
||||
endif
|
||||
|
||||
SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@ CPPFLAGS += -Wpacked -Wredundant-decls -Winline -Wlong-long
|
||||
#CPPFLAGS += -Wmissing-noreturn
|
||||
#CPPFLAGS += -Wconversion
|
||||
|
||||
CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fno-rtti -fno-exceptions
|
||||
#-fno-rtti -fno-exceptions
|
||||
CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections
|
||||
CPPFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP)
|
||||
|
||||
# To reduce application size use only integer printf function.
|
||||
|
||||
@@ -2745,9 +2745,9 @@
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\WInterrupts.c</name>
|
||||
<excluded>
|
||||
<configuration>Debug</configuration>
|
||||
</excluded>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\WInterrupts.h</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\wiring.c</name>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
extern "C" void __cxa_pure_virtual(void) ;
|
||||
|
||||
/* We compile with nodefaultlibs, so we need to provide an error
|
||||
* handler for an empty pure virtual function */
|
||||
extern "C" void __cxa_pure_virtual(void) {
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
/*
|
||||
%atmel_license%
|
||||
*/
|
||||
|
||||
#include "itoa.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif // __cplusplus
|
||||
|
||||
#if 0
|
||||
/* reverse: reverse string s in place */
|
||||
static void reverse( char s[] )
|
||||
{
|
||||
@@ -15,7 +24,6 @@ static void reverse( char s[] )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* itoa: convert n to characters in s */
|
||||
extern void itoa( int n, char s[] )
|
||||
{
|
||||
@@ -41,3 +49,108 @@ extern void itoa( int n, char s[] )
|
||||
|
||||
reverse( s ) ;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
extern char* itoa( int value, char *string, int radix )
|
||||
{
|
||||
return ltoa( value, string, radix ) ;
|
||||
}
|
||||
|
||||
extern char* ltoa( long value, char *string, int radix )
|
||||
{
|
||||
char tmp[33];
|
||||
char *tp = tmp;
|
||||
long i;
|
||||
unsigned long v;
|
||||
int sign;
|
||||
char *sp;
|
||||
|
||||
if ( string == NULL )
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
if (radix > 36 || radix <= 1)
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
sign = (radix == 10 && value < 0);
|
||||
if (sign)
|
||||
{
|
||||
v = -value;
|
||||
}
|
||||
else
|
||||
{
|
||||
v = (unsigned long)value;
|
||||
}
|
||||
|
||||
while (v || tp == tmp)
|
||||
{
|
||||
i = v % radix;
|
||||
v = v / radix;
|
||||
if (i < 10)
|
||||
*tp++ = i+'0';
|
||||
else
|
||||
*tp++ = i + 'a' - 10;
|
||||
}
|
||||
|
||||
sp = string;
|
||||
|
||||
if (sign)
|
||||
*sp++ = '-';
|
||||
while (tp > tmp)
|
||||
*sp++ = *--tp;
|
||||
*sp = 0;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
extern char* utoa( unsigned long value, char *string, int radix )
|
||||
{
|
||||
return ultoa( value, string, radix ) ;
|
||||
}
|
||||
|
||||
extern char* ultoa( unsigned long value, char *string, int radix )
|
||||
{
|
||||
char tmp[33];
|
||||
char *tp = tmp;
|
||||
long i;
|
||||
unsigned long v = value;
|
||||
char *sp;
|
||||
|
||||
if ( string == NULL )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (radix > 36 || radix <= 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (v || tp == tmp)
|
||||
{
|
||||
i = v % radix;
|
||||
v = v / radix;
|
||||
if (i < 10)
|
||||
*tp++ = i+'0';
|
||||
else
|
||||
*tp++ = i + 'a' - 10;
|
||||
}
|
||||
|
||||
sp = string;
|
||||
|
||||
|
||||
while (tp > tmp)
|
||||
*sp++ = *--tp;
|
||||
*sp = 0;
|
||||
|
||||
return string;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
#ifndef _ITOA_
|
||||
#define _ITOA_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif // __cplusplus
|
||||
|
||||
#if 0
|
||||
|
||||
extern void itoa( int n, char s[] ) ;
|
||||
|
||||
#else
|
||||
|
||||
extern char* itoa( int value, char *string, int radix ) ;
|
||||
extern char* ltoa( long value, char *string, int radix ) ;
|
||||
extern char* utoa( unsigned long value, char *string, int radix ) ;
|
||||
extern char* ultoa( unsigned long value, char *string, int radix ) ;
|
||||
#endif /* 0 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _ITOA_
|
||||
|
||||
@@ -49,7 +49,8 @@ CPPFLAGS += -Wsign-compare -Waggregate-return -Wmissing-declarations
|
||||
CPPFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations
|
||||
CPPFLAGS += -Wpacked -Wredundant-decls -Winline -Wlong-long
|
||||
|
||||
CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fno-rtti -fno-exceptions
|
||||
#-fno-rtti -fno-exceptions
|
||||
CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections
|
||||
CPPFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP)
|
||||
|
||||
# To reduce application size use only integer printf function.
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
# putting default variant
|
||||
ifeq ("$(VARIANT)", "")
|
||||
#VARIANT=sam3s_ek
|
||||
#VARIANT=sam3u_ek
|
||||
VARIANT=arduino_due
|
||||
VARIANT=sam3u_ek
|
||||
#VARIANT=arduino_due
|
||||
endif
|
||||
|
||||
ifeq ("$(VARIANT)", "sam3s_ek")
|
||||
@@ -88,12 +88,12 @@ endif
|
||||
|
||||
OUTPUT_BIN=test_$(TOOLCHAIN)_$(LIBS_POSTFIX)
|
||||
#LIBS=-L../libsam_$(CHIP_NAME)_$(TOOLCHAIN)_rel.a -L../arduino_$(VARIANT)_$(TOOLCHAIN)_rel.a
|
||||
#-lstdc++
|
||||
LIBS=-Wl,--start-group -lgcc -lc -lsam_$(CHIP_NAME)_$(TOOLCHAIN)_$(LIBS_POSTFIX) -larduino_$(VARIANT)_$(TOOLCHAIN)_$(LIBS_POSTFIX) -lvariant_$(VARIANT)_$(TOOLCHAIN)_$(LIBS_POSTFIX) -Wl,--end-group
|
||||
#
|
||||
LIBS=-Wl,--start-group -lgcc -lc -lstdc++ -lsam_$(CHIP_NAME)_$(TOOLCHAIN)_$(LIBS_POSTFIX) -larduino_$(VARIANT)_$(TOOLCHAIN)_$(LIBS_POSTFIX) -lvariant_$(VARIANT)_$(TOOLCHAIN)_$(LIBS_POSTFIX) -Wl,--end-group
|
||||
|
||||
LIB_PATH =-L$(PROJECT_BASE_PATH)/..
|
||||
LIB_PATH+=-L=/lib/thumb2
|
||||
LIB_PATH+=-L=/../lib/gcc/arm-none-eabi/4.4.1/thumb2
|
||||
#LIB_PATH+=-L=/../lib/gcc/arm-none-eabi/4.5.2/thumb2
|
||||
|
||||
LDFLAGS= -mcpu=cortex-m3 -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols
|
||||
|
||||
@@ -141,13 +141,14 @@ create_output:
|
||||
|
||||
$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp
|
||||
# @$(CC) -c $(CPPFLAGS) $< -o $@
|
||||
# @$(CXX) -c $(CPPFLAGS) $< -o $@
|
||||
$(CXX) -v -c $(CPPFLAGS) $< -o $@
|
||||
@$(CXX) -c $(CPPFLAGS) $< -o $@
|
||||
# @$(CXX) -v -c $(CPPFLAGS) $< -o $@
|
||||
|
||||
$(OUTPUT_BIN): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ))
|
||||
$(CC) $(LIB_PATH) $(LDFLAGS) -T"$(VARIANT_PATH)/linker_scripts/gcc/flash.ld" -Wl,-Map,$(OUTPUT_PATH)/$@.map -o $(OUTPUT_PATH)/$@.elf $^ $(LIBS)
|
||||
$(NM) $(OUTPUT_PATH)/$@.elf >$(OUTPUT_PATH)/$@.elf.txt
|
||||
$(OBJCOPY) -O binary $(OUTPUT_PATH)/$@.elf $(OUTPUT_PATH)/$@.bin
|
||||
@$(CC) $(LIB_PATH) $(LDFLAGS) -T"$(VARIANT_PATH)/linker_scripts/gcc/flash.ld" -Wl,-Map,$(OUTPUT_PATH)/$@.map -o $(OUTPUT_PATH)/$@.elf $^ $(LIBS)
|
||||
# @$(CC) $(LIB_PATH) $(LDFLAGS) -T"$(VARIANT_PATH)/linker_scripts/gcc/sram.ld" -Wl,-Map,$(OUTPUT_PATH)/$@.map -o $(OUTPUT_PATH)/$@.elf $^ $(LIBS)
|
||||
@$(NM) $(OUTPUT_PATH)/$@.elf >$(OUTPUT_PATH)/$@.elf.txt
|
||||
@$(OBJCOPY) -O binary $(OUTPUT_PATH)/$@.elf $(OUTPUT_PATH)/$@.bin
|
||||
$(SIZE) $^ $(OUTPUT_PATH)/$@.elf
|
||||
|
||||
.PHONY: clean
|
||||
@@ -160,4 +161,5 @@ clean:
|
||||
-@$(RM) $(OUTPUT_PATH)/$(OUTPUT_BIN).map 1>NUL 2>&1
|
||||
|
||||
debug: test
|
||||
$(GDB) -x "$(VARIANT_PATH)/debug_scripts/gcc/$(VARIANT)_flash.gdb" -ex "reset" -readnow -se $(OUTPUT_PATH)/$(OUTPUT_BIN).elf
|
||||
@$(GDB) -x "$(VARIANT_PATH)/debug_scripts/gcc/$(VARIANT)_flash.gdb" -ex "reset" -readnow -se $(OUTPUT_PATH)/$(OUTPUT_BIN).elf
|
||||
# @$(GDB) -w -x "$(VARIANT_PATH)/debug_scripts/gcc/$(VARIANT)_sram.gdb" -ex "reset" -readnow -se $(OUTPUT_PATH)/$(OUTPUT_BIN).elf
|
||||
|
||||
@@ -15,20 +15,54 @@ void setup( void )
|
||||
pinMode( PIN_LED2, OUTPUT ) ;
|
||||
digitalWrite( PIN_LED2, HIGH ) ;
|
||||
|
||||
Serial.begin( 19200 ) ;
|
||||
Serial.begin( 115200 ) ;
|
||||
}
|
||||
|
||||
void led_step1( void )
|
||||
{
|
||||
#if defined sam3s_ek
|
||||
digitalWrite( PIN_LED, HIGH ) ; // set the LED on
|
||||
digitalWrite( PIN_LED2, LOW ) ; // set the red LED off
|
||||
#endif /* sam3s_ek */
|
||||
|
||||
#if defined sam3u_ek
|
||||
digitalWrite( PIN_LED, HIGH ) ; // set the LED on
|
||||
digitalWrite( PIN_LED2, LOW ) ; // set the red LED off
|
||||
#endif /* sam3u_ek */
|
||||
|
||||
#if defined arduino_due
|
||||
digitalWrite( PIN_LED, LOW ) ; // set the LED on
|
||||
digitalWrite( PIN_LED2, LOW ) ; // set the red LED off
|
||||
#endif /* arduino_due */
|
||||
}
|
||||
|
||||
void led_step2( void )
|
||||
{
|
||||
#if defined sam3s_ek
|
||||
digitalWrite( PIN_LED, LOW ) ; // set the LED off
|
||||
digitalWrite( PIN_LED2, HIGH ) ; // set the red LED on
|
||||
#endif /* sam3s_ek */
|
||||
|
||||
#if defined sam3u_ek
|
||||
digitalWrite( PIN_LED, LOW ) ; // set the LED off
|
||||
digitalWrite( PIN_LED2, HIGH ) ; // set the red LED on
|
||||
#endif /* sam3u_ek */
|
||||
|
||||
#if defined arduino_due
|
||||
digitalWrite( PIN_LED, HIGH ) ; // set the LED off
|
||||
digitalWrite( PIN_LED2, HIGH ) ; // set the red LED on
|
||||
#endif /* arduino_due */
|
||||
}
|
||||
|
||||
void loop( void )
|
||||
{
|
||||
digitalWrite( PIN_LED, HIGH ) ; // set the LED on
|
||||
digitalWrite( PIN_LED2, LOW ) ; // set the red LED off
|
||||
led_step1() ;
|
||||
delay( 1000 ) ; // wait for a second
|
||||
digitalWrite( PIN_LED, LOW ) ; // set the LED off
|
||||
digitalWrite( PIN_LED2, HIGH ) ; // set the red LED on
|
||||
led_step2() ;
|
||||
delay( 1000 ) ; // wait for a second
|
||||
|
||||
// Serial.write( '*' ) ; // send an initial char
|
||||
// Serial.println( "test1" ) ; // send an initial string
|
||||
Serial.write( '-' ) ; // send an initial char
|
||||
Serial.println( "test1\n" ) ; // send an initial string
|
||||
// delay( 1000 ) ; // wait for a second
|
||||
// Serial.println( "test2" ) ; // send an initial string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user