##// END OF EJS Templates
LFR's Leon3 target added and and tested with simple hello world.
LFR's Leon3 target added and and tested with simple hello world.

File last commit:

r13:8ca866292111 default
r13:8ca866292111 default
Show More
main.c
117 lines | 3.4 KiB | text/x-c | CLexer
/*------------------------------------------------------------------------------
-- This file is a part of the libuc, microcontroler library
-- Copyright (C) 2011, Alexis Jeandet
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------
-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@gmail.com
-------------------------------------------------------------------------------*/
#include "LPC17xx.h"
#include "bsp.h"
#include "core.h"
#include "uart.h"
#include "libucstrings.h"
#define __delay(t) for(volatile int i=0;i<t;i++);
#define ledspos1 LED1_OFF;LED2_ON;LED3_OFF;LED4_ON;LED5_OFF;LED6_ON;LED7_OFF;LED8_ON
#define ledspos2 LED1_ON;LED2_OFF;LED3_ON;LED4_OFF;LED5_ON;LED6_OFF;LED7_ON;LED8_OFF
#define tableSize 256
#define data0Size 3
volatile int16_t data0[data0Size] __attribute__ ((section (".testData"))) = {0x1234,0x4567,0xFF00};
const int* const test1[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
void eepromTest();
int main (void)
{
int i=0;
volatile int16_t* testptr = 0x2007C000 + (16*1024) - 6;
bsp_init();
uartsetbaudrate(UART0,38400);
eepromTest();
libucprintf("CPU Freq =%dMHz\n\r",currentCpuFreq/1000000);
libucprintf("IIC Freq =%dKHz\n\r",i2cgetdatarate(IIC0)/1000);
libucprintf("data0 = %x",data0);
for(i=0;i<data0Size;i++)
libucprintf("data0[%d] = %x",i,0xFFFF&data0[i]);
for(i=0;i<20;i++)
libucprintf("test1[%d] = %x",i,test1[i]);
while(1)
{
ledspos1;
__delay(1024*1024);
ledspos2;
__delay(1024*1024);
}
return 0;
}
void eepromTest()
{
unsigned char val1,val2;
unsigned char table1[256];
unsigned char table2[256];
int i=0;
for(i=0;i<tableSize;i++)table1[i]=i;
libucprintf("Writing 0x56 @ 0x10...");
eeprom24lc0xbytewrite(eeprom0,0x10,0x56);
libucprintf("\tdone\n\r");
libucprintf("Writing 0xF1 @ 0x39...");
eeprom24lc0xbytewrite(eeprom0,0x39,0xF1);
libucprintf("\tdone\n\r");
libucprintf("Reading @ 0x10 ...");
val1=eeprom24lc0xbyteread(eeprom0,0x10);
libucprintf("\tdone result = 0x%X\n\r",val1);
libucprintf("Reading @ 0x39 ...");
val2=eeprom24lc0xbyteread(eeprom0,0x39);
libucprintf("\tdone result = 0x%X\n\r",val2);
libucprintf("Writing folowing table @ 0x00");
libucprintchartable(table1,tableSize,"0x%X"," ");
libucprintf("...");
eeprom24lc0xwriten(eeprom0,0,table1, tableSize);
libucprintf("\tdone\n\r");
libucprintf("Reading table @ 0x00 ...");
eeprom24lc0xreadn(eeprom0,0,table2, tableSize);
libucprintf("\tdone\n\r");
libucprintf("result = ");
libucprintchartable(table2,tableSize,"0x%X"," ");
libucprintf("\n\r");
}