Skip to content

Commit 09f2c4e

Browse files
committed
More ZPU2.0 fixes
1 parent 2f29d92 commit 09f2c4e

File tree

7 files changed

+5
-145
lines changed

7 files changed

+5
-145
lines changed

hardware/zpuino/zpu/cores/zpuino/HardwareSerial.cpp

+1-21
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,12 @@
22

33
HardwareSerial Serial(1); /* 1st instance/slot */
44

5-
#ifdef ZPU15
6-
7-
void HardwareSerial::begin_slow(const unsigned int baudrate) {
8-
REG(1) = BAUDRATEGEN(baudrate)|BIT(UARTEN);
9-
}
10-
11-
void HardwareSerial::flush() {
12-
while (REG(1) & 4);
13-
}
14-
15-
size_t HardwareSerial::write(unsigned char c) {
16-
while ((REG(1) & 2)==2);
17-
REG(0) = c;
18-
return 1;
19-
}
20-
21-
#else
22-
235
void HardwareSerial::begin_slow(const unsigned int baudrate) {
246
REGISTER(ioslot,1) = BAUDRATEGEN(baudrate)|BIT(UARTEN);
257
}
268

279
size_t HardwareSerial::write(unsigned char c) {
2810
while ((REGISTER(ioslot,1) & 2)==2);
2911
REGISTER(ioslot,0) = c;
12+
return 1;
3013
}
31-
32-
33-
#endif

hardware/zpuino/zpu/cores/zpuino/HardwareSerial.h

-52
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,6 @@
66
#include "Stream.h"
77
#include "Print.h"
88

9-
#ifdef ZPU15
10-
#include "BaseDevice.h"
11-
12-
#define VENDOR_ZPUINO 0x08
13-
#define PRODUCT_ZPUINO_UART 0x11
14-
15-
namespace ZPUino {
16-
};
17-
18-
class HardwareSerial: public ZPUino::BaseDevice, public Stream
19-
{
20-
private:
21-
public:
22-
HardwareSerial(uint8_t instance=0xff): BaseDevice(instance) {}
23-
24-
__attribute__((always_inline)) inline void begin(const unsigned int baudrate) {
25-
if (deviceBegin(VENDOR_ZPUINO, PRODUCT_ZPUINO_UART)==0) {
26-
if (__builtin_constant_p(baudrate)) {
27-
REG(1) = BAUDRATEGEN(baudrate) | BIT(UARTEN);
28-
} else {
29-
begin_slow(baudrate);
30-
}
31-
}
32-
}
33-
void begin_slow(const unsigned int baudrate);
34-
35-
int available(void) {
36-
return (REG(1) & 1);
37-
}
38-
39-
virtual int read(void) {
40-
return REG(0);
41-
}
42-
43-
virtual void flush(void);
44-
45-
size_t write(uint8_t c);
46-
47-
virtual int peek() { return -1; }
48-
49-
using Print::write; // pull in write(str) and write(buf, size) from Print
50-
private:
51-
unsigned int ioslot;
52-
};
53-
54-
extern void serialEventRun(void) __attribute__((weak));
55-
56-
extern HardwareSerial Serial; /* 1st slot */
57-
extern HardwareSerial Serial1; /* 1st slot */
58-
59-
#else
609
class HardwareSerial: public Stream
6110
{
6211
private:
@@ -94,6 +43,5 @@ class HardwareSerial: public Stream
9443
extern void serialEventRun(void) __attribute__((weak));
9544

9645
extern HardwareSerial Serial; /* 1st slot */
97-
#endif
9846

9947
#endif

hardware/zpuino/zpu/cores/zpuino/register.h

-6
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,8 @@ typedef volatile unsigned int* register_t;
3131

3232
#define REGISTER(SLOT, y) *(volatile unsigned int*)(SLOT + (y<<2))
3333

34-
#ifndef ZPU15
3534
#define SPIBASE IO_SLOT(0)
3635
#define INTRBASE IO_SLOT(4)
37-
#else
38-
#define SPIBASE IO_SLOT(4)
39-
#define INTRBASE IO_SLOT(0)
40-
#define SYSCTLBASE INTRBASE
41-
#endif
4236

4337
#define UARTBASE IO_SLOT(1)
4438
#define GPIOBASE IO_SLOT(2)

hardware/zpuino/zpu20/boards.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
##############################################################
2-
zpuino15_papilio_one500.name=ZPUino 1.5 on Papilio One (500) board
2+
zpuino15_papilio_one500.name=ZPUino 2.0 on Papilio One (500) board
3+
zpuino15_papilio_one500.boardid=0xa5010f00
34
zpuino15_papilio_one500.upload.protocol=zpuino-serial
45
zpuino15_papilio_one500.upload.maximum_size=27648
56
zpuino15_papilio_one500.upload.size_sections=all
@@ -11,5 +12,5 @@ zpuino15_papilio_one500.build.mcu=zpu
1112
zpuino15_papilio_one500.build.ldscript=zpuelf.lds
1213
zpuino15_papilio_one500.build.pins=standard
1314
zpuino15_papilio_one500.build.toolchain=zpu
14-
zpuino15_papilio_one500.build.extra_flags=-D__ZPUINO_PAPILIO_ONE__ -DZPU15 -DBOARD_ID=0xA5010F00 -DBOARD_MEMORYSIZE=0x8000 -D__S3E_500__ -nostartfiles
15-
zpuino15_papilio_one500.build.extraSflags=-DBOARD_ID=0xA5010F00 -DZPU15
15+
zpuino15_papilio_one500.build.extra_flags=-D__ZPUINO_PAPILIO_ONE__ -DZPU20 -DBOARD_ID=0xA5010F00 -DBOARD_MEMORYSIZE=0x8000 -D__S3E_500__ -nostartfiles
16+
zpuino15_papilio_one500.build.extraSflags=-DBOARD_ID=0xA5010F00 -DZPU20

hardware/zpuino/zpu20/cores/zpuino/HardwareSerial.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
HardwareSerial Serial(1); /* 1st instance/slot */
44

5-
#ifdef ZPU15
6-
75
void HardwareSerial::begin_slow(const unsigned int baudrate) {
86
REG(1) = BAUDRATEGEN(baudrate)|BIT(UARTEN);
97
}
@@ -17,17 +15,3 @@ size_t HardwareSerial::write(unsigned char c) {
1715
REG(0) = c;
1816
return 1;
1917
}
20-
21-
#else
22-
23-
void HardwareSerial::begin_slow(const unsigned int baudrate) {
24-
REGISTER(ioslot,1) = BAUDRATEGEN(baudrate)|BIT(UARTEN);
25-
}
26-
27-
size_t HardwareSerial::write(unsigned char c) {
28-
while ((REGISTER(ioslot,1) & 2)==2);
29-
REGISTER(ioslot,0) = c;
30-
}
31-
32-
33-
#endif

hardware/zpuino/zpu20/cores/zpuino/HardwareSerial.h

-42
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#include <zpuino-types.h>
66
#include "Stream.h"
77
#include "Print.h"
8-
9-
#ifdef ZPU15
108
#include "BaseDevice.h"
119

1210
#define VENDOR_ZPUINO 0x08
@@ -56,44 +54,4 @@ extern void serialEventRun(void) __attribute__((weak));
5654
extern HardwareSerial Serial; /* 1st slot */
5755
extern HardwareSerial Serial1; /* 1st slot */
5856

59-
#else
60-
class HardwareSerial: public Stream
61-
{
62-
private:
63-
public:
64-
HardwareSerial(unsigned int b): ioslot(IO_SLOT(b)) {}
65-
66-
__attribute__((always_inline)) inline void begin(const unsigned int baudrate) {
67-
if (__builtin_constant_p(baudrate)) {
68-
REGISTER(ioslot,1) = BAUDRATEGEN(baudrate) | BIT(UARTEN);
69-
} else {
70-
begin_slow(baudrate);
71-
}
72-
}
73-
void begin_slow(const unsigned int baudrate);
74-
75-
int available(void) {
76-
return (REGISTER(ioslot,1) & 1);
77-
}
78-
79-
virtual int read(void) {
80-
return REGISTER(ioslot,0);
81-
}
82-
83-
virtual void flush(void) {};
84-
85-
size_t write(uint8_t c);
86-
87-
virtual int peek() { return -1; }
88-
89-
using Print::write; // pull in write(str) and write(buf, size) from Print
90-
private:
91-
unsigned int ioslot;
92-
};
93-
94-
extern void serialEventRun(void) __attribute__((weak));
95-
96-
extern HardwareSerial Serial; /* 1st slot */
97-
#endif
98-
9957
#endif

hardware/zpuino/zpu20/cores/zpuino/register.h

-5
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,9 @@ typedef volatile unsigned int* register_t;
3131

3232
#define REGISTER(SLOT, y) *(volatile unsigned int*)(SLOT + (y<<2))
3333

34-
#ifndef ZPU15
35-
#define SPIBASE IO_SLOT(0)
36-
#define INTRBASE IO_SLOT(4)
37-
#else
3834
#define SPIBASE IO_SLOT(4)
3935
#define INTRBASE IO_SLOT(0)
4036
#define SYSCTLBASE INTRBASE
41-
#endif
4237

4338
#define UARTBASE IO_SLOT(1)
4439
#define GPIOBASE IO_SLOT(2)

0 commit comments

Comments
 (0)