diff options
Diffstat (limited to 'nuttx/arch/arm/src/dm320')
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_ahb.h | 8 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_boot.c | 48 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_busc.h | 8 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_clkc.h | 8 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_decodeirq.c | 9 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_emif.h | 10 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_framebuffer.c | 60 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_gio.h | 14 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_intc.h | 8 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_irq.c | 53 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_memorymap.h | 10 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_osd.h | 8 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_serial.c | 100 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_timer.h | 10 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_timerisr.c | 8 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_uart.h | 32 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_usb.h | 8 | ||||
-rw-r--r-- | nuttx/arch/arm/src/dm320/dm320_usbdev.c | 204 |
18 files changed, 289 insertions, 317 deletions
diff --git a/nuttx/arch/arm/src/dm320/dm320_ahb.h b/nuttx/arch/arm/src/dm320/dm320_ahb.h index 054280bc0..7e238f54b 100644 --- a/nuttx/arch/arm/src/dm320/dm320_ahb.h +++ b/nuttx/arch/arm/src/dm320/dm320_ahb.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_uart.h * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -40,12 +40,8 @@ * Included Files ************************************************************************************/ -#ifndef __ASSEMBLY__ -# include <sys/types.h> -#endif - /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* AHB Bus Controller (AHBBUSC) Registers *******************************************/ diff --git a/nuttx/arch/arm/src/dm320/dm320_boot.c b/nuttx/arch/arm/src/dm320/dm320_boot.c index 9d7cb1a95..1dd7288f0 100644 --- a/nuttx/arch/arm/src/dm320/dm320_boot.c +++ b/nuttx/arch/arm/src/dm320/dm320_boot.c @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -38,7 +38,7 @@ ************************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <stdint.h> #include "arm.h" #include "up_internal.h" @@ -54,18 +54,18 @@ struct section_mapping_s { - uint32 physbase; /* Physical address of the region to be mapped */ - uint32 virtbase; /* Virtual address of the region to be mapped */ - uint32 mmuflags; /* MMU settings for the region (e.g., cache-able) */ - uint32 nsections; /* Number of mappings in the region */ + uint32_t physbase; /* Physical address of the region to be mapped */ + uint32_t virtbase; /* Virtual address of the region to be mapped */ + uint32_t mmuflags; /* MMU settings for the region (e.g., cache-able) */ + uint32_t nsections; /* Number of mappings in the region */ }; /************************************************************************************ * Public Variables ************************************************************************************/ -extern uint32 _vector_start; /* Beginning of vector block */ -extern uint32 _vector_end; /* End+1 of vector block */ +extern uint32_t _vector_start; /* Beginning of vector block */ +extern uint32_t _vector_end; /* End+1 of vector block */ /************************************************************************************ * Private Variables @@ -100,10 +100,10 @@ static const struct section_mapping_s section_mapping[] = * Name: up_setlevel1entry ************************************************************************************/ -static inline void up_setlevel1entry(uint32 paddr, uint32 vaddr, uint32 mmuflags) +static inline void up_setlevel1entry(uint32_t paddr, uint32_t vaddr, uint32_t mmuflags) { - uint32 *pgtable = (uint32*)PGTABLE_BASE_VADDR; - uint32 index = vaddr >> 20; + uint32_t *pgtable = (uint32_t*)PGTABLE_BASE_VADDR; + uint32_t index = vaddr >> 20; /* Save the page table entry */ @@ -114,11 +114,11 @@ static inline void up_setlevel1entry(uint32 paddr, uint32 vaddr, uint32 mmuflags * Name: up_setlevel2coarseentry ************************************************************************************/ -static inline void up_setlevel2coarseentry(uint32 ctabvaddr, uint32 paddr, - uint32 vaddr, uint32 mmuflags) +static inline void up_setlevel2coarseentry(uint32_t ctabvaddr, uint32_t paddr, + uint32_t vaddr, uint32_t mmuflags) { - uint32 *ctable = (uint32*)ctabvaddr; - uint32 index; + uint32_t *ctable = (uint32_t*)ctabvaddr; + uint32_t index; /* The coarse table divides a 1Mb address space up into 256 entries, each * corresponding to 4Kb of address space. The coarse page table index is @@ -142,9 +142,9 @@ static void up_setupmappings(void) for (i = 0; i < NMAPPINGS; i++) { - uint32 sect_paddr = section_mapping[i].physbase; - uint32 sect_vaddr = section_mapping[i].virtbase; - uint32 mmuflags = section_mapping[i].mmuflags; + uint32_t sect_paddr = section_mapping[i].physbase; + uint32_t sect_vaddr = section_mapping[i].virtbase; + uint32_t mmuflags = section_mapping[i].mmuflags; for (j = 0; j < section_mapping[i].nsections; j++) { @@ -161,9 +161,9 @@ static void up_setupmappings(void) static void up_vectormapping(void) { - uint32 vector_paddr = DM320_IRAM_PADDR; - uint32 vector_vaddr = DM320_VECTOR_VADDR; - uint32 end_paddr = vector_paddr + DM320_IRAM_SIZE; + uint32_t vector_paddr = DM320_IRAM_PADDR; + uint32_t vector_vaddr = DM320_VECTOR_VADDR; + uint32_t end_paddr = vector_paddr + DM320_IRAM_SIZE; /* We want to keep our interrupt vectors and interrupt-related logic in zero-wait * state internal RAM (IRAM). The DM320 has 16Kb of IRAM positioned at physical @@ -193,9 +193,9 @@ static void up_vectormapping(void) static void up_copyvectorblock(void) { - uint32 *src = (uint32*)&_vector_start; - uint32 *end = (uint32*)&_vector_end; - uint32 *dest = (uint32*)VECTOR_BASE; + uint32_t *src = (uint32_t*)&_vector_start; + uint32_t *end = (uint32_t*)&_vector_end; + uint32_t *dest = (uint32_t*)VECTOR_BASE; while (src < end) { diff --git a/nuttx/arch/arm/src/dm320/dm320_busc.h b/nuttx/arch/arm/src/dm320/dm320_busc.h index 3d234387d..b7c3287e5 100644 --- a/nuttx/arch/arm/src/dm320/dm320_busc.h +++ b/nuttx/arch/arm/src/dm320/dm320_busc.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_busc.h * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -40,12 +40,8 @@ * Included Files ************************************************************************************/ -#ifndef __ASSEMBLY__ -# include <sys/types.h> -#endif - /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* Bus Controller Register Map (BUSC) ***********************************************/ diff --git a/nuttx/arch/arm/src/dm320/dm320_clkc.h b/nuttx/arch/arm/src/dm320/dm320_clkc.h index ecb19c300..1e8e7da91 100644 --- a/nuttx/arch/arm/src/dm320/dm320_clkc.h +++ b/nuttx/arch/arm/src/dm320/dm320_clkc.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_clkc.h * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -40,12 +40,8 @@ * Included Files ************************************************************************************/ -#ifndef __ASSEMBLY__ -# include <sys/types.h> -#endif - /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* Clock Controller Register Map (CLKC) *********************************************/ diff --git a/nuttx/arch/arm/src/dm320/dm320_decodeirq.c b/nuttx/arch/arm/src/dm320/dm320_decodeirq.c index c93805d8f..e7953caf0 100644 --- a/nuttx/arch/arm/src/dm320/dm320_decodeirq.c +++ b/nuttx/arch/arm/src/dm320/dm320_decodeirq.c @@ -39,7 +39,8 @@ ********************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + +#include <stdint.h> #include <nuttx/irq.h> #include <nuttx/arch.h> #include <assert.h> @@ -50,7 +51,7 @@ #include "up_internal.h" /******************************************************************************** - * Definitions + * Pre-processor Definitions ********************************************************************************/ /******************************************************************************** @@ -69,7 +70,7 @@ * Public Funtions ********************************************************************************/ -void up_decodeirq(uint32* regs) +void up_decodeirq(uint32_t* regs) { #ifdef CONFIG_SUPPRESS_INTERRUPTS lib_lowprintf("Unexpected IRQ\n"); @@ -78,7 +79,7 @@ void up_decodeirq(uint32* regs) #else /* Decode the interrupt. First, fetch the interrupt id register. */ - uint16 irqentry = getreg16(DM320_INTC_IRQENTRY0); + uint16_t irqentry = getreg16(DM320_INTC_IRQENTRY0); /* The irqentry value is an offset into a table. Zero means no interrupt. */ diff --git a/nuttx/arch/arm/src/dm320/dm320_emif.h b/nuttx/arch/arm/src/dm320/dm320_emif.h index a54666387..0675595d0 100644 --- a/nuttx/arch/arm/src/dm320/dm320_emif.h +++ b/nuttx/arch/arm/src/dm320/dm320_emif.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_emif.h * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,12 +40,8 @@ * Included Files ************************************************************************************/ -#ifndef __ASSEMBLY__ -# include <sys/types.h> -#endif - /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* External Memory Interface (EMIF) Registers */ diff --git a/nuttx/arch/arm/src/dm320/dm320_framebuffer.c b/nuttx/arch/arm/src/dm320/dm320_framebuffer.c index 04cee0f96..60565deee 100644 --- a/nuttx/arch/arm/src/dm320/dm320_framebuffer.c +++ b/nuttx/arch/arm/src/dm320/dm320_framebuffer.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/dm320/dm320_framebuffer.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,7 @@ #include <nuttx/config.h> -#include <sys/types.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <errno.h> @@ -53,7 +53,7 @@ #include "dm320_osd.h" /************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************/ /* Configuration ********************************************************/ @@ -592,34 +592,34 @@ static struct fb_vtable_s g_osd1vtable = * Private Functions ****************************************************************************/ -static inline void dm320_blankscreen(ubyte *buffer, int len) +static inline void dm320_blankscreen(uint8_t *buffer, int len) { memset(buffer, 0xff, len); } -static inline uint32 dm320_physaddr(FAR void *fb_vaddr) +static inline uint32_t dm320_physaddr(FAR void *fb_vaddr) { - return (uint32)fb_vaddr - DM320_SDRAM_VADDR; + return (uint32_t)fb_vaddr - DM320_SDRAM_VADDR; } #ifndef CONFIG_DM320_VID0_DISABLE -static inline uint32 dm320_vid0upperoffset(void) +static inline uint32_t dm320_vid0upperoffset(void) { return (((dm320_physaddr(g_vid0base) / 32) >> 16) & 0xff); } -static inline uint32 dm320_vid0loweroffset(void) +static inline uint32_t dm320_vid0loweroffset(void) { return ((dm320_physaddr(g_vid0base) / 32) & 0xffff); } #ifndef CONFIG_DM320_DISABLE_PINGPONG -static inline uint32 dm320_vid0ppupperoffset(void) +static inline uint32_t dm320_vid0ppupperoffset(void) { return (((dm320_physaddr(g_vid0ppbase) / 32) >> 16) & 0xff); } -static inline uint32 dm320_vid0pploweroffset(void) +static inline uint32_t dm320_vid0pploweroffset(void) { return ((dm320_physaddr(g_vid0ppbase) / 32) & 0xffff); } @@ -627,36 +627,36 @@ static inline uint32 dm320_vid0pploweroffset(void) #endif #ifndef CONFIG_DM320_VID1_DISABLE -static inline uint32 dm320_vid1upperoffset(void) +static inline uint32_t dm320_vid1upperoffset(void) { return (((dm320_physaddr(g_vid1base) / 32) >> 16) & 0xff); } -static inline uint32 dm320_vid1loweroffset(void) +static inline uint32_t dm320_vid1loweroffset(void) { return ((dm320_physaddr(g_vid1base) / 32) & 0xffff); } #endif #ifndef CONFIG_DM320_OSD0_DISABLE -static inline uint32 dm320_osd0upperoffset(void) +static inline uint32_t dm320_osd0upperoffset(void) { return (((dm320_physaddr(g_osd0base) / 32) >> 16) & 0xff); } -static inline uint32 dm320_osd0loweroffset(void) +static inline uint32_t dm320_osd0loweroffset(void) { return ((dm320_physaddr(g_osd0base) / 32) & 0xffff); } #endif #ifndef CONFIG_DM320_OSD1_DISABLE -static inline uint32 dm320_osd1upperoffset(void) +static inline uint32_t dm320_osd1upperoffset(void) { return (((dm320_physaddr(g_osd1base) / 32) >> 16) & 0xff); } -static inline uint32 dm320_osd1loweroffset(void) +static inline uint32_t dm320_osd1loweroffset(void) { return ((dm320_physaddr(g_osd1base) / 32) & 0xffff); } @@ -823,7 +823,7 @@ static void dm320_hwinitialize(void) gvdbg("DM320_OSD_VIDWINADH: %04x\n", getreg16(DM320_OSD_VIDWINADH)); gvdbg("DM320_OSD_VIDWIN0ADL: %04x\n", getreg16(DM320_OSD_VIDWIN0ADL)); - dm320_blankscreen((ubyte *)g_vid0base, DM320_VID0_FBLEN); + dm320_blankscreen((uint8_t *)g_vid0base, DM320_VID0_FBLEN); #ifndef CONFIG_DM320_DISABLE_PINGPONG putreg16(dm320_vid0ppupperoffset(), DM320_OSD_PPVWIN0ADH); @@ -831,7 +831,7 @@ static void dm320_hwinitialize(void) gvdbg("DM320_OSD_PPVWIN0ADH: %04x\n", getreg16(DM320_OSD_PPVWIN0ADH)); gvdbg("DM320_OSD_PPVWIN0ADL: %04x\n", getreg16(DM320_OSD_PPVWIN0ADL)); - dm320_blankscreen((ubyte *)g_vid0ppbase, DM320_VID0_FBLEN); + dm320_blankscreen((uint8_t *)g_vid0ppbase, DM320_VID0_FBLEN); #endif putreg16(CONFIG_DM320_VID0_XPOS, DM320_OSD_VIDWIN0XP); @@ -855,7 +855,7 @@ static void dm320_hwinitialize(void) gvdbg("DM320_OSD_VIDWINADH: %04x\n", getreg16(DM320_OSD_VIDWINADH)); gvdbg("DM320_OSD_VIDWIN1ADL: %04x\n", getreg16(DM320_OSD_VIDWIN1ADL)); - dm320_blankscreen((ubyte *)g_vid1base, DM320_VID1_FBLEN); + dm320_blankscreen((uint8_t *)g_vid1base, DM320_VID1_FBLEN); putreg16(CONFIG_DM320_VID1_XPOS, DM320_OSD_VIDWIN1XP); putreg16(CONFIG_DM320_VID1_XPOS, DM320_OSD_VIDWIN1YP); @@ -877,7 +877,7 @@ static void dm320_hwinitialize(void) #ifndef CONFIG_DM320_OSD0_DISABLE gvdbg("Initialize OSD win0:\n"); - dm320_blankscreen((ubyte *)g_osd0base, DM320_OSD0_FBLEN); + dm320_blankscreen((uint8_t *)g_osd0base, DM320_OSD0_FBLEN); putreg16(CONFIG_DM320_OSD0_XPOS, DM320_OSD_OSDWIN0XP); putreg16(CONFIG_DM320_OSD0_YPOS, DM320_OSD_OSDWIN0YP); @@ -902,7 +902,7 @@ static void dm320_hwinitialize(void) #ifndef CONFIG_DM320_OSD1_DISABLE gvdbg("Initialize OSD win1\n"); - dm320_blankscreen((ubyte *)g_osd1base, DM320_OSD1_FBLEN); + dm320_blankscreen((uint8_t *)g_osd1base, DM320_OSD1_FBLEN); putreg16(CONFIG_DM320_OSD1_XPOS, DM320_OSD_OSDWIN1XP); putreg16(CONFIG_DM320_OSD1_YPOS, DM320_OSD_OSDWIN1YP); @@ -1183,12 +1183,12 @@ static int dm320_getcmap(FAR struct fb_vtable_s *vtable, FAR struct fb_cmap_s *c static int dm320_putcmap(FAR struct fb_vtable_s *vtable, FAR struct fb_cmap_s *cmap) { irqstate_t flags; - uint16 regval; - ubyte y; - ubyte u; - ubyte v; - int len - int i; + uint16_t regval; + uint8_t y; + uint8_t u; + uint8_t v; + int len + int i; #ifdef CONFIG_DEBUG if (!vtable || !cmap || !cmap->read || !cmap->green || !cmap->blue) @@ -1207,8 +1207,8 @@ static int dm320_putcmap(FAR struct fb_vtable_s *vtable, FAR struct fb_cmap_s *c /* Program the CLUT */ while (getreg16(DM320_OSD_MISCCTL) & 0x8); - putreg16(((uint16)y) << 8 | uint16(u)), DM320_OSD_CLUTRAMYCB); - putreg16(((uint16)v << 8 | i), DM320_OSD_CLUTRAMCR); + putreg16(((uint16_t)y) << 8 | uint16_t(u)), DM320_OSD_CLUTRAMYCB); + putreg16(((uint16_t)v << 8 | i), DM320_OSD_CLUTRAMCR); } /* Select RAM clut */ @@ -1279,7 +1279,7 @@ static int dm320_getcursor(FAR struct fb_vtable_s *vtable, FAR struct fb_cursora static int dm320_setcursor(FAR struct fb_vtable_s *vtable, FAR struct fb_setcursor_s *settings) { irqstate_t flags; - uint16 regval; + uint16_t regval; #ifdef CONFIG_DEBUG if (!vtable || !settings) diff --git a/nuttx/arch/arm/src/dm320/dm320_gio.h b/nuttx/arch/arm/src/dm320/dm320_gio.h index 642c68bc9..da21c6755 100644 --- a/nuttx/arch/arm/src/dm320/dm320_gio.h +++ b/nuttx/arch/arm/src/dm320/dm320_gio.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_gio.h * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,11 +41,11 @@ ************************************************************************************/ #ifndef __ASSEMBLY__ -# include <sys/types.h> +# include <stdint.h> #endif /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* General I/O Registers */ @@ -77,7 +77,7 @@ #define _GIO_READ_REG(pin, reg0, reg1, reg2, bval) \ do { \ - register uint32 _reg; register int _pin; \ + register uint32_t _reg; register int _pin; \ if ((pin) < 16) { _reg = (reg0); _pin = (pin); } \ else if ((pin) < 32) { _reg = (reg1); _pin = ((pin) - 16); } \ else { _reg = (reg2); _pin = ((pin) - 32); } \ @@ -86,7 +86,7 @@ #define _GIO_SET_REG(pin, reg0, reg1, reg2) \ do { \ - register uint32 _reg; register int _pin; \ + register uint32_t _reg; register int _pin; \ if ((pin) < 16) { _reg = (reg0); _pin = (pin); } \ else if ((pin) < 32) { _reg = (reg1); _pin = ((pin) - 16); } \ else { _reg = (reg2); _pin = ((pin) - 32); } \ @@ -95,7 +95,7 @@ #define _GIO_CLEAR_REG(pin, reg0, reg1, reg2) \ do { \ - register uint32 _reg; register int _pin; \ + register uint32_t _reg; register int _pin; \ if ((pin) < 16) { _reg = (reg0); _pin = (pin); } \ else if ((pin) < 32) { _reg = (reg1); _pin = ((pin) - 16); } \ else { _reg = (reg2); _pin = ((pin) - 32); } \ diff --git a/nuttx/arch/arm/src/dm320/dm320_intc.h b/nuttx/arch/arm/src/dm320/dm320_intc.h index 13f4452ec..245eb30ca 100644 --- a/nuttx/arch/arm/src/dm320/dm320_intc.h +++ b/nuttx/arch/arm/src/dm320/dm320_intc.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_intc.h * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -40,12 +40,8 @@ * Included Files ************************************************************************************/ -#ifndef __ASSEMBLY__ -# include <sys/types.h> -#endif - /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* Interrupt Controller Registers */ diff --git a/nuttx/arch/arm/src/dm320/dm320_irq.c b/nuttx/arch/arm/src/dm320/dm320_irq.c index 84e0efcf5..ec31e3246 100644 --- a/nuttx/arch/arm/src/dm320/dm320_irq.c +++ b/nuttx/arch/arm/src/dm320/dm320_irq.c @@ -1,4 +1,4 @@ -/************************************************************ +/************************************************************************ * arch/arm/src/dm320/dm320_irq.c * * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,14 +31,15 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************/ + ************************************************************************/ -/************************************************************ +/************************************************************************ * Included Files - ************************************************************/ + ************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + +#include <stdint.h> #include <nuttx/irq.h> #include "arm.h" @@ -46,19 +47,19 @@ #include "os_internal.h" #include "up_internal.h" -/************************************************************ - * Definitions - ************************************************************/ +/************************************************************************ + * Pre-processor Definitions + ************************************************************************/ -/************************************************************ +/************************************************************************ * Public Data - ************************************************************/ + ************************************************************************/ -uint32 *current_regs; +uint32_t *current_regs; -/************************************************************ +/************************************************************************ * Private Data - ************************************************************/ + ************************************************************************/ /* The value of _vflashstart is defined in ld.script. It * could be hard-coded because we know that correct IRAM @@ -67,17 +68,17 @@ uint32 *current_regs; extern int _svectors; /* Type does not matter */ -/************************************************************ +/************************************************************************ * Private Functions - ************************************************************/ + ************************************************************************/ -/************************************************************ +/************************************************************************ * Public Functions - ************************************************************/ + ************************************************************************/ -/************************************************************ +/************************************************************************ * Name: up_irqinitialize - ************************************************************/ + ************************************************************************/ void up_irqinitialize(void) { @@ -119,13 +120,13 @@ void up_irqinitialize(void) #endif } -/************************************************************ +/************************************************************************ * Name: up_disable_irq * * Description: * Disable the IRQ specified by 'irq' * - ************************************************************/ + ************************************************************************/ void up_disable_irq(int irq) { @@ -159,13 +160,13 @@ void up_disable_irq(int irq) } } -/************************************************************ +/************************************************************************ * Name: up_enable_irq * * Description: * Enable the IRQ specified by 'irq' * - ************************************************************/ + ************************************************************************/ void up_enable_irq(int irq) { @@ -199,13 +200,13 @@ void up_enable_irq(int irq) } } -/************************************************************ +/************************************************************************ * Name: up_maskack_irq * * Description: * Mask the IRQ and acknowledge it * - ************************************************************/ + ************************************************************************/ void up_maskack_irq(int irq) { diff --git a/nuttx/arch/arm/src/dm320/dm320_memorymap.h b/nuttx/arch/arm/src/dm320/dm320_memorymap.h index 7e7247b53..17afa183d 100644 --- a/nuttx/arch/arm/src/dm320/dm320_memorymap.h +++ b/nuttx/arch/arm/src/dm320/dm320_memorymap.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_memorymap.h * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,14 +40,10 @@ * Included Files ************************************************************************************/ -#ifndef __ASSEMBLY__ -# include <sys/types.h> -#endif - #include <nuttx/config.h> /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* Mapped base of all registers *****************************************************/ diff --git a/nuttx/arch/arm/src/dm320/dm320_osd.h b/nuttx/arch/arm/src/dm320/dm320_osd.h index a7857590d..496e49ff2 100644 --- a/nuttx/arch/arm/src/dm320/dm320_osd.h +++ b/nuttx/arch/arm/src/dm320/dm320_osd.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_osd.h * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -40,12 +40,8 @@ * Included Files ************************************************************************************/ -#ifndef __ASSEMBLY__ -# include <sys/types.h> -#endif - /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* On Screen Display Register Map (OSD) *********************************************/ diff --git a/nuttx/arch/arm/src/dm320/dm320_serial.c b/nuttx/arch/arm/src/dm320/dm320_serial.c index 35d0db17d..47e15defe 100644 --- a/nuttx/arch/arm/src/dm320/dm320_serial.c +++ b/nuttx/arch/arm/src/dm320/dm320_serial.c @@ -41,6 +41,8 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <unistd.h> #include <semaphore.h> #include <string.h> @@ -59,7 +61,7 @@ #ifdef CONFIG_USE_SERIALDRIVER /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -68,33 +70,33 @@ struct up_dev_s { - uint32 uartbase; /* Base address of UART registers */ - uint32 baud; /* Configured baud */ - uint16 msr; /* Saved MSR value */ - ubyte irq; /* IRQ associated with this UART */ - ubyte parity; /* 0=none, 1=odd, 2=even */ - ubyte bits; /* Number of bits (7 or 8) */ - boolean stopbits2; /* TRUE: Configure with 2 - * stop bits instead of 1 */ + uint32_t uartbase; /* Base address of UART registers */ + uint32_t baud; /* Configured baud */ + uint16_t msr; /* Saved MSR value */ + uint8_t irq; /* IRQ associated with this UART */ + uint8_t parity; /* 0=none, 1=odd, 2=even */ + uint8_t bits; /* Number of bits (7 or 8) */ + bool stopbits2; /* true: Configure with 2 + * stop bits instead of 1 */ }; /**************************************************************************** * Private Function Prototypes ****************************************************************************/ -static int up_setup(struct uart_dev_s *dev); -static void up_shutdown(struct uart_dev_s *dev); -static int up_attach(struct uart_dev_s *dev); -static void up_detach(struct uart_dev_s *dev); -static int up_interrupt(int irq, void *context); -static int up_ioctl(struct file *filep, int cmd, unsigned long arg); -static int up_receive(struct uart_dev_s *dev, uint32 *status); -static void up_rxint(struct uart_dev_s *dev, boolean enable); -static boolean up_rxavailable(struct uart_dev_s *dev); -static void up_send(struct uart_dev_s *dev, int ch); -static void up_txint(struct uart_dev_s *dev, boolean enable); -static boolean up_txready(struct uart_dev_s *dev); -static boolean up_txempty(struct uart_dev_s *dev); +static int up_setup(struct uart_dev_s *dev); +static void up_shutdown(struct uart_dev_s *dev); +static int up_attach(struct uart_dev_s *dev); +static void up_detach(struct uart_dev_s *dev); +static int up_interrupt(int irq, void *context); +static int up_ioctl(struct file *filep, int cmd, unsigned long arg); +static int up_receive(struct uart_dev_s *dev, uint32_t *status); +static void up_rxint(struct uart_dev_s *dev, bool enable); +static bool up_rxavailable(struct uart_dev_s *dev); +static void up_send(struct uart_dev_s *dev, int ch); +static void up_txint(struct uart_dev_s *dev, bool enable); +static bool up_txready(struct uart_dev_s *dev); +static bool up_txempty(struct uart_dev_s *dev); /**************************************************************************** * Private Variables @@ -199,7 +201,7 @@ static uart_dev_t g_uart1port = * Name: up_serialin ****************************************************************************/ -static inline uint16 up_serialin(struct up_dev_s *priv, uint32 offset) +static inline uint16_t up_serialin(struct up_dev_s *priv, uint32_t offset) { return getreg16(priv->uartbase + offset); } @@ -208,7 +210,7 @@ static inline uint16 up_serialin(struct up_dev_s *priv, uint32 offset) * Name: up_serialout ****************************************************************************/ -static inline void up_serialout(struct up_dev_s *priv, uint32 offset, uint16 value) +static inline void up_serialout(struct up_dev_s *priv, uint32_t offset, uint16_t value) { putreg16(value, priv->uartbase + offset); } @@ -217,7 +219,7 @@ static inline void up_serialout(struct up_dev_s *priv, uint32 offset, uint16 val * Name: up_disableuartint ****************************************************************************/ -static inline void up_disableuartint(struct up_dev_s *priv, uint16 *msr) +static inline void up_disableuartint(struct up_dev_s *priv, uint16_t *msr) { if (msr) { @@ -232,7 +234,7 @@ static inline void up_disableuartint(struct up_dev_s *priv, uint16 *msr) * Name: up_restoreuartint ****************************************************************************/ -static inline void up_restoreuartint(struct up_dev_s *priv, uint16 msr) +static inline void up_restoreuartint(struct up_dev_s *priv, uint16_t msr) { priv->msr |= msr & UART_MSR_ALLIE; up_serialout(priv, UART_MSR, priv->msr); @@ -259,9 +261,9 @@ static inline void up_waittxready(struct up_dev_s *priv) * Name: up_enablebreaks ****************************************************************************/ -static inline void up_enablebreaks(struct up_dev_s *priv, boolean enable) +static inline void up_enablebreaks(struct up_dev_s *priv, bool enable) { - uint16 lcr = up_serialin(priv, UART_LCR); + uint16_t lcr = up_serialin(priv, UART_LCR); if (enable) { lcr |= UART_LCR_BOC; @@ -287,7 +289,7 @@ static int up_setup(struct uart_dev_s *dev) { #ifndef CONFIG_SUPPRESS_UART_CONFIG struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - uint16 brsr; + uint16_t brsr; /* Clear fifos */ @@ -380,7 +382,7 @@ static int up_setup(struct uart_dev_s *dev) up_serialout(priv, UART_MSR, priv->msr); up_serialout(priv, UART_BRSR, brsr); - up_enablebreaks(priv, FALSE); + up_enablebreaks(priv, false); #endif return OK; } @@ -468,7 +470,7 @@ static int up_interrupt(int irq, void *context) { struct uart_dev_s *dev = NULL; struct up_dev_s *priv; - uint16 status; + uint16_t status; int passes = 0; if (g_uart1priv.irq == irq) @@ -559,7 +561,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { irqstate_t flags = irqsave(); - up_enablebreaks(priv, TRUE); + up_enablebreaks(priv, true); irqrestore(flags); } break; @@ -568,7 +570,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) { irqstate_t flags; flags = irqsave(); - up_enablebreaks(priv, FALSE); + up_enablebreaks(priv, false); irqrestore(flags); } break; @@ -591,10 +593,10 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) * ****************************************************************************/ -static int up_receive(struct uart_dev_s *dev, uint32 *status) +static int up_receive(struct uart_dev_s *dev, uint32_t *status) { struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - uint16 dtrr; + uint16_t dtrr; dtrr = up_serialin(priv, UART_DTRR); *status = dtrr; @@ -609,7 +611,7 @@ static int up_receive(struct uart_dev_s *dev, uint32 *status) * ****************************************************************************/ -static void up_rxint(struct uart_dev_s *dev, boolean enable) +static void up_rxint(struct uart_dev_s *dev, bool enable) { struct up_dev_s *priv = (struct up_dev_s*)dev->priv; if (enable) @@ -629,11 +631,11 @@ static void up_rxint(struct uart_dev_s *dev, boolean enable) * Name: up_rxavailable * * Description: - * Return TRUE if the receive fifo is not empty + * Return true if the receive fifo is not empty * ****************************************************************************/ -static boolean up_rxavailable(struct uart_dev_s *dev) +static bool up_rxavailable(struct uart_dev_s *dev) { struct up_dev_s *priv = (struct up_dev_s*)dev->priv; return ((up_serialin(priv, UART_SR) & UART_SR_RFNEF) != 0); @@ -650,7 +652,7 @@ static boolean up_rxavailable(struct uart_dev_s *dev) static void up_send(struct uart_dev_s *dev, int ch) { struct up_dev_s *priv = (struct up_dev_s*)dev->priv; - up_serialout(priv, UART_DTRR, (uint16)ch); + up_serialout(priv, UART_DTRR, (uint16_t)ch); } /**************************************************************************** @@ -661,7 +663,7 @@ static void up_send(struct uart_dev_s *dev, int ch) * ****************************************************************************/ -static void up_txint(struct uart_dev_s *dev, boolean enable) +static void up_txint(struct uart_dev_s *dev, bool enable) { struct up_dev_s *priv = (struct up_dev_s*)dev->priv; if (enable) @@ -681,11 +683,11 @@ static void up_txint(struct uart_dev_s *dev, boolean enable) * Name: up_txready * * Description: - * Return TRUE if the tranmsit fifo is not full + * Return true if the tranmsit fifo is not full * ****************************************************************************/ -static boolean up_txready(struct uart_dev_s *dev) +static bool up_txready(struct uart_dev_s *dev) { struct up_dev_s *priv = (struct up_dev_s*)dev->priv; return ((up_serialin(priv, UART_SR) & UART_SR_TFTI) != 0); @@ -695,11 +697,11 @@ static boolean up_txready(struct uart_dev_s *dev) * Name: up_txempty * * Description: - * Return TRUE if the transmit fifo is empty + * Return true if the transmit fifo is empty * ****************************************************************************/ -static boolean up_txempty(struct uart_dev_s *dev) +static bool up_txempty(struct uart_dev_s *dev) { struct up_dev_s *priv = (struct up_dev_s*)dev->priv; return ((up_serialin(priv, UART_SR) & UART_SR_TREF) == 0); @@ -724,7 +726,7 @@ void up_earlyserialinit(void) up_disableuartint(TTYS0_DEV.priv, NULL); up_disableuartint(TTYS1_DEV.priv, NULL); - CONSOLE_DEV.isconsole = TRUE; + CONSOLE_DEV.isconsole = true; up_setup(&CONSOLE_DEV); } @@ -756,11 +758,11 @@ void up_serialinit(void) int up_putc(int ch) { struct up_dev_s *priv = (struct up_dev_s*)CONSOLE_DEV.priv; - uint16 ier; + uint16_t ier; up_disableuartint(priv, &ier); up_waittxready(priv); - up_serialout(priv, UART_DTRR, (uint16)ch); + up_serialout(priv, UART_DTRR, (uint16_t)ch); /* Check for LF */ @@ -814,7 +816,7 @@ static inline void up_waittxready(void) int up_putc(int ch) { up_waittxready(); - putreg16((uint16)ch, DM320_REGISTER_BASE + UART_DTRR); + putreg16((uint16_t)ch, DM320_REGISTER_BASE + UART_DTRR); /* Check for LF */ @@ -823,7 +825,7 @@ int up_putc(int ch) /* Add CR */ up_waittxready(); - putreg16((uint16)'\r', DM320_REGISTER_BASE + UART_DTRR); + putreg16((uint16_t)'\r', DM320_REGISTER_BASE + UART_DTRR); } up_waittxready(); diff --git a/nuttx/arch/arm/src/dm320/dm320_timer.h b/nuttx/arch/arm/src/dm320/dm320_timer.h index 6c76f4824..31839a091 100644 --- a/nuttx/arch/arm/src/dm320/dm320_timer.h +++ b/nuttx/arch/arm/src/dm320/dm320_timer.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_timer.h * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,12 +40,8 @@ * Included Files ************************************************************************************/ -#ifndef __ASSEMBLY__ -# include <sys/types.h> -#endif - /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* Timer Registers */ diff --git a/nuttx/arch/arm/src/dm320/dm320_timerisr.c b/nuttx/arch/arm/src/dm320/dm320_timerisr.c index 59fa7581f..a8e3f39fe 100644 --- a/nuttx/arch/arm/src/dm320/dm320_timerisr.c +++ b/nuttx/arch/arm/src/dm320/dm320_timerisr.c @@ -39,15 +39,17 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> + +#include <stdint.h> #include <debug.h> #include <nuttx/arch.h> + #include "clock_internal.h" #include "up_internal.h" #include "up_arch.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* DM320 Timers @@ -114,7 +116,7 @@ * ****************************************************************************/ -int up_timerisr(int irq, uint32 *regs) +int up_timerisr(int irq, uint32_t *regs) { /* Process timer interrupt */ diff --git a/nuttx/arch/arm/src/dm320/dm320_uart.h b/nuttx/arch/arm/src/dm320/dm320_uart.h index 0c5d803be..f92a5ccdd 100644 --- a/nuttx/arch/arm/src/dm320/dm320_uart.h +++ b/nuttx/arch/arm/src/dm320/dm320_uart.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_uart.h * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,11 +41,11 @@ ************************************************************************************/ #ifndef __ASSEMBLY__ -# include <sys/types.h> +# include <stdint.h> #endif /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* UART definitions *****************************************************************/ @@ -80,18 +80,18 @@ /* And baud = UART_REFCLK / (brsr+1) */ -#define UART_BAUD_2400 ((uint16)((UART_REFCLK / 2400 ) - 1)) -#define UART_BAUD_4800 ((uint16)((UART_REFCLK / 4800 ) - 1)) -#define UART_BAUD_9600 ((uint16)((UART_REFCLK / 9600 ) - 1)) -#define UART_BAUD_14400 ((uint16)((UART_REFCLK / 14400 ) - 1)) -#define UART_BAUD_19200 ((uint16)((UART_REFCLK / 19200 ) - 1)) -#define UART_BAUD_28800 ((uint16)((UART_REFCLK / 28800 ) - 1)) -#define UART_BAUD_38400 ((uint16)((UART_REFCLK / 38400 ) - 1)) -#define UART_BAUD_57600 ((uint16)((UART_REFCLK / 57600 ) - 1)) -#define UART_BAUD_115200 ((uint16)((UART_REFCLK / 115200) - 1)) -#define UART_BAUD_230400 ((uint16)((UART_REFCLK / 230400) - 1)) -#define UART_BAUD_460800 ((uint16)((UART_REFCLK / 460800) - 1)) -#define UART_BAUD_921600 ((uint16)((UART_REFCLK / 921600) - 1)) +#define UART_BAUD_2400 ((uint16_t)((UART_REFCLK / 2400 ) - 1)) +#define UART_BAUD_4800 ((uint16_t)((UART_REFCLK / 4800 ) - 1)) +#define UART_BAUD_9600 ((uint16_t)((UART_REFCLK / 9600 ) - 1)) +#define UART_BAUD_14400 ((uint16_t)((UART_REFCLK / 14400 ) - 1)) +#define UART_BAUD_19200 ((uint16_t)((UART_REFCLK / 19200 ) - 1)) +#define UART_BAUD_28800 ((uint16_t)((UART_REFCLK / 28800 ) - 1)) +#define UART_BAUD_38400 ((uint16_t)((UART_REFCLK / 38400 ) - 1)) +#define UART_BAUD_57600 ((uint16_t)((UART_REFCLK / 57600 ) - 1)) +#define UART_BAUD_115200 ((uint16_t)((UART_REFCLK / 115200) - 1)) +#define UART_BAUD_230400 ((uint16_t)((UART_REFCLK / 230400) - 1)) +#define UART_BAUD_460800 ((uint16_t)((UART_REFCLK / 460800) - 1)) +#define UART_BAUD_921600 ((uint16_t)((UART_REFCLK / 921600) - 1)) /* UART MSR register bit definitions */ diff --git a/nuttx/arch/arm/src/dm320/dm320_usb.h b/nuttx/arch/arm/src/dm320/dm320_usb.h index 4dfe582ff..229c2857e 100644 --- a/nuttx/arch/arm/src/dm320/dm320_usb.h +++ b/nuttx/arch/arm/src/dm320/dm320_usb.h @@ -1,7 +1,7 @@ /************************************************************************************ * dm320/dm320_uart.h * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -40,12 +40,8 @@ * Included Files ************************************************************************************/ -#ifndef __ASSEMBLY__ -# include <sys/types.h> -#endif - /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /* USB Controller Registers *********************************************************/ diff --git a/nuttx/arch/arm/src/dm320/dm320_usbdev.c b/nuttx/arch/arm/src/dm320/dm320_usbdev.c index b77cf2317..9e8dc5ea1 100644 --- a/nuttx/arch/arm/src/dm320/dm320_usbdev.c +++ b/nuttx/arch/arm/src/dm320/dm320_usbdev.c @@ -1,7 +1,7 @@ /******************************************************************************* * arch/arm/src/dm320/dm320_usbdev.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -38,8 +38,10 @@ *******************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <string.h> #include <errno.h> @@ -208,11 +210,11 @@ struct dm320_ep_s struct dm320_usbdev_s *dev; /* Reference to private driver data */ struct dm320_req_s *head; /* Request list for this endpoint */ struct dm320_req_s *tail; - ubyte epphy; /* Physical EP address/index */ - ubyte stalled:1; /* Endpoint is halted */ - ubyte in:1; /* Endpoint is IN only */ - ubyte halted:1; /* Endpoint feature halted */ - ubyte txnullpkt:1; /* Null packet needed at end of transfer */ + uint8_t epphy; /* Physical EP address/index */ + uint8_t stalled:1; /* Endpoint is halted */ + uint8_t in:1; /* Endpoint is IN only */ + uint8_t halted:1; /* Endpoint feature halted */ + uint8_t txnullpkt:1; /* Null packet needed at end of transfer */ }; /* This structure encapsulates the overall driver state */ @@ -232,12 +234,12 @@ struct dm320_usbdev_s /* DM320-specific fields */ - ubyte stalled:1; /* 1: Protocol stalled */ - ubyte selfpowered:1; /* 1: Device is self powered */ - ubyte paddrset:1; /* 1: Peripheral addr has been set */ - ubyte attached:1; /* 1: Host attached */ - ubyte rxpending:1; /* 1: RX pending */ - ubyte paddr; /* Peripheral address */ + uint8_t stalled:1; /* 1: Protocol stalled */ + uint8_t selfpowered:1; /* 1: Device is self powered */ + uint8_t paddrset:1; /* 1: Peripheral addr has been set */ + uint8_t attached:1; /* 1: Host attached */ + uint8_t rxpending:1; /* 1: RX pending */ + uint8_t paddr; /* Peripheral address */ /* The endpoint list */ @@ -248,13 +250,13 @@ struct dm320_usbdev_s struct dm320_epinfo_s { - ubyte addr; /* Logical endpoint address */ - ubyte attr; /* Endpoint attributes */ - ubyte fifo; /* FIFO mx pkt size + dual buffer bits */ + uint8_t addr; /* Logical endpoint address */ + uint8_t attr; /* Endpoint attributes */ + uint8_t fifo; /* FIFO mx pkt size + dual buffer bits */ #ifdef CONFIG_USBDEV_HIGHSPEED - uint16 maxpacket; /* Max packet size */ + uint16_t maxpacket; /* Max packet size */ #else - ubyte maxpacket; /* Max packet size */ + uint8_t maxpacket; /* Max packet size */ #endif }; @@ -265,12 +267,12 @@ struct dm320_epinfo_s /* Register operations */ #if defined(CONFIG_DM320_USBDEV_REGDEBUG) && defined(CONFIG_DEBUG) -static uint32 dm320_getreg8(uint32 addr); -static uint32 dm320_getreg16(uint32 addr); -static uint32 dm320_getreg32(uint32 addr); -static void dm320_putreg8(ubyte val, uint32 addr); -static void dm320_putreg16(uint16 val, uint32 addr); -static void dm320_putreg32(uint32 val, uint32 addr); +static uint32_t dm320_getreg8(uint32_t addr); +static uint32_t dm320_getreg16(uint32_t addr); +static uint32_t dm320_getreg32(uint32_t addr); +static void dm320_putreg8(uint8_t val, uint32_t addr); +static void dm320_putreg16(uint16_t val, uint32_t addr); +static void dm320_putreg32(uint32_t val, uint32_t addr); #else # define dm320_getreg8(addr) getreg8(addr) # define dm320_getreg16(addr) getreg16(addr) @@ -287,12 +289,12 @@ static void dm320_rqenqueue(FAR struct dm320_ep_s *privep, FAR struct dm320_req_ /* Low level data transfers and request operations */ -static int dm320_ep0write(ubyte *buf, uint16 nbytes); -static int dm320_epwrite(ubyte epphy, ubyte *buf, uint16 nbytes); -static int dm320_epread(ubyte epphy, ubyte *buf, uint16 nbytes); +static int dm320_ep0write(uint8_t *buf, uint16_t nbytes); +static int dm320_epwrite(uint8_t epphy, uint8_t *buf, uint16_t nbytes); +static int dm320_epread(uint8_t epphy, uint8_t *buf, uint16_t nbytes); static inline void dm320_abortrequest(struct dm320_ep_s *privep, - struct dm320_req_s *privreq, sint16 result); -static void dm320_reqcomplete(struct dm320_ep_s *privep, sint16 result); + struct dm320_req_s *privreq, int16_t result); +static void dm320_reqcomplete(struct dm320_ep_s *privep, int16_t result); static int dm320_wrrequest(struct dm320_ep_s *privep); static int dm320_rdrequest(struct dm320_ep_s *privep); static void dm320_cancelrequests(struct dm320_ep_s *privep); @@ -300,11 +302,11 @@ static void dm320_cancelrequests(struct dm320_ep_s *privep); /* Interrupt handling */ static struct dm320_ep_s *dm320_epfindbyaddr(struct dm320_usbdev_s *priv, - uint16 eplog); + uint16_t eplog); static void dm320_dispatchrequest(struct dm320_usbdev_s *priv, const struct usb_ctrlreq_s *ctrl); static inline void dm320_ep0setup(struct dm320_usbdev_s *priv); -static inline uint32 dm320_highestpriinterrupt(int intstatus); +static inline uint32_t dm320_highestpriinterrupt(int intstatus); static int dm320_ctlrinterrupt(int irq, FAR void *context); static int dm320_attachinterrupt(int irq, FAR void *context); @@ -317,12 +319,12 @@ static void dm320_ctrlinitialize(struct dm320_usbdev_s *priv); /* Endpoint methods */ static int dm320_epconfigure(FAR struct usbdev_ep_s *ep, - const struct usb_epdesc_s *desc, boolean last); + const struct usb_epdesc_s *desc, bool last); static int dm320_epdisable(FAR struct usbdev_ep_s *ep); static FAR struct usbdev_req_s *dm320_epallocreq(FAR struct usbdev_ep_s *ep); static void dm320_epfreereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req); #ifdef CONFIG_DM320_USBDEV_DMA -static FAR void *dm320_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16 nbytes); +static FAR void *dm320_epallocbuffer(FAR struct usbdev_ep_s *ep, uint16_t nbytes); static void dm320_epfreebuffer(FAR struct usbdev_ep_s *ep, void *buf); #endif static int dm320_epsubmit(FAR struct usbdev_ep_s *ep, struct usbdev_req_s *privreq); @@ -331,12 +333,12 @@ static int dm320_epcancel(FAR struct usbdev_ep_s *ep, struct usbdev_req_s *priv /* USB device controller methods */ static FAR struct usbdev_ep_s *dm320_allocep(FAR struct usbdev_s *dev, - ubyte epno, boolean in, ubyte eptype); + uint8_t epno, bool in, uint8_t eptype); static void dm320_freeep(FAR struct usbdev_s *dev, FAR struct usbdev_ep_s *ep); static int dm320_getframe(struct usbdev_s *dev); static int dm320_wakeup(struct usbdev_s *dev); -static int dm320_selfpowered(struct usbdev_s *dev, boolean selfpowered); -static int dm320_pullup(struct usbdev_s *dev, boolean enable); +static int dm320_selfpowered(struct usbdev_s *dev, bool selfpowered); +static int dm320_pullup(struct usbdev_s *dev, bool enable); /******************************************************************************* * Private Data @@ -419,15 +421,15 @@ static const struct dm320_epinfo_s g_epinfo[DM320_NENDPOINTS] = *******************************************************************************/ #if defined(CONFIG_DM320_USBDEV_REGDEBUG) && defined(CONFIG_DEBUG) -static ubyte dm320_getreg8(uint32 addr) +static uint8_t dm320_getreg8(uint32_t addr) { - static uint32 prevaddr = 0; - static ubyte preval = 0; - static uint32 count = 0; + static uint32_t prevaddr = 0; + static uint8_t preval = 0; + static uint32_t count = 0; /* Read the value from the register */ - ubyte val = getreg8(addr); + uint8_t val = getreg8(addr); /* Is this the same value that we read from the same registe last time? Are * we polling the register? If so, suppress some of the output. @@ -481,15 +483,15 @@ static ubyte dm320_getreg8(uint32 addr) *******************************************************************************/ #if defined(CONFIG_DM320_USBDEV_REGDEBUG) && defined(CONFIG_DEBUG) -static uint32 dm320_getreg16(uint32 addr) +static uint32_t dm320_getreg16(uint32_t addr) { - static uint32 prevaddr = 0; - static uint16 preval = 0; - static uint32 count = 0; + static uint32_t prevaddr = 0; + static uint16_t preval = 0; + static uint32_t count = 0; /* Read the value from the register */ - uint16 val = getreg16(addr); + uint16_t val = getreg16(addr); /* Is this the same value that we read from the same registe last time? Are * we polling the register? If so, suppress some of the output. @@ -543,15 +545,15 @@ static uint32 dm320_getreg16(uint32 addr) *******************************************************************************/ #if defined(CONFIG_DM320_USBDEV_REGDEBUG) && defined(CONFIG_DEBUG) -static uint32 dm320_getreg32(uint32 addr) +static uint32_t dm320_getreg32(uint32_t addr) { - static uint32 prevaddr = 0; - static uint32 preval = 0; - static uint32 count = 0; + static uint32_t prevaddr = 0; + static uint32_t preval = 0; + static uint32_t count = 0; /* Read the value from the register */ - uint32 val = getreg32(addr); + uint32_t val = getreg32(addr); /* Is this the same value that we read from the same registe last time? Are * we polling the register? If so, suppress some of the output. @@ -605,7 +607,7 @@ static uint32 dm320_getreg32(uint32 addr) *******************************************************************************/ #if defined(CONFIG_DM320_USBDEV_REGDEBUG) && defined(CONFIG_DEBUG) -static void dm320_putreg8(ubyte val, uint32 addr) +static void dm320_putreg8(uint8_t val, uint32_t addr) { /* Show the register value being written */ @@ -626,7 +628,7 @@ static void dm320_putreg8(ubyte val, uint32 addr) *******************************************************************************/ #if defined(CONFIG_DM320_USBDEV_REGDEBUG) && defined(CONFIG_DEBUG) -static void dm320_putreg16(uint16 val, uint32 addr) +static void dm320_putreg16(uint16_t val, uint32_t addr) { /* Show the register value being written */ @@ -647,7 +649,7 @@ static void dm320_putreg16(uint16 val, uint32 addr) *******************************************************************************/ #if defined(CONFIG_DM320_USBDEV_REGDEBUG) && defined(CONFIG_DEBUG) -static void dm320_putreg32(uint32 val, uint32 addr) +static void dm320_putreg32(uint32_t val, uint32_t addr) { /* Show the register value being written */ @@ -717,11 +719,11 @@ static void dm320_rqenqueue(FAR struct dm320_ep_s *privep, * *******************************************************************************/ -static int dm320_ep0write(ubyte *buf, uint16 nbytes) +static int dm320_ep0write(uint8_t *buf, uint16_t nbytes) { - ubyte csr0 = USB_PERCSR0_TXPKTRDY; /* XMT packet ready bit */ - uint16 bytesleft; - uint16 nwritten; + uint8_t csr0 = USB_PERCSR0_TXPKTRDY; /* XMT packet ready bit */ + uint16_t bytesleft; + uint16_t nwritten; if ( nbytes <= DM320_EP0MAXPACKET) { @@ -752,10 +754,10 @@ static int dm320_ep0write(ubyte *buf, uint16 nbytes) * *******************************************************************************/ -static int dm320_epwrite(ubyte epphy, ubyte *buf, uint16 nbytes) +static int dm320_epwrite(uint8_t epphy, uint8_t *buf, uint16_t nbytes) { - volatile ubyte *fifo; - uint16 bytesleft; + volatile uint8_t *fifo; + uint16_t bytesleft; int ret = ERROR; if (/*epphy < USB_EP0_SELECT || */ epphy >= DM320_NENDPOINTS) @@ -776,7 +778,7 @@ static int dm320_epwrite(ubyte epphy, ubyte *buf, uint16 nbytes) } ret = bytesleft; - fifo = (volatile ubyte *)DM320_USB_FIFO0; + fifo = (volatile uint8_t *)DM320_USB_FIFO0; fifo = fifo + (epphy << 2); if (dm320_getreg8(DM320_USB_PERTXCSR1) & USB_TXCSR1_FIFOEMP) @@ -803,9 +805,9 @@ static int dm320_epwrite(ubyte epphy, ubyte *buf, uint16 nbytes) * *******************************************************************************/ -static int dm320_epread(ubyte epphy, ubyte *buf, uint16 nbytes) +static int dm320_epread(uint8_t epphy, uint8_t *buf, uint16_t nbytes) { - volatile ubyte *fifo; + volatile uint8_t *fifo; int bytesleft; int ret = ERROR; @@ -834,7 +836,7 @@ static int dm320_epread(ubyte epphy, ubyte *buf, uint16 nbytes) } ret = bytesleft; - fifo = (ubyte*)DM320_USB_FIFO0; + fifo = (uint8_t*)DM320_USB_FIFO0; fifo = fifo + (epphy << 2); while (bytesleft > 0) @@ -858,10 +860,10 @@ static int dm320_epread(ubyte epphy, ubyte *buf, uint16 nbytes) *******************************************************************************/ static inline void dm320_abortrequest(struct dm320_ep_s *privep, - struct dm320_req_s *privreq, - sint16 result) + struct dm320_req_s *privreq, + int16_t result) { - usbtrace(TRACE_DEVERROR(DM320_TRACEERR_REQABORTED), (uint16)privep->epphy); + usbtrace(TRACE_DEVERROR(DM320_TRACEERR_REQABORTED), (uint16_t)privep->epphy); /* Save the result in the request structure */ @@ -880,7 +882,7 @@ static inline void dm320_abortrequest(struct dm320_ep_s *privep, * *******************************************************************************/ -static void dm320_reqcomplete(struct dm320_ep_s *privep, sint16 result) +static void dm320_reqcomplete(struct dm320_ep_s *privep, int16_t result) { struct dm320_req_s *privreq; int stalled = privep->stalled; @@ -935,7 +937,7 @@ static void dm320_reqcomplete(struct dm320_ep_s *privep, sint16 result) static int dm320_wrrequest(struct dm320_ep_s *privep) { struct dm320_req_s *privreq; - ubyte *buf; + uint8_t *buf; int nbytes; int bytesleft; int nbyteswritten; @@ -1026,7 +1028,7 @@ static int dm320_wrrequest(struct dm320_ep_s *privep) static int dm320_rdrequest(struct dm320_ep_s *privep) { struct dm320_req_s *privreq; - ubyte *buf; + uint8_t *buf; int nbytesread; /* Check the request from the head of the endpoint request queue */ @@ -1092,7 +1094,7 @@ static void dm320_cancelrequests(struct dm320_ep_s *privep) *******************************************************************************/ static struct dm320_ep_s *dm320_epfindbyaddr(struct dm320_usbdev_s *priv, - uint16 eplog) + uint16_t eplog) { struct dm320_ep_s *privep; int i; @@ -1166,9 +1168,9 @@ static inline void dm320_ep0setup(struct dm320_usbdev_s *priv) struct dm320_req_s *privreq = dm320_rqpeek(ep0); struct dm320_ep_s *privep; struct usb_ctrlreq_s ctrl; - uint16 index; - uint16 value; - uint16 len; + uint16_t index; + uint16_t value; + uint16_t len; int ret; /* Starting a control request? */ @@ -1182,7 +1184,7 @@ static inline void dm320_ep0setup(struct dm320_usbdev_s *priv) while (!dm320_rqempty(ep0)) { - sint16 result = OK; + int16_t result = OK; if (privreq->req.xfrd != privreq->req.len) { result = -EPROTO; @@ -1199,7 +1201,7 @@ static inline void dm320_ep0setup(struct dm320_usbdev_s *priv) /* Read EP0 data */ - ret = dm320_epread(USB_EP0_SELECT, (ubyte*)&ctrl, USB_SIZEOF_CTRLREQ); + ret = dm320_epread(USB_EP0_SELECT, (uint8_t*)&ctrl, USB_SIZEOF_CTRLREQ); if (ret <= 0) { return; @@ -1285,7 +1287,7 @@ static inline void dm320_ep0setup(struct dm320_usbdev_s *priv) */ dm320_putreg8(USB_PERCSR0_CLRRXRDY | USB_PERCSR0_DATAEND, DM320_USB_PERCSR0); - usbtrace(TRACE_INTDECODE(DM320_TRACEINTID_CLEARFEATURE), (uint16)ctrl.req); + usbtrace(TRACE_INTDECODE(DM320_TRACEINTID_CLEARFEATURE), (uint16_t)ctrl.req); if (ctrl.type != USB_REQ_RECIPIENT_ENDPOINT) { dm320_dispatchrequest(priv, &ctrl); @@ -1433,7 +1435,7 @@ static inline void dm320_ep0setup(struct dm320_usbdev_s *priv) * *******************************************************************************/ -static inline uint32 dm320_highestpriinterrupt(int intstatus) +static inline uint32_t dm320_highestpriinterrupt(int intstatus) { if ((intstatus & USB_INT_CONNECTED) != 0) return USB_INT_CONNECTED; @@ -1473,17 +1475,17 @@ static int dm320_ctlrinterrupt(int irq, FAR void *context) { struct dm320_usbdev_s *priv = &g_usbdev; struct dm320_ep_s *privep ; - uint32 intstatus; - uint32 priorityint; - ubyte csr0; + uint32_t intstatus; + uint32_t priorityint; + uint8_t csr0; usbtrace(TRACE_INTENTRY(DM320_TRACEINTID_USBCTLR), 0); /* Combine interretup registers into one interrupt status value */ - intstatus = ((uint32)dm320_getreg8(DM320_USB_INTRTX1) << 12) | - (((uint32)dm320_getreg8(DM320_USB_INTRRX1) >> 1) << 8) | - (uint32)dm320_getreg8(DM320_USB_INTRUSB); + intstatus = ((uint32_t)dm320_getreg8(DM320_USB_INTRTX1) << 12) | + (((uint32_t)dm320_getreg8(DM320_USB_INTRRX1) >> 1) << 8) | + (uint32_t)dm320_getreg8(DM320_USB_INTRUSB); /* Then process each interrupt source, highest priority first */ do @@ -1639,7 +1641,7 @@ static int dm320_ctlrinterrupt(int irq, FAR void *context) static int dm320_attachinterrupt(int irq, FAR void *context) { struct dm320_usbdev_s *priv = &g_usbdev; - uint16 gio; + uint16_t gio; /* Check if the USB device was connected to or disconnected from a host */ @@ -1708,9 +1710,9 @@ static void dm320_epreset(unsigned int index) static inline void dm320_epinitialize(struct dm320_usbdev_s *priv) { - uint16 offset; /* Full USB buffer offset */ - ubyte addrhi; /* MS bytes of ofset */ - ubyte addrlo; /* LS bytes of offset */ + uint16_t offset; /* Full USB buffer offset */ + uint8_t addrhi; /* MS bytes of ofset */ + uint8_t addrlo; /* LS bytes of offset */ int i; /* Initialize endpoint 0 */ @@ -1862,7 +1864,7 @@ static void dm320_ctrlinitialize(FAR struct dm320_usbdev_s *priv) * Input Parameters: * ep - the struct usbdev_ep_s instance obtained from allocep() * desc - A struct usb_epdesc_s instance describing the endpoint - * last - TRUE if this this last endpoint to be configured. Some hardware + * last - true if this this last endpoint to be configured. Some hardware * needs to take special action when all of the endpoints have been * configured. * @@ -1870,7 +1872,7 @@ static void dm320_ctrlinitialize(FAR struct dm320_usbdev_s *priv) static int dm320_epconfigure(FAR struct usbdev_ep_s *ep, FAR const struct usb_epdesc_s *desc, - boolean last) + bool last) { FAR struct dm320_ep_s *privep = (FAR struct dm320_ep_s *)ep; @@ -2141,14 +2143,14 @@ static int dm320_epcancel(struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req) * eplog - 7-bit logical endpoint number (direction bit ignored). Zero means * that any endpoint matching the other requirements will suffice. The * assigned endpoint can be found in the eplog field. - * in - TRUE: IN (device-to-host) endpoint requested + * in - true: IN (device-to-host) endpoint requested * eptype - Endpoint type. One of {USB_EP_ATTR_XFER_ISOC, USB_EP_ATTR_XFER_BULK, * USB_EP_ATTR_XFER_INT} * *******************************************************************************/ -static FAR struct usbdev_ep_s *dm320_allocep(FAR struct usbdev_s *dev, ubyte eplog, - boolean in, ubyte eptype) +static FAR struct usbdev_ep_s *dm320_allocep(FAR struct usbdev_s *dev, uint8_t eplog, + bool in, uint8_t eptype) { FAR struct dm320_usbdev_s *priv = (FAR struct dm320_usbdev_s *)dev; int ndx; @@ -2212,7 +2214,7 @@ static FAR struct usbdev_ep_s *dm320_allocep(FAR struct usbdev_s *dev, ubyte epl static void dm320_freeep(FAR struct usbdev_s *dev, FAR struct usbdev_ep_s *ep) { FAR struct dm320_ep_s *privep = (FAR struct dm320_ep_s *)ep; - usbtrace(TRACE_DEVFREEEP, (uint16)privep->epphy); + usbtrace(TRACE_DEVFREEEP, (uint16_t)privep->epphy); /* Nothing needs to be done */ } @@ -2278,11 +2280,11 @@ static int dm320_wakeup(struct usbdev_s *dev) * *******************************************************************************/ -static int dm320_selfpowered(struct usbdev_s *dev, boolean selfpowered) +static int dm320_selfpowered(struct usbdev_s *dev, bool selfpowered) { struct dm320_usbdev_s *priv = &g_usbdev; - usbtrace(TRACE_DEVSELFPOWERED, (uint16)selfpowered); + usbtrace(TRACE_DEVSELFPOWERED, (uint16_t)selfpowered); #ifdef CONFIG_DEBUG if (!dev) @@ -2305,11 +2307,11 @@ static int dm320_selfpowered(struct usbdev_s *dev, boolean selfpowered) *******************************************************************************/ #ifdef CONFIG_DM320_GIO_USBDPPULLUP -static int dm320_pullup(struct usbdev_s *dev, boolean enable) +static int dm320_pullup(struct usbdev_s *dev, bool enable) { irqstate_t flags; - usbtrace(TRACE_DEVPULLUP, (uint16)enable); + usbtrace(TRACE_DEVPULLUP, (uint16_t)enable); flags = irqsave(); if (enable) @@ -2343,7 +2345,7 @@ void up_usbinitialize(void) struct dm320_usbdev_s *priv = &g_usbdev; struct dm320_ep_s *privep; #ifdef CONFIG_DEBUG_USB - uint16 chiprev; + uint16_t chiprev; #endif int i; @@ -2507,7 +2509,7 @@ int usbdev_register(FAR struct usbdevclass_driver_s *driver) ret = CLASS_BIND(driver, &g_usbdev.usbdev); if (ret) { - usbtrace(TRACE_DEVERROR(DM320_TRACEERR_BINDFAILED), (uint16)-ret); + usbtrace(TRACE_DEVERROR(DM320_TRACEERR_BINDFAILED), (uint16_t)-ret); g_usbdev.driver = NULL; return ret; } |