[realtek-ambz] Fix PWM output

This commit is contained in:
Kuba Szczodrzyński
2022-06-06 14:52:11 +02:00
parent 48f6210607
commit f72dd3b7d7
4 changed files with 11 additions and 18 deletions

View File

@@ -99,27 +99,27 @@ Note: this list will probably change with each functionality update.
  | `realtek-ambz`   | `realtek-ambz`
--------------------|--------------- --------------------|---------------
Core functions | ✔️ Core functions | ✔️
GPIO/PWM/IRQ | ✔️//✔️ GPIO/PWM/IRQ | ✔️/✔️/✔️
Analog input | ❓ Analog input | ❓
UART I/O | ✔️ UART I/O | ✔️
Flash I/O | Flash I/O | ✔️
**CORE LIBRARIES** | **CORE LIBRARIES** |
SoftwareSerial | ❌ SoftwareSerial | ❌
SPI | ❌ SPI | ❌
Wire | ❗ Wire | ❗
**OTHER LIBRARIES** | **OTHER LIBRARIES** |
Wi-Fi STA/AP/Mixed | ✔️ Wi-Fi STA/AP/Mixed | ✔️
Wi-Fi Client (SSL) | ✔️ (✔️)
Wi-Fi Server | ✔️
Wi-Fi Events | ✔️ Wi-Fi Events | ✔️
TCP Client (SSL) | ✔️ (✔️)
TCP Server | ✔️
IPv6 | ❌ IPv6 | ❌
HTTP Client (SSL) | ✔️ (✔️) HTTP Client (SSL) | ✔️ (✔️)
HTTP Server | ✔️ HTTP Server | ✔️
NVS / Preferences | ✔️ NVS / Preferences |
SPIFFS | ❌ SPIFFS | ❌
BLE | - BLE | -
NTP | ❌ NTP | ❌
OTA | OTA | ✔️
MDNS | ✔️ MDNS | ✔️
MQTT | ✅ MQTT | ✅
SD | ❌ SD | ❌

View File

@@ -126,7 +126,7 @@ void analogWrite(pin_size_t pinNumber, int value) {
pwmout_t *obj; pwmout_t *obj;
if ((g_APinDescription[pinNumber].ulPinAttribute & PIO_PWM) == PIO_PWM) { if ((g_APinDescription[pinNumber].ulPinAttribute & PIO_PWM) == PIO_PWM) {
/* Handle */ float percent = value * 1.0 / (1 << _writeResolution);
if (g_APinDescription[pinNumber].ulPinType != PIO_PWM) { if (g_APinDescription[pinNumber].ulPinType != PIO_PWM) {
if ((g_APinDescription[pinNumber].ulPinType == PIO_GPIO) || if ((g_APinDescription[pinNumber].ulPinType == PIO_GPIO) ||
(g_APinDescription[pinNumber].ulPinType == PIO_GPIO_IRQ)) { (g_APinDescription[pinNumber].ulPinType == PIO_GPIO_IRQ)) {
@@ -136,16 +136,13 @@ void analogWrite(pin_size_t pinNumber, int value) {
pwmout_t *obj = (pwmout_t *)gpio_pin_struct[pinNumber]; pwmout_t *obj = (pwmout_t *)gpio_pin_struct[pinNumber];
pwmout_init(obj, g_APinDescription[pinNumber].pinname); pwmout_init(obj, g_APinDescription[pinNumber].pinname);
pwmout_period_us(obj, _writePeriod); pwmout_period_us(obj, _writePeriod);
pwmout_write(obj, value * 1.0 / (1 << _writeResolution)); pwmout_write(obj, percent);
g_APinDescription[pinNumber].ulPinType = PIO_PWM; g_APinDescription[pinNumber].ulPinType = PIO_PWM;
g_APinDescription[pinNumber].ulPinMode = PWM_MODE_ENABLED; g_APinDescription[pinNumber].ulPinMode = PWM_MODE_ENABLED;
} else { } else {
pwmout_t *obj = (pwmout_t *)gpio_pin_struct[pinNumber]; pwmout_t *obj = (pwmout_t *)gpio_pin_struct[pinNumber];
pwmout_period_us(obj, _writePeriod); // pwmout_period_us(obj, _writePeriod);
pwmout_write(obj, value * 1.0 / (1 << _writeResolution)); pwmout_write(obj, percent);
/* if ( g_APinDescription[pinNumber].ulPinMode == PWM_MODE_DISABLED ) {
HAL_Pwm_Enable( &obj->pwm_hal_adp );
} */
} }
} }
} }

View File

@@ -2,13 +2,9 @@
``` ```
arm-none-eabi-gcc-ar xo lib_rtlstd.a arm-none-eabi-gcc-ar xo lib_rtlstd.a
arm-none-eabi-objcopy -N __aeabi_fsub rtl_eabi_cast_ram.o rm rtl_eabi_cast_ram.o
arm-none-eabi-objcopy -N __aeabi_fadd rtl_eabi_cast_ram.o
arm-none-eabi-objcopy -N __aeabi_ui2f rtl_eabi_cast_ram.o
arm-none-eabi-objcopy -N __aeabi_i2f rtl_eabi_cast_ram.o
arm-none-eabi-objcopy --strip-debug --strip-unneeded ram_libc.o arm-none-eabi-objcopy --strip-debug --strip-unneeded ram_libc.o
arm-none-eabi-objcopy --strip-debug --strip-unneeded ram_libgloss_retarget.o arm-none-eabi-objcopy --strip-debug --strip-unneeded ram_libgloss_retarget.o
arm-none-eabi-objcopy --strip-debug --strip-unneeded rtl_eabi_cast_ram.o
arm-none-eabi-objcopy --strip-debug --strip-unneeded rtl_math_ram.o arm-none-eabi-objcopy --strip-debug --strip-unneeded rtl_math_ram.o
arm-none-eabi-gcc-ar qs lib_rtlstd_patch.a *.o arm-none-eabi-gcc-ar qs lib_rtlstd_patch.a *.o
``` ```