kopia lustrzana https://github.com/eleccoder/raspi-pico-aprs-tnc
Code maintenance
rodzic
61462ae469
commit
9fcdbd51c2
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef APRS_PICO_H
|
||||
#define APRS_PICO_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <pico/audio_pwm.h> // 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
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <aprs_pico.h>
|
||||
#include "aprs_pico.h"
|
||||
|
||||
#include "ax25beacon.h"
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <pico/stdlib.h>
|
||||
#include <ax25beacon.h>
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue