Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stm32f4xx.h"
- #include "stm32f4xx_gpio.h"
- #include "stm32f4xx_rcc.h"
- void Delay(volatile uint32_t tick)
- {
- for(uint32_t i = 0; i < tick; i++);
- }
- void Play( uint32_t herz, uint32_t time)
- {
- uint32_t k;
- k=1000000/herz;
- time=time*100;
- for(int i=0; i<time;i+=k*2)
- {
- GPIO_SetBits(GPIOD, GPIO_Pin_11);
- Delay(k);
- GPIO_ResetBits(GPIOD, GPIO_Pin_11);
- Delay(k);
- }
- }
- int main(void)
- {
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
- // RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
- GPIO_InitTypeDef GPIO_InitStruct;
- GPIO_StructInit(&GPIO_InitStruct);
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_15| GPIO_Pin_11;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_Init(GPIOD, &GPIO_InitStruct);
- /*GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_Init(GPIOB, &GPIO_InitStruct);*/
- while(1)
- {
- Play(500,250);
- Play(550,250);
- Play(600,250);
- Play(650,250);
- Play(700,250);
- Play(750,250);
- Play(800,250);
- Play(850,250);
- Play(1000,1000);
- Play(970,1000);
- Play(940,1500);
- Play(910,250);
- Play(880,250);
- Play(820,1500);
- Play(790,500);
- Play(850,1500);
- Play(820,500);
- Play(720,1500);
- Play(30,0.2);
- Play(720,1000);
- Play(30,0.2);
- Play(720,1000);
- Play(30,0.2);
- Play(720,1000);
- Play(30,0.2);
- Play(720,250);
- Play(30,0.2);
- Play(720,250);
- Play(30,0.2);
- Play(720,250);
- Play(30,0.2);
- Play(720,250);
- Play(30,0.2);
- Play(720,250);
- Play(30,0.2);
- Play(720,250);
- Play(30,0.2);
- Play(720,250);
- Play(30,0.2);
- Play(720,250);
- Play(30,0.2);//ffff
- Play(750,250);
- Play(30,0.2);
- Play(750,250);
- Play(30,0.2);
- Play(750,250);
- Play(30,0.2);
- Play(750,250);
- Play(30,0.2);
- Play(780,250);
- Play(30,0.2);
- Play(780,250);
- Play(30,0.2);
- Play(780,250);
- Play(30,0.2);
- Play(780,250);
- Play(30,0.2);//fffff
- // Play(880,250);
- //Play(910,250);
- Play(830,250);
- Play(860,250);
- Play(780,250);
- Play(810,250);
- Play(730,250);
- Play(760,250);
- Play(680,250);
- Play(710,250);
- Play(630,250);
- Play(660,250);
- Play(580,250);
- Play(610,250);
- Play(530,250);
- //Delay(2000000);
- /*for(int i=0;i<1000000;i++){
- GPIO_SetBits(GPIOD, GPIO_Pin_11);
- Delay(2000);
- GPIO_ResetBits(GPIOD, GPIO_Pin_11);
- Delay(2000);*/
- /* for(int i=0;i<1000000;i++){
- GPIO_SetBits(GPIOD, GPIO_Pin_11);
- Delay(10000);
- GPIO_ResetBits(GPIOD, GPIO_Pin_11);
- Delay(10000);
- }
- */
- /*GPIO_SetBits(GPIOD, GPIO_Pin_15);
- Delay(100000);
- GPIO_ResetBits(GPIOD, GPIO_Pin_15);
- Delay(100000);
- GPIO_SetBits(GPIOB, GPIO_Pin_1);
- Delay(500000);
- GPIO_ResetBits(GPIOB, GPIO_Pin_1);
- Delay(100000);*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement