Example #1
0
File: main.c Project: Wiznet/W7500
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main()
{
    /*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
    /* NVIC configuration */
    NVIC_Configuration();

    /* CPIO configuration */
    GPIO_Setting();

    /* Dualtimer 0_0 clock enable */
    DUALTIMER_ClockEnable(DUALTIMER0_0);

    /* Dualtimer 0_0 configuration */
    Dualtimer_InitStructure.TimerLoad = 0x4FFFF;
    Dualtimer_InitStructure.TimerControl_Mode = DUALTIMER_TimerControl_Periodic;
    Dualtimer_InitStructure.TimerControl_OneShot = DUALTIMER_TimerControl_Wrapping;
    Dualtimer_InitStructure.TimerControl_Pre = DUALTIMER_TimerControl_Pre_16;
    Dualtimer_InitStructure.TimerControl_Size = DUALTIMER_TimerControl_Size_32;
    
    DUALTIMER_Init(DUALTIMER0_0, &Dualtimer_InitStructure);
    
    /* Dualtimer 0_0 Interrupt enable */
    DUALTIMER_IntConfig(DUALTIMER0_0, ENABLE);
    
    /* Dualtimer 0_0 start */
    DUALTIMER_Start(DUALTIMER0_0);

    while(1);
}
Example #2
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main()
{

    /* External Clock */
    CRG_PLL_InputFrequencySelect(CRG_OCLK);


    /* Set Systme init */
    SystemInit();

    /* CPIO configuration */
    GPIO_Setting();

    /* Get System Clock */
    sysclock = GetSystemClock();

    /* SysTick_Config */
    SysTick_Config((sysclock/1000));

    while(1)
    {
        delay(1000);
        /* RED LED toggled */
        if(GPIO_ReadOutputDataBit(GPIOC,GPIO_Pin_0) != (uint32_t)Bit_RESET)
            GPIO_ResetBits(GPIOC, GPIO_Pin_0);
        else
            GPIO_SetBits(GPIOC, GPIO_Pin_0);
    }

}
Example #3
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{	
    /*System clock configuration*/
    SystemInit();
    /* NVIC configuration */
    NVIC_Configuration();

    /* CPIO configuration */
    GPIO_Setting();

    /* Time base configuration */
    PrescalerValue = (SystemCoreClock / 1000000) / 10; // Prescale is 2 for 10MHz
    CaptureModeStruct.PWM_CHn_PR = PrescalerValue - 1;
    CaptureModeStruct.PWM_CHn_MR = 600000;
    CaptureModeStruct.PWM_CHn_LR = 1200000;
    CaptureModeStruct.PWM_CHn_UDMR = PWM_CHn_UDMR_UpCount;
    CaptureModeStruct.PWM_CHn_PDMR = PWM_CHn_PDMR_Periodic;
    CaptureModeStruct.PWM_CHn_CMR = PWM_CHn_CMR_RisingEdge;

    PWM_CaptureModeInit(PWM_CH0, &CaptureModeStruct);

    /* PWM interrupt configuration :*/
    PWM_IntConfig(PWM_CH0, ENABLE);
    PWM_CHn_IntConfig(PWM_CH0, PWM_CHn_IER_CIE, ENABLE);

    /* PWM channel 0 start */
    PWM_CHn_Start(PWM_CH0);

    while(1);
}
Example #4
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
    /*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
    /* NVIC configuration */
    NVIC_Configuration();

    /* CPIO configuration */
    GPIO_Setting();

    /* Time base configuration */
    CounterModeStruct.PWM_CHn_MR = 10;
    CounterModeStruct.PWM_CHn_LR = 20;
    CounterModeStruct.PWM_CHn_UDMR = PWM_CHn_UDMR_UpCount;
    CounterModeStruct.PWM_CHn_PDMR = PWM_CHn_PDMR_Periodic;
    CounterModeStruct.PWM_CHn_TCMR = PWM_CHn_TCMR_RisingCounterMode;

    PWM_CounterModeInit(PWM_CH0, &CounterModeStruct);

    /* PWM interrupt configuration */
    PWM_IntConfig(PWM_CH0, ENABLE);
    PWM_CHn_IntConfig(PWM_CH0, PWM_CHn_IER_MIE | PWM_CHn_IER_OIE, ENABLE);

    /* PWM channel 0 start */
    PWM_CHn_Start(PWM_CH0);

    while(1);
}
Example #5
0
File: main.c Project: Wiznet/W7500
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
    /*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
    /* NVIC configuration */
    NVIC_Configuration();

    /* CPIO configuration */
    GPIO_Setting();

    /* Timer mode configuration */
    PrescalerValue = ((SystemFrequency / 1000000) / 10); // Prescale is 2 for 10MHz
    TimerModeStructure.PWM_CHn_PR = PrescalerValue - 1;
    TimerModeStructure.PWM_CHn_MR = 600000;
    TimerModeStructure.PWM_CHn_LR = 1200000;
    TimerModeStructure.PWM_CHn_UDMR = PWM_CHn_UDMR_UpCount;
    TimerModeStructure.PWM_CHn_PDMR = PWM_CHn_PDMR_Periodic;
    
    PWM_TimerModeInit(PWM_CH0, &TimerModeStructure); 

    /* PWM interrupt configuration */
    PWM_IntConfig(PWM_CH0, ENABLE);
    PWM_CHn_IntConfig(PWM_CH0, PWM_CHn_IER_MIE | PWM_CHn_IER_OIE, ENABLE);

    /* PWM channel 0 start */
    PWM_CHn_Start(PWM_CH0);

    while(1);
}
Example #6
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
    /*System clock configuration*/
    SystemInit();
    /* NVIC configuration */
    NVIC_Configuration();

    /* CPIO configuration */
    GPIO_Setting();

    /* Time base configuration */
    CounterModeStruct.PWM_CHn_MR = 10;
    CounterModeStruct.PWM_CHn_LR = 20;
    CounterModeStruct.PWM_CHn_UDMR = PWM_CHn_UDMR_UpCount;
    CounterModeStruct.PWM_CHn_PDMR = PWM_CHn_PDMR_Periodic;
    CounterModeStruct.PWM_CHn_TCMR = PWM_CHn_TCMR_RisingCounterMode;

    PWM_CounterModeInit(PWM_CH0, &CounterModeStruct);

    /* PWM interrupt configuration */
    PWM_IntConfig(PWM_CH0, ENABLE);
    PWM_CHn_IntConfig(PWM_CH0, PWM_CHn_IER_MIE | PWM_CHn_IER_OIE, ENABLE);

    /* PWM channel 0 start */
    PWM_CHn_Start(PWM_CH0);

    while(1);
}
Example #7
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main()
{
    /*System clock configuration*/
    SystemInit();
    /* NVIC configuration */
    NVIC_Configuration();

    /* CPIO configuration */
    GPIO_Setting();

    /* Dualtimer 0_0 clock enable */
    DUALTIMER_ClockEnable(DUALTIMER0_0);

    /* Dualtimer 0_0 configuration */
    Dualtimer_InitStructure.TimerLoad = 0x4FFFF;
    Dualtimer_InitStructure.TimerControl_Mode = DUALTIMER_TimerControl_Periodic;
    Dualtimer_InitStructure.TimerControl_OneShot = DUALTIMER_TimerControl_Wrapping;
    Dualtimer_InitStructure.TimerControl_Pre = DUALTIMER_TimerControl_Pre_16;
    Dualtimer_InitStructure.TimerControl_Size = DUALTIMER_TimerControl_Size_32;
    
    DUALTIMER_Init(DUALTIMER0_0, &Dualtimer_InitStructure);
    
    /* Dualtimer 0_0 Interrupt enable */
    DUALTIMER_IntConfig(DUALTIMER0_0, ENABLE);
    
    /* Dualtimer 0_0 start */
    DUALTIMER_Start(DUALTIMER0_0);

    while(1);
}
Example #8
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
    /*System clock configuration*/
    SystemInit();
    /* CPIO configuration */
    GPIO_Setting();

    /* Timer mode configuration for PWM3*/
    PrescalerValue = (SystemCoreClock / 1000000) / 10; // Prescale is 2 for 10MHz
    TimerModeStructure.PWM_CHn_PR = PrescalerValue - 1;
    TimerModeStructure.PWM_CHn_MR = 80000;
    TimerModeStructure.PWM_CHn_LR = 100000; // 80% duty cycle
    TimerModeStructure.PWM_CHn_UDMR = PWM_CHn_UDMR_UpCount;
    TimerModeStructure.PWM_CHn_PDMR = PWM_CHn_PDMR_Periodic;
    
    PWM_TimerModeInit(PWM_CH3, &TimerModeStructure);
    
    /* Timer mode configuration for PWM4*/
    TimerModeStructure.PWM_CHn_PR = PrescalerValue - 1;
    TimerModeStructure.PWM_CHn_MR = 30000;
    TimerModeStructure.PWM_CHn_LR = 100000; // 30% duty cycle
    TimerModeStructure.PWM_CHn_UDMR = PWM_CHn_UDMR_UpCount;
    TimerModeStructure.PWM_CHn_PDMR = PWM_CHn_PDMR_Periodic;
    
    PWM_TimerModeInit(PWM_CH4, &TimerModeStructure);
    
    /* Timer mode configuration for PWM5*/
    TimerModeStructure.PWM_CHn_PR = PrescalerValue - 1;
    TimerModeStructure.PWM_CHn_MR = 4294900000UL;
    TimerModeStructure.PWM_CHn_LR =  4294800000UL;
    TimerModeStructure.PWM_CHn_UDMR = PWM_CHn_UDMR_DownCount;
    TimerModeStructure.PWM_CHn_PDMR = PWM_CHn_PDMR_Oneshot;
    
    PWM_TimerModeInit(PWM_CH5, &TimerModeStructure);
    

    /* PWM output enable */
    PWM_CtrlPWMOutputEnable(PWM_CH3);
    PWM_CtrlPWMOutputEnable(PWM_CH4);
    PWM_CtrlPWMOutputEnable(PWM_CH5);

    /* PWM start */
    PWM_CHn_Start(PWM_CH3);
    PWM_CHn_Start(PWM_CH4);
    PWM_CHn_Start(PWM_CH5);

    while(1);
}
Example #9
0
/**
 * @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

}