/**
******************************************************************************
* @file main.c
* @author MCD Application Team
* @version V1.0.2
* @date 06-June-2011
* @brief Main program body
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
*
© COPYRIGHT 2011 STMicroelectronics
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include
#include
#include
#include
#include "stm32f2x7_eth.h"
#include "main.h"
#include "dvoraj42.h"
//#include "letters.h"
#include "tests.h"
#include "FreeRTOS.h"
#include "task.h"
#include "tcpip.h"
#include "netconf.h"
#include "httpserver-socket.h"
#include "serial_debug.h"
#include "sckit_eval_lcd.h"
#include "timers.h"
/*--------------- Tasks Priority -------------*/
#define LED_TASK_PRIO ( tskIDLE_PRIORITY + 1 )
#define USER_TASK_PRIO ( tskIDLE_PRIORITY + 2 )
extern struct netif xnetif;
xSemaphoreHandle xTermSemaphore;
/* Private function prototypes -----------------------------------------------*/
void LCD_Init(void);
void LED_Init(void);
void Button_Init(void);
void Ethernet_Init(void);
void UserTask(void);
void AccelTask(void);
/* Private variables ---------------------------------------------------------*/
volatile int state;
volatile settings configuration;
volatile materialInfo material;
extern volatile uint32_t SYSTEM_S;
void AccelTask(void)
{
while(1)
{
handleAccelerometerData();
vTaskDelay(100);
}
}
/******************************************************************************/
/**
* Led Task method
*/
void LedTask(void * arg)
{
int i;
(void)arg; // ignore arg parameter
while(1)
{
// Button 1
i = getButton1State();
if (i==0) STM_EVAL_LEDOff(LED1); else STM_EVAL_LEDOn(LED1);
// Button 2
i = getButton2State();
if (i==0) STM_EVAL_LEDOff(LED2); else STM_EVAL_LEDOn(LED2);
// Encoder
i = getEncoderDirection();
if (i==1) STM_EVAL_LEDOn(LED3); else STM_EVAL_LEDOff(LED3);
if (i==-1) STM_EVAL_LEDOn(LED4); else STM_EVAL_LEDOff(LED4);
//printf("%d\r\n", getEncoderTicks());
LCDPrintNumber( getEncoderTicks(), 6, 99, 5);
// Blink led 8
STM_EVAL_LEDToggle(LED8);
vTaskDelay(100);
}
}
/******************************************************************************/
/**
* Main method
*/
int main(void)
{
/* 1) Inizialize */
SystemCoreClockUpdate();
ComPort_Init(COM1);
ComPort_Init(COM2);
ComPort_SetStdio(COM2);
printf("\r\nCOM STARTED\r\n");
LED_Init();
LCD_Init();
Button_Init();
/* 2) Own initializes */
initializeFLASH();
FLASHLoadData();
initializeEncoder(); // encoder
LCDASCIIConfigure(); // ascii table for lcd
initializeAccelerometer(); // accelerometer
SYSTEM_S = material.systemTime;
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
/* 3) Create tasks */
state = 12;
state = 0;
xTaskCreate(AccelTask, (signed char *)"AccelTask", 512, NULL, LED_TASK_PRIO, NULL);
xTaskCreate(UserTask, (signed char *)"UserTask", 4096, NULL, USER_TASK_PRIO, NULL);
//xTaskCreate(LedTask, (signed char *)"LedTask", 2048, NULL, LED_TASK_PRIO, NULL);
/* 4) Start scheduler */
vTaskStartScheduler();
UserTask();
while(1){}
return 0;
}
/******************************************************************************/
void Button_Init(void) {
// use interrupts
// STM_EVAL_PBInit(BUTTON_SW1, BUTTON_MODE_EXTI);
// STM_EVAL_PBInit(BUTTON_SW2, BUTTON_MODE_EXTI);
// dont use interrupts
STM_EVAL_PBInit(BUTTON_SW1, BUTTON_MODE_GPIO);
STM_EVAL_PBInit(BUTTON_SW2, BUTTON_MODE_GPIO);
}
void LED_Init(void) {
Led_TypeDef led;
for (led = LED1; led < (LED1 + LEDn); led++) {
/* Initialize STM322xG-EVAL's LEDs */
STM_EVAL_LEDInit(led);
/* leds off */
STM_EVAL_LEDOff(led);
}
}
void LCD_Init(void) {
SCKIT_LCD_Init();
STM_EVAL_LEDOn(LED_LCD);
//LCD_Display();
}
uint32_t sEE_TIMEOUT_UserCallback(void) {
return 1;
}
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ) {
(void)pxTask;
printf("Stack overflow %s\r\n", pcTaskName);
return;
}
#ifdef USE_FULL_ASSERT
#endif
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/