Beispiel #1
0
/******************************************************************************
* Function name : InitialiseLCD
* Description   : Initializes the LCD display. 
* Arguments     : none
* Return Value  : none
******************************************************************************/
void InitialiseLCD(void)
{
    if (GlyphOpen(&G_lcd, 0) == GLYPH_ERROR_NONE)
    {
        /* use Glyph full access direct functions */
        GlyphNormalScreen(G_lcd) ;
        GlyphSetFont(G_lcd, GLYPH_FONT_8_BY_8) ;
        GlyphClearScreen(G_lcd) ;
    }
}
Beispiel #2
0
void LCDInit (void)
{
    T_glyphError  err;
    
    err = GlyphOpen(&G_lcd, 0);

    if (err == GLYPH_ERROR_NONE) {
        GlyphNormalScreen(G_lcd);
        GlyphClearScreen(G_lcd);
    }
}
/*---------------------------------------------------------------------------*/
int MainTask(void)
{
    // Output a start up banner
    printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n");

    // Start up the heart beat of the LED
    UEZTaskCreate(Heartbeat, "Heart", 64, (void *)0, UEZ_PRIORITY_NORMAL, 0);

    // Load any non-volatile settings from the data flash.
    NVSettingsInit();
    // Load the settings from non-volatile memory
    if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) {
        printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }

    // Setup the glyph API to the LCD and draw the title screen.
    GlyphOpen(&G_glyphLCD, 0);
    IDrawTitle();

    // Setup any additional misc. tasks (such as the heartbeat task)
    SetupTasks();

    // Play startup tones
    PlayAudio(523, 100);
    PlayAudio(659, 100);
    PlayAudio(783, 100);
    PlayAudio(1046, 100);
    PlayAudio(783, 100);
    PlayAudio(659, 100);
    PlayAudio(523, 100);

    // Wait in an infinite loop.
    while(1) {
        UEZTaskDelay(10000);
    }

    return 0;
}
Beispiel #4
0
/*---------------------------------------------------------------------------*
 * Task:  main
 *---------------------------------------------------------------------------*
 * Description:
 *      In the uEZ system, main() is a task.  Do not exit this task
 *      unless you want to the board to reset.  This function should
 *      setup the system and then run the main loop of the program.
 * Outputs:
 *      int                     -- Output error code
 *---------------------------------------------------------------------------*/
int MainTask(void)
{	
	printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // clear serial screen and put up banner
	
	// Start up the heart beat of the LED
    UEZTaskCreate(Heartbeat, "Heart", 64, (void *)0, UEZ_PRIORITY_NORMAL, 0);
	
    NVSettingsInit();
    // Load the settings from non-volatile memory
    if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) {
        printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }

    // Delete old log file
    UEZFileDelete("0:/ACCELLOG.TXT");
    	
	// Setup any additional misc. tasks (such as the heartbeat task)
    SetupTasks();

    GlyphOpen(&G_glyphLCD, 0);
	IDrawTitle();

    // Play tones	
	PlayAudio(523, 100);
    PlayAudio(659, 100);
    PlayAudio(783, 100);
    PlayAudio(1046, 100);
    PlayAudio(783, 100);
    PlayAudio(659, 100);
    PlayAudio(523, 100);	
	
	while(1) {
		UEZTaskDelay(500);
	}

    return 0;
}
/*---------------------------------------------------------------------------*
 * Routine:  uEZPlatformStartup
 *---------------------------------------------------------------------------*
 * Description:
 *      When uEZ starts, a special Startup task is created and called.
 *      This task brings up the all the hardware, reports any problems,
 *      starts the main task, and then exits.
 *---------------------------------------------------------------------------*/
TUInt32 uEZPlatformStartup(T_uezTask aMyTask, void *aParameters)
{
    extern T_uezTask G_mainTask;
    const T_uezTimeDate resetTD = {
        {   0, 0, 0}, // 12:00 midnight
        {   1, 1, 2012}, // Jan 1, 2012
    };

    // Setup console immediately
    UEZPlatform_Console_Require(UEZ_CONSOLE_WRITE_BUFFER_SIZE,
            UEZ_CONSOLE_READ_BUFFER_SIZE);
	UEZPlatform_SPI0_Require();
	UEZPlatform_S12AD_Require();
	UEZPlatform_DataFlash_Require();
	UEZPlatform_Speaker_Require();
	UEZPlatform_Temp_Require();
	UEZPlatform_Accel_Require();
	UEZPlatform_RTC_Require();
	
	if (UEZTimeDateIsValid(&resetTD) == UEZ_ERROR_INVALID)
	    printf("RTC reset!\n");

    // Network needed?
    UEZPlatform_WiredNetwork0_Require();

    // SDCard needed?
    UEZPlatform_SDCard_Drive_Require(0);

    GlyphOpen(&G_glyphLCD, 0);
    
    // Create a main task (not running yet)
    UEZTaskCreate((T_uezTaskFunction)MainTask, "Main", MAIN_TASK_STACK_SIZE, 0,
            UEZ_PRIORITY_NORMAL, &G_mainTask);

    // Done with this task, fall out
    return 0;
}
Beispiel #6
0
/*---------------------------------------------------------------------------*
 * Task:  main
 *---------------------------------------------------------------------------*
 * Description:
 *      In the uEZ system, main() is a task.  Do not exit this task
 *      unless you want to the board to reset.  This function should
 *      setup the system and then run the main loop of the program.
 * Outputs:
 *      int                     -- Output error code
 *---------------------------------------------------------------------------*/
