Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08b6748d79 | ||
|
|
bedfbda372 | ||
|
|
9fbf6ab35d |
+8
-33
@@ -24,16 +24,11 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
// Wacky deprecated AVR compatibility functions
|
||||
#include "stdlib_noniso.h"
|
||||
|
||||
#include "stdlib_noniso.h" // Wacky deprecated AVR compatibility functions
|
||||
#include "api/ArduinoAPI.h"
|
||||
#include "api/itoa.h" // ARM toolchain doesn't provide itoa etc, provide them
|
||||
#include <pins_arduino.h>
|
||||
|
||||
|
||||
// Required for the port*Register macros
|
||||
#include "hardware/gpio.h"
|
||||
|
||||
#include "hardware/gpio.h" // Required for the port*Register macros
|
||||
#include "debug_internal.h"
|
||||
|
||||
// Try and make the best of the old Arduino abs() macro. When in C++, use
|
||||
@@ -44,8 +39,10 @@
|
||||
#endif // abs
|
||||
#ifdef __cplusplus
|
||||
using std::abs;
|
||||
using std::round;
|
||||
#else
|
||||
#define abs(x) ((x)>0?(x):-(x))
|
||||
#define abs(x) ({ __typeof__(x) _x = (x); _x >= 0 ? _x : -_x; })
|
||||
#define round(x) ({ __typeof__(x) _x = (x); _x >= 0 ? (long)(_x + 0.5) : (long)(_x - 0.5); })
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -61,10 +58,6 @@ extern "C" {
|
||||
void interrupts();
|
||||
void noInterrupts();
|
||||
|
||||
// GPIO change/value interrupts
|
||||
void attachInterrupt(pin_size_t pin, voidFuncPtr callback, PinStatus mode);
|
||||
void detachInterrupt(pin_size_t pin);
|
||||
|
||||
// AVR compatibility macros...naughty and accesses the HW directly
|
||||
#define digitalPinToPort(pin) (0)
|
||||
#define digitalPinToBitMask(pin) (1UL << (pin))
|
||||
@@ -75,28 +68,14 @@ void detachInterrupt(pin_size_t pin);
|
||||
#define portInputRegister(port) ((volatile uint32_t*) sio_hw->gpio_in)
|
||||
#define portModeRegister(port) ((volatile uint32_t*) sio_hw->gpio_oe)
|
||||
|
||||
// IO config
|
||||
void pinMode(pin_size_t pinNumber, PinMode pinMode);
|
||||
|
||||
// SIO (GPIO)
|
||||
void digitalWrite(pin_size_t pinNumber, PinStatus status);
|
||||
PinStatus digitalRead(pin_size_t pinNumber);
|
||||
|
||||
// ADC
|
||||
int analogRead(pin_size_t pinNumber);
|
||||
// ADC RP2040-specific calls
|
||||
float analogReadTemp(); // Returns core temp in Centigrade
|
||||
|
||||
// PWM
|
||||
void analogWrite(pin_size_t pinNumber, int value);
|
||||
// PWM RP2040-specific calls
|
||||
void analogWriteFreq(uint32_t freq);
|
||||
void analogWriteRange(uint32_t range);
|
||||
void analogWriteResolution(int res);
|
||||
|
||||
// Timing
|
||||
void delay(unsigned long);
|
||||
void delayMicroseconds(unsigned int us);
|
||||
unsigned long millis();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -127,8 +106,4 @@ constexpr uint32_t __bitset(const int (&a)[N], size_t i = 0U) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// ARM toolchain doesn't provide itoa etc, provide them
|
||||
#include "api/itoa.h"
|
||||
|
||||
#endif // Arduino_h
|
||||
|
||||
@@ -153,7 +153,8 @@ static uint8_t *GetDescHIDReport(int *len) {
|
||||
// Invoked when received GET HID REPORT DESCRIPTOR
|
||||
// Application return pointer to descriptor
|
||||
// Descriptor contents must exist long enough for transfer to complete
|
||||
uint8_t const * tud_hid_descriptor_report_cb(void) {
|
||||
uint8_t const * tud_hid_descriptor_report_cb(uint8_t instance) {
|
||||
(void) instance;
|
||||
return GetDescHIDReport(nullptr);
|
||||
}
|
||||
|
||||
@@ -177,7 +178,7 @@ const uint8_t *tud_descriptor_configuration_cb(uint8_t index) {
|
||||
uint8_t hid_itf = __USBInstallSerial ? 2 : 0;
|
||||
static uint8_t hid_desc[TUD_HID_DESC_LEN] = {
|
||||
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
|
||||
TUD_HID_DESCRIPTOR(hid_itf, 0, HID_PROTOCOL_NONE, hid_report_len, EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10)
|
||||
TUD_HID_DESCRIPTOR(hid_itf, 0, HID_ITF_PROTOCOL_NONE, hid_report_len, EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10)
|
||||
};
|
||||
|
||||
uint8_t midi_itf = hid_itf + (hasHID ? 1 : 0);
|
||||
@@ -230,15 +231,7 @@ const uint16_t *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
|
||||
};
|
||||
|
||||
if (!idString[0]) {
|
||||
// Get ID string into human readable serial number on the first pass
|
||||
pico_unique_board_id_t id;
|
||||
pico_get_unique_board_id(&id);
|
||||
idString[0] = 0;
|
||||
for (auto i = 0; i < PICO_UNIQUE_BOARD_ID_SIZE_BYTES; i++) {
|
||||
char hx[3];
|
||||
sprintf(hx, "%02X", id.id[i]);
|
||||
strcat(idString, hx);
|
||||
}
|
||||
pico_get_unique_board_id_string(idString, sizeof(idString));
|
||||
}
|
||||
|
||||
uint8_t len;
|
||||
@@ -296,8 +289,9 @@ void __USBStart() {
|
||||
// Invoked when received GET_REPORT control request
|
||||
// Application must fill buffer report's content and return its length.
|
||||
// Return zero will cause the stack to STALL request
|
||||
uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) {
|
||||
// TODO not Implemented
|
||||
extern "C" uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) {
|
||||
// TODO not implemented
|
||||
(void) instance;
|
||||
(void) report_id;
|
||||
(void) report_type;
|
||||
(void) buffer;
|
||||
@@ -308,8 +302,9 @@ uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type,
|
||||
|
||||
// Invoked when received SET_REPORT control request or
|
||||
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
|
||||
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) {
|
||||
extern "C" void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) {
|
||||
// TODO set LED based on CAPLOCK, NUMLOCK etc...
|
||||
(void) instance;
|
||||
(void) report_id;
|
||||
(void) report_type;
|
||||
(void) buffer;
|
||||
@@ -317,4 +312,3 @@ void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uin
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ int SerialUSB::peek() {
|
||||
}
|
||||
|
||||
uint8_t c;
|
||||
return tud_cdc_peek(0, &c) ? (int) c : -1;
|
||||
return tud_cdc_peek(&c) ? (int) c : -1;
|
||||
}
|
||||
|
||||
int SerialUSB::read() {
|
||||
|
||||
@@ -88,6 +88,7 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration) {
|
||||
newTone->alarm = 0;
|
||||
}
|
||||
}
|
||||
pio_sm_clear_fifos(newTone->pio, newTone->sm); // Remove any old updates that haven't yet taken effect
|
||||
pio_sm_put_blocking(newTone->pio, newTone->sm, RP2040::usToPIOCycles(us));
|
||||
pio_sm_set_enabled(newTone->pio, newTone->sm, true);
|
||||
|
||||
|
||||
Binary file not shown.
@@ -12,8 +12,8 @@
|
||||
#define _PICO_VERSION_H
|
||||
|
||||
#define PICO_SDK_VERSION_MAJOR 1
|
||||
#define PICO_SDK_VERSION_MINOR 1
|
||||
#define PICO_SDK_VERSION_REVISION 2
|
||||
#define PICO_SDK_VERSION_STRING "1.1.2"
|
||||
#define PICO_SDK_VERSION_MINOR 2
|
||||
#define PICO_SDK_VERSION_REVISION 0
|
||||
#define PICO_SDK_VERSION_STRING "1.2.0"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -135,6 +135,7 @@ void Servo::writeMicroseconds(int value) {
|
||||
value = constrain(value, _minUs, _maxUs);
|
||||
_valueUs = value;
|
||||
if (_attached) {
|
||||
pio_sm_clear_fifos(_pio, _smIdx); // Remove any old updates that haven't yet taken effect
|
||||
pio_sm_put_blocking(_pio, _smIdx, RP2040::usToPIOCycles(value) / 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (int i = 100; i < 10000; i += 5) {
|
||||
for (int i = 100; i < 10000; i += 1) {
|
||||
tone(TONEPIN, i);
|
||||
delayMicroseconds(20);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
Submodule pico-sdk updated: afc10f3599...bfcbefafc5
Reference in New Issue
Block a user