Skip to content
Closed
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
8 changes: 5 additions & 3 deletions src/machine/board_ae_rp2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

package machine

func init() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid init functions in machine package always unless absolutely required. I'd like to understand the problem you are trying to solve so I can propose a better way of doing this.

SysClockFrequency = Freq133MHz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exposes new API on machine package. Why would we want to expose a variable that can be modified by users? Is CPUFrequency() not good enough for your applications?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CPUFrequency() only gave me what the current sysClk frequency was and not the ability to overclock or under clock. There are several use cases for being able to change system frequency at runtime like peri synchronization, power management etc. This change makes changing clock speeds on the fly possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think changing clock frequency at runtime is in scope of this PR. If for nothing else, runtime clock support doesn't answer the question of what to do about all the code that assumes CPUFrequency never changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree that any changes about clock frequency should be in a separate PR.

xoscFreq = Freq12MHz
}

// GPIO pins
const (
GP0 Pin = GPIO0
Expand Down Expand Up @@ -31,9 +36,6 @@ const (
GP27 Pin = GPIO27
GP28 Pin = GPIO28
GP29 Pin = GPIO29

// Onboard crystal oscillator frequency, in MHz.
xoscFreq = 12 // MHz
)

// I2C Default pins on Raspberry Pico.
Expand Down
127 changes: 127 additions & 0 deletions src/machine/board_amken-max14-rp2350b.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
//go:build amken_max14

// This file contains the pin mappings for the Amken Max14 Intelligent Motion controller board.
//

package machine

//const (
// // Onboard crystal oscillator frequency, in MHz.
// xoscFreq uint32 = 12 // MHz
//)

func init() {
SysClockFrequency = Freq240MHz
xoscFreq = Freq12MHz
}

// I2C Default pins on Raspberry Pico.
const (
I2C0_SDA_PIN = NoPin
I2C0_SCL_PIN = NoPin

I2C1_SDA_PIN = GPIO34
I2C1_SCL_PIN = GPIO35

I2C_SDA_PIN = I2C1_SDA_PIN
I2C_SCL_PIN = I2C1_SCL_PIN
)

// SPI default pins
const (
// Default Serial Clock Bus 0 for SPI communications
SPI0_SCK_PIN = GPIO42
// Default Serial Out Bus 0 for SPI communications
SPI0_SDO_PIN = GPIO43 // Tx
// Default Serial In Bus 0 for SPI communications
SPI0_SDI_PIN = GPIO40 // Rx

// Default Serial Clock Bus 1 for SPI communications
SPI1_SCK_PIN = GPIO2
// Default Serial Out Bus 1 for SPI communications
SPI1_SDO_PIN = GPIO3 // Tx
// Default Serial In Bus 1 for SPI communications
SPI1_SDI_PIN = GPIO0 // Rx
)

// UART pins
const (
UART0_TX_PIN = GPIO0
UART0_RX_PIN = GPIO1
UART_TX_PIN = UART0_TX_PIN
UART_RX_PIN = UART0_RX_PIN
)

var DefaultUART = UART0

var StepperCS = [8]Pin{
GPIO36, GPIO37, GPIO38, GPIO39,
GPIO20, GPIO24, GPIO27, GPIO28,
}

const (
COMM_CS_PIN = GPIO1

MOTOR1_CS = GPIO36
MOTOR2_CS = GPIO37
MOTOR3_CS = GPIO38
MOTOR4_CS = GPIO39
MOTOR5_CS = GPIO20
MOTOR6_CS = GPIO24
MOTOR7_CS = GPIO27
MOTOR8_CS = GPIO28

MOTOR1_DIR_PIN = GPIO9
MOTOR2_DIR_PIN = GPIO13
MOTOR3_DIR_PIN = GPIO15
MOTOR4_DIR_PIN = GPIO17
MOTOR5_DIR_PIN = GPIO19
MOTOR6_DIR_PIN = GPIO23
MOTOR7_DIR_PIN = GPIO25
MOTOR8_DIR_PIN = GPIO30

MOTOR1_STEP_PIN = GPIO10
MOTOR2_STEP_PIN = GPIO12
MOTOR3_STEP_PIN = GPIO14
MOTOR4_STEP_PIN = GPIO16
MOTOR5_STEP_PIN = GPIO18
MOTOR6_STEP_PIN = GPIO22
MOTOR7_STEP_PIN = GPIO26
MOTOR8_STEP_PIN = GPIO29
)

const (
A2D1 = ADC6
A2D2 = ADC5
)

const (
END_STOP_MUX1 = GPIO33
END_STOP_MUX2 = GPIO32
END_STOP_MUX3 = GPIO31
)

const (
PWM_5V_1 = GPIO8
PWM_5V_2 = GPIO11
LOWPWR_PWM_24V_1 = GPIO21
LOWPWR_PWM_24V_2 = GPIO47
HIPWR_PWM_24V = GPIO7
MEDPWR_PWM_24V = GPIO6
)

const (
NEOPIXEL_1 = GPIO41
NEOPIXEL_2 = GPIO44
)

// USB identifiers
const (
usb_STRING_PRODUCT = "Max14 Intelligent Motion Controller"
usb_STRING_MANUFACTURER = "AmkenLLC"
)

var (
usb_VID uint16 = 0x2E8A
usb_PID uint16 = 0x7303
)
7 changes: 4 additions & 3 deletions src/machine/board_badger2040-w.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ SPI0_CS_PIN Pin = QSPI_CS
)

