Ejemplo n.º 1
0
/**
* @brief  Displays the message on LCD on device lib initialization
* @param  None
* @retval None
*/
void USBD_USR_Init(void)
{
  /* Initialize LEDs */
  STM_EVAL_LEDInit(LED4);   

  /* Init LCD */
  STM32f4_Discovery_LCD_Init();
  
  LCD_LOG_Init();
  
#ifdef USE_USB_OTG_HS 
  LCD_LOG_SetHeader(" USB OTG HS MSC Device");
#else
  LCD_LOG_SetHeader(" USB OTG FS MSC Device");
#endif
  LCD_UsrLog("> USB device library started.\n"); 
  LCD_LOG_SetFooter ("     USB Device Library v1.1.0" );
  
  
  /* Information panel */
  LCD_SetTextColor(Green);
  LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 42, USER_INFORMATION1);
  LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 30, USER_INFORMATION2);
  LCD_SetTextColor(LCD_LOG_DEFAULT_COLOR);  
}
/**
  * @brief  Initializes the LCD and LEDs resources.
  * @param  None
  * @retval None
  */
void LCD_LED_Init(void)
{
#ifdef USE_LCD
  /* Initialize the STM324xG-EVAL's LCD */
  STM32f4_Discovery_LCD_Init();
#endif

  STM_EVAL_LEDInit(LED4); 
#ifdef USE_LCD
  /* Clear the LCD */
  LCD_Clear(Black);

  /* Set the LCD Back Color */
  LCD_SetBackColor(Black);

  /* Set the LCD Text Color */
  LCD_SetTextColor(White);

  /* Display message on the LCD*/
  LCD_DisplayStringLine(Line0, (uint8_t*)MESSAGE1);
  LCD_DisplayStringLine(Line1, (uint8_t*)MESSAGE2);
  LCD_DisplayStringLine(Line2, (uint8_t*)MESSAGE3);
  LCD_DisplayStringLine(Line3, (uint8_t*)MESSAGE4); 
#endif
}
Ejemplo n.º 3
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  volatile uint32_t dlycnt;

  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
  */

  /* wait the power stable */
  for (dlycnt = 0; dlycnt < 10000000; dlycnt++);

  STM32f4_Discovery_LCD_Init();

  /* Display message on stm32f4_discovery LCD **********************************/
  /* Clear the LCD */ 
  LCD_Clear(LCD_COLOR_WHITE);

  /* Set the LCD Back Color */
  LCD_SetBackColor(LCD_COLOR_BLUE);
  /* Set the LCD Text Color */
  LCD_SetTextColor(LCD_COLOR_WHITE);
  LCD_DisplayStringLine(LINE(3), (uint8_t *)MESSAGE1);
  LCD_DisplayStringLine(LINE(4), (uint8_t *)MESSAGE2);
  LCD_DisplayStringLine(LINE(5), (uint8_t *)MESSAGE3);
  /* wait for a moment */
  for (dlycnt = 0; dlycnt < 50000000; dlycnt++);

  /* LCD RGB Test */
  LCD_RGB_Test();
  while (1);
}
Ejemplo n.º 4
0
/*
 * MAIN TASK
 */
