Merge pull request #2772 from kwagyeman/kwabena/remove_buzzer
Some checks are pending
🔥 Firmware Build / build-firmware (ARDUINO_GIGA) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_33_BLE_SENSE) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_RP2040_CONNECT) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NICLA_VISION) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_PORTENTA_H7) (push) Waiting to run
🔥 Firmware Build / build-firmware (DOCKER) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV2) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4P) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMVPT) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_AE3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_N6) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_RT1060) (push) Waiting to run
🔥 Firmware Build / code-size-report (push) Blocked by required conditions
🔥 Firmware Build / stable-release (push) Blocked by required conditions
🔥 Firmware Build / development-release (push) Blocked by required conditions

ports/stm32: Remove old buzzer module.
This commit is contained in:
Ibrahim Abdelkader 2025-07-21 11:03:33 +03:00 committed by GitHub
commit c736ea4076
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 29 additions and 197 deletions

View File

@ -191,11 +191,6 @@ MPY_CFLAGS += -DMICROPY_PY_TV=1
MPY_MKARGS += MICROPY_PY_TV=1
endif
ifeq ($(MICROPY_PY_BUZZER), 1)
MPY_CFLAGS += -DMICROPY_PY_BUZZER=1
MPY_MKARGS += MICROPY_PY_BUZZER=1
endif
ifeq ($(CUBEAI), 1)
MPY_CFLAGS += -DMICROPY_PY_CUBEAI=1
MPY_MKARGS += MICROPY_PY_CUBEAI=1

View File

@ -20,4 +20,3 @@ MICROPY_PY_ULAB=1
MICROPY_PY_AUDIO=1
MICROPY_PY_DISPLAY = 0
MICROPY_PY_TV = 0
MICROPY_PY_BUZZER = 0

View File

@ -10,5 +10,4 @@ set(MICROPY_PY_AUDIO 1)
set(MICROPY_PY_MICRO_SPEECH 0)
set(MICROPY_PY_DISPLAY 0)
set(MICROPY_PY_TV 0)
set(MICROPY_PY_BUZZER 0)
set(CMSIS_MCU_H "RP2040.h")

View File

@ -31,6 +31,5 @@ MICROPY_BLUETOOTH_NIMBLE = 1
MICROPY_PY_AUDIO = 1
MICROPY_PY_DISPLAY = 0
MICROPY_PY_TV = 0
MICROPY_PY_BUZZER = 0
MICROPY_PY_ML = 1
MICROPY_PY_ML_TFLM = 1

View File

@ -29,7 +29,6 @@ MICROPY_BLUETOOTH_NIMBLE = 1
MICROPY_PY_AUDIO = 1
MICROPY_PY_DISPLAY = 1
MICROPY_PY_TV = 1
MICROPY_PY_BUZZER = 0
MICROPY_PY_OPENAMP = 1
MICROPY_PY_OPENAMP_REMOTEPROC = 1
MICROPY_PY_ML = 1

View File

@ -15,7 +15,6 @@ MICROPY_PY_FIR = 1
MICROPY_PY_WINC1500 = 1
MICROPY_PY_DISPLAY = 1
MICROPY_PY_TV = 1
MICROPY_PY_BUZZER = 0
MICROPY_PY_LWIP = 0
MICROPY_PY_SSL = 1
MICROPY_PY_SSL_ECDSA_SIGN_ALT = 0

View File

@ -16,7 +16,6 @@ MICROPY_PY_ULAB = 1
MICROPY_PY_WINC1500 = 1
MICROPY_PY_DISPLAY = 1
MICROPY_PY_TV = 1
MICROPY_PY_BUZZER = 0
MICROPY_PY_ML = 1
MICROPY_PY_ML_TFLM = 1
MICROPY_PY_LWIP = 0

View File

@ -17,7 +17,6 @@ MICROPY_PY_ULAB = 1
MICROPY_PY_WINC1500 = 1
MICROPY_PY_DISPLAY = 1
MICROPY_PY_TV = 1
MICROPY_PY_BUZZER = 0
MICROPY_PY_ML = 1
MICROPY_PY_ML_TFLM = 1
MICROPY_PY_LWIP = 0

View File

@ -18,7 +18,6 @@ MICROPY_PY_ULAB = 1
MICROPY_PY_WINC1500 = 1
MICROPY_PY_DISPLAY = 1
MICROPY_PY_TV = 1
MICROPY_PY_BUZZER = 0
MICROPY_PY_ML = 1
MICROPY_PY_ML_TFLM = 1
MICROPY_PY_LWIP = 0

View File