// Onboard crystal oscillator frequency, in MHz.
const (
xoscFreq = 12 // MHz
)
func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}

// USB CDC identifiers
const (
Expand Down
8 changes: 4 additions & 4 deletions src/machine/board_badger2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ SPI0_CS_PIN Pin = QSPI_CS
*/
)

// Onboard crystal oscillator frequency, in MHz.
const (
xoscFreq = 12 // MHz
)
func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}

// USB CDC identifiers
const (
Expand Down
8 changes: 5 additions & 3 deletions src/machine/board_challenger_rp2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

package machine

func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}

const (
LED = GPIO24

// Onboard crystal oscillator frequency, in MHz.
xoscFreq = 12 // MHz
)

// GPIO Pins
Expand Down
8 changes: 5 additions & 3 deletions src/machine/board_elecrow-rp2040-w5.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ const (

// Onboard LED
LED Pin = GPIO25

// Onboard crystal oscillator frequency, in MHz.
xoscFreq = 12 // MHz
)

// I2C Default pins on Raspberry Pico.
Expand Down Expand Up @@ -92,3 +89,8 @@ var (
usb_VID uint16 = 0x2E8A
usb_PID uint16 = 0x000A
)

func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}
8 changes: 5 additions & 3 deletions src/machine/board_elecrow-rp2350-w5.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ const (

// Onboard LED
LED Pin = GPIO25

// Onboard crystal oscillator frequency, in MHz.
xoscFreq = 12 // MHz
)

// I2C Default pins on Raspberry Pico.
Expand Down Expand Up @@ -92,3 +89,8 @@ var (
usb_VID uint16 = 0x2E8A
usb_PID uint16 = 0x000F
)

func init() {
SysClockFrequency = Freq150MHz
xoscFreq = Freq12MHz
}
6 changes: 4 additions & 2 deletions src/machine/board_feather_rp2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

package machine

// Onboard crystal oscillator frequency, in MHz.
const xoscFreq = 12 // MHz
func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}

// GPIO Pins
const (
Expand Down
10 changes: 5 additions & 5 deletions src/machine/board_gopher-badge.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
GPIO8 Pin = GPIO8
GPIO9 Pin = GPIO9*/

PENIRQ Pin = GPIO13

Check failure on line 19 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / assert-test-linux

undefined: GPIO13

Check failure on line 19 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / build-macos (macos-14)

undefined: GPIO13

LED Pin = GPIO2

Check failure on line 21 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / assert-test-linux

undefined: GPIO2

Check failure on line 21 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / build-macos (macos-14)

undefined: GPIO2
NEOPIXELS Pin = GPIO15

Check failure on line 22 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / assert-test-linux

undefined: GPIO15

Check failure on line 22 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / build-macos (macos-14)

undefined: GPIO15
WS2812 Pin = GPIO15

Check failure on line 23 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / assert-test-linux

undefined: GPIO15

Check failure on line 23 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / build-macos (macos-14)

undefined: GPIO15

BUTTON_A Pin = GPIO10

Check failure on line 25 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / assert-test-linux

undefined: GPIO10

Check failure on line 25 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / build-macos (macos-14)

undefined: GPIO10
BUTTON_B Pin = GPIO11

Check failure on line 26 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / assert-test-linux

undefined: GPIO11

Check failure on line 26 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / build-macos (macos-14)

undefined: GPIO11
BUTTON_LEFT Pin = GPIO25

Check failure on line 27 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / assert-test-linux

undefined: GPIO25

Check failure on line 27 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / build-macos (macos-14)

undefined: GPIO25
BUTTON_UP Pin = GPIO24

Check failure on line 28 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / assert-test-linux

undefined: GPIO24

Check failure on line 28 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / build-macos (macos-14)

undefined: GPIO24
BUTTON_RIGHT Pin = GPIO22

Check failure on line 29 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / assert-test-linux

undefined: GPIO22

Check failure on line 29 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / build-macos (macos-14)

undefined: GPIO22
BUTTON_DOWN Pin = GPIO23

Check failure on line 30 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / assert-test-linux

undefined: GPIO23

Check failure on line 30 in src/machine/board_gopher-badge.go

View workflow job for this annotation

GitHub Actions / build-macos (macos-14)

undefined: GPIO23

TFT_RST Pin = GPIO21
TFT_SDI Pin = GPIO19
Expand Down Expand Up @@ -61,11 +61,6 @@
SPI1_SDI_PIN Pin = NoPin
)

