Beispiel #1
0
/* serialEE_PrintBlock:
 * Prints out the block data pointed by EE_AddressData.
 */
void serialEE_PrintBlock(uint8_t block, uint8_t datasize)
{
	uint8_t buffer[80];
	
	EE_AddressStruct EE_Current;
	EE_Current.EE_Address = 0x00;
	EE_Current.EE_Block = block;	
	
	uartTxString("\n\rNow reading from memory block:");
	uartTx( (EE_Current.EE_Block) + '0');
	uartTxString("\n\r");
	
	/* Read until the last entry of the current block */
	for(  EE_Current.EE_Address = EE_START_ADDRESS; 
			EE_Current.EE_Address < serialEE_getEndBlock(EE_Current.EE_Block); 
			EE_Current.EE_Address += datasize)
	{
						
		serialEE_ReadBlock(buffer, 
								datasize, 
								&EE_Current);			
								
		/* Parse the relevant information*/
		uartTxString("\r\n");						
		uartTxString(buffer);
	}
	
}
Beispiel #2
0
void printEEPointer(EE_AddressStruct* EE_AddressData)
{
	uartTxString("\n\rCurrent location of the EEPROM Pointer: \n\rBlock: ");
	uartTx( (EE_AddressData->EE_Block) + '0' );
	
	utoa( (EE_AddressData->EE_Address / EE_PAGE_SIZE), OutputString, 10);
	uartTxString("\n\rPage: ");
	uartTxString(OutputString);
	
	utoa( EE_AddressData->EE_Address, OutputString, 10);
	uartTxString("\n\rAddress: ");
	uartTxString(OutputString);
}
Beispiel #3
0
/* Returns the last memory entry for the passed block */
uint16_t serialEE_getEndBlock(uint8_t Block )
{
	
#if	DEBUG == 1	
	
	uartTxString("\n\rThe end of Block ");
	
	utoa(Block , OutputString, 10);
	
	uartTxString(OutputString);
	uartTxString(" is.. : ");
	utoa(EE_EndBlockAddress[Block] , OutputString, 10);
	
	uartTxString(OutputString);

#endif	
	
	
	return EE_EndBlockAddress[Block];
}
Beispiel #4
0
void serialEE_HandleBlockOverflow( EE_AddressStruct* EE_AddressData,
											  uint8_t datasize)
{
	
	/* Check that the current memory block is not full
	 * (For 24XX16 & 24XX1025 devices only!)
	 */
	if( ((EE_AddressData->EE_Address) + datasize) > EE_BLOCK_SIZE )
	{		
		/* Record the last entry of the block */	
		EE_EndBlockAddress[(EE_AddressData->EE_Block)] = EE_AddressData->EE_Address;
		/* Select the next block */
		EE_AddressData->EE_Block++;


		if( EE_AddressData->EE_Block >= EE_NUMBER_OF_BLOCKS)
		{
		/*ALL MEMORY BLOCKS HAVE BEEN USED UP!*/
		/* Handle event here: */	
			uartTxString("\n\rWarning : All memory blocks have been used up!");
			EE_AddressData->EE_Block = (EE_NUMBER_OF_BLOCKS - 1);
			
		}
		
		/* Reset Block address pointer */
		EE_AddressData->EE_Address = 0x00;
		
		
		
		/* Print which block is currently selected */				
		uartTxString("\n\rNow writing to memory block:");
		uartTx( (EE_AddressData->EE_Block) + '0');
		uartTxString("\n\r");
			
	}

	
	
}
Beispiel #5
0
/* entry point of application */
int main ( )
{
    /* first thing is to enable the watchdog - so if the app crashes, the watchdog will 
       expire and the AS7000 will reset */
    wdgEnable( ONE_SECOND );
    
    /* count variable to see some movement on uart */
    cnt = 0;
    
    /* now we want to use the UART to report */
    ccuSelectUartPins( GPIO_NONE, UART_TX_PIN );
    uartInitialise( );
    uartOpen( UART_BAUD_RATE_FAST );
    
    /* send a greeting via uart */
    uartTxString( "AS7000 is alive\n" );
    
    /* we need the timers to measure the real slow clock frequency */
    tmrInitialise( ); 
    slowClockFrequency = tmrSlowClockFrequency( 10 ); /* make sure you measure for less than 1 seconds, otherwise the watchdog will expire */
    /* note: the real slow clock frequency is than used by the SW for further timer calculations - or sleep mode calculations */
    
    /* print the measured frequency */
    uartTxString( "SlowClockFrequency=" );
    uartTxUint( slowClockFrequency );
    uartTxString( "Hz\n" );
    
    /* e.g. configure i2c as slave to be used */
    ccuSelectI2CPins( 0 /* slave */, I2C_SCL_PIN, 0 /* SCL - no internal pull-up */, I2C_SDA_PIN, 0 /* SDA - no internal pull-up */ ); 
    i2cSlaveInitialise( );
    i2cSlaveOpen( I2C_SLAVE_ADDRESS );

    /* drive a led through one of the gpio pins */
    ccuSelectGPIOPin( LED_PIN, 1 /* digital */, CCU_NO_PULL );
    gpioInitialise();
    gpioConfigure( 0 /* no input */, LED_MASK /* led is output */ );
    gpioWrite( LED_MASK, LED_OFF ); /* switch off */

    /* enalbe interrupts in system */
    __enable_irq( );
    
    /* show how to use the delays */
    delayInMicroseconds( 0 );
    delayInMicroseconds( 1 );
    delayInMicroseconds( 2 );
    
    /* put the AS7000 to sleep always for 500 milliseconds */
    ccuConfigureDeepSleep( 500, 0 /* no wake-up on gpio7 */, 0 /* no wake-up on gpio8 */ );
    
    while ( 1 )
    {
        wdgToggle( ); /* make sure the watchdog does not expire */
        
        /* count up and report value on uart and blink led - to see something */
        cnt++;
        if ( cnt & 1 )
        {
            gpioWrite( LED_MASK, LED_ON );
        }
        else
        {
            gpioWrite( LED_MASK, LED_OFF );
        }
        uartTxUint( cnt );
        uartTx( '\n' );
        
        /* do some usefull stuff here */
        
        /* not to be used in debugger:
                ccuEnterDeepSleep( ); <---- debugger does not see the CPU anymore and stops
        */
        /* use instead:  */ delayInMilliseconds( 500 ); 
            
    }

}