int main(void)
{
	//GPIO_InitTypeDef GPIO_InitStructure;

	SystemInit();
	/*Initializes Erika related stuffs*/
	EE_system_init();

	SWatch_state.errorStatus = errorSig;
	SWatch_state.ModelData.prevZCSigState = &ZCSig;
	SWatch_state.ModelData.dwork = &DWork;

	/* init state machine */
	SWatch_initialize(&SWatch_state,
			&Bplus, &Bminus, &Btime, &Btimer, &Balarm, &Bswatch, &Bstart, &Bstop,
			&hours, &minutes, &seconds, &tenths, &mode, &alarm_signal, &timer_exp);

	/*Initialize systick */
	EE_systick_set_period(MILLISECONDS_TO_TICKS(1, SystemCoreClock));
	EE_systick_enable_int();
	EE_systick_start();

	/* Initializes LCD and touchscreen */
	IOE_Config();
	/* Initialize the LCD */
	STM32f4_Discovery_LCD_Init();

	//	LCD_Clear(White);

	/* Set the LCD Text size */
	//	LCD_SetFont(&Font8x12);
	//	Lcd_Touch_Calibration();
	InitTouch(-0.102, 0.0656, -335, 10);

	/* Draw the background */
	DrawInit(MyWatchScr);
	LCD_SetTextColor(Black);
	LCD_SetBackColor(Black);
	LCD_DrawFullRect(10, 80, 240, 56);
	WPrint(&MyWatchScr[SEP1STR], ":");
	WPrint(&MyWatchScr[SEP2STR], ":");


	/* Program cyclic alarms which will fire after an initial offset,
	 * and after that periodically
	 * */
	SetRelAlarm(AlarmTaskLCD, 10, 50);
	SetRelAlarm(AlarmTaskClock, 10, 100);

	/* Forever loop: background activities (if any) should go here */
	for (;;) { 
	}

}
Ejemplo n.º 5
0
/**
  * @brief  Program entry point
  * @param  None
  * @retval None
*/
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
  this is done through SystemInit() function which is called from startup
  file (startup_stm32fxxx_xx.s) before to branch to application main.
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32fxxx.c file
  */  
  
  /* Initialize the LCD */
  STM32f4_Discovery_LCD_Init();

  LCD_LOG_Init();
  
  LCD_LOG_SetHeader(" Binary image template ");
  LCD_UsrLog("> Systick template example started.\n"); 
  LCD_LOG_SetFooter ("     Binary image template " ); 
  
  /* Configure the LEDs */
  STM_EVAL_LEDInit(LED4);  

   /* Set the Vector Table base location at the application start address
      (this is already done in system_stm32fxxx.c file) */   
//#ifdef STM32F2XX
//  /* Set the Vector Table base location at 0xC000 */ 
//  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0xC000);
//#elif defined(STM32F4XX)
//  /* Set the Vector Table base location at 0xC000 */ 
//  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0xC000);
//#elif defined(STM32F10X_CL)
//  /* Set the Vector Table base location at 0x8000 */ 
//  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x8000);
//#endif /* STM32F2XX */
  
  /* SysTick end of count event each 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);  
  
  while (1)
  {
    /* Toggle all leds */
    STM_EVAL_LEDToggle(LED4);
    
    /* Insert 200 ms delay */
    Delay(200);
    
    /* Toggle all leds */
    STM_EVAL_LEDToggle(LED4);
    
    /* Insert 200 ms delay */
    Delay(200);
  }
} 
Ejemplo n.º 6
0
/*********************************************************************
*
*       LCD_X_DisplayDriver
*
* Function description:
*   This function is called by the display driver for several purposes.
*   To support the according task the routine needs to be adapted to
*   the display controller. Please note that the commands marked with
*   'optional' are not cogently required and should only be adapted if
*   the display controller supports these features.
*
* Parameter:
*   LayerIndex - Index of layer to be configured
*   Cmd        - Please refer to the details in the switch statement below
*   pData      - Pointer to a LCD_X_DATA structure
*
* Return Value:
*   < -1 - Error
*     -1 - Command not handled
*      0 - Ok
*/
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
  int r;
  (void) LayerIndex;
  (void) pData;

  switch (Cmd) {
  case LCD_X_INITCONTROLLER: {
    /* Already Done in bsp.c file */
    STM32f4_Discovery_LCD_Init();
    return 0;
  }
  default:
    r = -1;
  }
  return r;
}
Ejemplo n.º 7
0
/**
* @brief  USBH_USR_Init 
*         Displays the message on LCD for host lib initialization
* @param  None
* @retval None
*/
void USBH_USR_Init(void)
{
  static uint8_t startup = 0;  
  
  if (startup == 0 ) {
    startup = 1;
    /* Configure the LEDs */ 
    STM_EVAL_LEDInit(LED4); 
    
    STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
    
    STM32f4_Discovery_LCD_Init();

    LCD_LOG_Init();
      
#ifdef USE_USB_OTG_HS 
    LCD_LOG_SetHeader(" USB OTG HS MSC Host");
#else
    LCD_LOG_SetHeader(" USB OTG FS MSC Host");
#endif
    LCD_UsrLog("> USB Host library started.\n"); 
    LCD_LOG_SetFooter ("     USB Host Library v2.1.0" );
  }
}
Ejemplo n.º 8
0
/**
  * @brief  Calibre l'écran tactile
  * @param  mode: le mode de calibration	(@ref TS_Calibration_mode_e)
  * @pre	Cette fonction doit être appelée en boucle jusqu'à ce qu'elle renvoit TRUE (calibration terminée).
  * @post	Lors de l'état INIT, l'appel à TS_Init() est réalisé.
  * @retval running_e END_OK si la calibration est terminée, IN_PROGRESS sinon.
  */
