void initx(void) { SCB ->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); STM_EVAL_LEDInit(LED5); STM_EVAL_LEDInit(LED6); STM_EVAL_LEDOff(LED3); STM_EVAL_LEDOff(LED4); STM_EVAL_LEDOff(LED5); STM_EVAL_LEDOff(LED6); init_usart(); send_string_uart("INIT UART\n"); init_accelerometer(); send_string_uart("INIT ACCE\n"); wire_exti_interrupt0_to_acceleromerter_int1(); send_string_uart("INIT INT\n"); init_DAC_DMA(); send_string_uart("INIT DMA\n"); DAC_Ch2_SineWaveConfig(); send_string_uart("INIT SINE\n"); }
/** * @brief Main program * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f2xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f2xx.c file */ /* Preconfiguration before using DAC----------------------------------------*/ GPIO_InitTypeDef GPIO_InitStructure; /* DMA1 clock and GPIOA clock enable (to be used with DAC) */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1 | RCC_AHB1Periph_GPIOA, ENABLE); /* DAC Periph clock enable */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); /* DAC channel 1 & 2 (DAC_OUT1 = PA.4)(DAC_OUT2 = PA.5) configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure); /* TIM6 Configuration ------------------------------------------------------*/ TIM6_Config(); /* Configures Key Button */ STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); while (1) { /* If the Key is pressed */ if (KeyPressed != RESET) { DAC_DeInit(); /* select waves forms according to the Key Button status */ if (SelectedWavesForm == 1) { /* The sine wave and the escalator wave has been selected */ /* Escalator Wave generator ------------------------------------------*/ DAC_Ch1_EscalatorConfig(); /* Sine Wave generator -----------------------------------------------*/ DAC_Ch2_SineWaveConfig(); } else { /* The triangle wave and the noise wave has been selected */ /* Noise Wave generator ----------------------------------------------*/ DAC_Ch1_NoiseConfig(); /* Triangle Wave generator -------------------------------------------*/ DAC_Ch2_TriangleConfig(); } KeyPressed = RESET; } } }
void sineWave_init(void) { soundOutput_GPIO_Init(); TIM6_Config(); DAC_Ch2_SineWaveConfig(); }