Compare commits
No commits in common. "lab5" and "master" have entirely different histories.
7 changed files with 1 additions and 1518 deletions
65
audio.c
65
audio.c
|
@ -1,65 +0,0 @@
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include "driverlib/pwm.h"
|
|
||||||
#include "driverlib/sysctl.h"
|
|
||||||
#include "driverlib/gpio.h"
|
|
||||||
#include "driverlib/timer.h"
|
|
||||||
#include "driverlib/pin_map.h"
|
|
||||||
#include "inc/tm4c1294ncpdt.h"
|
|
||||||
#include "driverlib/interrupt.h"
|
|
||||||
#include "inc/hw_types.h"
|
|
||||||
#include "inc/hw_memmap.h"
|
|
||||||
#include "driverlib/fpu.h"
|
|
||||||
#include <math.h>
|
|
||||||
#include "driverlib/pwm.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "audio_waveform.h"
|
|
||||||
#include "frequency.h"
|
|
||||||
|
|
||||||
#define AUDIO_PWM_PERIOD 258
|
|
||||||
|
|
||||||
uint32_t gSamplingRateDivider = 29; // sampling rate divider
|
|
||||||
|
|
||||||
void configure_audio() {
|
|
||||||
// configure M0PWM2, at GPIO PF2, BoosterPack 1 header C1 pin 2
|
|
||||||
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
|
|
||||||
GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_1);
|
|
||||||
GPIOPinConfigure(GPIO_PG1_M0PWM5);
|
|
||||||
GPIOPadConfigSet(GPIO_PORTG_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA,
|
|
||||||
GPIO_PIN_TYPE_STD);
|
|
||||||
// configure the PWM0 peripheral, gen 2, outputs 5
|
|
||||||
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
|
|
||||||
// use system clock without division
|
|
||||||
PWMClockSet(PWM0_BASE, PWM_SYSCLK_DIV_1);
|
|
||||||
PWMGenConfigure(PWM0_BASE, PWM_GEN_2,
|
|
||||||
PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
|
|
||||||
|
|
||||||
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2,
|
|
||||||
AUDIO_PWM_PERIOD);
|
|
||||||
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_5,
|
|
||||||
roundf((float)AUDIO_PWM_PERIOD * 0.5f));
|
|
||||||
|
|
||||||
gSamplingRateDivider = gSystemClock / AUDIO_PWM_PERIOD / AUDIO_SAMPLING_RATE;
|
|
||||||
|
|
||||||
PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_2, PWM_INT_CNT_ZERO);
|
|
||||||
|
|
||||||
PWMOutputState(PWM0_BASE, PWM_OUT_5_BIT, true);
|
|
||||||
PWMGenEnable(PWM0_BASE, PWM_GEN_2);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t gPWMSample = 0; // PWM sample counter
|
|
||||||
void PWM_ISR(void)
|
|
||||||
{
|
|
||||||
PWMGenIntClear(PWM0_BASE, PWM_GEN_2, PWM_INT_CNT_ZERO); // clear PWM interrupt flag
|
|
||||||
// waveform sample index
|
|
||||||
int i = (gPWMSample++) / gSamplingRateDivider;
|
|
||||||
// write directly to the PWM compare B register
|
|
||||||
PWM0_2_CMPB_R = 1 + gWaveform[i];
|
|
||||||
if (i > gWaveformSize) { // if at the end of the waveform array
|
|
||||||
// disable these interrupts
|
|
||||||
PWMIntDisable(PWM0_BASE, PWM_INT_GEN_2);
|
|
||||||
// reset sample index so the waveform starts from the beginning
|
|
||||||
gPWMSample = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
6
audio.h
6
audio.h
|
@ -1,6 +0,0 @@
|
||||||
#ifndef AUDIO_C
|
|
||||||
#define AUDIO_C
|
|
||||||
|
|
||||||
void configure_audio();
|
|
||||||
|
|
||||||
#endif
|
|
1418
audio_waveform.c
1418
audio_waveform.c
File diff suppressed because it is too large
Load diff
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* audio_waveform.h
|
|
||||||
*
|
|
||||||
* Created on: Apr 15, 2020
|
|
||||||
* Author: Gene Bogdanov
|
|
||||||
*
|
|
||||||
* ECE 3849 Lab 3 Audio Waveform header
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef AUDIO_WAVEFORM_H_
|
|
||||||
#define AUDIO_WAVEFORM_H_
|
|
||||||
|
|
||||||
#define AUDIO_SAMPLING_RATE 16000 // [samples/sec] waveform sampling rate
|
|
||||||
extern const uint8_t gWaveform[]; // waveform array, stored in the flash
|
|
||||||
extern const size_t gWaveformSize; // number of elements in the waveform array
|
|
||||||
|
|
||||||
#endif /* AUDIO_WAVEFORM_H_ */
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#define PWM_FREQUENCY 20000 // PWM frequency = 20 kHz
|
#define PWM_FREQUENCY 20000 // PWM frequency = 20 kHz
|
||||||
|
|
||||||
void start_signal(void);
|
|
||||||
void start_frequency_scan(void);
|
void start_frequency_scan(void);
|
||||||
void set_pwm_period(uint32_t period);
|
void set_pwm_period(uint32_t period);
|
||||||
|
|
||||||
|
|
5
main.c
5
main.c
|
@ -32,7 +32,6 @@
|
||||||
#include "sampling.h"
|
#include "sampling.h"
|
||||||
#include "buttons.h"
|
#include "buttons.h"
|
||||||
#include "frequency.h"
|
#include "frequency.h"
|
||||||
#include "audio.h"
|
|
||||||
#include "kiss_fft.h"
|
#include "kiss_fft.h"
|
||||||
#include "_kiss_fft_guts.h"
|
#include "_kiss_fft_guts.h"
|
||||||
|
|
||||||
|
@ -127,7 +126,6 @@ int main(void)
|
||||||
ButtonInit();
|
ButtonInit();
|
||||||
start_cputimer();
|
start_cputimer();
|
||||||
start_frequency_scan();
|
start_frequency_scan();
|
||||||
configure_audio();
|
|
||||||
|
|
||||||
Crystalfontz128x128_Init(); // Initialize the LCD display driver
|
Crystalfontz128x128_Init(); // Initialize the LCD display driver
|
||||||
Crystalfontz128x128_SetOrientation(LCD_ORIENTATION_UP); // set screen orientation
|
Crystalfontz128x128_SetOrientation(LCD_ORIENTATION_UP); // set screen orientation
|
||||||
|
@ -257,9 +255,6 @@ void handle_user_input() {
|
||||||
case SW2:
|
case SW2:
|
||||||
set_pwm_period(--gPWMPeriod);
|
set_pwm_period(--gPWMPeriod);
|
||||||
break;
|
break;
|
||||||
case Right:
|
|
||||||
PWMIntEnable(PWM0_BASE, PWM_INT_GEN_2);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Semaphore_pend(options_sem, BIOS_WAIT_FOREVER);
|
Semaphore_pend(options_sem, BIOS_WAIT_FOREVER);
|
||||||
|
|
7
rtos.cfg
7
rtos.cfg
|
@ -599,10 +599,5 @@ gateHwi0Params.instance.name = "gateHwiDMA";
|
||||||
Program.global.gateHwi0 = GateHwi.create(gateHwi0Params);
|
Program.global.gateHwi0 = GateHwi.create(gateHwi0Params);
|
||||||
var m3Hwi1Params = new m3Hwi.Params();
|
var m3Hwi1Params = new m3Hwi.Params();
|
||||||
m3Hwi1Params.instance.name = "m3Hwi1";
|
m3Hwi1Params.instance.name = "m3Hwi1";
|
||||||
m3Hwi1Params.priority = 0;
|
m3Hwi1Params.priority = 4;
|
||||||
Program.global.m3Hwi1 = m3Hwi.create(35, "&capture_handler", m3Hwi1Params);
|
Program.global.m3Hwi1 = m3Hwi.create(35, "&capture_handler", m3Hwi1Params);
|
||||||
var m3Hwi2Params = new m3Hwi.Params();
|
|
||||||
m3Hwi2Params.instance.name = "m3Hwi2";
|
|
||||||
m3Hwi2Params.priority = 0;
|
|
||||||
m3Hwi2Params.enableInt = true;
|
|
||||||
Program.global.m3Hwi2 = m3Hwi.create(28, "&PWM_ISR", m3Hwi2Params);
|
|
||||||
|
|
Loading…
Reference in a new issue