diff --git a/include/aprs_pico.h b/include/aprs_pico.h index 1b79d21..f1d87cd 100644 --- a/include/aprs_pico.h +++ b/include/aprs_pico.h @@ -13,16 +13,15 @@ * GNU General Public License for more details. * You should have received a copy of the GNU General Public License -* along with this program. If not, see . +* along with this program. If not, see . */ -#ifndef APRS_PICO_H -#define APRS_PICO_H +#pragma once #include #include -#include // For 'audio_buffer_pool_t' +#include "pico/audio_pwm.h" // For 'audio_buffer_pool_t' /** \brief Initializes the APRS Pico library @@ -69,5 +68,3 @@ bool aprs_pico_sendAPRS(audio_buffer_pool_t* audio_buffer_pool, * \param[in] volume The volume level of the generated signal (0 ... 256) */ void aprs_pico_send_sine_wave(audio_buffer_pool_t* audio_buffer_pool, unsigned int freq_in_hz, unsigned int sample_freq_in_hz, uint16_t volume); - -#endif // APRS_PICO_H diff --git a/src/aprs_pico.c b/src/aprs_pico.c index 51a4a5a..2805a39 100644 --- a/src/aprs_pico.c +++ b/src/aprs_pico.c @@ -13,22 +13,21 @@ * GNU General Public License for more details. * You should have received a copy of the GNU General Public License -* along with this program. If not, see . +* along with this program. If not, see . */ -#include +#include "aprs_pico.h" + +#include "ax25beacon.h" +#include "pico/stdlib.h" -#include #include -#include -#include - -// WARNING: ATTOW, the pico audio PWM lib worked only @ 22050 Hz sampling frequency and 48 MHz system clock -// This is documented here: https://github.com/raspberrypi/pico-extras -#define APRS_PICO__PICO_EXTRA_AUDIO_PWM_LIB_FIXED_SAMPLE_FREQ_IN_HZ (22050) -#define APRS_PICO__SYS_CLOCK_FREQ_OF_PICO_EXTRA_AUDIO_PWM_LIB_IN_MHZ (48) +// NOTE: ATTOW, the pico-extra audio PWM lib worked only at a fixed 22050 Hz sampling frequency, while the +// system clock runs at 48 MHz. This is documented here: https://github.com/raspberrypi/pico-extras +#define APRS_PICO__PICO_EXTRA_AUDIO_PWM_LIB__FIXED_SAMPLE_FREQ_IN_HZ (22050) +#define APRS_PICO__PICO_EXTRA_AUDIO_PWM_LIB__SYS_CLOCK_FREQ_OF_IN_MHZ (48) typedef struct AudioCallBackUserData @@ -81,14 +80,14 @@ static audio_buffer_pool_t* aprs_pico_initAudio(unsigned int sample_freq_in_hz, */ static void aprs_pico_initClock(unsigned int sample_freq_in_hz) { - // WARNING: ATTOW, the pico audio PWM lib worked only @ 22050 Hz sampling frequency and 48 MHz system clock - // This is documented here: https://github.com/raspberrypi/pico-extras + // NOTE: ATTOW, the pico-extra audio PWM lib worked only at a fixed 22050 Hz sampling frequency, while the + // system clock runs at 48 MHz. This is documented here: https://github.com/raspberrypi/pico-extras - // Compensate a non-'PICO_EXTRA_AUDIO_PWM_LIB_FIXED_SAMPLE_FREQ_IN_HZ' sampling frequency - // by adapting the system clock accordingly + // Compensate a non-'APRS_PICO__PICO_EXTRA_AUDIO_PWM_LIB__FIXED_SAMPLE_FREQ_IN_HZ' sampling frequency + // by adapting the system clock frequency accordingly. - float sys_clock_in_mhz = (float)APRS_PICO__SYS_CLOCK_FREQ_OF_PICO_EXTRA_AUDIO_PWM_LIB_IN_MHZ * - ((float)sample_freq_in_hz / (float)APRS_PICO__PICO_EXTRA_AUDIO_PWM_LIB_FIXED_SAMPLE_FREQ_IN_HZ); + float sys_clock_in_mhz = (float)APRS_PICO__PICO_EXTRA_AUDIO_PWM_LIB__SYS_CLOCK_FREQ_OF_IN_MHZ * + ((float)sample_freq_in_hz / (float)APRS_PICO__PICO_EXTRA_AUDIO_PWM_LIB__FIXED_SAMPLE_FREQ_IN_HZ); if (!set_sys_clock_khz((uint32_t)(1000.0f * sys_clock_in_mhz), false)) { @@ -177,7 +176,7 @@ static void aprs_pico_sendAPRSAudioCallback(const void* callback_user_data, cons // See the header file for documentation audio_buffer_pool_t* aprs_pico_init() { - audio_buffer_pool_t* audio_buffer_pool = aprs_pico_initAudio(APRS_PICO__PICO_EXTRA_AUDIO_PWM_LIB_FIXED_SAMPLE_FREQ_IN_HZ, + audio_buffer_pool_t* audio_buffer_pool = aprs_pico_initAudio(APRS_PICO__PICO_EXTRA_AUDIO_PWM_LIB__FIXED_SAMPLE_FREQ_IN_HZ, AUDIO_BUFFER_FORMAT_PCM_S16); return audio_buffer_pool; } diff --git a/src/aprs_pico_example.c b/src/aprs_pico_beacon_demo.c similarity index 100% rename from src/aprs_pico_example.c rename to src/aprs_pico_beacon_demo.c