/* * See the serial2.h header file. */ xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength ) { xComPortHandle xReturn; /* Create the queues used to hold Rx/Tx characters. */ xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) ); xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed char ) ); /* If the queue/semaphore was created correctly then setup the serial port hardware. */ if( ( xRxedChars != serINVALID_QUEUE ) && ( xCharsForTx != serINVALID_QUEUE ) ) { S_UART_Init(115200); S_UART_ITConfig(S_UART_CTRL_RXI,ENABLE); NVIC_EnableIRQ(UART2_IRQn); xReturn = (xComPortHandle)UART2; } else { xReturn = ( xComPortHandle ) 0; } /* This demo file only supports a single port but we have to return something to comply with the standard demo header file. */ return xReturn; }
/** * @brief Main program * @param None * @retval None */ int main() { int i; /*System clock configuration*/ SystemInit(); /* Configure UART2 */ S_UART_Init(115200); conf.scl = I2C_PA_9; conf.sda = I2C_PA_10; I2C_Init(&conf); //============ Write ============== I2C_Write(&conf, 0xa0, &Transmit_Data[0], MAX_SIZE); delay_function(4000); //========= Read ============= //Write memory address I2C_Write(&conf, 0xA0, &Transmit_Data[0], 1); delay_function(4000); //Read data I2C_Read(&conf, 0xA0, &Recv_Data[0], MAX_SIZE - 1); printf("Recv data : "); for(i=0; i<MAX_SIZE - 1; i++) { printf("0x%x ", Recv_Data[i]); } printf("\r\n"); }
int main() { /*System clock configuration*/ SystemInit(); /* UART2 configuration*/ S_UART_Init(115200); /* GPIO LED1 & LED2 Set */ GPIO_InitDef.GPIO_Pin = ( GPIO_Pin_1 | GPIO_Pin_2) ; // Set to Pin_1 (LED1) & Pin_2 (LED2) GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to Mode Output GPIO_Init(GPIOA, &GPIO_InitDef); PAD_AFConfig(PAD_PA,(GPIO_Pin_1|GPIO_Pin_2), PAD_AF1); // PAD Config - LED used 2nd Function GPIO_SetBits(GPIOA, ( GPIO_Pin_1 | GPIO_Pin_2) ); // LED1 & LED2 Off while(1) { delay_ms(500); // LED1 OFF, LED2 OFF printf("LED 1 OFF, LED2 OFF\r\n"); GPIO_SetBits(GPIOA, ( GPIO_Pin_1 | GPIO_Pin_2) ); // LED1 & LED2 Off delay_ms(500); // LED1 ON, LED2 OFF printf("LED 1 ON, LED2 OFF\r\n"); GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_RESET); delay_ms(500); // LED1 ON, LED2 ON printf("LED 1 ON, LED2 ON\r\n"); GPIO_WriteBit(GPIOA, GPIO_Pin_2, Bit_RESET); } }
void UART_Configuration(void) { UART_InitTypeDef UART_InitStructure; /* UART Configuration for UART1*/ UART_StructInit(&UART_InitStructure); UART_Init(UART1,&UART_InitStructure); /* UART Configuration for UART2*/ S_UART_Init(115200); }
int main() { /*System clock configuration*/ SystemInit(); /* UART0 and UART1 configuration*/ UART_StructInit(&UART_InitStructure); /* Configure UART0 */ UART_Init(UART1,&UART_InitStructure); S_UART_Init(115200); /* Retarget functions for GNU Tools for ARM Embedded Processors*/ UartPuts(UART1,"UART 1 Test(#1)\r\n"); printf("UART 2 Test(#2)\r\n"); }
int main() { uint32_t i; /*System clock configuration*/ SystemInit(); // *(volatile uint32_t *)(0x41001014) = 0x0060100; //clock setting 48MHz /* CLK OUT Set */ // PAD_AFConfig(PAD_PA,GPIO_Pin_2, PAD_AF2); // PAD Config - CLKOUT used 3nd Function /*using debugging*/ S_UART_Init(115200); /* UART0 and UART1 configuration*/ UART_StructInit(&UART_InitStructure); /* Configure UART0 */ UART_Init(UART0,&UART_InitStructure); /* Configure UART1 */ UART_Init(UART1,&UART_InitStructure); /* Configure Uart0 Interrupt Enable*/ UART_ITConfig(UART0, (UART_IT_FLAG_TXI|UART_IT_FLAG_RXI),ENABLE); /* NVIC configuration */ NVIC_ClearPendingIRQ(UART0_IRQn); NVIC_EnableIRQ(UART0_IRQn); /* Configure Uart1 Interrupt Enable*/ UART_ITConfig(UART1,(UART_IT_FLAG_TXI|UART_IT_FLAG_RXI),ENABLE); /* NVIC configuration */ NVIC_ClearPendingIRQ(UART1_IRQn); NVIC_EnableIRQ(UART1_IRQn); /*send the data from UART0 to UART1*/ printf("Send UART0\r\n"); for(i=0;i<409600;i++) { UartPutc(UART0,(uint8_t)i); } /*send the data from UART1 to UART0*/ printf("Send UART1\r\n"); for(i=0;i<409600;i++) { UartPutc(UART1,(uint8_t)i); } /*confirm the rx/tx data counter of Uart0,1 using Uart2*/ printf("Press Any Key\r\n"); while( S_UartGetc() != 0 ) { printf("uart0_rx_cnt = %d, uart0_tx_cnt = %d\r\n",uart0_rx_cnt, uart0_tx_cnt); printf("uart1_rx_cnt = %d, uart1_tx_cnt = %d\r\n",uart1_rx_cnt, uart1_tx_cnt); } }
int main() { uint32_t i; /*System clock configuration*/ SystemInit(); /*using debugging*/ S_UART_Init(115200); /* UART0 and UART1 configuration*/ UART_StructInit(&UART_InitStructure); /* Configure UART0 */ UART_Init(UART0,&UART_InitStructure); /* Configure UART1 */ UART_Init(UART1,&UART_InitStructure); /* Configure Uart0 Interrupt Enable*/ UART_ITConfig(UART0, (UART_IT_FLAG_TXI|UART_IT_FLAG_RXI),ENABLE); /* NVIC configuration */ NVIC_ClearPendingIRQ(UART0_IRQn); NVIC_EnableIRQ(UART0_IRQn); /* Configure Uart1 Interrupt Enable*/ UART_ITConfig(UART1,(UART_IT_FLAG_TXI|UART_IT_FLAG_RXI),ENABLE); /* NVIC configuration */ NVIC_ClearPendingIRQ(UART1_IRQn); NVIC_EnableIRQ(UART1_IRQn); /*send the data from UART0 to UART1*/ printf("Send UART0\r\n"); for(i=0;i<409600;i++) { UartPutc(UART0,(uint8_t)i); } /*send the data from UART1 to UART0*/ printf("Send UART1\r\n"); for(i=0;i<409600;i++) { UartPutc(UART1,(uint8_t)i); } /*confirm the rx/tx data counter of Uart0,1 using Uart2*/ printf("Press Any Key\r\n"); while( S_UartGetc() != 0 ) { printf("uart0_rx_cnt = %d, uart0_tx_cnt = %d\r\n",uart0_rx_cnt, uart0_tx_cnt); printf("uart1_rx_cnt = %d, uart1_tx_cnt = %d\r\n",uart1_rx_cnt, uart1_tx_cnt); } }
int main() { int32_t ch; /*System clock configuration*/ SystemInit(); /* CLK OUT Set */ // PAD_AFConfig(PAD_PA,GPIO_Pin_2, PAD_AF2); // PAD Config - CLKOUT used 3nd Function /*using debugging*/ S_UART_Init(115200); UART_StructInit(&UART_InitStructure); //UART_Init(UART0,&UART_InitStructure); UART_Init(UART1,&UART_InitStructure); UART_ITConfig(UART0,(UART_IT_FLAG_RXI),ENABLE); UART_ITConfig(UART1,(UART_IT_FLAG_RXI),ENABLE); //UART_FIFO_Enable(UART0,0,4); UART_FIFO_Enable(UART1,0,0); //S_UART_ITConfig(S_UART_CTRL_RXI,ENABLE); /* NVIC configuration */ NVIC_ClearPendingIRQ(UART0_IRQn); NVIC_EnableIRQ(UART0_IRQn); NVIC_ClearPendingIRQ(UART1_IRQn); NVIC_EnableIRQ(UART1_IRQn); while(1) { ch = uart_getc(1); uart_putc(1,(uint8_t)ch); //printf("u1rx_cnt %d\r\n",u1rx_cnt); } }
int main() { UART_InitTypeDef UART_InitStructure; SystemInit(); /* Configure UART2 */ S_UART_Init(115200); conf.scl = I2C_PA_9; conf.sda = I2C_PA_10; I2C_Init(&conf); OLED_Init(); OLED_Fill(0xFF); delay_ms(20); OLED_Fill(0x00); delay_ms(10); OLED_ShowStr(0,3,"Welcome to",1); OLED_ShowStr(0,4,"WIznet ^^",2); }
int main() { uint32_t i; uint8_t idx; /*System clock configuration*/ SystemInit(); /* UART0 and UART1 configuration*/ UART_StructInit(&UART_InitStructure); /*Hardware Flow Control use(RTS/CTS).*/ UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_RTS_CTS; /*Transmit and receive FIFO buffers are enable(FIFO mode)*/ UART0->LCR_H |=UART_LCR_H_FEN; UART1->LCR_H |=UART_LCR_H_FEN; /*UART FIFO Level Select - TX/RX level select 1/4 full. */ SetUartIFLS(UART0,UART_IFLS_RXIFLSEL1_4,UART_IFLS_TXIFLSEL1_4); SetUartIFLS(UART1,UART_IFLS_RXIFLSEL1_4,UART_IFLS_TXIFLSEL1_4); /* Configure UART0 */ UART_Init(UART0,&UART_InitStructure); /* Configure UART1 */ UART_Init(UART1,&UART_InitStructure); #ifdef UART2_DEBUG S_UART_Init(115200); #endif #ifdef UART2_DEBUG printf("TxBufferSize= %x\r\n",TxBufferSize); #endif /* The data of TXbuffer send from UART0 to UART1.*/ for(idx=0; idx<= TxBufferSize-1; idx++) { /*Check the RTS of UART1 bit*/ if((UART0->FR &UART_FR_CTS )!=0) { UART0->DR = TxBuffer[idx]; /*If this bit is set to 1, the UART is busy transmitting data. * This bitt remains set until the complete byte, including all the stop bits, has been sent from the shift register,*/ while(UART0->FR & UART_FR_BUSY); #ifdef UART2_DEBUG printf("idx = %x\r\n",idx); #endif } } #ifdef UART2_DEBUG printf("\r\n"); printf("Read DATA : \r\n"); #endif /*Check the data of RXbuffer(from UART0 to UART1)*/ for(i=0; i<=idx-2 ; i++) { /*Confirm the RX FIFO Empty flag*/ if((UART1->FR & UART_FR_RXFE)==0) { RxBuffer[i] = (UART1->DR & 0xFF); #ifdef UART2_DEBUG printf("%x = %c\r\n",i,RxBuffer[i]); #endif } } }
/** * @brief Main program * @param None * @retval None */ int main() { //uint8_t tx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; //uint8_t rx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x71, 0x72, 0x77}; uint8_t src_addr[4] = {192, 168, 1, 98}; uint8_t gw_addr[4] = {192, 168, 1, 1}; uint8_t sub_addr[4] = {255, 255, 255, 0}; uint8_t tmp[8]; uint8_t i; /* External Clock */ //CRG_PLL_InputFrequencySelect(CRG_OCLK); /* Set Systme init */ SystemInit(); /* UART0 and UART1 configuration*/ //UART_StructInit(&UART_InitStructure); /* Configure UART1 */ //UART_Init(UART1,&UART_InitStructure); S_UART_Init(115200); /* SysTick_Config */ SysTick_Config((GetSystemClock()/1000)); /* LED configuration */ GPIO_Setting(); /* Set WZ_100US Register */ setTIC100US((GetSystemClock()/10000)); //getTIC100US(); //printf(" GetSystemClock: %X, getTIC100US: %X, (%X) \r\n", // GetSystemClock, getTIC100US(), *(uint32_t *)TIC100US); #ifdef __DEF_USED_IC101AG__ //For using IC+101AG *(volatile uint32_t *)(0x41003068) = 0x64; //TXD0 - set PAD strengh and pull-up *(volatile uint32_t *)(0x4100306C) = 0x64; //TXD1 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003070) = 0x64; //TXD2 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003074) = 0x64; //TXD3 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003050) = 0x64; //TXE - set PAD strengh and pull-up #endif #ifdef __W7500P__ *(volatile uint32_t *)(0x41003070) = 0x61; *(volatile uint32_t *)(0x41003054) = 0x61; #endif #ifdef __DEF_USED_MDIO__ /* mdio Init */ mdio_init(GPIOB, MDC, MDIO ); /* PHY Link Check via gpio mdio */ while( link() == 0x0 ) { printf("."); delay(500); } printf("PHY is linked. \r\n"); #else delay(1000); #endif /* Network Configuration (Default setting) */ setSHAR(mac_addr); setSIPR(src_addr); setGAR(gw_addr); setSUBR(sub_addr); getSHAR(tmp); printf("MAC ADDRESS : %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\r\n",tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]); getSIPR(tmp); printf("IP ADDRESS : %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); getGAR(tmp); printf("GW ADDRESS : %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); getSUBR(tmp); printf("SN MASK: %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); /* Set Network Configuration */ //wizchip_init(tx_size, rx_size); /* HTTP Server Initialization */ httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); // Tx/Rx buffers (1kB) reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: MCU Reset { /* Web content registration (web content in webpage.h, Example web pages) */ // Index page and netinfo / base64 image demo reg_httpServer_webContent((uint8_t *)"index.html", (uint8_t *)index_page); // index.html : Main page example reg_httpServer_webContent((uint8_t *)"netinfo.html", (uint8_t *)netinfo_page); // netinfo.html : Network information example page reg_httpServer_webContent((uint8_t *)"netinfo.js", (uint8_t *)WIZwiki_W7500_web_netinfo_js); // netinfo.js : JavaScript for Read Network configuration (+ ajax.js) //reg_httpServer_webContent((uint8_t *)"img.html", (uint8_t *)img_page); // img.html : Base64 Image data example page // Example #1 reg_httpServer_webContent((uint8_t *)"dio.html", (uint8_t *)dio_page); // dio.html : Digital I/O control example page reg_httpServer_webContent((uint8_t *)"dio.js", (uint8_t *)WIZwiki_W7500_web_dio_js); // dio.js : JavaScript for digital I/O control (+ ajax.js) // Example #2 //reg_httpServer_webContent((uint8_t *)"ain.html", (uint8_t *)ain_page); // ain.html : Analog input monitor example page //reg_httpServer_webContent((uint8_t *)"ain.js", (uint8_t *)WIZwiki_W7500_web_ain_js); // ain.js : JavaScript for Analog input monitor (+ ajax.js) // Example #3 //reg_httpServer_webContent((uint8_t *)"ain_gauge.html", (uint8_t *)ain_gauge_page); // ain_gauge.html : Analog input monitor example page; using Google Gauge chart //reg_httpServer_webContent((uint8_t *)"ain_gauge.js", (uint8_t *)ain_gauge_js); // ain_gauge.js : JavaScript for Google Gauge chart (+ ajax.js) // AJAX JavaScript functions reg_httpServer_webContent((uint8_t *)"ajax.js", (uint8_t *)WIZwiki_W7500_web_ajax_js); // ajax.js : JavaScript for AJAX request transfer #ifdef _MAIN_DEBUG_ display_reg_webContent_list(); #endif } /* Main loop ***************************************/ while(1) { // TODO: insert user's code here for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP Server handler loopback_tcps(SOCK_TCPS, RX_BUF, 5000); } // End of Main loop }
/** * @brief Main program * @param None * @retval None */ int main() { //uint8_t tx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; //uint8_t rx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x71, 0x72, 0x77}; uint8_t src_addr[4] = {192, 168, 77, 9}; uint8_t gw_addr[4] = {192, 168, 77, 1}; uint8_t sub_addr[4] = {255, 255, 255, 0}; //uint8_t dns_server[4] = {8, 8, 8, 8}; // for Example domain name server uint8_t tmp[8]; uint32_t toggle = 1; /* External Clock */ //CRG_PLL_InputFrequencySelect(CRG_OCLK); /* Set Systme init */ SystemInit(); /* UART0 and UART1 configuration*/ //UART_StructInit(&UART_InitStructure); /* Configure UART0 */ //UART_Init(UART1,&UART_InitStructure); S_UART_Init(115200); /* SysTick_Config */ SysTick_Config((GetSystemClock()/1000)); /* Set WZ_100US Register */ setTIC100US((GetSystemClock()/10000)); //getTIC100US(); //printf(" GetSystemClock: %X, getTIC100US: %X, (%X) \r\n", // GetSystemClock, getTIC100US(), *(uint32_t *)TIC100US); #ifdef __DEF_USED_IC101AG__ //For using IC+101AG *(volatile uint32_t *)(0x41003068) = 0x64; //TXD0 - set PAD strengh and pull-up *(volatile uint32_t *)(0x4100306C) = 0x64; //TXD1 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003070) = 0x64; //TXD2 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003074) = 0x64; //TXD3 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003050) = 0x64; //TXE - set PAD strengh and pull-up #endif #ifdef __W7500P__ *(volatile uint32_t *)(0x41003070) = 0x61; *(volatile uint32_t *)(0x41003054) = 0x61; #endif #ifdef __DEF_USED_MDIO__ /* mdio Init */ mdio_init(GPIOB, MDC, MDIO ); //mdio_error_check(GPIOB, MDC, MDIO); //need verify... /* PHY Link Check via gpio mdio */ while( link() == 0x0 ) { printf("."); delay(500); } printf("PHY is linked. \r\n"); #else delay(1000); #endif /* Network Configuration (Default setting) */ setSHAR(mac_addr); setSIPR(src_addr); setGAR(gw_addr); setSUBR(sub_addr); getSHAR(tmp); printf("MAC ADDRESS : %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\r\n",tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]); getSIPR(tmp); printf("IP ADDRESS : %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); getGAR(tmp); printf("GW ADDRESS : %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); getSUBR(tmp); printf("SN MASK: %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); /* Set Network Configuration */ //wizchip_init(tx_size, rx_size); /* DHCP client Initialization */ DHCP_init(SOCK_DHCP, test_buf); /* DHCP IP allocation and check the DHCP lease time (for IP renewal) */ while(1) { switch(DHCP_run()) { case DHCP_IP_ASSIGN: case DHCP_IP_CHANGED: /* If this block empty, act with default_ip_assign & default_ip_update */ // // This example calls the registered 'my_ip_assign' in the two case. // // Add to ... // // toggle = 1; if(toggle) { getSIPR(tmp); printf("> DHCP IP : %d.%d.%d.%d\r\n", tmp[0], tmp[1], tmp[2], tmp[3]); getGAR(tmp); printf("> DHCP GW : %d.%d.%d.%d\r\n", tmp[0], tmp[1], tmp[2], tmp[3]); getSUBR(tmp); printf("> DHCP SN : %d.%d.%d.%d\r\n", tmp[0], tmp[1], tmp[2], tmp[3]); toggle = 0; close(SOCK_TCPS); /* If renewal IP address was defferent previous IP address, socket becomes to disconnect or close for new connection. */ } break; case DHCP_IP_LEASED: // if(toggle) { getSIPR(tmp); printf("> DHCP IP : %d.%d.%d.%d\r\n", tmp[0], tmp[1], tmp[2], tmp[3]); getGAR(tmp); printf("> DHCP GW : %d.%d.%d.%d\r\n", tmp[0], tmp[1], tmp[2], tmp[3]); getSUBR(tmp); printf("> DHCP SN : %d.%d.%d.%d\r\n", tmp[0], tmp[1], tmp[2], tmp[3]); toggle = 0; } // TO DO YOUR NETWORK APPs. loopback_tcps(SOCK_TCPS, test_buf, 5000); break; case DHCP_FAILED: /* ===== Example pseudo code ===== */ // The below code can be replaced your code or omitted. // if omitted, retry to process DHCP my_dhcp_retry++; if(my_dhcp_retry > MY_MAX_DHCP_RETRY) { #if DEBUG_MODE != DEBUG_NO printf(">> DHCP %d Failed\r\n",my_dhcp_retry); #endif my_dhcp_retry = 0; DHCP_stop(); // if restart, recall DHCP_init() } break; default: break; } } }
/** * @brief Main program * @param None * @retval None */ int main() { //uint8_t tx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; //uint8_t rx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; //uint8_t dns_server[4] = {8, 8, 8, 8}; // for Example domain name server uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03}; uint8_t src_addr[4] = {192, 168, 77, 123}; uint8_t gw_addr[4] = {192, 168, 77, 1}; uint8_t sub_addr[4] = {255, 255, 255, 0}; uint8_t tmp[8]; /* External Clock */ CRG_PLL_InputFrequencySelect(CRG_OCLK); /* Set Systme init */ SystemInit(); /* Configure UART2 */ S_UART_Init(115200); printf("run \r\n"); /* SysTick_Config */ SysTick_Config((GetSystemClock()/1000)); /* Set WZ_100US Register */ setTIC100US((GetSystemClock()/10000)); //getTIC100US(); //printf(" GetSystemClock: %X, getTIC100US: %X, (%X) \r\n", // GetSystemClock, getTIC100US(), *(uint32_t *)TIC100US); #ifdef __DEF_USED_IC101AG__ //For using IC+101AG *(volatile uint32_t *)(0x41003068) = 0x64; //TXD0 - set PAD strengh and pull-up *(volatile uint32_t *)(0x4100306C) = 0x64; //TXD1 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003070) = 0x64; //TXD2 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003074) = 0x64; //TXD3 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003050) = 0x64; //TXE - set PAD strengh and pull-up #endif #ifdef __W7500P__ *(volatile uint32_t *)(0x41003070) = 0x61; *(volatile uint32_t *)(0x41003054) = 0x61; #endif #ifdef __DEF_USED_MDIO__ /* mdio Init */ mdio_init(GPIOB, MDC, MDIO); //mdio_error_check(GPIOB, MDC, MDIO); //need verify... /* PHY Link Check via gpio mdio */ while( link() == 0x0) { printf("."); delay(500); } printf("PHY is linked. \r\n"); #else delay(1000); delay(1000); #endif /* Network Configuration */ setSHAR(mac_addr); setSIPR(src_addr); setGAR(gw_addr); setSUBR(sub_addr); getSHAR(tmp); printf("MAC ADDRESS : %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\r\n",tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]); getSIPR(tmp); printf("IP ADDRESS : %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); getGAR(tmp); printf("GW ADDRESS : %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); getSUBR(tmp); printf("SN MASK: %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); /* Set Network Configuration */ //wizchip_init(tx_size, rx_size); printf("TEST- START \r\n"); while(1) { loopback_tcps(0, test_buf, 5000); } }
/** * @brief Main routine for WIZwiki-W7500 * @return Function should not exit. */ int main(void) { uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x71, 0x72, 0x77}; uint8_t src_addr[4] = {192, 168, 77, 9}; uint8_t gw_addr[4] = {192, 168, 77, 1}; uint8_t sub_addr[4] = {255, 255, 255, 0}; uint8_t tmp[8]; uint32_t toggle = 1; /* Set Systme init */ SystemInit(); /* UART0 and UART1 configuration*/ //UART_StructInit(&UART_InitStructure); /* Configure UART1 */ //UART_Init(UART1,&UART_InitStructure); S_UART_Init(115200); /* SysTick_Config */ SysTick_Config((GetSystemClock()/1000)); /* Set WZ_100US Register */ setTIC100US((GetSystemClock()/10000)); //getTIC100US(); //printf(" GetSystemClock: %X, getTIC100US: %X, (%X) \r\n", // GetSystemClock, getTIC100US(), *(uint32_t *)TIC100US); #ifdef __DEF_USED_IC101AG__ //For using IC+101AG *(volatile uint32_t *)(0x41003068) = 0x64; //TXD0 - set PAD strengh and pull-up *(volatile uint32_t *)(0x4100306C) = 0x64; //TXD1 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003070) = 0x64; //TXD2 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003074) = 0x64; //TXD3 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003050) = 0x64; //TXE - set PAD strengh and pull-up #endif #ifdef __W7500P__ *(volatile uint32_t *)(0x41003070) = 0x61; *(volatile uint32_t *)(0x41003054) = 0x61; #endif #ifdef __DEF_USED_MDIO__ /* mdio Init */ mdio_init(GPIOB, MDC, MDIO ); /* PHY Link Check via gpio mdio */ while( link() == 0x0 ) { printf("."); delay(500); } printf("PHY is linked. \r\n"); #else delay(1000); #endif /* Network Configuration (Default setting) */ setSHAR(mac_addr); setSIPR(src_addr); setGAR(gw_addr); setSUBR(sub_addr); printf("======W%d NET CONF : DHCP======\r\n",_WIZCHIP_); getSHAR(tmp); printf("MAC ADDRESS : %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\r\n",tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]); getSIPR(tmp); printf("IP ADDRESS : %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); getGAR(tmp); printf("GW ADDRESS : %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); getSUBR(tmp); printf("SN MASK: %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); /* Set Network Configuration */ //wizchip_init(tx_size, rx_size); /* DHCP client Initialization */ DHCP_init(SOCK_DHCP, test_buf); /* DHCP IP allocation and check the DHCP lease time (for IP renewal) */ while(1) { switch(DHCP_run()) { case DHCP_IP_ASSIGN: case DHCP_IP_CHANGED: /* If this block empty, act with default_ip_assign & default_ip_update */ // // This example calls the registered 'my_ip_assign' in the two case. // // Add to ... // // break; case DHCP_IP_LEASED: // if(toggle) { getSIPR(tmp); printf("> DHCP IP : %d.%d.%d.%d\r\n", tmp[0], tmp[1], tmp[2], tmp[3]); getGAR(tmp); printf("> DHCP GW : %d.%d.%d.%d\r\n", tmp[0], tmp[1], tmp[2], tmp[3]); getSUBR(tmp); printf("> DHCP SN : %d.%d.%d.%d\r\n", tmp[0], tmp[1], tmp[2], tmp[3]); toggle = 0; printf("===========================\r\n"); printf("DHCP LEASED TIME : %d Sec\r\n", getDHCPLeasetime()); } // TO DO YOUR NETWORK APPs. while(1) { httpclient(SOCK_HTTPC, gDATABUF, PORT_HTTPC); } break; case DHCP_FAILED: /* ===== Example pseudo code ===== */ // The below code can be replaced your code or omitted. // if omitted, retry to process DHCP my_dhcp_retry++; if(my_dhcp_retry > MY_MAX_DHCP_RETRY) { #if DEBUG_MODE != DEBUG_NO printf(">> DHCP %d Failed\r\n",my_dhcp_retry); #endif my_dhcp_retry = 0; DHCP_stop(); // if restart, recall DHCP_init() } break; default: break; } } }
/** * @brief Main program * @param None * @retval None */ int main() { //uint8_t tx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; //uint8_t rx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03}; uint8_t src_addr[4] = {192, 168, 77, 9}; uint8_t gw_addr[4] = {192, 168, 77, 1}; uint8_t sub_addr[4] = {255, 255, 255, 0}; //uint8_t dns_server[4] = {8, 8, 8, 8}; // for Example domain name server uint8_t tmp[8], ret, cid[16]; int i; GPIO_InitTypeDef GPIO_InitDef; /* External Clock */ CRG_PLL_InputFrequencySelect(CRG_OCLK); /* Clock */ *(volatile uint32_t *)(0x41001014) = 0x000C0200; // 48MHz //*(volatile uint32_t *)(0x41001014) = 0x00050200; // 20MHz, Default //*(volatile uint32_t *)(0x41001014) = 0x00040200; // 16MHz /* Set Systme init */ SystemInit(); /* UART2 Init */ S_UART_Init(115200); /* SysTick_Config */ SysTick_Config((GetSystemClock()/1000)); /* Set WZ_100US Register */ printf(" GetSystemClock : %d (Hz) \r\n", GetSystemClock()); setTIC100US((GetSystemClock()/10000)); printf(" val: %X, getTIC100US: %X, (%X) \r\n", GetSystemClock(), getTIC100US(), *(uint32_t *)WZTOE_TIC100US); #ifdef __DEF_USED_IC101AG__ //For using IC+101AG *(volatile uint32_t *)(0x41003068) = 0x64; //TXD0 - set PAD strengh and pull-up *(volatile uint32_t *)(0x4100306C) = 0x64; //TXD1 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003070) = 0x64; //TXD2 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003074) = 0x64; //TXD3 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003050) = 0x64; //TXE - set PAD strengh and pull-up #endif printf("PHY is linked. \r\n"); #ifdef __DEF_USED_MDIO__ /* mdio Init */ mdio_init(GPIOB, MDC, MDIO ); /* PHY Link Check via gpio mdio */ while( link() == 0x0 ) { printf("."); delay(500); } printf("PHY is linked. \r\n"); #else delay(1000); delay(1000); #endif GPIO_InitDef.GPIO_Pin = (GPIO_Pin_1 | GPIO_Pin_2); GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; GPIO_Init(GPIOA, &GPIO_InitDef); PAD_AFConfig(PAD_PA, (GPIO_Pin_1 | GPIO_Pin_2), PAD_AF1); for(i=0; i<4; i++) { // LED ON GPIO_ResetBits(GPIOA, (GPIO_Pin_1 | GPIO_Pin_2)) ; delay(200); // LED OFF GPIO_SetBits(GPIOA, (GPIO_Pin_1 | GPIO_Pin_2)) ; delay(200); } printf("[DEBUG] SD Card Test\r\n"); bsp_sd_gpio_init(); ret = SD_Init(); switch(SD_Type) { case SD_TYPE_MMC: printf("[DEBUG] init ret : %d , SD Card Type : MMC\r\n", ret); break; case SD_TYPE_V1: printf("[DEBUG] init ret : %d , SD Card Type : SD\r\n", ret); break; case SD_TYPE_V2: printf("[DEBUG] init ret : %d , SD Card Type : SD2\r\n", ret); break; case SD_TYPE_V2HC: printf("[DEBUG] init ret : %d , SD Card Type : SDHC\r\n", ret); break; default: printf("[DEBUG] init ret : %d , SD Card Type : %d\r\n", ret, SD_Type); break; } memset(&cid[0], 0x00, 16); ret = SD_GetCID(cid); if( (cid[0]==0x00) && (cid[1]==0x00) && (cid[2]==0x00) && (cid[3]==0x00) && (cid[4]==0x00) && (cid[5]==0x00) && (cid[6]==0x00) && (cid[7]==0x00) && (cid[8]==0x00) && (cid[9]==0x00) && (cid[10]==0x00) && (cid[11]==0x00) && (cid[12]==0x00) && (cid[13]==0x00) && (cid[14]==0x00) && (cid[15]==0x00) ) { // Turn on LED 1 printf("SD Test Fail!!\r\n"); GPIO_ResetBits(GPIOA, GPIO_Pin_1); } else { // Turn on LED 1 & LED 2 printf("SD Test O.K!!!r\n"); GPIO_ResetBits(GPIOA, (GPIO_Pin_1|GPIO_Pin_2) ); } //printf("[DEBUG] state : %d\r\n", state); printf("[DEBUG] CID / MID : 0x%.2X\r\n", cid[0]); printf("[DEBUG] CID / OID : %c%c\r\n", cid[1], cid[2]); printf("[DEBUG] CID / PNM : %c%c%c%c%c\r\n", cid[3], cid[4], cid[5], cid[6], cid[7]); /* Network Configuration */ setSHAR(mac_addr); getSHAR(tmp); printf(" MAC ADDRESS : %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\r\n",tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]); setSIPR(src_addr); getSIPR(tmp); printf("IP ADDRESS : %d.%d.%d.%d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); setGAR(gw_addr); getGAR(tmp); printf("GW ADDRESS : %d.%d.%d.%d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); setSUBR(sub_addr); getSUBR(tmp); printf("SN MASK: %d.%d.%d.%d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); while(1) { loopback_tcps(0, test_buf, 5000); } }