int MainTask(void)
{	
	T_uezDevice temp;
	T_uezDevice accel;
	T_uezError tempDeviceError;
	T_uezError accelDeviceError;
	TUInt8 displayString[100];
	TInt32 tempValue;
	float tempFloatValue;
	AccelerometerReading accelReading;
	
	printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n"); // clear serial screen and put up banner
	
	// Start up the heart beat of the LED
    UEZTaskCreate(Heartbeat, "Heart", 64, (void *)0, UEZ_PRIORITY_NORMAL, 0);
	
    NVSettingsInit();
    // Load the settings from non-volatile memory
    if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) {
        printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }
	
	// Setup any additional misc. tasks (such as the heartbeat task)
    SetupTasks();

    GlyphOpen(&G_glyphLCD, 0);
	IDrawTitle();
	
	PlayAudio(523, 100);
    PlayAudio(659, 100);
    PlayAudio(783, 100);
    PlayAudio(1046, 100);
    PlayAudio(783, 100);
    PlayAudio(659, 100);
    PlayAudio(523, 100);	
	
	tempDeviceError = UEZTemperatureOpen("Temp0", &temp);
	if (tempDeviceError == UEZ_ERROR_NONE) {
		printf("MainTask: Temperature Device Open\n");
    } else {
        printf("MainTask: Failed to Open Temperature Device\n");
    }
	
	accelDeviceError = UEZAccelerometerOpen("Accel0", &accel);
	if (accelDeviceError == UEZ_ERROR_NONE) {
		printf("MainTask: Accelerometer Device Open\n");
    } else {
        printf("MainTask: Failed to Open Accelerometer Device\n");
    }
	
	while(1) {
		
		if ( tempDeviceError == UEZ_ERROR_NONE ) {
			if (UEZTemperatureRead(temp, &tempValue) == UEZ_ERROR_NONE) {
				tempFloatValue = tempValue/65536.0;
				sprintf((char *)displayString, "Temp: %.2f C", tempFloatValue);
				GlyphSetXY(G_glyphLCD, 0, 0);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
            }
		}
		
		if ( accelDeviceError == UEZ_ERROR_NONE ) {
			if(UEZAccelerometerReadXYZ(accel, &accelReading, 10) == UEZ_ERROR_NONE )
			{				
				sprintf((char *)displayString, "ACCEL X: %d", accelReading.iX);
				GlyphSetXY(G_glyphLCD, 0, 16);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
				
				sprintf((char *)displayString, "ACCEL Y: %d", accelReading.iY);
				GlyphSetXY(G_glyphLCD, 0, 24);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
				
				sprintf((char *)displayString, "ACCEL Z: %d", accelReading.iZ);
				GlyphSetXY(G_glyphLCD, 0, 32);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
			}
		}
		
		UEZTaskDelay(500);
	}

    return 0;
}
Beispiel #7
0
/*---------------------------------------------------------------------------*
 * Task:  main
 *---------------------------------------------------------------------------*
 * Description:
 *      In the uEZ system, main() is a task.  Do not exit this task
 *      unless you want to the board to reset.  This function should
 *      setup the system and then run the main loop of the program.
 * Outputs:
 *      int                     -- Output error code
 *---------------------------------------------------------------------------*/