@ -367,16 +367,4 @@
#define OMV_FIR_LEPTON_MCLK_TIM_RELEASE_RESET() __HAL_RCC_TIM15_RELEASE_RESET()
#define OMV_FIR_LEPTON_MCLK_TIM_PCLK_FREQ() HAL_RCC_GetPCLK2Freq()
// Buzzer
#define OMV_BUZZER_PIN (&omv_pin_A1_TIM2)
#define OMV_BUZZER_FREQ (4000)
#define OMV_BUZZER_TIM (TIM2)
#define OMV_BUZZER_TIM_CHANNEL (TIM_CHANNEL_2)
#define OMV_BUZZER_TIM_CLK_ENABLE() __HAL_RCC_TIM2_CLK_ENABLE()
#define OMV_BUZZER_TIM_CLK_DISABLE() __HAL_RCC_TIM2_CLK_DISABLE()
#define OMV_BUZZER_TIM_FORCE_RESET() __HAL_RCC_TIM2_FORCE_RESET()
#define OMV_BUZZER_TIM_RELEASE_RESET() __HAL_RCC_TIM2_RELEASE_RESET()
#define OMV_BUZZER_TIM_PCLK_FREQ() HAL_RCC_GetPCLK1Freq()
#endif //__OMV_BOARDCONFIG_H__

View File

@ -17,7 +17,6 @@ MICROPY_PY_ULAB = 1
MICROPY_PY_WINC1500 = 1
MICROPY_PY_DISPLAY = 1
MICROPY_PY_TV = 1
MICROPY_PY_BUZZER = 1
MICROPY_PY_ML = 1
MICROPY_PY_ML_TFLM = 1
MICROPY_PY_LWIP = 0

View File

@ -24,6 +24,5 @@ MICROPY_PY_BLUETOOTH = 1
MICROPY_BLUETOOTH_NIMBLE = 1
MICROPY_PY_DISPLAY = 1
MICROPY_PY_TV = 1
MICROPY_PY_BUZZER = 0
MICROPY_PY_ML = 1
MICROPY_PY_ML_TFLM = 1

View File

@ -9,5 +9,4 @@ set(MICROPY_BLUETOOTH_NIMBLE 0)
set(MICROPY_PY_AUDIO 0)
set(MICROPY_PY_DISPLAY 0)
set(MICROPY_PY_TV 0)
set(MICROPY_PY_BUZZER 0)
set(CMSIS_MCU_H "RP2040.h")

View File

@ -101,9 +101,6 @@ soft_reset:
#if MICROPY_PY_TV
py_tv_init0();
#endif
#if MICROPY_PY_BUZZER
py_buzzer_init0();
#endif // MICROPY_PY_BUZZER
imlib_init_all();
readline_init0();
fb_alloc_init0();

View File

@ -92,7 +92,6 @@
#include "py_image.h"
#include "py_fir.h"
#include "py_tv.h"
#include "py_buzzer.h"
#include "py_imu.h"
#include "py_audio.h"
@ -210,9 +209,6 @@ soft_reset:
#if MICROPY_PY_TV
py_tv_init0();
#endif
#if MICROPY_PY_BUZZER
py_buzzer_init0();
#endif // MICROPY_PY_BUZZER
imlib_init_all();
readline_init0();
pin_init0();

View File

