Skip to content

RP2040: Customizing

Paciente8159 edited this page Apr 17, 2023 · 7 revisions

µCNC for RP2040 can be configured/customized to fit different boards like Pico and Pico W

Jump to section

Customizing boardmap

µCNC for RP2040 can be customized either using the Web Config Tool or by manually modifing the source code files. For the latest method most configurations and pin assigning should be done in the corresponding boardmap file inside the uCNC/src/hal/boards/rp2040/ directory and then the respective board file.

Configure IO pin

An HAL pin need to be mapped to a physical IO pin. The way this is done is by defining the IO BIT. There is no need do define IO PORT on this MCU. This must be performed for every used pin. RP2040 PORT is ignored. This is similar to the general customization instructions

Input pin options

Weak input pull-ups

All input pins can have a weak pull-up activated to drive them high if unconnected. This is similar to the general customization instructions

External interrupt feature

All pins all repeatedly read by a soft polling routine. But for special function pins an interrupt driven event to force a reading and respective action can be also activated. This causes the response to be immediate and not depend on the pin reading routine cycle. To make an input pin interruptable just declare #define <pin_name>_ISR.

For RP2040 the pin mapping can be checked here. RPi Pico W pin mapping

Configure communications

This is similar to the general customization instructions

Configure pwm clock

PWM clock is internally set in the mcumap file and there is no need to configure it. The only thing needed is to choose the PWM pin output.

/Setup PWM 
#define PWM0_BIT 8	//assigns PWM0 pin 

Configure analog channel

For analog pins, like in PWM the only thing you need to define is the pin. Arduino framework takes care of the rest:

#define ANALOG0_BIT 0

To make a read just do

uint8_t value = mcu_get_analog(ANALOG0);

Configure step generator timer

All RP2040 timers are internally set in the mcumap. No need to configure.

Configure servo pins

This is similar to the step generator timer

Configure WiFi

WiFi saves the last state. On power on the previous state (enabled or disabled) will automatically be reinstated.

WiFi interface exposes the following system commands that can be used to configure and control WiFi:

$wifion - this enables WiFi. When this command is issued all changes made to the WiFi settings are stored.
$wifioff - this disables WiFi. When this command is issued all changes made to the WiFi settings are stored.
$wifireset - this resets all WiFi settings.
$wifisave - this saves all WiFi settings. Settings will only be in effect after disabling and enabling the WiFi.
$wifiscan - scans all available WiFi AP's.
$wifissid - gets the current defined AP SSID.
$wifissid <ssid> - sets the current defined AP SSID.
$wifipass <pass> - sets the current WiFi password.