int MainTask(void)
{	
	T_uezDevice adc;
	T_uezDevice temp;
	T_uezDevice accel;
	T_uezError adcDeviceError;
	T_uezError tempDeviceError;
	T_uezError accelDeviceError;
	ADC_RequestSingle adcRequest;
	TUInt32 adcReading;
	TUInt8 displayString[100];
	TInt32 tempValue;
	float tempFloatValue;
	AccelerometerReading accelReading;
	
	printf("\f" PROJECT_NAME " " VERSION_AS_TEXT "\n\n");
	
	NVSettingsInit();
    // Load the settings from non-volatile memory
    if (NVSettingsLoad() == UEZ_ERROR_CHECKSUM_BAD) {
        printf("EEPROM Settings\n");
        NVSettingsInit();
        NVSettingsSave();
    }
	
	SetupTasks();

	GlyphOpen(&G_glyphLCD, 0);
	IDrawTitle();

	PlayAudio(523, 100);
    PlayAudio(659, 100);
    PlayAudio(783, 100);
    PlayAudio(1046, 100);
    PlayAudio(783, 100);
    PlayAudio(659, 100);
    PlayAudio(523, 100);	

	adcDeviceError = UEZADCOpen("ADC_S12AD", &adc);
	if (adcDeviceError == UEZ_ERROR_NONE) {
		printf("MainTask: ADC Device Open\n");
	} else {
		printf("MainTask: Failed to Open ADC Device\n");
	}
	
	tempDeviceError = UEZTemperatureOpen("Temp0", &temp);
	if (tempDeviceError == UEZ_ERROR_NONE) {
		printf("MainTask: Temperature Device Open\n");
    } else {
        printf("MainTask: Failed to Open Temperature Device\n");
    }
	
	accelDeviceError = UEZAccelerometerOpen("Accel0", &accel);
	if (accelDeviceError == UEZ_ERROR_NONE) {
		printf("MainTask: Accelerometer Device Open\n");
    } else {
        printf("MainTask: Failed to Open Accelerometer Device\n");
    }
	    
	//PORTE.PDR.BIT.B3 = 1;
	while(1) {
		if( adcDeviceError == UEZ_ERROR_NONE )
		{
			// the device opened properly
		    adcRequest.iADCChannel = 2;
		    adcRequest.iBitSampleSize = 12;
		    adcRequest.iTrigger = ADC_TRIGGER_NOW;
		    adcRequest.iCapturedData = &adcReading;
		    if (UEZADCRequestSingle(adc,&adcRequest) == UEZ_ERROR_NONE) {
				printf("MainTask: Potentiometer Reading: %d\n", adcReading);
		    } else {
		        printf("MainTask: Failed to get a Potentiometer Reading\n");
		    }
		}
		
		if ( tempDeviceError == UEZ_ERROR_NONE ) {
			if (UEZTemperatureRead(temp, &tempValue) == UEZ_ERROR_NONE) {
				tempFloatValue = tempValue/65536.0;
				sprintf((char *)displayString, "Temp: %.2f C", tempFloatValue);
				GlyphSetXY(G_glyphLCD, 0, 0);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
            }
		}

		if ( accelDeviceError == UEZ_ERROR_NONE ) {
			if(UEZAccelerometerReadXYZ(accel, &accelReading, 10) == UEZ_ERROR_NONE )
			{				
				sprintf((char *)displayString, "ACCEL X: %d", accelReading.iX);
				GlyphSetXY(G_glyphLCD, 0, 16);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
				
				sprintf((char *)displayString, "ACCEL Y: %d", accelReading.iY);
				GlyphSetXY(G_glyphLCD, 0, 24);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
				
				sprintf((char *)displayString, "ACCEL Z: %d", accelReading.iZ);
				GlyphSetXY(G_glyphLCD, 0, 32);
    			GlyphString(G_glyphLCD, displayString, strlen(displayString));
			}
		}

		UEZTaskDelay(1000);
	}
    return 0;
}
Beispiel #8
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 FTP Client Demo ***\r\n");
   TRACE_INFO("**********************************\r\n");
   TRACE_INFO("Copyright: 2010-2015 Oryx Embedded SARL\r\n");
   TRACE_INFO("Compiled: %s %s\r\n", __DATE__, __TIME__);
   TRACE_INFO("Target: RX63N\r\n");
   TRACE_INFO("\r\n");

   //Configure I/Os
   ioInit();

   //Initialize RSPI channel
   R_RSPI_Init(RSPI_CHANNEL_0);
   //Initialize LCD display
   GlyphOpen(&lcdHandle, 0);
   GlyphNormalScreen(lcdHandle);
   GlyphSetFont(lcdHandle, GLYPH_FONT_6_BY_13);
   //Clear display
   GlyphClearScreen(lcdHandle);

   //Welcome message
   lcdSetCursor(0, 0);
   printf("FTP Client\r\nDemo\r\n");

   //TCP/IP stack initialization
   error = netInit();
   //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
   netSetInterfaceName(interface, "eth0");
   //Set host name
   netSetHostname(interface, "FTPClientDemo");
   //Select the relevant network adapter
   netSetDriver(interface, &rx63nEthDriver);
   netSetPhyDriver(interface, &dp83620PhyDriver);
   //Set external interrupt line driver
   netSetExtIntDriver(interface, &extIntDriver);
   //Set host MAC address
   macStringToAddr(APP_MAC_ADDR, &macAddr);
   netSetMacAddr(interface, &macAddr);

   //Initialize network interface
   error = netConfigInterface(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);

   //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);

   //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

   //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");
   }

   //Enable interrupts
   __enable_interrupt();

   //Start the execution of tasks
   osStartKernel();

   //This function should never return
   return 0;
}