@ -1,119 +0,0 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright (C) 2013-2024 OpenMV, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Buzzer Python module.
*/
#include "py/obj.h"
#include "omv_boardconfig.h"
#if MICROPY_PY_BUZZER
#include STM32_HAL_H
#include "omv_gpio.h"
static TIM_HandleTypeDef buzzer_tim_handle = {};
static int buzzer_freq = OMV_BUZZER_FREQ;
static int buzzer_duty = 0;
static void buzzer_setup(int freq, int duty) {
int tclk = OMV_BUZZER_TIM_PCLK_FREQ() * 2;
int period = (tclk / freq) - 1;
int pulse = (period * duty) / 510;
if (((buzzer_duty <= 0) || (255 < buzzer_duty)) && (0 < duty) && (duty <= 255)) {
omv_gpio_config(OMV_BUZZER_PIN, OMV_GPIO_MODE_ALT, OMV_GPIO_PULL_NONE, OMV_GPIO_SPEED_LOW, -1);
buzzer_tim_handle.Instance = OMV_BUZZER_TIM;
buzzer_tim_handle.Init.Prescaler = 0;
buzzer_tim_handle.Init.CounterMode = TIM_COUNTERMODE_UP;
buzzer_tim_handle.Init.Period = period;
buzzer_tim_handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
buzzer_tim_handle.Init.RepetitionCounter = 0;
buzzer_tim_handle.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
TIM_OC_InitTypeDef buzzer_tim_oc_handle;
buzzer_tim_oc_handle.Pulse = pulse;
buzzer_tim_oc_handle.OCMode = TIM_OCMODE_PWM1;
buzzer_tim_oc_handle.OCPolarity = TIM_OCPOLARITY_HIGH;
buzzer_tim_oc_handle.OCNPolarity = TIM_OCNPOLARITY_HIGH;
buzzer_tim_oc_handle.OCFastMode = TIM_OCFAST_DISABLE;
buzzer_tim_oc_handle.OCIdleState = TIM_OCIDLESTATE_RESET;
buzzer_tim_oc_handle.OCNIdleState = TIM_OCNIDLESTATE_RESET;
HAL_TIM_PWM_Init(&buzzer_tim_handle);
HAL_TIM_PWM_ConfigChannel(&buzzer_tim_handle, &buzzer_tim_oc_handle, OMV_BUZZER_TIM_CHANNEL);
HAL_TIM_PWM_Start(&buzzer_tim_handle, OMV_BUZZER_TIM_CHANNEL);
} else if ((0 < buzzer_duty) && (buzzer_duty <= 255) && ((duty <= 0) || (255 < duty))) {
HAL_TIM_PWM_Stop(&buzzer_tim_handle, OMV_BUZZER_TIM_CHANNEL);
HAL_TIM_PWM_DeInit(&buzzer_tim_handle);
omv_gpio_deinit(OMV_BUZZER_PIN);
} else if ((0 < buzzer_duty) && (buzzer_duty <= 255) && (0 < duty) && (duty <= 255)) {
__HAL_TIM_SET_AUTORELOAD(&buzzer_tim_handle, period);
__HAL_TIM_SET_COMPARE(&buzzer_tim_handle, OMV_BUZZER_TIM_CHANNEL, pulse);
}
buzzer_freq = freq;
buzzer_duty = duty;
}
static mp_obj_t py_buzzer_freq(uint n_args, const mp_obj_t *args) {
if (!n_args) {
return mp_obj_new_int(buzzer_freq);
} else {
buzzer_setup(mp_obj_get_int(*args), buzzer_duty);
return mp_const_none;
}
}
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(py_buzzer_freq_obj, 0, 1, py_buzzer_freq);
static mp_obj_t py_buzzer_duty(uint n_args, const mp_obj_t *args) {
if (!n_args) {
return mp_obj_new_int(buzzer_duty);
} else {
buzzer_setup(buzzer_freq, mp_obj_get_int(*args));
return mp_const_none;
}
}
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(py_buzzer_duty_obj, 0, 1, py_buzzer_duty);
static const mp_rom_map_elem_t globals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_buzzer) },
{ MP_ROM_QSTR(MP_QSTR_RESONANT_FREQ), MP_ROM_INT(OMV_BUZZER_FREQ) },
{ MP_ROM_QSTR(MP_QSTR_freq), MP_ROM_PTR(&py_buzzer_freq_obj) },
{ MP_ROM_QSTR(MP_QSTR_duty), MP_ROM_PTR(&py_buzzer_duty_obj) }
};
static MP_DEFINE_CONST_DICT(globals_dict, globals_dict_table);
const mp_obj_module_t buzzer_module = {
.base = { &mp_type_module },
.globals = (mp_obj_t) &globals_dict,
};
void py_buzzer_init0() {
buzzer_setup(OMV_BUZZER_FREQ, 0);
}
MP_REGISTER_MODULE(MP_QSTR_buzzer, buzzer_module);
#endif // MICROPY_PY_BUZZER

View File

@ -1,29 +0,0 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright (C) 2013-2024 OpenMV, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Buzzer Python module.
*/
#ifndef __PY_BUZZER_H__
#define __PY_BUZZER_H__
void py_buzzer_init0();
#endif // __PY_BUZZER_H__

View File

@ -409,12 +409,6 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim) {
#endif
}
#endif // (OMV_CSI_TIM)
#if defined(OMV_BUZZER_TIM)
if (htim->Instance == OMV_BUZZER_TIM) {
OMV_BUZZER_TIM_CLK_ENABLE();
}
#endif
}
void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim) {
@ -430,14 +424,6 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim) {
#endif
}
#endif // (OMV_CSI_TIM)
#if defined(OMV_BUZZER_TIM)
if (htim->Instance == OMV_BUZZER_TIM) {
OMV_BUZZER_TIM_FORCE_RESET();
OMV_BUZZER_TIM_RELEASE_RESET();
OMV_BUZZER_TIM_CLK_DISABLE();
}
#endif
}
void HAL_DCMI_MspInit(DCMI_HandleTypeDef *hdcmi) {

View File

@ -0,0 +1,29 @@
# This work is licensed under the MIT license.
# Copyright (c) 2013-2025 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Pure Thermal Buzzer Example Script
#
# Thanks for buying the Pure Thermal OpenMV! This is a simple example
# script showing off how to control the buzzer onboard.
from pyb import Timer, Pin
import time
# Timer2, Channel2
tim2 = Timer(2, freq=4000)
ch2 = tim2.channel(2, Timer.PWM, pin=Pin("BUZZER"), pulse_width_percent=50)
# Play a Catchy Jingle by controlling the buzzer frequency and duty cycle
# using a lookup table of freq and duty cycle values.
jingle = [
(1000, 50), (1200, 60), (1400, 70), (1600, 80),
(1800, 90), (2000, 100), (2200, 90), (2400, 80),
(2600, 70), (2800, 60), (3000, 50), (3200, 40),
]
while True:
for freq, duty in jingle:
tim2.freq(freq)
ch2.pulse_width_percent(duty)
time.sleep_ms(200)