main.c

00001 /*
00002 # This file is Copyright 2006, 2007, 2009 Dean Hall.
00003 #
00004 # This file is part of the Python-on-a-Chip program.
00005 # Python-on-a-Chip is free software: you can redistribute it and/or modify
00006 # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
00007 # 
00008 # Python-on-a-Chip is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00011 # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
00012 # is seen in the file COPYING up one directory from this.
00013 */
00014 
00015 
00016 #include "Board.h"
00017 #include "pm.h"
00018 
00019 
00020 extern unsigned char usrlib_img[];
00021 
00022 
00023 int
00024 main(void)
00025 {
00026     PmReturn_t retval;
00027 
00028     /* Init PyMite */
00029     retval = pm_init(MEMSPACE_PROG, usrlib_img);
00030 
00031     /* Configure PIOA for LEDs and clear them */
00032     AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, LED_MASK);
00033     AT91F_PIO_SetOutput(AT91C_BASE_PIOA, LED_MASK);
00034 
00035     PM_RETURN_IF_ERROR(retval);
00036 
00037     /* Run the sample program */
00038     retval = pm_run((uint8_t *)"main");
00039 
00040     /* Report results via LEDs */
00041     if (retval == PM_RET_OK)
00042     {
00043         AT91F_PIO_SetOutput(AT91C_BASE_PIOA, LED_MASK);
00044         AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, 0x03);
00045     }
00046     else
00047     {
00048         AT91F_PIO_SetOutput(AT91C_BASE_PIOA, LED_MASK);
00049         AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, 0x04);
00050     }
00051     return (int)retval;
00052 }

Generated on Mon Oct 18 07:40:46 2010 for Python-on-a-chip by  doxygen 1.5.9