Skip to content

Commit 9a7e633

Browse files
aykevldeadprogram
authored andcommitted
teensy36: add to smoketest
This required some changes to the UART code to get it to compile on Go 1.11.
1 parent 39b1f8b commit 9a7e633

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ smoketest:
327327
@$(MD5SUM) test.hex
328328
$(TINYGO) build -size short -o test.hex -target=teensy40 examples/blinky1
329329
@$(MD5SUM) test.hex
330+
$(TINYGO) build -size short -o test.hex -target=teensy36 examples/blinky1
331+
@$(MD5SUM) test.hex
330332
# test pwm
331333
$(TINYGO) build -size short -o test.hex -target=itsybitsy-m0 examples/pwm
332334
@$(MD5SUM) test.hex

src/machine/uart_nxpmk66f18.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func gosched()
6464

6565
// PutcharUART writes a byte to the UART synchronously, without using interrupts
6666
// or calling the scheduler
67-
func PutcharUART(u UART, c byte) {
67+
func PutcharUART(u *UART, c byte) {
6868
// ensure the UART has been configured
6969
if !u.SCGC.HasBits(u.SCGCMask) {
7070
u.configure(UARTConfig{}, false)
@@ -79,15 +79,13 @@ func PutcharUART(u UART, c byte) {
7979

8080
// PollUART manually checks a UART status and calls the ISR. This should only be
8181
// called by runtime.abort.
82-
func PollUART(u UART) {
82+
func PollUART(u *UART) {
8383
if u.SCGC.HasBits(u.SCGCMask) {
8484
u.handleStatusInterrupt(u.Interrupt)
8585
}
8686
}
8787

88-
type UART = *UARTData
89-
90-
type UARTData struct {
88+
type UART struct {
9189
*nxp.UART_Type
9290
SCGC *volatile.Register32
9391
SCGCMask uint32
@@ -103,11 +101,11 @@ type UARTData struct {
103101
Interrupt interrupt.Interrupt
104102
}
105103

106-
var UART0 = UARTData{UART_Type: nxp.UART0, SCGC: &nxp.SIM.SCGC4, SCGCMask: nxp.SIM_SCGC4_UART0, DefaultRX: defaultUART0RX, DefaultTX: defaultUART0TX}
107-
var UART1 = UARTData{UART_Type: nxp.UART1, SCGC: &nxp.SIM.SCGC4, SCGCMask: nxp.SIM_SCGC4_UART1, DefaultRX: defaultUART1RX, DefaultTX: defaultUART1TX}
108-
var UART2 = UARTData{UART_Type: nxp.UART2, SCGC: &nxp.SIM.SCGC4, SCGCMask: nxp.SIM_SCGC4_UART2, DefaultRX: defaultUART2RX, DefaultTX: defaultUART2TX}
109-
var UART3 = UARTData{UART_Type: nxp.UART3, SCGC: &nxp.SIM.SCGC4, SCGCMask: nxp.SIM_SCGC4_UART3, DefaultRX: defaultUART3RX, DefaultTX: defaultUART3TX}
110-
var UART4 = UARTData{UART_Type: nxp.UART4, SCGC: &nxp.SIM.SCGC1, SCGCMask: nxp.SIM_SCGC1_UART4, DefaultRX: defaultUART4RX, DefaultTX: defaultUART4TX}
104+
var UART0 = UART{UART_Type: nxp.UART0, SCGC: &nxp.SIM.SCGC4, SCGCMask: nxp.SIM_SCGC4_UART0, DefaultRX: defaultUART0RX, DefaultTX: defaultUART0TX}
105+
var UART1 = UART{UART_Type: nxp.UART1, SCGC: &nxp.SIM.SCGC4, SCGCMask: nxp.SIM_SCGC4_UART1, DefaultRX: defaultUART1RX, DefaultTX: defaultUART1TX}
106+
var UART2 = UART{UART_Type: nxp.UART2, SCGC: &nxp.SIM.SCGC4, SCGCMask: nxp.SIM_SCGC4_UART2, DefaultRX: defaultUART2RX, DefaultTX: defaultUART2TX}
107+
var UART3 = UART{UART_Type: nxp.UART3, SCGC: &nxp.SIM.SCGC4, SCGCMask: nxp.SIM_SCGC4_UART3, DefaultRX: defaultUART3RX, DefaultTX: defaultUART3TX}
108+
var UART4 = UART{UART_Type: nxp.UART4, SCGC: &nxp.SIM.SCGC1, SCGCMask: nxp.SIM_SCGC1_UART4, DefaultRX: defaultUART4RX, DefaultTX: defaultUART4TX}
111109

112110
func init() {
113111
UART0.Interrupt = interrupt.New(nxp.IRQ_UART0_RX_TX, UART0.handleStatusInterrupt)
@@ -118,11 +116,11 @@ func init() {
118116
}
119117

120118
// Configure the UART.
121-
func (u UART) Configure(config UARTConfig) {
119+
func (u *UART) Configure(config UARTConfig) {
122120
u.configure(config, true)
123121
}
124122

125-
func (u UART) configure(config UARTConfig, canSched bool) {
123+
func (u *UART) configure(config UARTConfig, canSched bool) {
126124
// from: serial_begin
127125

128126
if !u.Configured {
@@ -183,7 +181,7 @@ func (u UART) configure(config UARTConfig, canSched bool) {
183181
}
184182
}
185183

186-
func (u UART) Disable() {
184+
func (u *UART) Disable() {
187185
// from: serial_end
188186

189187
// check if the device has been enabled already
@@ -206,13 +204,13 @@ func (u UART) Disable() {
206204
u.Buffer.Clear()
207205
}
208206

209-
func (u UART) Flush() {
207+
func (u *UART) Flush() {
210208
for u.Transmitting.Get() != 0 {
211209
gosched()
212210
}
213211
}
214212

215-
func (u UART) handleStatusInterrupt(interrupt.Interrupt) {
213+
func (u *UART) handleStatusInterrupt(interrupt.Interrupt) {
216214
// from: uart0_status_isr
217215

218216
// receive
@@ -290,7 +288,7 @@ func (u UART) handleStatusInterrupt(interrupt.Interrupt) {
290288
}
291289

292290
// WriteByte writes a byte of data to the UART.
293-
func (u UART) WriteByte(c byte) error {
291+
func (u *UART) WriteByte(c byte) error {
294292
if !u.Configured {
295293
return ErrNotConfigured
296294
}

0 commit comments

Comments
 (0)