running_e TS_Calibration(bool_e ask_for_finish, TS_Calibration_mode_e mode)
{
	typedef enum{
		INIT=0,
		LEFT_CROSS_DISPLAY,
		WAIT_FIRST_PRESS,
		WAIT_FIRST_RELEASE,
		RIGHT_CROSS_DISPLAY,
		WAIT_SECOND_PRESS,
		WAIT_SECOND_RELEASE,
		COMPUTE,
		WAIT_PRESS_TO_EXIT,
		PLAY_TELECRAN,
		CLOSE
	}state_e;

	static state_e state = INIT;
	static TS_ADC first_cross_point, second_cross_point;
	static bool_e asked_for_finish = FALSE;
	TS_ADC trash;
	char* text[35];
	running_e ret;

	ret = IN_PROGRESS;
	if(ask_for_finish)
		asked_for_finish = TRUE;
	switch(state)
	{
		case INIT:
			asked_for_finish = FALSE;
			TS_Init();
			STM32f4_Discovery_LCD_Init();
			LCD_Clear(LCD_COLOR_WHITE);
			LCD_SetFont(&Font12x12);
			if(mode == CALIBRATION_MODE_NO_CALIBRATION)
				state = CLOSE;
			else
			{
				printf("Calibration of Touchscreen (for display DM-LCD25RT)\n");
				state = LEFT_CROSS_DISPLAY;
			}
			break;


		case LEFT_CROSS_DISPLAY:
			LCD_DrawUniLine(CROSS_MARGIN-CROSS_SIZE, 	CROSS_MARGIN, 			CROSS_MARGIN+CROSS_SIZE,CROSS_MARGIN, 			 LCD_COLOR_BLUE);
			LCD_DrawUniLine(CROSS_MARGIN-CROSS_SIZE, 	CROSS_MARGIN-1, 		CROSS_MARGIN+CROSS_SIZE,CROSS_MARGIN-1, 		 LCD_COLOR_BLUE);
			LCD_DrawUniLine(CROSS_MARGIN-CROSS_SIZE,	CROSS_MARGIN+1,			CROSS_MARGIN+CROSS_SIZE,CROSS_MARGIN+1, 		 LCD_COLOR_BLUE);
			LCD_DrawUniLine(CROSS_MARGIN,				CROSS_MARGIN-CROSS_SIZE,CROSS_MARGIN,			CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE);
			LCD_DrawUniLine(CROSS_MARGIN-1,			 	CROSS_MARGIN-CROSS_SIZE,CROSS_MARGIN-1, 		CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE);
			LCD_DrawUniLine(CROSS_MARGIN+1,				CROSS_MARGIN-CROSS_SIZE,CROSS_MARGIN+1,	 		CROSS_MARGIN+CROSS_SIZE, LCD_COLOR_BLUE);
			state = WAIT_FIRST_PRESS;
			break;


		case WAIT_FIRST_PRESS:
			if(!t)
			{
				t = 100;
				TS_Get_Filtered_Touch(&first_cross_point);
				if(first_cross_point.touch_detected)
					state = WAIT_FIRST_RELEASE;
			}
			if(asked_for_finish)
				state = CLOSE;
			break;

		case WAIT_FIRST_RELEASE:
			if(!t)
			{
				t = 100;
				if(!TS_Get_Filtered_Touch(&trash))
					state = RIGHT_CROSS_DISPLAY;
			}
			if(asked_for_finish)
				state = CLOSE;
			break;


		case RIGHT_CROSS_DISPLAY:
			LCD_Clear(LCD_COLOR_WHITE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-CROSS_SIZE,	LCD_PIXEL_HEIGHT-CROSS_MARGIN, 				LCD_PIXEL_WIDTH-CROSS_MARGIN+CROSS_SIZE,  	LCD_PIXEL_HEIGHT-CROSS_MARGIN,				LCD_COLOR_BLUE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-CROSS_SIZE,	LCD_PIXEL_HEIGHT-CROSS_MARGIN-1,			LCD_PIXEL_WIDTH-CROSS_MARGIN+CROSS_SIZE, 	LCD_PIXEL_HEIGHT-CROSS_MARGIN-1,			LCD_COLOR_BLUE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-CROSS_SIZE,	LCD_PIXEL_HEIGHT-CROSS_MARGIN+1,			LCD_PIXEL_WIDTH-CROSS_MARGIN+CROSS_SIZE,  	LCD_PIXEL_HEIGHT-CROSS_MARGIN+1,			LCD_COLOR_BLUE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN,  				LCD_PIXEL_HEIGHT-CROSS_MARGIN-CROSS_SIZE,  	LCD_PIXEL_WIDTH-CROSS_MARGIN,  				LCD_PIXEL_HEIGHT-CROSS_MARGIN+CROSS_SIZE,	LCD_COLOR_BLUE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN-1,  			LCD_PIXEL_HEIGHT-CROSS_MARGIN-CROSS_SIZE,  	LCD_PIXEL_WIDTH-CROSS_MARGIN-1, 			LCD_PIXEL_HEIGHT-CROSS_MARGIN+CROSS_SIZE,	LCD_COLOR_BLUE);
			LCD_DrawUniLine(LCD_PIXEL_WIDTH-CROSS_MARGIN+1,  			LCD_PIXEL_HEIGHT-CROSS_MARGIN-CROSS_SIZE,  	LCD_PIXEL_WIDTH-CROSS_MARGIN+1,  			LCD_PIXEL_HEIGHT-CROSS_MARGIN+CROSS_SIZE,	LCD_COLOR_BLUE);
			state = WAIT_SECOND_PRESS;
			break;

		case WAIT_SECOND_PRESS:
			if(!t)
			{
				t = 100;
				TS_Get_Filtered_Touch(&second_cross_point);
				if(second_cross_point.touch_detected)
					state = COMPUTE;
			}
			if(asked_for_finish)
				state = CLOSE;
			break;

		case COMPUTE:
			ts_coeff.scale_x = (float)((LCD_PIXEL_WIDTH-2*CROSS_MARGIN))	/	((float)second_cross_point.x-(float)first_cross_point.x);
			ts_coeff.scale_y = (float)((LCD_PIXEL_HEIGHT-2*CROSS_MARGIN))	/	((float)second_cross_point.y-(float)first_cross_point.y);

			ts_coeff.offset_x = (float)(CROSS_MARGIN-ts_coeff.scale_x*(float)first_cross_point.x);
			ts_coeff.offset_y = (float)(CROSS_MARGIN-ts_coeff.scale_y*(float)first_cross_point.y);

			if(mode >= CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE)
			{
				LCD_Clear(LCD_COLOR_WHITE);
				sprintf((char*)text,"First cross x = %d  ", first_cross_point.x);
				LCD_DisplayStringLine(LINE(3),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"Second cross x = %d  ", second_cross_point.x);
				LCD_DisplayStringLine(LINE(5),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"First cross y = %d  ", first_cross_point.y);
				LCD_DisplayStringLine(LINE(4),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"Second cross y = %d  ", second_cross_point.y);
				LCD_DisplayStringLine(LINE(6),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);

				LCD_DisplayStringLine(LINE(8),COLUMN(0),(uint8_t *)"Toucher pour continuer !",LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);

				sprintf((char*)text,"Scale x = %f",ts_coeff.scale_x);	//%ld.%03ld  ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.scale_x*1000)-(1000*(int32_t)ts_coeff.scale_x));
				LCD_DisplayStringLine(LINE(10),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"Offset x = %f",ts_coeff.offset_x);	// = %ld.%03ld  ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.offset_x*1000)-(1000*(int32_t)ts_coeff.offset_x));
				LCD_DisplayStringLine(LINE(11),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"Scale y = %f",ts_coeff.scale_y);	// = %ld.%03ld  ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.scale_y*1000)-(1000*(int32_t)ts_coeff.scale_y));
				LCD_DisplayStringLine(LINE(12),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				sprintf((char*)text,"Offset y = %f",ts_coeff.offset_y);	// = %ld.%03ld  ", (int32_t)ts_coeff.scale_x,(int32_t)(ts_coeff.offset_y*1000)-(1000*(int32_t)ts_coeff.offset_y));
				LCD_DisplayStringLine(LINE(13),COLUMN(0),(uint8_t *)text,LCD_COLOR_BLACK, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);

				if(mode == CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE_AND_PROVIDE_TELECRAN_GAME)
				{
					LCD_DisplayStringLine(LINE(15),COLUMN(0),(uint8_t *)"To quit the Telecran Game,",LCD_COLOR_RED, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
					LCD_DisplayStringLine(LINE(16),COLUMN(0),(uint8_t *)"Just press the blue button",LCD_COLOR_RED, LCD_COLOR_WHITE,LCD_DISPLAY_ON_UART);
				}
			}
			state = WAIT_SECOND_RELEASE;
			break;

		case WAIT_SECOND_RELEASE:
			if(!t)
			{
				t = 100;
				if(!TS_Get_Filtered_Touch(&trash))
				{
					switch(mode)
					{
						case CALIBRATION_MODE_JUST_CALIBRATE:
							state = CLOSE;
							break;
						case CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE:
							state = WAIT_PRESS_TO_EXIT;
							break;
						case CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE_AND_PROVIDE_TELECRAN_GAME:
							state = WAIT_PRESS_TO_EXIT;
							break;
						default:
							state = CLOSE;
							break;
					}
				}
			}
			if(asked_for_finish)
				state = CLOSE;
			break;

		case WAIT_PRESS_TO_EXIT:
			if(!t)
			{
				t = 100;
				if(TS_Get_Filtered_Touch(&trash))
				{
					if(mode == CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE)
					{
						LCD_Clear(LCD_COLOR_WHITE);
						state = CLOSE;
					}
					else	//CALIBRATION_MODE_CALIBRATE_AND_SHOW_VALUE_AND_PROVIDE_TELECRAN_GAME
					{
						LCD_Clear(LCD_COLOR_BLACK);
						state = PLAY_TELECRAN;
					}
				}
			}
			if(asked_for_finish)
				state = CLOSE;
			break;
		case PLAY_TELECRAN:{
			uint16_t x,y;
			char str[30];
			if(!t)
			{
				t = 15;
				if(TS_Get_Touch(&x,&y))
				{
					sprintf((char*)str,"x = %5d",x);
					LCD_DisplayStringLine(LINE(1),COLUMN(0),(uint8_t *)str, LCD_COLOR_WHITE, LCD_COLOR_BLACK,LCD_NO_DISPLAY_ON_UART);
					sprintf((char*)str,"y = %5d",y);
					LCD_DisplayStringLine(LINE(2),COLUMN(0),(uint8_t *)str, LCD_COLOR_WHITE, LCD_COLOR_BLACK,LCD_NO_DISPLAY_ON_UART);
					LCD_PutPixel(x, y, LCD_COLOR_YELLOW);
				}
			}
			if(asked_for_finish)
				state = CLOSE;
			break;}

		case CLOSE:
			LCD_Clear(LCD_COLOR_WHITE);
			state = INIT;
			ret = END_OK;
			break;
		default:
			break;
	}

	return ret;
}
Ejemplo n.º 9
0
int_t main(void)
{
   error_t error;
   NetInterface *interface;
   OsTask *task;
   MacAddr macAddr;
#if (APP_USE_DHCP == DISABLED)
   Ipv4Addr ipv4Addr;
#endif
#if (APP_USE_SLAAC == DISABLED)
   Ipv6Addr ipv6Addr;
#endif

   //Initialize kernel
   osInitKernel();
   //Configure debug UART
   debugInit(115200);

   //Start-up message
   TRACE_INFO("\r\n");
   TRACE_INFO("**********************************\r\n");
   TRACE_INFO("*** CycloneTCP Web Server Demo ***\r\n");
   TRACE_INFO("**********************************\r\n");
   TRACE_INFO("Copyright: 2010-2014 Oryx Embedded\r\n");
   TRACE_INFO("Compiled: %s %s\r\n", __DATE__, __TIME__);
   TRACE_INFO("Target: STM32F407\r\n");
   TRACE_INFO("\r\n");

   //Configure I/Os
   ioInit();

   //Initialize LCD display
   STM32f4_Discovery_LCD_Init();
   LCD_SetBackColor(Blue);
   LCD_SetTextColor(White);
   LCD_SetFont(&Font16x24);
   LCD_Clear(Blue);

   //Welcome message
   lcdSetCursor(0, 0);
   printf("Web Server Demo");

   //TCP/IP stack initialization
   error = tcpIpStackInit();
   //Any error to report?
   if(error)
   {
      //Debug message
      TRACE_ERROR("Failed to initialize TCP/IP stack!\r\n");
   }

   //Configure the first Ethernet interface
   interface = &netInterface[0];

   //Set interface name
   tcpIpStackSetInterfaceName(interface, "eth0");
   //Set host name
   tcpIpStackSetHostname(interface, "WebServerDemo");
   //Select the relevant network adapter
   tcpIpStackSetDriver(interface, &stm32f4x7EthDriver);
   tcpIpStackSetPhyDriver(interface, &lan8720PhyDriver);
   //Set host MAC address
   macStringToAddr(APP_MAC_ADDR, &macAddr);
   tcpIpStackSetMacAddr(interface, &macAddr);

   //Initialize network interface
   error = tcpIpStackConfigInterface(interface);
   //Any error to report?
   if(error)
   {
      //Debug message
      TRACE_ERROR("Failed to configure interface %s!\r\n", interface->name);
   }

#if (IPV4_SUPPORT == ENABLED)
#if (APP_USE_DHCP == ENABLED)
   //Get default settings
   dhcpClientGetDefaultSettings(&dhcpClientSettings);
   //Set the network interface to be configured by DHCP
   dhcpClientSettings.interface = interface;
   //Disable rapid commit option
   dhcpClientSettings.rapidCommit = FALSE;

   //DHCP client initialization
   error = dhcpClientInit(&dhcpClientContext, &dhcpClientSettings);
   //Failed to initialize DHCP client?
   if(error)
   {
      //Debug message
      TRACE_ERROR("Failed to initialize DHCP client!\r\n");
   }

   //Start DHCP client
   error = dhcpClientStart(&dhcpClientContext);
   //Failed to start DHCP client?
   if(error)
   {
      //Debug message
      TRACE_ERROR("Failed to start DHCP client!\r\n");
   }
#else
   //Set IPv4 host address
   ipv4StringToAddr(APP_IPV4_HOST_ADDR, &ipv4Addr);
   ipv4SetHostAddr(interface, ipv4Addr);

   //Set subnet mask
   ipv4StringToAddr(APP_IPV4_SUBNET_MASK, &ipv4Addr);
   ipv4SetSubnetMask(interface, ipv4Addr);

   //Set default gateway
   ipv4StringToAddr(APP_IPV4_DEFAULT_GATEWAY, &ipv4Addr);
   ipv4SetDefaultGateway(interface, ipv4Addr);

   //Set primary and secondary DNS servers
   ipv4StringToAddr(APP_IPV4_PRIMARY_DNS, &ipv4Addr);
   ipv4SetDnsServer(interface, 0, ipv4Addr);
   ipv4StringToAddr(APP_IPV4_SECONDARY_DNS, &ipv4Addr);
   ipv4SetDnsServer(interface, 1, ipv4Addr);
#endif
#endif

#if (IPV6_SUPPORT == ENABLED)
#if (APP_USE_SLAAC == ENABLED)
   //Get default settings
   slaacGetDefaultSettings(&slaacSettings);
   //Set the network interface to be configured
   slaacSettings.interface = interface;

   //SLAAC initialization
   error = slaacInit(&slaacContext, &slaacSettings);
   //Failed to initialize SLAAC?
   if(error)
   {
      //Debug message
      TRACE_ERROR("Failed to initialize SLAAC!\r\n");
   }

   //Start IPv6 address autoconfiguration process
   error = slaacStart(&slaacContext);
   //Failed to start SLAAC process?
   if(error)
   {
      //Debug message
      TRACE_ERROR("Failed to start SLAAC!\r\n");
   }
#else
   //Set link-local address
   ipv6StringToAddr(APP_IPV6_LINK_LOCAL_ADDR, &ipv6Addr);
   ipv6SetLinkLocalAddr(interface, &ipv6Addr, IPV6_ADDR_STATE_VALID);

   //Set IPv6 prefix
   ipv6StringToAddr(APP_IPV6_PREFIX, &ipv6Addr);
   ipv6SetPrefix(interface, &ipv6Addr, APP_IPV6_PREFIX_LENGTH);

   //Set global address
   ipv6StringToAddr(APP_IPV6_GLOBAL_ADDR, &ipv6Addr);
   ipv6SetGlobalAddr(interface, &ipv6Addr, IPV6_ADDR_STATE_VALID);

   //Set router
   ipv6StringToAddr(APP_IPV6_ROUTER, &ipv6Addr);
   ipv6SetRouter(interface, &ipv6Addr);

   //Set primary and secondary DNS servers
   ipv6StringToAddr(APP_IPV6_PRIMARY_DNS, &ipv6Addr);
   ipv6SetDnsServer(interface, 0, &ipv6Addr);
   ipv6StringToAddr(APP_IPV6_SECONDARY_DNS, &ipv6Addr);
   ipv6SetDnsServer(interface, 1, &ipv6Addr);
#endif
#endif

   //Get default settings
   httpServerGetDefaultSettings(&httpServerSettings);
   //Bind HTTP server to the desired interface
   httpServerSettings.interface = &netInterface[0];
   //Listen to port 80
   httpServerSettings.port = HTTP_PORT;
   //Specify the server's root directory
   strcpy(httpServerSettings.rootDirectory, "/www/");
   //Set default home page
   strcpy(httpServerSettings.defaultDocument, "index.shtm");
   //Callback functions
   httpServerSettings.cgiCallback = httpServerCgiCallback;
   httpServerSettings.uriNotFoundCallback = httpServerUriNotFoundCallback;

   //HTTP server initialization
   error = httpServerInit(&httpServerContext, &httpServerSettings);
   //Failed to initialize HTTP server?
   if(error)
   {
      //Debug message
      TRACE_ERROR("Failed to initialize HTTP server!\r\n");
   }

   //Start HTTP server
   error = httpServerStart(&httpServerContext);
   //Failed to start HTTP server?
   if(error)
   {
      //Debug message
      TRACE_ERROR("Failed to start HTTP server!\r\n");
   }

   //Create user task
   task = osCreateTask("User Task", userTask, NULL, 500, 1);
   //Failed to create the task?
   if(task == OS_INVALID_HANDLE)
   {
      //Debug message
      TRACE_ERROR("Failed to create task!\r\n");
   }

   //Create a task to blink the LED
   task = osCreateTask("Blink", blinkTask, NULL, 500, 1);
   //Failed to create the task?
   if(task == OS_INVALID_HANDLE)
   {
      //Debug message
      TRACE_ERROR("Failed to create task!\r\n");
   }

   //Start the execution of tasks
   osStartKernel();

   //This function should never return
   return 0;
}
Ejemplo n.º 10
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */
  /* SysTick end of count event each 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);

  LIS302DL_Reset();

  /* SET USER Key */
  /* Configure EXTI Line0 (connected to PA0 pin) in interrupt mode */
  EXTILine0_Config();

  /* Initialize the LCD */
  STM32f4_Discovery_LCD_Init();
  LCD_Clear(LCD_COLOR_WHITE);
  LCD_SetTextColor(LCD_COLOR_BLUE);

  DCMI_Control_IO_Init();

  LCD_DisplayStringLine(LINE(2), "   Camera Init..");
		   
  /* OV9655 Camera Module configuration */
  if (DCMI_OV9655Config() == 0x00)
  {
    LCD_DisplayStringLine(LINE(2), "                ");
    LCD_SetDisplayWindow(0, 0, 320, 240);
    LCD_WriteRAM_Prepare();

    /* Start Image capture and Display on the LCD *****************************/
    /* Enable DMA transfer */
    DMA_Cmd(DMA2_Stream1, ENABLE);

    /* Enable DCMI interface */
    DCMI_Cmd(ENABLE); 

    /* Start Image capture */ 
    DCMI_CaptureCmd(ENABLE);   

    /*init the picture count*/
    init_picture_count();

    KeyPressFlg = 0;
    while (1)
    {
      /* Insert 100ms delay */
      Delay(100);

      if (KeyPressFlg) {
        KeyPressFlg = 0;
        /* press user KEY take a photo */
        if (capture_Flag == ENABLE) {
          DCMI_CaptureCmd(DISABLE);
          capture_Flag = DISABLE;
          Capture_Image_TO_Bmp();
          LCD_SetDisplayWindow(0, 0, 320, 240);
          LCD_WriteRAM_Prepare();
          DCMI_CaptureCmd(ENABLE);
          capture_Flag = ENABLE;
        }			
      }
    }  
  } else {
    LCD_SetTextColor(LCD_COLOR_RED);

    LCD_DisplayStringLine(LINE(2), "Camera Init.. fails");    
    LCD_DisplayStringLine(LINE(4), "Check the Camera HW ");    
    LCD_DisplayStringLine(LINE(5), "  and try again ");

    /* Go to infinite loop */
    while (1);      
  }
}