/** * @brief 使用esp8266模块和EDP协议向ONENET平台发送开发板四个LED指示灯的实时状态,并通过平台或者开发板按键控制LED。 **/ int main(void) { //SystemInit(); LED_Init(); //LED指示灯初始化函数 KEY_Init(); //按键初始化函数 USART1_Init(); //USART1串口初始化函数 USART2_Init(); //USART2串口初始化函数 while(1) { LED_Switch(LED_ON,LED_R|LED_G|LED_Y|LED_B); //点亮开发板四个指示灯,表示程序进入主流程 ESP8266_Init(); //ESP8266初始化 ESP8266_DevLink(DEVICEID,APIKEY,20); //和平台建立设备连接 LED_Switch(LED_OFF,LED_R|LED_G|LED_Y|LED_B); //熄灭开发板四个指示灯,表示程序完成设备连接,进入数据发送循环 while(1) { if(!(ESP8266_CheckStatus(30))) //检测ESP8266模块连接状态 { ESP8266_SendDat(); //向平台发送数据 } else { break; } } } }
void board_init(void) { printf("\n\n"); printf("BWCT FSB-A920-1\n"); printf("http://www.bwct.de\n"); printf("\n"); #if defined(SDRAM_128M) printf("AT92RM9200 180MHz 128MB\n"); #else printf("AT92RM9200 180MHz 64MB\n"); #endif printf("Initialising USART0\n"); USART0_Init(); printf("Initialising USART1\n"); USART1_Init(); printf("Initialising USART2\n"); USART2_Init(); printf("Initialising USART3\n"); USART3_Init(); printf("Initialising TWI\n"); EEInit(); printf("Initialising DS1672\n"); DS1672_Init(); printf("Initialising Ethernet\n"); printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); EMAC_Init(); EMAC_SetMACAddress(mac); printf("Initialising SD-card\n"); sdcard_init(); }
/*=====================================================================================================*/ int main( void ) { u8 TrData[10] = {0}; u8 RrData[7] = {0}; GPIO_Config(); USART1_Init(); while(1) { USART_WriteString((u8*)"Waiting for cmommand!\r\n"); USART_ReceiveStdString(RrData,sizeof(RrData)); USART_WriteString((u8*)"USART Received: "); USART_WriteString(RrData); USART_WriteString((u8*)"\n\r"); if(STR_CMP(RrData,str1,6)) { USART_WriteString((u8*)"Relay1 toggle\n\r"); OUT1 = ~OUT1; LED_B = ~LED_B; } else if(STR_CMP(RrData,str2,6)) { USART_WriteString((u8*)"Relay2 toggle\n\r"); OUT2 = ~OUT2; LED_R = ~LED_R; } LED_G = ~LED_G; } }
/******************************************************************************* * 函数名:主函数 * 功 能: * 参 数: * 返 回: *******************************************************************************/ int main(void) { uint8_t rate; uint32_t *p1, *p2; Delay_init(72); NVIC_Configuration(); USART1_Init(9600); Delayms(5000); USART1_PrintString("Start \r\n"); MEMORY_Init(); p1 = MEMORY_Malloc(1000); p2 = MEMORY_Malloc(1000); rate = MEMORY_GetUtilizationRate(); USART1_PrintString("Point is:"); USART1_PrintfInt((uint32_t)p1); USART1_PrintfInt((uint32_t)p2); USART1_PrintString("Rate is:"); USART1_PrintfInt(rate); MEMORY_Free(p1); MEMORY_Free(p2); rate = MEMORY_GetUtilizationRate(); USART1_PrintString("Rate is:"); USART1_PrintfInt(rate); while(1) { } }
int main(void) { unsigned int nCount; unsigned char vEncoder[20]="--------------------"; int i; RCC_Configuration(); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); NVIC_Configuration(); EXTI_Configuration(); USART1_Init(); USART2_Init(); USART3_Init(); UART4_Init(); UART5_Init(); SPI2_Init(); SysTick_Init(); //init_NRF24L01(); RX_Mode(); //nRF24L01_ISR(); while(1) { //Serial_PutString("While "); } }
void BSP_Init() { NVIC_Configuration(); #if USING_SRAM_AS_HEAP > 0 FSMC_SRAM_Init(); #endif #if WATCHDOG_ENABLE > 0 WATCHDOG_setTimeOut(15); //如果15秒仍未启动完成,那么就复位 WATCHDOG_enable(); //调试时要屏蔽 #endif _init_alloc(HEAP_BASE, HEAP_TOP); USART1_Init(); USART2_Init(); USART3_Init(); #ifdef STM32F10X_CL UART4_Init(); UART5_Init(); #endif //STM32F10X_CL Delay_ms(10); }
/******************************************************************************* * 函数名:主函数 * 功 能: * 参 数: * 返 回: *******************************************************************************/ int main(void) { SystemInit(); Delay_init(72); NVIC_Configuration(); USART1_Init(9600); Delayms(5000); //Initialize SPI and W25x16, after it , must delay time SPI_Parameter(); SPI_HW_Init(SPI_DefaultInit); W25X_Init(); Delayms(50); id = W25X_ReadID(); USART1_PrintChar(id >> 8); USART1_PrintChar(id); Delayms(50); USART1_PrintString("erase chip \r\n"); W25X_EraseChip(); USART1_PrintString("erase over"); W25X_WritePage(245, buffer1, 12); USART1_PrintString("Write over"); while(1) { W25X_ReadPage(245, buffer2, 12); USART1_PrintBuff(buffer2, 12); USART1_PrintChar( W25X_ReadByte(0) ); Delayms(2000); } }
/* Private function ----------------------------------------------------------*/ int main(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB , ENABLE); /* LED0 -> PB0 */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); USART1_Init(); USART1_Print("\r\n"); USART1_Print("*************************************************************\r\n"); USART1_Print("* *\r\n"); USART1_Print("* Thank you for using MatchboxARM Development Board ! ^_^ *\r\n"); USART1_Print("* *\r\n"); USART1_Print("*************************************************************\r\n"); /* Configure PA0 in interrupt mode */ EXTI0_Config(); /* Generate software interrupt on EXTI0 line */ EXTI_GenerateSWInterrupt(EXTI_Line0); /* Infinite loop */ while(1) { } }
/******************************************************************************* * Function Name : main * Description : Main program. * Input : None * Output : None * Return : None *******************************************************************************/ int main(void) { RCC_Configuration(); // Configure the system clocks GPIO_Configuration(); NVIC_Configuration(); // NVIC Configuration USART1_Init(); Timer_Configuration(); wizspi_init(WIZ_SPI_1); WIZ_Config(); // network config & Call Set_network (); // LED3 and LED4 On! LED3_onoff(ON); LED4_onoff(ON); // Start Application //Main_Menu(); while(1) { ftp_client_PI(FTP_CLIENT_PI_SOCK); ftp_client_DTP(FTP_CLIENT_DTP_SOCK); } }
//Flash orange LED at about 1hz int main(void) { long cnt = 0; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOA, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); //RCC_AHB1PeriphClockCmd ( RCC_AHB1Periph_GPIOB, ENABLE); GPIO_InitTypeDef gpio_initstructure; gpio_initstructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; gpio_initstructure.GPIO_Speed= GPIO_Speed_50MHz; gpio_initstructure.GPIO_Mode = GPIO_Mode_OUT; gpio_initstructure.GPIO_OType = GPIO_OType_PP; gpio_initstructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init( GPIOB, &gpio_initstructure ); USART1_Init(); if (SysTick_Config(SystemCoreClock / 1000)) while (1); mxchipInit(); for (;;) { cnt++; GPIO_SetBits(GPIOB,GPIO_Pin_0); GPIO_SetBits(GPIOB,GPIO_Pin_1); Delay(100); GPIO_ResetBits(GPIOB,GPIO_Pin_0); GPIO_ResetBits(GPIOB,GPIO_Pin_1); Delay(100); printf("Hello World %ld\r\n", cnt); } }
/******************************************************************************* * Function Name : main * Description : Main program. * Input : None * Output : None * Return : None *******************************************************************************/ int main(void) { RCC_Configuration(); // Configure the system clocks GPIO_Configuration(); NVIC_Configuration(); // NVIC Configuration USART1_Init(); Timer_Configuration(); WIZ_SPI_Init(); WIZ_Config(); // network config // LED3 and LED4 On! LED3_onoff(ON); LED4_onoff(ON); // Start Application printf("\r\n\r\n----------------------------------- \r\n"); printf("Twitter and DNS using W5200\r\n"); printf("----------------------------------- "); Main_Menu(); while(1) { } }
void start_task(void *pdata) { OS_CPU_SR cpu_sr = 0; pdata = pdata; u8 err; delay_init(168); USART1_Init();//初始化 LED_Init(); BEEP_Init(); pringf("Hello world\n"); OS_ENTER_CRITICLE(); //进入临界区 无法被中断打断 //创建系统定时器 pTmrLed = OSTmrCreate( 0,//dly 计时前的延迟 OS_TMR_CFG_TICKS_PER_SEC/2,//周期 宏本身表示1s OS_TMR_OPT_PERIODIC,//周期模式 (OS_TMR_CALLBACK)LedTmrCallback, NULL, NULL, &err );//定时器时间到了 自动调用回调函数 pTmrBeep = OSTmrCreate( 0, OS_TMR_CFG_TICKS_PER_SEC/2, OS_TMR_OPT_PERIODIC, (OS_TMR_CALLBACK)BeepTmrCallback, NULL, NULL, &err ); //启动定时器 if( OSTmrStart(pTmrLED,&err) == OS_TRUE ) { printf("LED TMR Start.\n"); } else printf("LED TMR Fail.\n"); if( OSTmrStart(pTmrBeep,&err) == OS_TRUE ) { printf("BEEP TMR Start.\n"); } else printf("BEEP TMR Fail.\n"); OS_EXIT_CRITICLE(); //退出临界区 可以被中断打断 while(1)//一直延时 等待程序运行 OSTimeDlyHMSM(0,0,0,500); }
/* Private function ----------------------------------------------------------*/ int main(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Set the Vector Table base adress at 0x8004000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000); /* Enable clock for GPIOB port */ RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB , ENABLE); /* LED0 -> PB0 LED1 -> PB1 */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); USART1_Init(); USART1_Print("\r\n"); USART1_Print("*************************************************************\r\n"); USART1_Print("* *\r\n"); USART1_Print("* Thank you for using MatchboxARM Development Board ! ^_^ *\r\n"); USART1_Print("* *\r\n"); USART1_Print("*************************************************************\r\n"); /* Enable CRC clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE); /* Compute the CRC of "DataBuffer" */ CRCValue = CRC_CalcBlockCRC((uint32_t *)DataBuffer, BUFFER_SIZE); /* Display the computed CRC variable */ USART1_Print("The CRC of the buffer is = "); USART1_Print_Int(CRCValue); USART1_Print("\n\r"); /* Infinite loop, just toggle leds */ while(1) { /* LED0-ON LED1-OFF */ GPIO_SetBits(GPIOB , GPIO_Pin_0); GPIO_ResetBits(GPIOB , GPIO_Pin_1); Delay(0xfffff); Delay(0xfffff); Delay(0xfffff); Delay(0xfffff); Delay(0x5ffff); /* LED0-OFF LED1-ON */ GPIO_ResetBits(GPIOB , GPIO_Pin_0); GPIO_SetBits(GPIOB , GPIO_Pin_1); Delay(0xfffff); Delay(0xfffff); Delay(0xfffff); Delay(0xfffff); Delay(0x5ffff); } }
/* * Name : main * Input : None * Output : None * Return : None */ int main(void) { uint8_t ch; RCC_Configuration(); RCC->APB2ENR |= RCC_APB2Periph_GPIOA; RCC->APB2ENR |= RCC_APB2Periph_GPIOB; RCC->APB2ENR |= RCC_APB2Periph_USART1; GPIO_Configuration(); USART1_Init(); while(1) { printf("\n---------------------\n"); printf("Press menu key\n"); printf("---------------------\n"); printf("0> System Information\n"); printf("---------------------\n"); printf("1> LED Test\n"); printf("2> KEY Test\n"); printf("3> 7-Segment Test\n"); printf("---------------------\n"); printf("x> quit\n\n"); ch = USART_GetCharacter(USART1); printf(" is selected\n\n"); switch((char)ch) { case '0': System_Information(); break; case '1': LED_Test(); break; case '2': KEY_Test(); break; case '3': Seven_Segment_Test(); break; } if('x' == (char)ch) { break; } } }
void BSP_Init(void) { SystemInit(); SysTick_init(); MYLCD_Init(); USART1_Init(); Normal_Init(); DAC_Initialize(); DAC_Output(1, 2048); DAC_Output(2, 2048); }
/* The core is running at 72MHz */ int main(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Set the Vector Table base adress at 0x8004000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000); RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOA , ENABLE); /* Full SWJ Disabled (JTAG-DP + SW-DP) */ GPIO_PinRemapConfig (GPIO_Remap_SWJ_Disable, ENABLE); //LED0 -> PB0, LED1 -> PB1 // Reset GPIO init structure GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); // Configure PA1 as input floating // Reset GPIO init structure GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//GPIO_Mode_IPD; GPIO_Init(GPIOA, &GPIO_InitStructure); USART1_Init(); ADC_Configuration(); while (1) { /* LED0-ON LED1-OFF */ GPIO_SetBits(GPIOB , GPIO_Pin_0); GPIO_ResetBits(GPIOB , GPIO_Pin_1); Delay(0xfffff); /* LED0-OFF LED1-ON */ GPIO_ResetBits(GPIOB , GPIO_Pin_0); GPIO_SetBits(GPIOB , GPIO_Pin_1); Delay(0xfffff); /* Print the ADC PA1 DIP Switch value to USART */ USART1_Print_Int(readDIPSwitch()); if (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1) == 1) USART1_Print(", ON\n"); else USART1_Print(", OFF\n"); } }
int main(void) { USART1_Init(); USART2_Init(); mDelay(1000); Hal_I2C_Init(); /*初始化8266,并连接CWJAP配置的AP,与MQTT_CIPSTART配置的服务器建立TCP连接*/ ESP8266_Init((int8_t *)MQTT_CIPSTART, (int8_t *)CWJAP); /*进入MQTT协议测试主循环*/ MQTT_Loop(); }
// ***************************************************************************** // Function Name : main // Description : Main program. // Input : None // Output : None // Return : None // ***************************************************************************** int main(void) { #ifdef DEBUG debug(); #endif int i,j; // System clock configuration RCC_Configuration(); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); // Nested Vector Interrupt Controller configuration NVIC_Configuration(); LCD_GPIO_Configuration(); FSMC_LCD_Init(); USART1_Init(); ILI9325_Init(); ILI9325_VerticalScreen(); ILI9325_GRAMOperation(); //Tell ILI9325 that I'm now starting to write GRAM. for(i=0;i<240;i++) { for(j=0;j<320;j++) { unsigned int n=i*320+j; if(n<25600) { ILI9325_WriteWDR(n); } else if(n<51200) { ILI9325_WriteWDR(n); } else if(n<76800) { ILI9325_WriteWDR(0xf800); } } } ILI9325_FillWindowArea(10,10,100,100,0x001f); while(1) { } }
///---------------------------------------------------------------------------- /// /// \brief main /// \return - /// \remarks - /// ///---------------------------------------------------------------------------- int32_t main(void) { USART1_Init(); while (Test_Running()) { MWI_Receive(); } USART1_Init(); while (Test_Running()) { MWI_Receive(); } USART1_Init(); while (Test_Running()) { MWI_Receive(); } USART1_Init(); while (Test_Running()) { MWI_Receive(); } USART1_Init(); while (Test_Running()) { MWI_Receive(); } USART1_Init(); while (Test_Running()) { MWI_Receive(); } }
void SPIRIT_INIT(void) { NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0000); // Use STM32L1xx_flash.icf RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC, ENABLE ); SdkEvalIdentification(); SdkStartSysTick(); SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); SdkEvalLedInit(LED1); SdkEvalLedInit(LED2); SdkEvalM2SGpioInit(M2S_GPIO_SDN,M2S_MODE_GPIO_OUT); SpiritSpiInit(); USART1_Init(); SpiritEnterShutdown(); SpiritExitShutdown(); SpiritManagementIdentificationRFBoard(); SdkEvalM2SGpioInit(M2S_GPIO_0, M2S_MODE_EXTI_IN); SdkEvalM2SGpioInterruptCmd(M2S_GPIO_0,0x0F,0x0F,ENABLE); SpiritGpioInit(&xGpioIRQ); SpiritRadioInit(&xRadioInit); SpiritPktBasicInit(&xBasicInit); SpiritPktBasicAddressesInit(&xAddressInit); SpiritIrqDeInit(&xIrqStatus); SpiritIrq(RX_DATA_DISC, S_ENABLE); SpiritIrq(RX_DATA_READY, S_ENABLE); // testy dla odbioru komend !!!!! SpiritIrq(TX_DATA_SENT, S_ENABLE); SpiritIrq(TX_FIFO_ERROR, S_ENABLE); // Declare Length of Payload SpiritPktBasicSetPayloadLength(PAYLOAD_LENGTH); SpiritQiSetSqiThreshold(SQI_TH_0); SpiritQiSqiCheck(S_ENABLE); SpiritIrqClearStatus(); // SET_INFINITE_RX_TIMEOUT(); SpiritTimerSetRxTimeoutMs(RX_TIMEOUT); //SpiritTimerSetRxTimeoutStopCondition(TIMEOUT_ALWAYS_STOPPED); SpiritTimerSetRxTimeoutStopCondition(SQI_ABOVE_THRESHOLD); SpiritIrqClearStatus(); //USART_Conf(); //*** For test purposes only: create unsigned, 16-bit counter vectcTxBuff[0] = 0; // Clear Counter to overwrite initial values vectcTxBuff[1] = 0; SdkDelayMs(2000); //wait till the tested board FW active // IWDG_Init(); // let the dogs out, }
/******************************************************************************* * 函数名:主函数 * 功 能: * 参 数: * 返 回: *******************************************************************************/ int main(void) { SystemInit(); Delay_init(72); NVIC_Configuration(); USART1_Init(9600); while(1) { count++; Delayms(1000); USART1_PrintChar(count); } }
int main(void) { /* Initialize GPIOA PIN8 */ GPIOD_Init(); /* Initialize USART1 */ USART1_Init(); while(1) { USART_SendData(USART1, 'a'); /* Do nothing, all happens in ISR */ } }
void main() { RCC_Configuration(); // Configure the system clocks GPIO_Configuration(); //GPIO configuration NVIC_Configuration(); //NVIC Configuration Timer_Configuration(); iic_init(); //ov2640_jpeg_config(JPEG_800x600); ov2640_jpeg_config(JPEG_640x480); //ov2640_jpeg_config(JPEG_320x240); /* 设置COMS参数 */ ov2640_brightness_config(0x40); ov2640_auto_exposure(3);//3 ov2640_contrast_config(0x28, 0x0c); ov2640_black_white_config(0x00); ov2640_color_saturation(0x68, 0x68); ov2640_light_mode_config(OFFICE); o2640_capture_gpio_init(); /* 关闭像素同步中断 */ ov2640_interrupt_disable(); USART1_Init(); //115200@8-n-1 //UART4_Init(38400);//camera printf("MCU initialized.\r\n"); Reset_W5500(); printf("Ethernet initialized over.\r\n"); WIZ_SPI_Init(); set_network(); printf("W5500 is ready!\r\n"); printf("camera init......OK\r\n"); JPEGCnt=0; ov2640_interrupt_enable(); while(1) { do_websocket_server(SOCK_WEBSOCKET); do_http(); } }
//------------------------------------------------------------------------------ // === Initialize Function === //------------------------------------------------------------------------------ void Init_Main(void) { RCC_Configuration(); // RCC_GetClocksFreq(&rcc_clocks); GPIO_Configuration(); NVIC_Configuration(); DMA_Configuration(); ADC_Configuration(); // TIM_Configuration(); EXTI_Configuration(); nRF24_init(); // nRF24_ClearIRQFlags(); USART1_Init(57600); // in 36mhz error 0% }
int main() { Timer2_Init(); //Initialize Timer2 USART0_Init(9600); //Initialize USART0 with baud rate of 9600 USART1_Init(9600); //Initialize USART1 with baud rate of 9600 _delay_ms(500); //delay 500 milisecond sei();//Enable Gloabal Interrupt while(1)//dead loop { } return 0; }
/******************************************************************************* * 函数名:主函数 * 功 能: * 参 数: * 返 回: *******************************************************************************/ int main(void) { SystemInit(); Delay_init(72); NVIC_Configuration(); USART1_Init(9600); Delayms(5000); while( SD_Initialize() != 0 ) { USART1_PrintString("SD Initialize Fail \r\n"); } USART1_PrintString("SD Initialize OK \r\n"); sector_num = SD_GetSectorNum(); USART1_PrintString("The SD sector num is: "); USART1_PrintChar(sector_num>>24); USART1_PrintChar(sector_num>>16); USART1_PrintChar(sector_num>>8); USART1_PrintChar(sector_num>>0); USART1_PrintString("\r\n"); USART1_PrintString("The SD size is: "); sector_num >>= 12; USART1_PrintChar(sector_num>>24); USART1_PrintChar(sector_num>>16); USART1_PrintChar(sector_num>>8); USART1_PrintChar(sector_num>>0); if( 0 == SD_WriteDisk(buf1, 1, 1) ) { USART1_PrintString("Write OK \r\n"); } while(1) { Delayms(4000); if(0 == SD_ReadDisk(buf,0,2)) { for(n=0; n<1024; n++) { USART1_PrintChar(buf[n]); } } } }
int main (void) { // enable pull ups for the 4 keys PORTA |= (1<<PORTA4)|(1<<PORTA5)|(1<<PORTA6)|(1<<PORTA7); // set LED Pins to output DDRC |= (1<<DDC2); // BL-LED1 DDRD |= (1<<DDD6); // BL-LED2 DDRD |= (1<<DDD7); // BL-LED3 DDRC |= (1<<DDC6); // buzzer // disable bootloader LED DDRC |= (1<<DDC3); PORTC |= (1<<PORTC3); LCD_Init (); USART_Init (); USART1_Init (); TWIM_Init (200000); TIMER0_Init (); sei (); lcd_cls (); lcd_printp (PSTR("Hallo"), 0); for (;;) { } }
//------------------------------------------------------------------------------ // === Initialize Function === //------------------------------------------------------------------------------ void Init_Main(void) { RCC_Configuration(); //RCC_GetClocksFreq(&rcc_clocks); GPIO_Configuration(); NVIC_Configuration(); DMA_Configuration(); ADC_Configuration(); TIM_Configuration(); EXTI_Configuration(); Tim_Encoder_initial(); USART1_Init(57600); // in 36mhz error 0% USART3_Init(115200);// in 72mhz error 0% //if (SysTick_Config(rcc_clocks.SYSCLK_Frequency / 1000)) //{ /* Capture error */ // while (1); //} }
/******************************************************************************* * 函数名:主函数 * 功 能: * 参 数: * 返 回: *******************************************************************************/ int main(void) { SystemInit(); Delay_init(72); NVIC_Configuration(); USART1_Init(9600); while(1) { //Delayms(100); //UART1_PrintChar(0x55); //UART1_PrintBuff(buf, 6); //UART1_PrintString("string..."); len = USART1_RxAvailable(); if( len > 0 ) { tx_len = USART1_ReadRxBUF(buf, len); USART1_PrintBuff(buf, tx_len); } } }
int main(void) { USART1_Init(921600); BTN_Init(); BTN_Interrupts(); LED_Init(); // Tick every 1 ms if (SysTick_Config(SystemCoreClock / 1000)) while (1); printf("Hello, World!\r\n"); ds18b20_init(GPIOC, GPIO_Pin_6, TIM2); while(1) { ds18b20_read_temperature_all(); ds18b20_wait_for_conversion(); printf("%d---\r\n", ds18b20_get_precission()); ds18b20_convert_temperature_all(); } }