|
|
|
|
@ -2268,13 +2268,15 @@ void start_pwm() {
|
|
|
|
|
//
|
|
|
|
|
Serial.println("Starting pwm!");
|
|
|
|
|
|
|
|
|
|
pwm_value = 128 - pwm_amplitude;
|
|
|
|
|
// pwm_value = 128 - pwm_amplitude;
|
|
|
|
|
|
|
|
|
|
// set_sys_clock_khz(125000, true);
|
|
|
|
|
set_sys_clock_khz(133000, true);
|
|
|
|
|
gpio_set_function(BPSK_PWM_PIN, GPIO_FUNC_PWM);
|
|
|
|
|
|
|
|
|
|
bpsk_pin_slice = pwm_gpio_to_slice_num(BPSK_PWM_PIN);
|
|
|
|
|
gpio_set_function(BPSK_PWM_A_PIN, GPIO_FUNC_PWM);
|
|
|
|
|
gpio_set_function(BPSK_PWM_B_PIN, GPIO_FUNC_PWM);
|
|
|
|
|
|
|
|
|
|
bpsk_pin_slice_A = pwm_gpio_to_slice_num(BPSK_PWM_A_PIN);
|
|
|
|
|
bpsk_pin_slice_B = pwm_gpio_to_slice_num(BPSK_PWM_B_PIN);
|
|
|
|
|
/*
|
|
|
|
|
// Setup PWM interrupt to fire when PWM cycle is complete
|
|
|
|
|
pwm_clear_irq(bpsk_pin_slice);
|
|
|
|
|
@ -2289,10 +2291,12 @@ void start_pwm() {
|
|
|
|
|
// pwm_config_set_wrap(&config, 178); // 250);
|
|
|
|
|
pwm_config_set_wrap(&config, 3);
|
|
|
|
|
|
|
|
|
|
pwm_config_set_output_polarity( &config, polarity, polarity);
|
|
|
|
|
pwm_init(bpsk_pin_slice, &config, true);
|
|
|
|
|
pwm_set_gpio_level(BPSK_PWM_PIN, (config.top + 1) * 0.5);
|
|
|
|
|
|
|
|
|
|
// pwm_config_set_output_polarity( &config, polarity, polarity);
|
|
|
|
|
pwm_config_set_output_polarity( &config, true, false);
|
|
|
|
|
pwm_init(bpsk_pin_slice_A, &config, true);
|
|
|
|
|
pwm_init(bpsk_pin_slice_B, &config, true);
|
|
|
|
|
pwm_set_gpio_level(BPSK_PWM_A_PIN, (config.top + 1) * 0.5);
|
|
|
|
|
pwm_set_gpio_level(BPSK_PWM_B_PIN, (config.top + 1) * 0.5);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
void pwm_interrupt_handler() {
|
|
|
|
|
@ -2712,22 +2716,32 @@ bool TimerHandler0(struct repeating_timer *t) {
|
|
|
|
|
// Serial.print("l1 ");
|
|
|
|
|
// Serial.print(wav_position);
|
|
|
|
|
// Serial.print(" ");
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
if (buffer[wav_position++] > 0) {
|
|
|
|
|
digitalWrite(BPSK_CONTROL_A, HIGH);
|
|
|
|
|
digitalWrite(BPSK_CONTROL_B, LOW);
|
|
|
|
|
} else {
|
|
|
|
|
digitalWrite(BPSK_CONTROL_A, LOW);
|
|
|
|
|
digitalWrite(BPSK_CONTROL_B, HIGH);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
tx_bit = (buffer[wav_position] > 0) ? HIGH: LOW;
|
|
|
|
|
|
|
|
|
|
digitalWrite(AUDIO_OUT_PIN, tx_bit);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
tx_bit = (buffer[wav_position++] > 0) ? true: false;
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
if (tx_bit)
|
|
|
|
|
Serial.print("-");
|
|
|
|
|
else
|
|
|
|
|
Serial.print("_");
|
|
|
|
|
*/
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
pwm_config_set_output_polarity( &config, tx_bit, tx_bit);
|
|
|
|
|
pwm_init(bpsk_pin_slice, &config, true);
|
|
|
|
|
pwm_set_gpio_level(BPSK_PWM_PIN, (config.top + 1) * 0.5);
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
if (wav_position > bufLen) { // 300) {
|
|
|
|
|
wav_position = wav_position - bufLen;
|
|
|
|
|
// Serial.print("\nR");
|
|
|
|
|
@ -2746,7 +2760,9 @@ void start_isr() {
|
|
|
|
|
|
|
|
|
|
Serial.println("Starting ISR");
|
|
|
|
|
|
|
|
|
|
pinMode(AUDIO_OUT_PIN, OUTPUT);
|
|
|
|
|
pinMode(BPSK_CONTROL_A, OUTPUT);
|
|
|
|
|
pinMode(BPSK_CONTROL_B, OUTPUT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ITimer0.attachInterruptInterval(833, TimerHandler0))
|
|
|
|
|
{
|
|
|
|
|
|