Skip to content

Commit a419be1

Browse files
committed
separated test functions from the sduino library functions, corrected spelling error in dirname
1 parent ce55838 commit a419be1

22 files changed

Lines changed: 466 additions & 42 deletions
File renamed without changes.
Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
HardwareSerial.c - Hardware serial library for plainduino
2+
HardwareSerial.c - Hardware serial library for sduino
33
Copyright (c) 2016 Michael Mayer
44
55
Plain C version of HardwareSerial.cpp of the Arduino project.
@@ -22,12 +22,13 @@
2222
Modified 23 November 2006 by David A. Mellis
2323
Modified 28 September 2010 by Mark Sproul
2424
Modified 14 August 2012 by Alarus
25+
Modified 15 December 2016 by Michael Mayer
2526
*/
2627

2728

2829
#include"stm8s.h"
2930

30-
//#include "c-HardwareSerial.h"
31+
#include "HardwareSerial.h"
3132

3233

3334
#define SERIAL_BUFFER_SIZE 16
@@ -38,10 +39,14 @@ typedef struct ring_buffer
3839
volatile unsigned int tail;
3940
} ring_buffer;
4041

41-
ring_buffer rx_buffer = { { 0 }, 0, 0};
42-
ring_buffer tx_buffer = { { 0 }, 0, 0};
42+
static ring_buffer rx_buffer = { { 0 }, 0, 0};
43+
static ring_buffer tx_buffer = { { 0 }, 0, 0};
4344

44-
void store_char(unsigned char c, ring_buffer *buffer)
45+
static volatile char transmitting=0;
46+
47+
// private functions //////////////////////////////////////////////////////////
48+
49+
static void store_char(unsigned char c, ring_buffer *buffer)
4550
//inline void store_char(unsigned char c, ring_buffer *buffer)
4651
{
4752
int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE;
@@ -56,8 +61,6 @@ void store_char(unsigned char c, ring_buffer *buffer)
5661
}
5762
}
5863

59-
volatile char transmitting=0;
60-
6164
// Interrupt handler ///////////////////////////////////////////////////////////
6265

6366
void UART1_RX_IRQHandler(void) __interrupt(ITC_IRQ_UART1_RX) /* UART1 RX */
@@ -195,34 +198,3 @@ int HardwareSerial_write(uint8_t c)
195198

196199
return 1;
197200
}
198-
199-
200-
void send_string(char *str)
201-
{
202-
char c;
203-
204-
if (!str) return;
205-
206-
while ( c=*str++ ) HardwareSerial_write(c); // assignment intented
207-
}
208-
209-
210-
void main (void)
211-
{
212-
uint32_t i;
213-
214-
UART1_DeInit();
215-
enableInterrupts();
216-
217-
HardwareSerial_begin(9600);
218-
219-
while (1) {
220-
send_string("Hello World!\r\n");
221-
for (i=15000; i; i--);
222-
while(HardwareSerial_available()) {
223-
HardwareSerial_write('.');
224-
HardwareSerial_write(HardwareSerial_read());
225-
};
226-
for (i=15000; i; i--);
227-
}
228-
}

sdunio/Makefile renamed to sduino/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 \
1212
LIBBASE=../STM8S_StdPeriph_Driver
1313
LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s
1414

15-
OBJECTS=main.rel wiring.rel wiring_digital.rel wiring_shift.rel \
16-
wiring_pulse.rel sketch.rel
15+
OBJECTS=main.rel wiring.rel wiring_digital.rel \
16+
wiring_shift.rel wiring_pulse.rel \
17+
HardwareSerial.rel \
18+
sketch.rel
1719

1820
.PHONY: all clean flash
1921

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

sdunio/wiring.c renamed to sduino/wiring.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ void init()
254254
GPIO_DeInit(GPIOC);
255255
GPIO_DeInit(GPIOD);
256256
GPIO_DeInit(GPIOE);
257+
258+
UART1_DeInit();
259+
257260
// set timer 0 prescale factor to 64, period 0 (=256)
258261
TIM4_DeInit();
259262
TIM4_TimeBaseInit(TIM4_PRESCALER_64, 0);

0 commit comments

Comments
 (0)