// Onboard crystal oscillator frequency, in MHz.
const (
xoscFreq = 12 // MHz
)

// USB CDC identifiers
const (
usb_STRING_PRODUCT = "Gopher Badge"
Expand All @@ -88,3 +83,8 @@
)

var DefaultUART = UART1

func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}
6 changes: 4 additions & 2 deletions src/machine/board_kb2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

package machine

// Onboard crystal oscillator frequency, in MHz.
const xoscFreq = 12 // MHz
func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}

// GPIO Pins
const (
Expand Down
8 changes: 5 additions & 3 deletions src/machine/board_macropad-rp2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ package machine

const (
NeopixelCount = 12

// Onboard crystal oscillator frequency, in MHz.
xoscFreq = 12 // MHz
)

const (
Expand Down Expand Up @@ -85,3 +82,8 @@ var (
usb_VID uint16 = 0x239A
usb_PID uint16 = 0x8107
)

func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}
7 changes: 4 additions & 3 deletions src/machine/board_nano-rp2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ const (
)

// Onboard crystal oscillator frequency, in MHz.
const (
xoscFreq = 12 // MHz
)
func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}

// USB CDC identifiers
// https://github.com/arduino/ArduinoCore-mbed/blob/master/variants/NANO_RP2040_CONNECT/pins_arduino.h
Expand Down
8 changes: 5 additions & 3 deletions src/machine/board_pico.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ const (

// Onboard LED
LED Pin = GPIO25

// Onboard crystal oscillator frequency, in MHz.
xoscFreq = 12 // MHz
)

// I2C Default pins on Raspberry Pico.
Expand Down Expand Up @@ -86,3 +83,8 @@ var (
usb_VID uint16 = 0x2E8A
usb_PID uint16 = 0x000A
)

func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}
9 changes: 7 additions & 2 deletions src/machine/board_pico2.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

package machine

func init() {
SysClockFrequency = Freq150MHz
xoscFreq = Freq12MHz
}

// GPIO pins
const (
GP0 Pin = GPIO0
Expand Down Expand Up @@ -34,8 +39,8 @@ const (
// Onboard LED
LED Pin = GPIO25

// Onboard crystal oscillator frequency, in MHz.
xoscFreq = 12 // MHz
//// Onboard crystal oscillator frequency, in MHz.
//xoscFreq = 12 // MHz
)

// I2C Default pins on Raspberry Pico.
Expand Down
6 changes: 4 additions & 2 deletions src/machine/board_qtpy_rp2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

package machine

// Onboard crystal oscillator frequency, in MHz.
const xoscFreq = 12 // MHz
func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}

// GPIO Pins
const (
Expand Down
6 changes: 4 additions & 2 deletions src/machine/board_thingplus_rp2040.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

package machine

// Onboard crystal oscillator frequency, in MHz.
const xoscFreq = 12 // MHz
func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}

// GPIO Pins
const (
Expand Down
7 changes: 4 additions & 3 deletions src/machine/board_thumby.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ const (
)

// Onboard crystal oscillator frequency, in MHz.
const (
xoscFreq = 12 // MHz
)
func init() {
SysClockFrequency = Freq133MHz
xoscFreq = Freq12MHz
}

// USB CDC identifiers
const (
Expand Down
Loading
Loading