7segtst.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009 by Rittal GmbH & Co. KG,
00003  * Ulrich Prinz <prinz.u@rittal.de> All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. Neither the name of the copyright holders nor the names of
00015  *    contributors may be used to endorse or promote products derived
00016  *    from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY EMBEDDED IT AND CONTRIBUTORS
00019  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00021  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EMBEDDED IT
00022  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  * For additional information see http://www.ethernut.de/
00031  *
00032  */
00033 
00034 /*
00035  * $Log$
00036  *
00037  * Revision 1.0  2009/04/13 ulrichprinz
00038  * First checkin, new twi driver for AS1108 3 Digit 7-Segment driver 
00039  * (currently SAM7X256 is tested only)
00040  *
00041  */
00042 
00048 #include <cfg/os.h>
00049 
00050 #include <string.h>
00051 #include <io.h>
00052 #include <fcntl.h>
00053 #include <stdio.h>
00054 
00055 #include <dev/spi_7seg.h>
00056 
00057 #include <dev/board.h>
00058 #include <dev/gpio.h>
00059 
00060 #include <sys/heap.h>
00061 #include <sys/thread.h>
00062 #include <sys/timer.h>
00063 
00064 #ifdef NUTDEBUG
00065 #include <sys/osdebug.h>
00066 #endif
00067 
00068 
00069 
00070 
00071 /*
00072  * Main application routine.
00073  *
00074  * Nut/OS automatically calls this entry after initialization.
00075  */
00076 /******************************************************************/
00077 int main(void)
00078 /******************************************************************/
00079 {
00080 
00081 
00082     u_long baud = 115200;
00083     uint8_t rc;
00084     unsigned int count=0;
00085     /*
00086      * Register the UART device, open it, assign stdout to it and set 
00087      * the baudrate.
00088      */
00089     NutRegisterDevice(&DEV_DEBUG, 0, 0);
00090     freopen(DEV_DEBUG_NAME, "w", stdout);
00091     _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
00092     /*
00093      * Initialize digital I/O.
00094      */
00095     printf("initSPI_disp7seg\n");
00096     
00097     //rc = NutRegisterSpiDevice(&devSpi7SEG,&nodeSpi7SEG.node_bus,nodeSpi7SEG.node_cs);
00098     rc = NutRegisterSpiDevice(&devSpi7SEG,&NUT_CONFIG_7SEG_SPIBUS,NUT_CONFIG_7SEG_CS);
00099     if (rc != 0){
00100         printf("spi init failed\n");
00101         while(1);
00102     }
00103     printf("display_7seg\n");
00104 
00105      for (;;)
00106     {
00107         display_7seg(&devSpi7SEG,count++);
00108         if(count >999)count=0;
00109         NutSleep(200);
00110     }
00111     return 0;
00112 }

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/