void mdio_init(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin_MDC, uint16_t GPIO_Pin_MDIO) { /* Set GPIOs for MDIO and MDC */ GPIO_InitTypeDef GPIO_InitDef; GPIO_InitDef.GPIO_Pin = GPIO_Pin_MDC | GPIO_Pin_MDIO; GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; GPIO_Init(GPIOx, &GPIO_InitDef); PAD_AFConfig(PAD_PB, GPIO_Pin_MDIO, PAD_AF1); PAD_AFConfig(PAD_PB, GPIO_Pin_MDC, PAD_AF1); }
/** * @brief Configure the GPIO Pins. * @param None * @retval None */ void GPIO_Setting(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Configuration for red LED */ GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8; ///< Connecting GPIO_Pin_8(LED(R)) GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; ///< Set GPIO Mode as Output Port GPIO_Init(GPIOC, &GPIO_InitStruct); PAD_AFConfig(PAD_PC, GPIO_Pin_4, PAD_AF1); ///< PAD Config - LED used 2nd Function /* PAD configuration for PWM0 input */ PAD_AFConfig(PAD_PC, GPIO_Pin_0, PAD_AF2); }
void GPIO_Initialize(void) { /* GPIO LED(R) Setting */ GPIO_InitDef.GPIO_Pin = GPIO_Pin_8; // Connecting GPIO_Pin_8(LED(R)) GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to GPIO Mode to Output Port GPIO_Init(GPIOC, &GPIO_InitDef); // Set to GPIOC PAD_AFConfig(PAD_PC,GPIO_Pin_8, PAD_AF1); // PAD Config - LED used 2nd Function /* GPIO LED(G) Setting */ GPIO_InitDef.GPIO_Pin = GPIO_Pin_9; // Connecting GPIO_Pin_9(LED(G)) GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to GPIO Mode to Output Port GPIO_Init(GPIOC, &GPIO_InitDef); // Set to GPIOC PAD_AFConfig(PAD_PC,GPIO_Pin_9, PAD_AF1); // PAD Config - LED used 2nd Function }
void vLEDsInitialise( void ) { static xTimerHandle xLEDToggleTimer = NULL; /* Set the LED pin-muxing and configure as output. */ GPIO_InitTypeDef GPIO_InitDef; /* 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 /* Create the timer used to toggle LED0. */ xLEDToggleTimer = xTimerCreate( "LEDTmr", /* Just a text name to associate with the timer, useful for debugging, but not used by the kernel. */ ledTOGGLE_RATE, /* The period of the timer. */ pdTRUE, /* This timer will autoreload, so uxAutoReload is set to pdTRUE. */ NULL, /* The timer ID is not used, so can be set to NULL. */ prvLEDToggleTimerCallback ); /* The callback function executed each time the timer expires. */ /* Sanity check that the timer was actually created. */ configASSERT( xLEDToggleTimer ); /* Start the timer. If this is called before the scheduler is started then the block time will automatically get changed to 0 (from portMAX_DELAY). */ xTimerStart( xLEDToggleTimer, portMAX_DELAY ); }
/** * @brief Configure the GPIO Pins. * @param None * @retval None */ void GPIO_Setting(void) { GPIO_InitTypeDef GPIO_InitStructure; /* GPIO Configuration for red LED */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; ///< Connecting GPIO_Pin_8(LED(R)) GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; ///< Set to GPIO Mode to Output Port GPIO_Init(GPIOC, &GPIO_InitStructure); PAD_AFConfig(PAD_PC, GPIO_Pin_8, PAD_AF1); ///< PAD Config - LED used 2nd Function /* GPIO Configuration for green LED */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; ///< Connecting GPIO_Pin_9(LED(G)) GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; ///< Set to GPIO Mode to Output Port GPIO_Init(GPIOC, &GPIO_InitStructure); PAD_AFConfig(PAD_PC, GPIO_Pin_9, PAD_AF1); ///< PAD Config - LED used 2nd Function }
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 GPIO_Setting(void) { GPIO_InitTypeDef GPIO_InitStructure; /*GPIO Configuration for red,green,blue LED */ PAD_AFConfig(PAD_PC,GPIO_Pin_0,PAD_AF1); ///< PAD Config - RED LED used 2nd Function PAD_AFConfig(PAD_PC,GPIO_Pin_5,PAD_AF1); ///< PAD Config - GREEN LED used 2nd Function PAD_AFConfig(PAD_PC,GPIO_Pin_4,PAD_AF1); ///< PAD Config - BLUE LED used 2nd Function GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_4 | GPIO_Pin_5; ///< Connecting GPIO_Pin_0(R),5(G),4(B) GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; ///< Set to GPIO Mode to Output Port GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_SetBits(GPIOC, GPIO_Pin_0);// Red - High(off) GPIO_SetBits(GPIOC, GPIO_Pin_5);// Green - High(off) GPIO_SetBits(GPIOC, GPIO_Pin_4);// Blue - High(off) }
uint32_t I2C_Init(void) { //SCL setting GPIO_InitDef.GPIO_Pin = GPIO_Pin_4; GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; GPIO_Init(GPIOC, &GPIO_InitDef); GPIO_SetBits(GPIOC, GPIO_Pin_4); //SDA setting GPIO_InitDef.GPIO_Pin = GPIO_Pin_5; GPIO_InitDef.GPIO_Mode = GPIO_Mode_IN; GPIO_Init(GPIOC, &GPIO_InitDef); GPIO_ResetBits(GPIOC, GPIO_Pin_5); PAD_AFConfig((PAD_Type) PAD_PC, GPIO_Pin_4, (PAD_AF_TypeDef) PAD_AF1); PAD_AFConfig((PAD_Type) PAD_PC, GPIO_Pin_5, (PAD_AF_TypeDef) PAD_AF1); return 0; }
void Board_LED_Set(uint16_t GPIO_Pin) { GPIO_InitDef.GPIO_Pin = GPIO_Pin; // Set to Pin_5 (LED(R)) GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to Mode Output GPIO_Init(GPIOC, &GPIO_InitDef); PAD_AFConfig(PAD_PC,GPIO_Pin, PAD_AF1); // PAD Config - LED used 2nd Function delay(500); GPIO_ResetBits(GPIOC, GPIO_Pin); delay(500); GPIO_SetBits(GPIOC, GPIO_Pin); delay(500); GPIO_ResetBits(GPIOC, GPIO_Pin); }
void Board_LED_Toggle(void) { /* GPIO LED(R) Set */ GPIO_InitDef.GPIO_Pin = GPIO_Pin_8; // Set to Pin_5 (LED(R)) GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to Mode Output GPIO_Init(GPIOC, &GPIO_InitDef); PAD_AFConfig(PAD_PC,GPIO_Pin_8, PAD_AF1); // PAD Config - LED used 2nd Function delay(500); GPIO_ResetBits(GPIOC, GPIO_Pin_8); delay(500); GPIO_SetBits(GPIOC, GPIO_Pin_8); delay(500); GPIO_ResetBits(GPIOC, GPIO_Pin_8); }
/** * @brief Configures LED GPIO. * @param Led: Specifies the Led to be configured. * This parameter can be one of following parameters: * @arg WIZWIKI-W7500 board: LED_R / LED_G / LED_B * @arg WIZWIKI-W7500ECO board: LED1 / LED2 * @retval None */ void LED_Init(Led_TypeDef Led) { GPIO_InitTypeDef GPIO_InitStructure; if(Led >= LEDn) return; /* Configure the GPIO_LED pin */ GPIO_InitStructure.GPIO_Pin = LED_PIN[Led]; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_Init(LED_PORT[Led], &GPIO_InitStructure); PAD_AFConfig(LED_PAD[Led], LED_PIN[Led], LED_PAD_AF[Led]); /* LED off */ GPIO_SetBits(LED_PORT[Led], LED_PIN[Led]); }
int main(int argc, char *argv[]) { uint32_t delay = 0; SystemInit(); GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitDef.GPIO_Pin = GPIO_Pin_8; GPIO_Init(GPIOC, &GPIO_InitDef); PAD_AFConfig(PAD_PC, GPIO_Pin_8, PAD_AF1); while(1) { GPIO_SetBits(GPIOC, GPIO_Pin_8); for (delay = 1250000; delay != 0; delay--); GPIO_ResetBits(GPIOC, GPIO_Pin_8); for (delay = 1250000; delay != 0; delay--); } return 0; }
uint32_t I2C_Init(I2C_ConfigStruct* conf) { uint32_t scl_port_num; uint32_t scl_pin_index; uint32_t sda_port_num; uint32_t sda_pin_index; scl_port_num = I2C_PORT(conf->scl); scl_pin_index = I2C_PIN_INDEX(conf->scl); sda_port_num = I2C_PORT(conf->sda); sda_pin_index = I2C_PIN_INDEX(conf->sda); //SCL setting GPIO_InitDef.GPIO_Pin = scl_pin_index; GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; if(scl_port_num == 0) { GPIO_Init(GPIOA, &GPIO_InitDef); GPIO_SetBits(GPIOA, scl_pin_index); } else if(scl_port_num == 1) { GPIO_Init(GPIOB, &GPIO_InitDef); GPIO_SetBits(GPIOB, scl_pin_index); } else if(scl_port_num == 2) { GPIO_Init(GPIOC, &GPIO_InitDef); GPIO_SetBits(GPIOC, scl_pin_index); } else if(scl_port_num == 3) { GPIO_Init(GPIOD, &GPIO_InitDef); GPIO_SetBits(GPIOD, scl_pin_index); } else { printf("SCL pin Port number error\r\n"); return 1; } //SDA setting GPIO_InitDef.GPIO_Pin = sda_pin_index; GPIO_InitDef.GPIO_Mode = GPIO_Mode_IN; if(sda_port_num == 0) { GPIO_Init(GPIOA, &GPIO_InitDef); GPIO_ResetBits(GPIOA, sda_pin_index); } else if(sda_port_num == 1) { GPIO_Init(GPIOB, &GPIO_InitDef); GPIO_ResetBits(GPIOB, sda_pin_index); } else if(sda_port_num == 2) { GPIO_Init(GPIOC, &GPIO_InitDef); GPIO_ResetBits(GPIOC, sda_pin_index); } else if(sda_port_num == 3) { GPIO_Init(GPIOD, &GPIO_InitDef); GPIO_ResetBits(GPIOD, sda_pin_index); } else { printf("SDA pin Port number error\r\n"); return 1; } PAD_AFConfig((PAD_Type) scl_port_num, scl_pin_index, (PAD_AF_TypeDef) PAD_AF1); PAD_AFConfig((PAD_Type) sda_port_num, sda_pin_index, (PAD_AF_TypeDef) PAD_AF1); return 0; }
/** * @brief Main Function */ int main() { /* Set Systme init */ 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 /* < SSP_StructInit default values SSP_InitStructure.SSP_SerialClockRate = 0x00; SSP_InitStructure.SSP_FrameFormat = SSP_FrameFormat_MO; SSP_InitStructure.SSP_CPHA = SSP_CPHA_1Edge; SSP_InitStructure.SSP_CPOL = SSP_CPOL_Low; SSP_InitStructure.SSP_DataSize = SSP_DataSize_8b; SSP_InitStructure.SSP_SOD = SSP_SOD_RESET; SSP_InitStructure.SSP_Mode = SSP_Mode_Master; SSP_InitStructure.SSP_NSS = SSP_NSS_Hard; SSP_InitStructure.SSP_LBM = SSP_LBM_RESET; SSP_InitStructure.SSP_SSE = SSP_SSE_SET; SSP_InitStructure.SSP_BaudRatePrescaler = SSP_BaudRatePrescaler_2; */ /* SSP0 Init -- SSP Master */ SSP_StructInit(&SSP0_InitStructure); SSP0_InitStructure.SSP_FrameFormat = SSP_FrameFormat_MO; // Motorora SPI mode SSP0_InitStructure.SSP_DataSize = SSP_DataSize_16b; SSP_Init(SSP0,&SSP0_InitStructure); /* SSP1 Init -- SSP Slave */ SSP_StructInit(&SSP1_InitStructure); SSP1_InitStructure.SSP_DataSize = SSP_DataSize_16b; SSP1_InitStructure.SSP_Mode = SSP_Mode_Slave; // SSP1 = Slave SSP_Init(SSP1,&SSP1_InitStructure); /* GPIO LED(R) Setting */ GPIO_InitDef.GPIO_Pin = GPIO_Pin_8; // Connecting GPIO_Pin_8(LED(R)) GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to GPIO Mode to Output Port GPIO_Init(GPIOC, &GPIO_InitDef); // Set to GPIOC PAD_AFConfig(PAD_PC,GPIO_Pin_8, PAD_AF1); // PAD Config - LED used 2nd Function /* GPIO LED(G) Setting */ GPIO_InitDef.GPIO_Pin = GPIO_Pin_9; // Connecting GPIO_Pin_9(LED(G)) GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to GPIO Mode to Output Port GPIO_Init(GPIOC, &GPIO_InitDef); // Set to GPIOC PAD_AFConfig(PAD_PC,GPIO_Pin_9, PAD_AF1); // PAD Config - LED used 2nd Function GPIO_SetBits(GPIOC, GPIO_Pin_8); // LED red off GPIO_SetBits(GPIOC, GPIO_Pin_9); // LED green off /* Send only data to SSP1 */ for (TxIdx=0; TxIdx<BufferSize; TxIdx++) { SSP_SendData(SSP0, SSP0_Buffer_Tx[TxIdx]); while( SSP_GetFlagStatus(SSP0, SSP_FLAG_BSY) ); } /* Receive only data from SSP0 */ while(SSP_GetFlagStatus(SSP1, SSP_FLAG_RNE)) { SSP1_Buffer_Rx[RxIdx] = (uint16_t)SSP_ReceiveData(SSP1); RxIdx++; } /* Check the received data with the send ones */ TransferStatus = Buffercmp(SSP0_Buffer_Tx, SSP1_Buffer_Rx, BufferSize); /* TransferStatus = PASSED, if the data transmitted and received are correct */ /* TransferStatus = FAILED, if the data transmitted and received are different */ if(TransferStatus == PASSED) { GPIO_ResetBits(GPIOC, GPIO_Pin_9); //Received are correct == LED green On } else if(TransferStatus == FAILED) { GPIO_ResetBits(GPIOC, GPIO_Pin_8); //Received are different == LED red On } }
/** * @brief Main Function */ int main() { /* Set Systme init */ SystemInit(); /* GPIO LED(R) Set */ GPIO_InitDef.GPIO_Pin = GPIO_Pin_0; // Set to Pin_0 (LED(R)) GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to Mode Output GPIO_Init(GPIOC, &GPIO_InitDef); PAD_AFConfig(PAD_PC,GPIO_Pin_0, PAD_AF1); // PAD Config - LED used 2nd Function /* GPIO LED(G) Set */ GPIO_InitDef.GPIO_Pin = GPIO_Pin_4; // Set to Pin_4 (LED(G)) GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to Mode Output GPIO_Init(GPIOC, &GPIO_InitDef); PAD_AFConfig(PAD_PC,GPIO_Pin_4, PAD_AF1); // PAD Config - LED used 2nd Function /* GPIO LED(B) Set */ GPIO_InitDef.GPIO_Pin = GPIO_Pin_5; // Set to Pin_5 (LED(B)) GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT; // Set to Mode Output GPIO_Init(GPIOC, &GPIO_InitDef); PAD_AFConfig(PAD_PC,GPIO_Pin_5, PAD_AF1); // PAD Config - LED used 2nd Function GPIO_SetBits(GPIOC, GPIO_Pin_0); // LED(R) Off GPIO_SetBits(GPIOC, GPIO_Pin_4); // LED(G) Off GPIO_SetBits(GPIOC, GPIO_Pin_5); // LED(B) Off while(1) { // LED(RGB) On/off delay_ms(500); GPIO_ResetBits(GPIOC, GPIO_Pin_0); GPIO_ResetBits(GPIOC, GPIO_Pin_4); GPIO_ResetBits(GPIOC, GPIO_Pin_5); delay_ms(500); GPIO_SetBits(GPIOC, GPIO_Pin_0); GPIO_SetBits(GPIOC, GPIO_Pin_4); GPIO_SetBits(GPIOC, GPIO_Pin_5); // LED(RG) On/off delay_ms(500); GPIO_ResetBits(GPIOC, GPIO_Pin_0); GPIO_ResetBits(GPIOC, GPIO_Pin_4); delay_ms(500); GPIO_SetBits(GPIOC, GPIO_Pin_0); GPIO_SetBits(GPIOC, GPIO_Pin_4); // LED(GB) On/off delay_ms(500); GPIO_ResetBits(GPIOC, GPIO_Pin_4); GPIO_ResetBits(GPIOC, GPIO_Pin_5); delay_ms(500); GPIO_SetBits(GPIOC, GPIO_Pin_4); GPIO_SetBits(GPIOC, GPIO_Pin_5); // LED(BR) On/off delay_ms(500); GPIO_ResetBits(GPIOC, GPIO_Pin_0); GPIO_ResetBits(GPIOC, GPIO_Pin_5); delay_ms(500); GPIO_SetBits(GPIOC, GPIO_Pin_0); GPIO_SetBits(GPIOC, GPIO_Pin_5); // LED(R) On/off delay_ms(500); GPIO_ResetBits(GPIOC, GPIO_Pin_0); delay_ms(500); GPIO_SetBits(GPIOC, GPIO_Pin_0); // LED(G) On/off delay_ms(500); GPIO_ResetBits(GPIOC, GPIO_Pin_4); delay_ms(500); GPIO_SetBits(GPIOC, GPIO_Pin_4); // LED(B) On/off delay_ms(500); GPIO_ResetBits(GPIOC, GPIO_Pin_5); delay_ms(500); GPIO_SetBits(GPIOC, GPIO_Pin_5); } }
/** * @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); } }
/** * @brief Configure the GPIO Pins. * @param None * @retval None */ void GPIO_Setting(void) { PAD_AFConfig(PAD_PA, GPIO_Pin_6, PAD_AF3); ///< PAD Configuration for PWM3 output PAD_AFConfig(PAD_PA, GPIO_Pin_7, PAD_AF3); ///< PAD Configuration for PWM4 output PAD_AFConfig(PAD_PA, GPIO_Pin_8, PAD_AF3); ///< PAD Configuration for PWM5 output }