diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-12-15 14:25:14 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-12-15 14:25:14 +0000 |
commit | 329bf67f0c4b6beb77e5856c8038a3202909be58 (patch) | |
tree | d607f3c7db4e8415665c0ef9c35bc5cbc287b971 | |
parent | 2b8c1142b851c7a81eafe69ed35c490f3d9c6735 (diff) | |
download | nuttx-329bf67f0c4b6beb77e5856c8038a3202909be58.tar.gz nuttx-329bf67f0c4b6beb77e5856c8038a3202909be58.tar.bz2 nuttx-329bf67f0c4b6beb77e5856c8038a3202909be58.zip |
Changing NuttX fixed size type names to C99 standard names -- things will be broken for awhile
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2343 42af7a65-404d-4744-a932-0658087f49c3
41 files changed, 1168 insertions, 1149 deletions
diff --git a/nuttx/drivers/bch/bch_internal.h b/nuttx/drivers/bch/bch_internal.h index 1a5ba5889..c24eeebbd 100644 --- a/nuttx/drivers/bch/bch_internal.h +++ b/nuttx/drivers/bch/bch_internal.h @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bch_internal.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 @@ -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,16 +41,19 @@ ****************************************************************************/ #include <nuttx/config.h> + #include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <semaphore.h> #include <nuttx/fs.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define bchlib_semgive(d) sem_post(&(d)->sem) /* To match bchlib_semtake */ -#define MAX_OPENCNT (255) /* Limit of ubyte */ +#define MAX_OPENCNT (255) /* Limit of uint8_t */ /**************************************************************************** * Public Types @@ -58,15 +61,15 @@ struct bchlib_s { - struct inode *inode; /* I-node of the block driver */ - sem_t sem; /* For atomic accesses to this structure */ - size_t nsectors; /* Number of sectors supported by the device */ - size_t sector; /* The current sector in the buffer */ - uint16 sectsize; /* The size of one sector on the device */ - ubyte refs; /* Number of references */ - boolean dirty; /* Data has been written to the buffer */ - boolean readonly; /* TRUE: Only read operations are supported */ - FAR ubyte *buffer; /* One sector buffer */ + struct inode *inode; /* I-node of the block driver */ + sem_t sem; /* For atomic accesses to this structure */ + size_t nsectors; /* Number of sectors supported by the device */ + size_t sector; /* The current sector in the buffer */ + uint16_t sectsize; /* The size of one sector on the device */ + uint8_t refs; /* Number of references */ + bool dirty; /* Data has been written to the buffer */ + bool readonly; /* true: Only read operations are supported */ + FAR uint8_t *buffer; /* One sector buffer */ }; /**************************************************************************** diff --git a/nuttx/drivers/bch/bchdev_register.c b/nuttx/drivers/bch/bchdev_register.c index f4d55dfa8..5bbedb6b9 100644 --- a/nuttx/drivers/bch/bchdev_register.c +++ b/nuttx/drivers/bch/bchdev_register.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchdev_register.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 @@ -34,17 +34,12 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> - +#include <stdbool.h> #include <errno.h> #include <assert.h> #include <debug.h> @@ -52,7 +47,7 @@ #include "bch_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -80,7 +75,7 @@ * ****************************************************************************/ -int bchdev_register(const char *blkdev, const char *chardev, boolean readonly) +int bchdev_register(const char *blkdev, const char *chardev, bool readonly) { FAR void *handle; int ret; diff --git a/nuttx/drivers/bch/bchdev_unregister.c b/nuttx/drivers/bch/bchdev_unregister.c index 6f25a2330..d9172bc85 100644 --- a/nuttx/drivers/bch/bchdev_unregister.c +++ b/nuttx/drivers/bch/bchdev_unregister.c @@ -34,16 +34,11 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> @@ -60,7 +55,7 @@ #include "bch_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/drivers/bch/bchlib_cache.c b/nuttx/drivers/bch/bchlib_cache.c index e7ad5e70e..3e2887c94 100644 --- a/nuttx/drivers/bch/bchlib_cache.c +++ b/nuttx/drivers/bch/bchlib_cache.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_cache.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 @@ -34,17 +34,13 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <sys/types.h> - +#include <stdbool.h> #include <errno.h> #include <assert.h> #include <debug.h> @@ -97,7 +93,7 @@ int bchlib_flushsector(FAR struct bchlib_s *bch) { fdbg("Write failed: %d\n"); } - bch->dirty = FALSE; + bch->dirty = false; } return (int)ret; } diff --git a/nuttx/drivers/bch/bchlib_read.c b/nuttx/drivers/bch/bchlib_read.c index d2301d439..7319e3412 100644 --- a/nuttx/drivers/bch/bchlib_read.c +++ b/nuttx/drivers/bch/bchlib_read.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_read.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 @@ -34,17 +34,13 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <sys/types.h> - +#include <stdint.h> #include <string.h> #include <errno.h> #include <assert.h> @@ -86,12 +82,12 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, size_t len) { FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle; - size_t nsectors; - size_t sector; - uint16 sectoffset; - size_t nbytes; - size_t bytesread; - int ret; + size_t nsectors; + size_t sector; + uint16_t sectoffset; + size_t nbytes; + size_t bytesread; + int ret; /* Get rid of this special case right away */ diff --git a/nuttx/drivers/bch/bchlib_sem.c b/nuttx/drivers/bch/bchlib_sem.c index c7b0f39f7..b0c67a997 100644 --- a/nuttx/drivers/bch/bchlib_sem.c +++ b/nuttx/drivers/bch/bchlib_sem.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_sem.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 @@ -34,17 +34,11 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> - #include <errno.h> #include <assert.h> #include <debug.h> @@ -52,7 +46,7 @@ #include "bch_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/drivers/bch/bchlib_setup.c b/nuttx/drivers/bch/bchlib_setup.c index 35520ad3b..f0ce24dae 100644 --- a/nuttx/drivers/bch/bchlib_setup.c +++ b/nuttx/drivers/bch/bchlib_setup.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_setup.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 @@ -34,10 +34,6 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ @@ -46,6 +42,8 @@ #include <sys/types.h> #include <sys/mount.h> +#include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <errno.h> #include <assert.h> @@ -84,7 +82,7 @@ * ****************************************************************************/ -int bchlib_setup(const char *blkdev, boolean readonly, FAR void **handle) +int bchlib_setup(const char *blkdev, bool readonly, FAR void **handle) { FAR struct bchlib_s *bch; struct geometry geo; @@ -143,7 +141,7 @@ int bchlib_setup(const char *blkdev, boolean readonly, FAR void **handle) /* Allocate the sector I/O buffer */ - bch->buffer = (FAR ubyte *)malloc(bch->sectsize); + bch->buffer = (FAR uint8_t *)malloc(bch->sectsize); if (!bch->buffer) { fdbg("Failed to allocate sector buffer\n"); diff --git a/nuttx/drivers/bch/bchlib_teardown.c b/nuttx/drivers/bch/bchlib_teardown.c index 9580d24e4..3b97ff167 100644 --- a/nuttx/drivers/bch/bchlib_teardown.c +++ b/nuttx/drivers/bch/bchlib_teardown.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_teardown.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 @@ -34,17 +34,11 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> - #include <stdlib.h> #include <errno.h> #include <assert.h> diff --git a/nuttx/drivers/bch/bchlib_write.c b/nuttx/drivers/bch/bchlib_write.c index ad0737faf..0f362ef8d 100644 --- a/nuttx/drivers/bch/bchlib_write.c +++ b/nuttx/drivers/bch/bchlib_write.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/bch/bchlib_write.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 @@ -34,17 +34,14 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <sys/types.h> - +#include <stdint.h> +#include <stdbool.h> #include <string.h> #include <errno.h> #include <assert.h> @@ -86,12 +83,12 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, size_t len) { FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle; - size_t nsectors; - size_t sector; - uint16 sectoffset; - size_t nbytes; - size_t byteswritten; - int ret; + size_t nsectors; + size_t sector; + uint16_t sectoffset; + size_t nbytes; + size_t byteswritten; + int ret; /* Get rid of this special case right away */ @@ -131,7 +128,7 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si } memcpy(&bch->buffer[sectoffset], buffer, nbytes); - bch->dirty = TRUE; + bch->dirty = true; /* Adjust pointers and counts */ @@ -195,7 +192,7 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, si /* Copy the head end of the sector from the user buffer */ memcpy(bch->buffer, buffer, len); - bch->dirty = TRUE; + bch->dirty = true; /* Adjust counts */ diff --git a/nuttx/drivers/can.c b/nuttx/drivers/can.c index 834765183..47525257d 100644 --- a/nuttx/drivers/can.c +++ b/nuttx/drivers/can.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/can.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,8 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <unistd.h> #include <string.h> #include <semaphore.h> @@ -58,7 +60,7 @@ #include <arch/irq.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define HALF_SECOND_MSEC 500 @@ -113,7 +115,7 @@ static int can_open(FAR struct file *filep) { FAR struct inode *inode = filep->f_inode; FAR struct can_dev_s *dev = inode->i_private; - ubyte tmp; + uint8_t tmp; int ret = OK; /* If the port is the middle of closing, wait until the close is finished */ @@ -132,7 +134,7 @@ static int can_open(FAR struct file *filep) tmp = dev->cd_ocount + 1; if (tmp == 0) { - /* More than 255 opens; ubyte overflows to zero */ + /* More than 255 opens; uint8_t overflows to zero */ ret = -EMFILE; } @@ -157,7 +159,7 @@ static int can_open(FAR struct file *filep) /* Finally, Enable the CAN RX interrupt */ - dev_rxint(dev, TRUE); + dev_rxint(dev, true); /* Save the new open count on success */ @@ -210,7 +212,7 @@ static int can_close(FAR struct file *filep) /* Stop accepting input */ - dev_rxint(dev, FALSE); + dev_rxint(dev, false); /* Now we wait for the transmit FIFO to clear */ @@ -347,7 +349,7 @@ return_with_irqdisabled: static int can_xmit(FAR struct can_dev_s *dev) { - boolean enable = FALSE; + bool enable = false; int ret = OK; /* Check if the xmit FIFO is empty */ @@ -360,7 +362,7 @@ static int can_xmit(FAR struct can_dev_s *dev) /* Make sure the TX done interrupts are enabled */ - enable = (ret == OK ? TRUE : FALSE); + enable = (ret == OK ? true : false); } dev_txint(dev, enable); return ret; @@ -376,7 +378,7 @@ static ssize_t can_write(FAR struct file *filep, FAR const char *buffer, size_t FAR struct can_dev_s *dev = inode->i_private; FAR struct can_fifo_s *fifo = &dev->cd_xmit; FAR struct can_msg_s *msg; - boolean empty = FALSE; + bool empty = false; ssize_t nsent = 0; irqstate_t flags; int nexttail; @@ -632,10 +634,10 @@ int can_register(FAR const char *path, FAR struct can_dev_s *dev) * ************************************************************************************/ -int can_receive(FAR struct can_dev_s *dev, uint16 hdr, FAR ubyte *data) +int can_receive(FAR struct can_dev_s *dev, uint16_t hdr, FAR uint8_t *data) { FAR struct can_fifo_s *fifo = &dev->cd_recv; - FAR ubyte *dest; + FAR uint8_t *dest; int nexttail; int err = -ENOMEM; int i; diff --git a/nuttx/drivers/dev_null.c b/nuttx/drivers/dev_null.c index 2208823e6..f473f1b87 100644 --- a/nuttx/drivers/dev_null.c +++ b/nuttx/drivers/dev_null.c @@ -34,16 +34,13 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <sys/types.h> +#include <stdbool.h> #include <string.h> #include <poll.h> #include <errno.h> @@ -57,7 +54,7 @@ static ssize_t devnull_read(FAR struct file *, FAR char *, size_t); static ssize_t devnull_write(FAR struct file *, FAR const char *, size_t); #ifndef CONFIG_DISABLE_POLL static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds, - boolean setup); + bool setup); #endif /**************************************************************************** @@ -105,7 +102,7 @@ static ssize_t devnull_write(FAR struct file *filp, FAR const char *buffer, size #ifndef CONFIG_DISABLE_POLL static int devnull_poll(FAR struct file *filp, FAR struct pollfd *fds, - boolean setup) + bool setup) { if (setup) { diff --git a/nuttx/drivers/dev_zero.c b/nuttx/drivers/dev_zero.c index 2a85e134a..c4b453798 100644 --- a/nuttx/drivers/dev_zero.c +++ b/nuttx/drivers/dev_zero.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/dev_null.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 @@ -34,16 +34,13 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <sys/types.h> +#include <stdbool.h> #include <string.h> #include <poll.h> #include <errno.h> @@ -57,7 +54,7 @@ static ssize_t devzero_read(FAR struct file *, FAR char *, size_t); static ssize_t devzero_write(FAR struct file *, FAR const char *, size_t); #ifndef CONFIG_DISABLE_POLL static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds, - boolean setup); + bool setup); #endif /**************************************************************************** @@ -106,7 +103,7 @@ static ssize_t devzero_write(FAR struct file *filp, FAR const char *buffer, size #ifndef CONFIG_DISABLE_POLL static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds, - boolean setup) + bool setup) { if (setup) { diff --git a/nuttx/drivers/loop.c b/nuttx/drivers/loop.c index 21e68e9cb..dffa6e078 100644 --- a/nuttx/drivers/loop.c +++ b/nuttx/drivers/loop.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/loop.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 @@ -45,6 +45,8 @@ #include <sys/ioctl.h> #include <sys/mount.h> +#include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -57,11 +59,11 @@ #include <nuttx/fs.h> /**************************************************************************** - * Private Definitions + * Pre-processor Definitions ****************************************************************************/ #define loop_semgive(d) sem_post(&(d)->sem) /* To match loop_semtake */ -#define MAX_OPENCNT (255) /* Limit of ubyte */ +#define MAX_OPENCNT (255) /* Limit of uint8_t */ /**************************************************************************** * Private Types @@ -70,12 +72,12 @@ struct loop_struct_s { sem_t sem; /* For safe read-modify-write operations */ - uint32 nsectors; /* Number of sectors on device */ + uint32_t nsectors; /* Number of sectors on device */ off_t offset; /* Offset (in bytes) to the first sector */ - uint16 sectsize; /* The size of one sector */ - ubyte opencnt; /* Count of open references to the loop device */ + uint16_t sectsize; /* The size of one sector */ + uint8_t opencnt; /* Count of open references to the loop device */ #ifdef CONFIG_FS_WRITABLE - boolean writeenabled; /* TRUE: can write to device */ + bool writeenabled; /* true: can write to device */ #endif int fd; /* Descriptor of char device/file */ }; @@ -313,12 +315,12 @@ static int loop_geometry(FAR struct inode *inode, struct geometry *geometry) if (geometry) { dev = (FAR struct loop_struct_s *)inode->i_private; - geometry->geo_available = TRUE; - geometry->geo_mediachanged = FALSE; + geometry->geo_available = true; + geometry->geo_mediachanged = false; #ifdef CONFIG_FS_WRITABLE geometry->geo_writeenabled = dev->writeenabled; #else - geometry->geo_writeenabled = FALSE; + geometry->geo_writeenabled = false; #endif geometry->geo_nsectors = dev->nsectors; geometry->geo_sectorsize = dev->sectsize; @@ -340,8 +342,8 @@ static int loop_geometry(FAR struct inode *inode, struct geometry *geometry) * ****************************************************************************/ -int losetup(const char *devname, const char *filename, uint16 sectsize, - off_t offset, boolean readonly) +int losetup(const char *devname, const char *filename, uint16_t sectsize, + off_t offset, bool readonly) { FAR struct loop_struct_s *dev; struct stat sb; @@ -391,7 +393,7 @@ int losetup(const char *devname, const char *filename, uint16 sectsize, /* Open the file. */ #ifdef CONFIG_FS_WRITABLE - dev->writeenabled = FALSE; /* Assume failure */ + dev->writeenabled = false; /* Assume failure */ dev->fd = -1; /* First try to open the device R/W access (unless we are asked @@ -405,7 +407,7 @@ int losetup(const char *devname, const char *filename, uint16 sectsize, if (dev->fd >= 0) { - dev->writeenabled = TRUE; /* Success */ + dev->writeenabled = true; /* Success */ } else #endif diff --git a/nuttx/drivers/mmcsd/mmcsd_csd.h b/nuttx/drivers/mmcsd/mmcsd_csd.h index a17e4cbf4..448bababf 100644 --- a/nuttx/drivers/mmcsd/mmcsd_csd.h +++ b/nuttx/drivers/mmcsd/mmcsd_csd.h @@ -41,7 +41,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <stdint.h> /**************************************************************************** * Pre-Processor Definitions @@ -252,7 +252,7 @@ /* CCC 84-95 = Card command classes */ -#define MMCSD_CSD_CCC(csd) (((uint16)csd[4] << 4) | ((uint16)csd[5] >> 4)) +#define MMCSD_CSD_CCC(csd) (((uint16_t)csd[4] << 4) | ((uint16_t)csd[5] >> 4)) #define SD20_CSD_CCC(csd) MMCSD_CSD_CCC(csd) /* READ_BL_LEN 80-83 = Max. read data block length */ diff --git a/nuttx/drivers/mmcsd/mmcsd_debug.c b/nuttx/drivers/mmcsd/mmcsd_debug.c index 2b05f3df6..03872f5cf 100644 --- a/nuttx/drivers/mmcsd/mmcsd_debug.c +++ b/nuttx/drivers/mmcsd/mmcsd_debug.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/mmcsd/mmcsd_debug.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,8 +39,8 @@ #include <nuttx/config.h> -#include <sys/types.h> - +#include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <string.h> #include <errno.h> @@ -90,10 +90,10 @@ ****************************************************************************/ #if defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS) -void mmcsd_dmpcsd(FAR const ubyte *csd, ubyte cardtype) +void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype) { - boolean mmc = (cardtype == MMCSD_CARDTYPE_MMC); - boolean sd2 = (MMCSD_CSD_CSDSTRUCT(csd) == 1); + bool mmc = (cardtype == MMCSD_CARDTYPE_MMC); + bool sd2 = (MMCSD_CSD_CSDSTRUCT(csd) == 1); fvdbg("CSD\n"); fvdbg(" CSD_STRUCTURE: 1.%d\n", MMCSD_CSD_CSDSTRUCT(csd)); diff --git a/nuttx/drivers/mmcsd/mmcsd_internal.h b/nuttx/drivers/mmcsd/mmcsd_internal.h index 02589d973..577ebbba9 100644 --- a/nuttx/drivers/mmcsd/mmcsd_internal.h +++ b/nuttx/drivers/mmcsd/mmcsd_internal.h @@ -41,7 +41,7 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <stdint.h> #include <debug.h> /**************************************************************************** @@ -93,7 +93,7 @@ extern "C" { #endif #if defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS) -EXTERN void mmcsd_dmpcsd(FAR const ubyte *csd, ubyte cardtype); +EXTERN void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype); #else # define mmcsd_dmpcsd(csd,cadtype) #endif diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c index 9601bdc0f..7eea71983 100644 --- a/nuttx/drivers/mmcsd/mmcsd_sdio.c +++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c @@ -42,6 +42,8 @@ #include <sys/types.h> #include <sys/ioctl.h> +#include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -64,7 +66,7 @@ * Pre-processor Definitions ****************************************************************************/ -/* The maximum number of references on the driver (because a ubyte is used. +/* The maximum number of references on the driver (because a uint8_t is used. * Use a larger type if more references are needed. */ @@ -100,32 +102,32 @@ struct mmcsd_state_s { FAR struct sdio_dev_s *dev; /* The SDIO device bound to this instance */ - ubyte crefs; /* Open references on the driver */ + uint8_t crefs; /* Open references on the driver */ sem_t sem; /* Assures mutually exclusive access to the slot */ /* Status flags */ - ubyte probed:1; /* TRUE: mmcsd_probe() discovered a card */ - ubyte widebus:1; /* TRUE: Wide 4-bit bus selected */ - ubyte mediachanged:1; /* TRUE: Media changed since last check */ - ubyte wrbusy:1; /* TRUE: Last transfer was a write, card may be busy */ - ubyte wrprotect:1; /* TRUE: Card is write protected (from CSD) */ - ubyte locked:1; /* TRUE: Media is locked (from R1) */ - ubyte dsrimp:1; /* TRUE: card supports CMD4/DSR setting (from CSD) */ + uint8_t probed:1; /* true: mmcsd_probe() discovered a card */ + uint8_t widebus:1; /* true: Wide 4-bit bus selected */ + uint8_t mediachanged:1; /* true: Media changed since last check */ + uint8_t wrbusy:1; /* true: Last transfer was a write, card may be busy */ + uint8_t wrprotect:1; /* true: Card is write protected (from CSD) */ + uint8_t locked:1; /* true: Media is locked (from R1) */ + uint8_t dsrimp:1; /* true: card supports CMD4/DSR setting (from CSD) */ #ifdef CONFIG_SDIO_DMA - ubyte dma:1; /* TRUE: hardware supports DMA */ + uint8_t dma:1; /* true: hardware supports DMA */ #endif - ubyte mode:2; /* (See MMCSDMODE_* definitions) */ - ubyte type:4; /* Card type (See MMCSD_CARDTYPE_* definitions) */ - ubyte buswidth:4; /* Bus widthes supported (SD only) */ - uint16 selblocklen; /* The currently selected block length */ - uint16 rca; /* Relative Card Address (RCS) register */ + uint8_t mode:2; /* (See MMCSDMODE_* definitions) */ + uint8_t type:4; /* Card type (See MMCSD_CARDTYPE_* definitions) */ + uint8_t buswidth:4; /* Bus widthes supported (SD only) */ + uint16_t selblocklen; /* The currently selected block length */ + uint16_t rca; /* Relative Card Address (RCS) register */ /* Memory card geometry (extracted from the CSD) */ - ubyte blockshift; /* Log2 of blocksize */ - uint16 blocksize; /* Read block length (== block size) */ + uint8_t blockshift; /* Log2 of blocksize */ + uint16_t blocksize; /* Read block length (== block size) */ size_t nblocks; /* Number of blocks */ size_t capacity; /* Total capacity of volume */ @@ -147,47 +149,51 @@ static void mmcsd_takesem(FAR struct mmcsd_state_s *priv); /* Command/response helpers *************************************************/ -static int mmcsd_sendcmdpoll(FAR struct mmcsd_state_s *priv, uint32 cmd, - uint32 arg); -static int mmcsd_recvR1(FAR struct mmcsd_state_s *priv, uint32 cmd); -static int mmcsd_recvR6(FAR struct mmcsd_state_s *priv, uint32 cmd); -static int mmcsd_getSCR(FAR struct mmcsd_state_s *priv, uint32 scr[2]); +static int mmcsd_sendcmdpoll(FAR struct mmcsd_state_s *priv, + uint32_t cmd, uint32_t arg); +static int mmcsd_recvR1(FAR struct mmcsd_state_s *priv, uint32_t cmd); +static int mmcsd_recvR6(FAR struct mmcsd_state_s *priv, uint32_t cmd); +static int mmcsd_getSCR(FAR struct mmcsd_state_s *priv, uint32_t scr[2]); -static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32 csd[4]); +static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, + uint32_t csd[4]); #if defined(CONFIG_DEBUG) && defined (CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS) -static void mmcsd_decodeCID(FAR struct mmcsd_state_s *priv, uint32 cid[4]); +static void mmcsd_decodeCID(FAR struct mmcsd_state_s *priv, + uint32_t cid[4]); #else # define mmcsd_decodeCID(priv,cid) #endif -static void mmcsd_decodeSCR(FAR struct mmcsd_state_s *priv, uint32 scr[2]); +static void mmcsd_decodeSCR(FAR struct mmcsd_state_s *priv, + uint32_t scr[2]); -static int mmcsd_getR1(FAR struct mmcsd_state_s *priv, FAR uint32 *r1); -static int mmcsd_verifystate(FAR struct mmcsd_state_s *priv, uint32 status); +static int mmcsd_getR1(FAR struct mmcsd_state_s *priv, FAR uint32_t *r1); +static int mmcsd_verifystate(FAR struct mmcsd_state_s *priv, + uint32_t status); /* Transfer helpers *********************************************************/ -static boolean mmcsd_wrprotected(FAR struct mmcsd_state_s *priv); +static bool mmcsd_wrprotected(FAR struct mmcsd_state_s *priv); static int mmcsd_eventwait(FAR struct mmcsd_state_s *priv, - sdio_eventset_t failevents, uint32 timeout); + sdio_eventset_t failevents, uint32_t timeout); static int mmcsd_transferready(FAR struct mmcsd_state_s *priv); static int mmcsd_stoptransmission(FAR struct mmcsd_state_s *priv); static int mmcsd_setblocklen(FAR struct mmcsd_state_s *priv, - uint32 blocklen); + uint32_t blocklen); static ssize_t mmcsd_readsingle(FAR struct mmcsd_state_s *priv, - FAR ubyte *buffer, off_t startblock); + FAR uint8_t *buffer, off_t startblock); static ssize_t mmcsd_readmultiple(FAR struct mmcsd_state_s *priv, - FAR ubyte *buffer, off_t startblock, size_t nblocks); + FAR uint8_t *buffer, off_t startblock, size_t nblocks); #ifdef CONFIG_FS_READAHEAD -static ssize_t mmcsd_reload(FAR void *dev, FAR ubyte *buffer, +static ssize_t mmcsd_reload(FAR void *dev, FAR uint8_t *buffer, off_t startblock, size_t nblocks); #endif #ifdef CONFIG_FS_WRITABLE static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv, - FAR const ubyte *buffer, off_t startblock); + FAR const uint8_t *buffer, off_t startblock); static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv, - FAR const ubyte *buffer, off_t startblock, size_t nblocks); + FAR const uint8_t *buffer, off_t startblock, size_t nblocks); #ifdef CONFIG_FS_WRITEBUFFER -static ssize_t mmcsd_flush(FAR void *dev, FAR const ubyte *buffer, +static ssize_t mmcsd_flush(FAR void *dev, FAR const uint8_t *buffer, off_t startblock, size_t nblocks); #endif #endif @@ -272,8 +278,8 @@ static void mmcsd_takesem(FAR struct mmcsd_state_s *priv) * ****************************************************************************/ -static int mmcsd_sendcmdpoll(FAR struct mmcsd_state_s *priv, uint32 cmd, - uint32 arg) +static int mmcsd_sendcmdpoll(FAR struct mmcsd_state_s *priv, uint32_t cmd, + uint32_t arg) { int ret; @@ -310,7 +316,7 @@ static inline int mmcsd_sendcmd4(FAR struct mmcsd_state_s *priv) * the DSR via CMD4 or not. */ - if (priv->dsrimp != FALSE) + if (priv->dsrimp != false) { /* CMD4 = SET_DSR will set the cards DSR register. The DSR and CMD4 * support are optional. However, since this is a broadcast command @@ -338,9 +344,9 @@ static inline int mmcsd_sendcmd4(FAR struct mmcsd_state_s *priv) * ****************************************************************************/ -static int mmcsd_recvR1(FAR struct mmcsd_state_s *priv, uint32 cmd) +static int mmcsd_recvR1(FAR struct mmcsd_state_s *priv, uint32_t cmd) { - uint32 r1; + uint32_t r1; int ret; /* Get the R1 response from the hardware */ @@ -373,9 +379,9 @@ static int mmcsd_recvR1(FAR struct mmcsd_state_s *priv, uint32 cmd) * ****************************************************************************/ -static int mmcsd_recvR6(FAR struct mmcsd_state_s *priv, uint32 cmd) +static int mmcsd_recvR6(FAR struct mmcsd_state_s *priv, uint32_t cmd) { - uint32 r6 = 0; + uint32_t r6 = 0; int ret; /* R6 Published RCA Response (48-bit, SD card only) @@ -400,7 +406,7 @@ static int mmcsd_recvR6(FAR struct mmcsd_state_s *priv, uint32 cmd) { /* No, save the RCA and return success */ - priv->rca = (uint16)(r6 >> 16); + priv->rca = (uint16_t)(r6 >> 16); return OK; } @@ -424,7 +430,7 @@ static int mmcsd_recvR6(FAR struct mmcsd_state_s *priv, uint32 cmd) * ****************************************************************************/ -static int mmcsd_getSCR(FAR struct mmcsd_state_s *priv, uint32 scr[2]) +static int mmcsd_getSCR(FAR struct mmcsd_state_s *priv, uint32_t scr[2]) { int ret; @@ -439,7 +445,7 @@ static int mmcsd_getSCR(FAR struct mmcsd_state_s *priv, uint32 scr[2]) /* Send CMD55 APP_CMD with argument as card's RCA */ - mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32)priv->rca << 16); + mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32_t)priv->rca << 16); ret = mmcsd_recvR1(priv, SD_CMD55); if (ret != OK) { @@ -449,7 +455,7 @@ static int mmcsd_getSCR(FAR struct mmcsd_state_s *priv, uint32 scr[2]) /* Setup up to receive data with interrupt mode */ - SDIO_RECVSETUP(priv->dev, (FAR ubyte*)scr, 8); + SDIO_RECVSETUP(priv->dev, (FAR uint8_t*)scr, 8); /* Send ACMD51 SD_APP_SEND_SCR with argument as 0 to start data receipt */ @@ -484,22 +490,22 @@ static int mmcsd_getSCR(FAR struct mmcsd_state_s *priv, uint32 scr[2]) * OK on success; a negated ernno on failure. On success, the following * values will be set in the driver state structure: * - * priv->dsrimp TRUE: card supports CMD4/DSR setting (from CSD) - * priv->wrprotect TRUE: card is write protected (from CSD) + * priv->dsrimp true: card supports CMD4/DSR setting (from CSD) + * priv->wrprotect true: card is write protected (from CSD) * priv->blocksize Read block length (== block size) * priv->nblocks Number of blocks * priv->capacity Total capacity of volume * ****************************************************************************/ -static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32 csd[4]) +static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4]) { #if defined(CONFIG_DEBUG) && defined (CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS) struct mmcsd_csd_s decoded; #endif unsigned int readbllen; - boolean permwriteprotect; - boolean tmpwriteprotect; + bool permwriteprotect; + bool tmpwriteprotect; /* Word 1: Bits 127-96: * @@ -590,7 +596,7 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32 csd[4]) * 512*1024 = (1 << 19) */ - uint32 csize = ((csd[1] & 0x3f) << 16) | (csd[2] >> 16); + uint32_t csize = ((csd[1] & 0x3f) << 16) | (csd[2] >> 16); priv->capacity = (csize + 1) << 19; priv->blockshift = 9; priv->blocksize = 1 << 9; @@ -607,10 +613,10 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32 csd[4]) { /* C_SIZE: 73:64 from Word 2 and 63:62 from Word 3 */ - uint16 csize = ((csd[1] & 0x03ff) << 2) | ((csd[2] >> 30) & 3); - ubyte csizemult = (csd[2] >> 15) & 7; + uint16_t csize = ((csd[1] & 0x03ff) << 2) | ((csd[2] >> 30) & 3); + uint8_t csizemult = (csd[2] >> 15) & 7; - priv->nblocks = ((uint32)csize + 1) * (1 << (csizemult + 2)); + priv->nblocks = ((uint32_t)csize + 1) * (1 << (csizemult + 2)); priv->blockshift = readbllen; priv->blocksize = (1 << readbllen); priv->capacity = (priv->nblocks << readbllen); @@ -756,7 +762,7 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32 csd[4]) ****************************************************************************/ #if defined(CONFIG_DEBUG) && defined (CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS) -static void mmcsd_decodeCID(FAR struct mmcsd_state_s *priv, uint32 cid[4]) +static void mmcsd_decodeCID(FAR struct mmcsd_state_s *priv, uint32_t cid[4]) { struct mmcsd_cid_s decoded; @@ -819,7 +825,7 @@ static void mmcsd_decodeCID(FAR struct mmcsd_state_s *priv, uint32 cid[4]) * ****************************************************************************/ -static void mmcsd_decodeSCR(FAR struct mmcsd_state_s *priv, uint32 scr[2]) +static void mmcsd_decodeSCR(FAR struct mmcsd_state_s *priv, uint32_t scr[2]) { #if defined(CONFIG_DEBUG) && defined (CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS) struct mmcsd_scr_s decoded; @@ -884,9 +890,9 @@ struct mmcsd_scr_s decoded; * ****************************************************************************/ -static int mmcsd_getR1(FAR struct mmcsd_state_s *priv, FAR uint32 *r1) +static int mmcsd_getR1(FAR struct mmcsd_state_s *priv, FAR uint32_t *r1) { - uint32 localR1; + uint32_t localR1; int ret; DEBUGASSERT(priv != NULL && r1 != NULL); @@ -928,9 +934,9 @@ static int mmcsd_getR1(FAR struct mmcsd_state_s *priv, FAR uint32 *r1) * ****************************************************************************/ -static int mmcsd_verifystate(FAR struct mmcsd_state_s *priv, uint32 state) +static int mmcsd_verifystate(FAR struct mmcsd_state_s *priv, uint32_t state) { - uint32 r1; + uint32_t r1; int ret; /* Get the current R1 status from the card */ @@ -948,7 +954,7 @@ static int mmcsd_verifystate(FAR struct mmcsd_state_s *priv, uint32 state) { /* Yes.. return Success */ - priv->wrbusy = FALSE; + priv->wrbusy = false; return OK; } return -EINVAL; @@ -967,7 +973,7 @@ static int mmcsd_verifystate(FAR struct mmcsd_state_s *priv, uint32 state) * ****************************************************************************/ -static boolean mmcsd_wrprotected(FAR struct mmcsd_state_s *priv) +static bool mmcsd_wrprotected(FAR struct mmcsd_state_s *priv) { /* Check if the card is locked (priv->locked) or write protected either (1) * via software as reported via the CSD and retained in priv->wrprotect or @@ -987,7 +993,7 @@ static boolean mmcsd_wrprotected(FAR struct mmcsd_state_s *priv) ****************************************************************************/ static int mmcsd_eventwait(FAR struct mmcsd_state_s *priv, - sdio_eventset_t failevents, uint32 timeout) + sdio_eventset_t failevents, uint32_t timeout) { sdio_eventset_t wkupevent; @@ -1027,10 +1033,10 @@ static int mmcsd_eventwait(FAR struct mmcsd_state_s *priv, static int mmcsd_transferready(FAR struct mmcsd_state_s *priv) { - uint32 starttime; - uint32 elapsed; - uint32 r1; - int ret; + uint32_t starttime; + uint32_t elapsed; + uint32_t r1; + int ret; /* First, check if the card has been removed. */ @@ -1078,7 +1084,7 @@ static int mmcsd_transferready(FAR struct mmcsd_state_s *priv) { /* Yes.. return Success */ - priv->wrbusy = FALSE; + priv->wrbusy = false; return OK; } @@ -1140,7 +1146,7 @@ static int mmcsd_stoptransmission(FAR struct mmcsd_state_s *priv) * ****************************************************************************/ -static int mmcsd_setblocklen(FAR struct mmcsd_state_s *priv, uint32 blocklen) +static int mmcsd_setblocklen(FAR struct mmcsd_state_s *priv, uint32_t blocklen) { int ret = OK; @@ -1177,7 +1183,7 @@ static int mmcsd_setblocklen(FAR struct mmcsd_state_s *priv, uint32 blocklen) ****************************************************************************/ static ssize_t mmcsd_readsingle(FAR struct mmcsd_state_s *priv, - FAR ubyte *buffer, off_t startblock) + FAR uint8_t *buffer, off_t startblock) { off_t offset; int ret; @@ -1282,7 +1288,7 @@ static ssize_t mmcsd_readsingle(FAR struct mmcsd_state_s *priv, ****************************************************************************/ static ssize_t mmcsd_readmultiple(FAR struct mmcsd_state_s *priv, - FAR ubyte *buffer, off_t startblock, + FAR uint8_t *buffer, off_t startblock, size_t nblocks) { size_t nbytes; @@ -1397,7 +1403,7 @@ static ssize_t mmcsd_readmultiple(FAR struct mmcsd_state_s *priv, ****************************************************************************/ #ifdef CONFIG_FS_READAHEAD -static ssize_t mmcsd_reload(FAR void *dev, FAR ubyte *buffer, +static ssize_t mmcsd_reload(FAR void *dev, FAR uint8_t *buffer, off_t startblock, size_t nblocks) { FAR struct mmcsd_state_s *priv = (FAR struct mmcsd_state_s *)dev; @@ -1429,7 +1435,7 @@ static ssize_t mmcsd_reload(FAR void *dev, FAR ubyte *buffer, ****************************************************************************/ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv, - FAR const ubyte *buffer, off_t startblock) + FAR const uint8_t *buffer, off_t startblock) { off_t offset; int ret; @@ -1512,7 +1518,7 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv, * write complete at the beginning of the next transfer. */ - priv->wrbusy = TRUE; + priv->wrbusy = true; /* Wait for the transfer to complete */ @@ -1537,7 +1543,7 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv, ****************************************************************************/ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv, - FAR const ubyte *buffer, off_t startblock, + FAR const uint8_t *buffer, off_t startblock, size_t nblocks) { off_t offset; @@ -1654,7 +1660,7 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv, * write complete at the beginning of the next transfer. */ - priv->wrbusy = TRUE; + priv->wrbusy = true; /* Wait for the transfer to complete */ @@ -1688,7 +1694,7 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv, ****************************************************************************/ #if defined(CONFIG_FS_WRITABLE) && defined(CONFIG_FS_WRITEBUFFER) -static ssize_t mmcsd_flush(FAR void *dev, FAR const ubyte *buffer, +static ssize_t mmcsd_flush(FAR void *dev, FAR const uint8_t *buffer, off_t startblock, size_t nblocks) { FAR struct mmcsd_state_s *priv = (FAR struct mmcsd_state_s *)dev; @@ -1878,23 +1884,23 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry) { /* Yes.. return the geometry of the card */ - geometry->geo_available = TRUE; + geometry->geo_available = true; geometry->geo_mediachanged = priv->mediachanged; #ifdef CONFIG_FS_WRITABLE geometry->geo_writeenabled = !mmcsd_wrprotected(priv); #else - geometry->geo_writeenabled = FALSE; + geometry->geo_writeenabled = false; #endif geometry->geo_nsectors = priv->nblocks; geometry->geo_sectorsize = priv->blocksize; - fvdbg("available: TRUE mediachanged: %s writeenabled: %s\n", - geometry->geo_mediachanged ? "TRUE" : "FALSE", - geometry->geo_writeenabled ? "TRUE" : "FALSE"); + fvdbg("available: true mediachanged: %s writeenabled: %s\n", + geometry->geo_mediachanged ? "true" : "false", + geometry->geo_writeenabled ? "true" : "false"); fvdbg("nsectors: %ld sectorsize: %d\n", (long)geometry->geo_nsectors, geometry->geo_sectorsize); - priv->mediachanged = FALSE; + priv->mediachanged = false; ret = OK; } mmcsd_givesem(priv); @@ -2047,7 +2053,7 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv) * First end CMD55 APP_CMD with argument as card's RCA. */ - mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32)priv->rca << 16); + mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32_t)priv->rca << 16); ret = mmcsd_recvR1(priv, SD_CMD55); if (ret != OK) { @@ -2071,7 +2077,7 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv) * with CMD55, APP_CMD: */ - mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32)priv->rca << 16); + mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32_t)priv->rca << 16); ret = mmcsd_recvR1(priv, SD_CMD55); if (ret != OK) { @@ -2091,8 +2097,8 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv) /* Configure the SDIO peripheral */ fvdbg("Wide bus operation selected\n"); - SDIO_WIDEBUS(priv->dev, TRUE); - priv->widebus = TRUE; + SDIO_WIDEBUS(priv->dev, true); + priv->widebus = true; SDIO_CLOCK(priv->dev, CLOCK_SD_TRANSFER_4BIT); up_udelay(MMCSD_CLK_DELAY); @@ -2117,8 +2123,8 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv) static int mmcsd_mmcinitialize(FAR struct mmcsd_state_s *priv) { #ifdef CONFIG_MMCSD_MMCSUPPORT - uint32 cid[4]; - uint32 csd[4]; + uint32_t cid[4]; + uint32_t csd[4]; int ret; /* At this point, slow, ID mode clocking has been supplied to the card @@ -2210,9 +2216,9 @@ static int mmcsd_mmcinitialize(FAR struct mmcsd_state_s *priv) static int mmcsd_sdinitialize(FAR struct mmcsd_state_s *priv) { - uint32 cid[4]; - uint32 csd[4]; - uint32 scr[2]; + uint32_t cid[4]; + uint32_t csd[4]; + uint32_t scr[2]; int ret; /* At this point, clocking has been supplied to the card, both CMD0 and @@ -2346,11 +2352,11 @@ static int mmcsd_sdinitialize(FAR struct mmcsd_state_s *priv) static int mmcsd_cardidentify(FAR struct mmcsd_state_s *priv) { - uint32 response; - uint32 start; - uint32 elapsed; - uint32 sdcapacity = MMCSD_ACMD41_STDCAPACITY; - int ret; + uint32_t response; + uint32_t start; + uint32_t elapsed; + uint32_t sdcapacity = MMCSD_ACMD41_STDCAPACITY; + int ret; /* Assume failure to identify the card */ @@ -2665,7 +2671,7 @@ static int mmcsd_probe(FAR struct mmcsd_state_s *priv) /* Yes... */ fvdbg("Capacity: %d Kbytes\n", priv->capacity / 1024); - priv->mediachanged = TRUE; + priv->mediachanged = true; /* Set up to receive asynchronous, media removal events */ @@ -2675,7 +2681,7 @@ static int mmcsd_probe(FAR struct mmcsd_state_s *priv) /* In any event, we have probed this card */ - priv->probed = TRUE; + priv->probed = true; } else { @@ -2709,16 +2715,16 @@ static int mmcsd_removed(FAR struct mmcsd_state_s *priv) priv->capacity = 0; /* Capacity=0 sometimes means no media */ priv->blocksize = 0; - priv->mediachanged = FALSE; + priv->mediachanged = false; priv->type = MMCSD_CARDTYPE_UNKNOWN; - priv->probed = FALSE; + priv->probed = false; priv->rca = 0; priv->selblocklen = 0; /* Go back to the default 1-bit data bus. */ - SDIO_WIDEBUS(priv->dev, FALSE); - priv->widebus = FALSE; + SDIO_WIDEBUS(priv->dev, false); + priv->widebus = false; /* Disable clocking to the card */ diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.h b/nuttx/drivers/mmcsd/mmcsd_sdio.h index 735831825..71765310c 100644 --- a/nuttx/drivers/mmcsd/mmcsd_sdio.h +++ b/nuttx/drivers/mmcsd/mmcsd_sdio.h @@ -1,338 +1,338 @@ -/******************************************************************************************** - * drivers/mmcsd/mmcsd_sdio.h - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ********************************************************************************************/ - -#ifndef __DRIVERS_MMCSD_MMCSD_SDIO_H -#define __DRIVERS_MMCSD_MMCSD_SDIO_H - -/******************************************************************************************** - * Included Files - ********************************************************************************************/ - -#include <nuttx/config.h> -#include <sys/types.h> - -/******************************************************************************************** - * Pre-Processor Definitions - ********************************************************************************************/ - -/* CMD8 Argument: +/********************************************************************************************
+ * drivers/mmcsd/mmcsd_sdio.h
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ********************************************************************************************/
+
+#ifndef __DRIVERS_MMCSD_MMCSD_SDIO_H
+#define __DRIVERS_MMCSD_MMCSD_SDIO_H
+
+/********************************************************************************************
+ * Included Files
+ ********************************************************************************************/
+
+#include <nuttx/config.h>
+#include <stdint.h>
+
+/********************************************************************************************
+ * Pre-Processor Definitions
+ ********************************************************************************************/
+
+/* CMD8 Argument:
* [31:12]: Reserved (shall be set to '0')
* [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V)
* [7:0]: Check Pattern (recommended 0xaa)
- * CMD8 Response: R7 + * CMD8 Response: R7
*/
- -#define MMCSD_CMD8VOLTAGE_SHIFT 8 /* Bits 8-11: Supply voltage */ -#define MMCSD_CMD8VOLTAGE_MASK (0x0f << MMCSD_CMD8VOLTAGE_SHIFT) -# define MMCSD_CMD8VOLTAGE_27 (0x01 << MMCSD_CMD8VOLTAGE_SHIFT) /* 2.7-3.6V */ -#define MMCSD_CMD8ECHO_SHIFT 0 /* Bits 0-7: Check pattern */ -#define MMCSD_CMD8ECHO_MASK (0xff << MMCSD_CMD8ECHO_SHIFT) -# define MMCSD_CMD8CHECKPATTERN (0xaa << MMCSD_CMD8ECHO_SHIFT) - -/* ACMD6 argument */ - -#define MMCSD_ACMD6_BUSWIDTH_1 (0) /* Bus width = 1-bit */ -#define MMCSD_ACMD6_BUSWIDTH_4 (2) /* Bus width = 4-bit */ - -/* ACMD41 argument */ - +
+#define MMCSD_CMD8VOLTAGE_SHIFT 8 /* Bits 8-11: Supply voltage */
+#define MMCSD_CMD8VOLTAGE_MASK (0x0f << MMCSD_CMD8VOLTAGE_SHIFT)
+# define MMCSD_CMD8VOLTAGE_27 (0x01 << MMCSD_CMD8VOLTAGE_SHIFT) /* 2.7-3.6V */
+#define MMCSD_CMD8ECHO_SHIFT 0 /* Bits 0-7: Check pattern */
+#define MMCSD_CMD8ECHO_MASK (0xff << MMCSD_CMD8ECHO_SHIFT)
+# define MMCSD_CMD8CHECKPATTERN (0xaa << MMCSD_CMD8ECHO_SHIFT)
+
+/* ACMD6 argument */
+
+#define MMCSD_ACMD6_BUSWIDTH_1 (0) /* Bus width = 1-bit */
+#define MMCSD_ACMD6_BUSWIDTH_4 (2) /* Bus width = 4-bit */
+
+/* ACMD41 argument */
+
#define MMCSD_ACMD41_VOLTAGEWINDOW 0x80100000
#define MMCSD_ACMD41_HIGHCAPACITY (1 << 30)
#define MMCSD_ACMD41_STDCAPACITY (0)
- -/* ACMD42 argument */ - -#define MMCSD_ACMD42_CD_DISCONNECT (0) /* Disconnect card detection logic */ -#define MMCSD_ACMD42_CD_CONNECT (1) /* Connect card detection logic */ - -/* R1 Card Status bit definitions */ - -#define MMCSD_R1_OUTOFRANGE (1 << 31) /* Bad argument */ -#define MMCSD_R1_ADDRESSERROR (1 << 30) /* Bad address */ -#define MMCSD_R1_BLOCKLENERROR (1 << 29) /* Bad block length */ -#define MMCSD_R1_ERASESEQERROR (1 << 28) /* Erase cmd error */ -#define MMCSD_R1_ERASEPARAM (1 << 27) /* Bad write blocks */ -#define MMCSD_R1_WPVIOLATION (1 << 26) /* Erase access failure */ -#define MMCSD_R1_CARDISLOCKED (1 << 25) /* Card is locked */ -#define MMCSD_R1_LOCKUNLOCKFAILED (1 << 24) /* Password error */ -#define MMCSD_R1_COMCRCERROR (1 << 23) /* CRC error */ -#define MMCSD_R1_ILLEGALCOMMAND (1 << 22) /* Bad command */ -#define MMCSD_R1_CARDECCFAILED (1 << 21) /* Failed to correct data */ -#define MMCSD_R1_CCERROR (1 << 20) /* Card controller error */ -#define MMCSD_R1_ERROR (1 << 19) /* General error */ -#define MMCSD_R1_UNDERRUN (1 << 18) /* Underrun (MMC only) */ -#define MMCSD_R1_OVERRRUN (1 << 17) /* Overrun (MMC only) */ -#define MMCSD_R1_CIDCSDOVERWRITE (1 << 16) /* CID/CSD error */ -#define MMCSD_R1_WPERASESKIP (1 << 15) /* Not all erased */ -#define MMCSD_R1_CARDECCDISABLED (1 << 14) /* Internal ECC not used */ -#define MMCSD_R1_ERASERESET (1 << 13) /* Reset sequence cleared */ -#define MMCSD_R1_STATE_SHIFT (9) /* Current card state */ -#define MMCSD_R1_STATE_MASK (15 << MMCSD_R1_STATE_SHIFT) - /* Card identification mode states */ -# define MMCSD_R1_STATE_IDLE (0 << MMCSD_R1_STATE_SHIFT) /* 0=Idle state */ -# define MMCSD_R1_STATE_READY (1 << MMCSD_R1_STATE_SHIFT) /* 1=Ready state */ -# define MMCSD_R1_STATE_IDENT (2 << MMCSD_R1_STATE_SHIFT) /* 2=Identification state */ - /* Data transfer states */ -# define MMCSD_R1_STATE_STBY (3 << MMCSD_R1_STATE_SHIFT) /* 3=Standby state */ -# define MMCSD_R1_STATE_TRAN (4 << MMCSD_R1_STATE_SHIFT) /* 4=Transfer state */ -# define MMCSD_R1_STATE_DATA (5 << MMCSD_R1_STATE_SHIFT) /* 5=Sending data state */ -# define MMCSD_R1_STATE_RCV (6 << MMCSD_R1_STATE_SHIFT) /* 6=Receiving data state */ -# define MMCSD_R1_STATE_PRG (7 << MMCSD_R1_STATE_SHIFT) /* 7=Programming state */ -# define MMCSD_R1_STATE_DIS (8 << MMCSD_R1_STATE_SHIFT) /* 8=Disconnect state */ -#define MMCSD_R1_READYFORDATA (1 << 8) /* Buffer empty */ -#define MMCSD_R1_APPCMD (1 << 5) /* Next CMD is ACMD */ -#define MMCSD_R1_AKESEQERROR (1 << 3) /* Authentication error */ -#define MMCSD_R1_ERRORMASK 0xfdffe008 /* Error mask */ - -#define IS_STATE(v,s) (((v)&MMCSD_R1_STATE_MASK)==(s)) - -/* R3 (OCR) */ - -#define MMC_VDD_20_36 0x00ffff00 /* VDD voltage 2.0-3.6 */ - -#define MMCSD_VDD_145_150 (1 << 0) /* VDD voltage 1.45 - 1.50 */ -#define MMCSD_VDD_150_155 (1 << 1) /* VDD voltage 1.50 - 1.55 */ -#define MMCSD_VDD_155_160 (1 << 2) /* VDD voltage 1.55 - 1.60 */ -#define MMCSD_VDD_160_165 (1 << 3) /* VDD voltage 1.60 - 1.65 */ -#define MMCSD_VDD_165_170 (1 << 4) /* VDD voltage 1.65 - 1.70 */ -#define MMCSD_VDD_17_18 (1 << 5) /* VDD voltage 1.7 - 1.8 */ -#define MMCSD_VDD_18_19 (1 << 6) /* VDD voltage 1.8 - 1.9 */ -#define MMCSD_VDD_19_20 (1 << 7) /* VDD voltage 1.9 - 2.0 */ -#define MMCSD_VDD_20_21 (1 << 8) /* VDD voltage 2.0-2.1 */ -#define MMCSD_VDD_21_22 (1 << 9) /* VDD voltage 2.1-2.2 */ -#define MMCSD_VDD_22_23 (1 << 10) /* VDD voltage 2.2-2.3 */ -#define MMCSD_VDD_23_24 (1 << 11) /* VDD voltage 2.3-2.4 */ -#define MMCSD_VDD_24_25 (1 << 12) /* VDD voltage 2.4-2.5 */ -#define MMCSD_VDD_25_26 (1 << 13) /* VDD voltage 2.5-2.6 */ -#define MMCSD_VDD_26_27 (1 << 14) /* VDD voltage 2.6-2.7 */ -#define MMCSD_VDD_27_28 (1 << 15) /* VDD voltage 2.7-2.8 */ -#define MMCSD_VDD_28_29 (1 << 16) /* VDD voltage 2.8-2.9 */ -#define MMCSD_VDD_29_30 (1 << 17) /* VDD voltage 2.9-3.0 */ -#define MMCSD_VDD_30_31 (1 << 18) /* VDD voltage 3.0-3.1 */ -#define MMCSD_VDD_31_32 (1 << 19) /* VDD voltage 3.1-3.2 */ -#define MMCSD_VDD_32_33 (1 << 20) /* VDD voltage 3.2-3.3 */ -#define MMCSD_VDD_33_34 (1 << 21) /* VDD voltage 3.3-3.4 */ -#define MMCSD_VDD_34_35 (1 << 22) /* VDD voltage 3.4-3.5 */ -#define MMCSD_VDD_35_36 (1 << 23) /* VDD voltage 3.5-3.6 */ -#define MMCSD_R3_HIGHCAPACITY (1 << 30) /* TRUE: Card supports block addressing */
-#define MMCSD_CARD_BUSY (1 << 31) /* Card power-up busy bit */ - -/* R6 Card Status bit definitions */ - -#define MMCSD_R6_RCA_SHIFT (16) /* New published RCA */ -#define MMCSD_R6_RCA_MASK (0xffff << MMCSD_R6_RCA_SHIFT) -#define MMCSD_R6_COMCRCERROR (1 << 15) /* CRC error */ -#define MMCSD_R6_ILLEGALCOMMAND (1 << 14) /* Bad command */ -#define MMCSD_R6_ERROR (1 << 13) /* General error */ -#define MMCSD_R6_STATE_SHIFT (9) /* Current card state */ -#define MMCSD_R6_STATE_MASK (15 << MMCSD_R6_STATE_SHIFT) - /* Card identification mode states */ -# define MMCSD_R6_STATE_IDLE (0 << MMCSD_R6_STATE_SHIFT) /* 0=Idle state */ -# define MMCSD_R6_STATE_READY (1 << MMCSD_R6_STATE_SHIFT) /* 1=Ready state */ -# define MMCSD_R6_STATE_IDENT (2 << MMCSD_R6_STATE_SHIFT) /* 2=Identification state */ - /* Data transfer states */ -# define MMCSD_R6_STATE_STBY (3 << MMCSD_R6_STATE_SHIFT) /* 3=Standby state */ -# define MMCSD_R6_STATE_TRAN (4 << MMCSD_R6_STATE_SHIFT) /* 4=Transfer state */ -# define MMCSD_R6_STATE_DATA (5 << MMCSD_R6_STATE_SHIFT) /* 5=Sending data state */ -# define MMCSD_R6_STATE_RCV (6 << MMCSD_R6_STATE_SHIFT) /* 6=Receiving data state */ -# define MMCSD_R6_STATE_PRG (7 << MMCSD_R6_STATE_SHIFT) /* 7=Programming state */ -# define MMCSD_R6_STATE_DIS (8 << MMCSD_R6_STATE_SHIFT) /* 8=Disconnect state */ -#define MMCSD_R6_ERRORMASK 0x0000e000 /* Error mask */ - -/* SD Configuration Register (SCR) encoding */ - -#define MMCSD_SCR_BUSWIDTH_1BIT (1) -#define MMCSD_SCR_BUSWIDTH_2BIT (2) -#define MMCSD_SCR_BUSWIDTH_4BIT (4) -#define MMCSD_SCR_BUSWIDTH_8BIT (8) - -/* Last 4 bytes of the 48-bit R7 response */ - -#define MMCSD_R7VERSION_SHIFT 28 /* Bits 28-31: Command version number */ -#define MMCSD_R7VERSION_MASK (0x0f << MMCSD_R7VERSION_SHIFT) -#define MMCSD_R7VOLTAGE_SHIFT 8 /* Bits 8-11: Voltage accepted */ -#define MMCSD_R7VOLTAGE_MASK (0x0f << MMCSD_R7VOLTAGE_SHIFT) -# define MMCSD_R7VOLTAGE_27 (0x01 << MMCSD_R7VOLTAGE_SHIFT) /* 2.7-3.6V */ -#define MMCSD_R7ECHO_SHIFT 0 /* Bits 0-7: Echoed check pattern */ -#define MMCSD_R7ECHO_MASK (0xff << MMCSD_R7ECHO_SHIFT) -# define MMCSD_R7CHECKPATTERN (0xaa << MMCSD_R7ECHO_SHIFT) - -/******************************************************************************************** - * Public Types - ********************************************************************************************/ - -/* Decoded Card Identification (CID) register */ - -struct mmcsd_cid_s -{ - ubyte mid; /* 127:120 8-bit Manufacturer ID */ - uint16 oid; /* 119:104 16-bit OEM/Application ID (ascii) */ - ubyte pnm[6]; /* 103:64 40-bit Product Name (ascii) + null terminator */ - ubyte prv; /* 63:56 8-bit Product revision */ - uint32 psn; /* 55:24 32-bit Product serial number */ - /* 23:20 4-bit (reserved) */ - uint16 mdt; /* 19:8 12-bit Manufacturing date */ - ubyte crc; /* 7:1 7-bit CRC7 */ - /* 0:0 1-bit (not used) */ -}; - -/* Decoded Card Specific Data (CSD) register */ - -struct mmcsd_csd_s -{ - ubyte csdstructure; /* 127:126 CSD structure */ - ubyte mmcspecvers; /* 125:122 MMC Spec version (MMC only) */ - - struct - { - ubyte timeunit; /* 2:0 Time exponent */ - ubyte timevalue; /* 6:3 Time mantissa */ - } taac; /* 119:112 Data read access-time-1 */ - - ubyte nsac; /* 111:104 Data read access-time-2 in CLK cycle(NSAC*100) */ - - struct - { - ubyte transferrateunit; /* 2:0 Rate exponent */ - ubyte timevalue; /* 6:3 Rate mantissa */ - } transpeed; /* 103:96 Max. data transfer rate */ - - uint16 ccc; /* 95:84 Card command classes */ - ubyte readbllen; /* 83:80 Max. read data block length */ - ubyte readblpartial; /* 79:79 Partial blocks for read allowed */ - ubyte writeblkmisalign; /* 78:78 Write block misalignment */ - ubyte readblkmisalign; /* 77:77 Read block misalignment */ - ubyte dsrimp; /* 76:76 DSR implemented */ - - union - { -#ifdef CONFIG_MMCSD_MMCSUPPORT - struct - { - uint16 csize; /* 73:62 Device size */ - ubyte vddrcurrmin; /* 61:59 Max. read current at Vdd min */ - ubyte vddrcurrmax; /* 58:56 Max. read current at Vdd max */ - ubyte vddwcurrmin; /* 55:53 Max. write current at Vdd min */ - ubyte vddwcurrmax; /* 52:50 Max. write current at Vdd max */ - ubyte csizemult; /* 49:47 Device size multiplier */ - - union - { - struct /* MMC system specification version 3.1 */ - { - ubyte ergrpsize; /* 46:42 Erase group size (MMC 3.1) */ - ubyte ergrpmult; /* 41:37 Erase group multiplier (MMC 3.1) */ - } mmc31; - struct /* MMC system specification version 2.2 */ - { - ubyte sectorsize; /* 46:42 Erase sector size (MMC 2.2) */ - ubyte ergrpsize; /* 41:37 Erase group size (MMC 2.2) */ - } mmc22; - } er; - - ubyte mmcwpgrpsize; /* 36:32 Write protect group size (MMC) */ - } mmc; -#endif - struct - { - uint16 csize; /* 73:62 Device size */ - ubyte vddrcurrmin; /* 61:59 Max. read current at Vdd min */ - ubyte vddrcurrmax; /* 58:56 Max. read current at Vdd max */ - ubyte vddwcurrmin; /* 55:53 Max. write current at Vdd min */ - ubyte vddwcurrmax; /* 52:50 Max. write current at Vdd max */ - ubyte csizemult; /* 49:47 Device size multiplier */ - ubyte sderblen; /* 46:46 Erase single block enable (SD) */ - ubyte sdsectorsize; /* 45:39 Erase sector size (SD) */ - ubyte sdwpgrpsize; /* 38:32 Write protect group size (SD) */ - } sdbyte; - - struct - { - /* 73:70 (reserved) */ - uint32 csize; /* 69:48 Device size */ - /* 47:47 (reserved) */ - ubyte sderblen; /* 46:46 Erase single block enable (SD) */ - ubyte sdsectorsize; /* 45:39 Erase sector size (SD) */ - ubyte sdwpgrpsize; /* 38:32 Write protect group size (SD) */ - } sdblock; - } u; - - ubyte wpgrpen; /* 31:31 Write protect group enable */ - ubyte mmcdfltecc; /* 30:29 Manufacturer default ECC (MMC) */ - ubyte r2wfactor; /* 28:26 Write speed factor */ - ubyte writebllen; /* 25:22 Max. write data block length */ - ubyte writeblpartial; /* 21:21 Partial blocks for write allowed */ - ubyte fileformatgrp; /* 15:15 File format group */ - ubyte copy; /* 14:14 Copy flag (OTP) */ - ubyte permwriteprotect; /* 13:13 Permanent write protection */ - ubyte tmpwriteprotect; /* 12:12 Temporary write protection */ - ubyte fileformat; /* 10:11 File format */ - ubyte mmcecc; /* 9:8 ECC (MMC) */ - ubyte crc; /* 7:1 CRC */ - /* 0:0 Not used */ -}; - -struct mmcsd_scr_s -{ - ubyte scrversion; /* 63:60 Version of SCR structure */ - ubyte sdversion; /* 59:56 SD memory card physical layer version */ - ubyte erasestate; /* 55:55 Data state after erase (1 or 0) */ - ubyte security; /* 54:52 SD security support */ - ubyte buswidth; /* 51:48 DAT bus widthes supported */ - /* 47:32 SD reserved space */ - uint32 mfgdata; /* 31:0 Reserved for manufacturing data */ -}; - -/******************************************************************************************** - * Public Data - ********************************************************************************************/ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" { -#else -#define EXTERN extern -#endif - -/******************************************************************************************** - * Public Functions - ********************************************************************************************/ - - -#undef EXTERN -#if defined(__cplusplus) -} -#endif -#endif /* __DRIVERS_MMCSD_MMCSD_SDIO_H */ +
+/* ACMD42 argument */
+
+#define MMCSD_ACMD42_CD_DISCONNECT (0) /* Disconnect card detection logic */
+#define MMCSD_ACMD42_CD_CONNECT (1) /* Connect card detection logic */
+
+/* R1 Card Status bit definitions */
+
+#define MMCSD_R1_OUTOFRANGE (1 << 31) /* Bad argument */
+#define MMCSD_R1_ADDRESSERROR (1 << 30) /* Bad address */
+#define MMCSD_R1_BLOCKLENERROR (1 << 29) /* Bad block length */
+#define MMCSD_R1_ERASESEQERROR (1 << 28) /* Erase cmd error */
+#define MMCSD_R1_ERASEPARAM (1 << 27) /* Bad write blocks */
+#define MMCSD_R1_WPVIOLATION (1 << 26) /* Erase access failure */
+#define MMCSD_R1_CARDISLOCKED (1 << 25) /* Card is locked */
+#define MMCSD_R1_LOCKUNLOCKFAILED (1 << 24) /* Password error */
+#define MMCSD_R1_COMCRCERROR (1 << 23) /* CRC error */
+#define MMCSD_R1_ILLEGALCOMMAND (1 << 22) /* Bad command */
+#define MMCSD_R1_CARDECCFAILED (1 << 21) /* Failed to correct data */
+#define MMCSD_R1_CCERROR (1 << 20) /* Card controller error */
+#define MMCSD_R1_ERROR (1 << 19) /* General error */
+#define MMCSD_R1_UNDERRUN (1 << 18) /* Underrun (MMC only) */
+#define MMCSD_R1_OVERRRUN (1 << 17) /* Overrun (MMC only) */
+#define MMCSD_R1_CIDCSDOVERWRITE (1 << 16) /* CID/CSD error */
+#define MMCSD_R1_WPERASESKIP (1 << 15) /* Not all erased */
+#define MMCSD_R1_CARDECCDISABLED (1 << 14) /* Internal ECC not used */
+#define MMCSD_R1_ERASERESET (1 << 13) /* Reset sequence cleared */
+#define MMCSD_R1_STATE_SHIFT (9) /* Current card state */
+#define MMCSD_R1_STATE_MASK (15 << MMCSD_R1_STATE_SHIFT)
+ /* Card identification mode states */
+# define MMCSD_R1_STATE_IDLE (0 << MMCSD_R1_STATE_SHIFT) /* 0=Idle state */
+# define MMCSD_R1_STATE_READY (1 << MMCSD_R1_STATE_SHIFT) /* 1=Ready state */
+# define MMCSD_R1_STATE_IDENT (2 << MMCSD_R1_STATE_SHIFT) /* 2=Identification state */
+ /* Data transfer states */
+# define MMCSD_R1_STATE_STBY (3 << MMCSD_R1_STATE_SHIFT) /* 3=Standby state */
+# define MMCSD_R1_STATE_TRAN (4 << MMCSD_R1_STATE_SHIFT) /* 4=Transfer state */
+# define MMCSD_R1_STATE_DATA (5 << MMCSD_R1_STATE_SHIFT) /* 5=Sending data state */
+# define MMCSD_R1_STATE_RCV (6 << MMCSD_R1_STATE_SHIFT) /* 6=Receiving data state */
+# define MMCSD_R1_STATE_PRG (7 << MMCSD_R1_STATE_SHIFT) /* 7=Programming state */
+# define MMCSD_R1_STATE_DIS (8 << MMCSD_R1_STATE_SHIFT) /* 8=Disconnect state */
+#define MMCSD_R1_READYFORDATA (1 << 8) /* Buffer empty */
+#define MMCSD_R1_APPCMD (1 << 5) /* Next CMD is ACMD */
+#define MMCSD_R1_AKESEQERROR (1 << 3) /* Authentication error */
+#define MMCSD_R1_ERRORMASK 0xfdffe008 /* Error mask */
+
+#define IS_STATE(v,s) (((v)&MMCSD_R1_STATE_MASK)==(s))
+
+/* R3 (OCR) */
+
+#define MMC_VDD_20_36 0x00ffff00 /* VDD voltage 2.0-3.6 */
+
+#define MMCSD_VDD_145_150 (1 << 0) /* VDD voltage 1.45 - 1.50 */
+#define MMCSD_VDD_150_155 (1 << 1) /* VDD voltage 1.50 - 1.55 */
+#define MMCSD_VDD_155_160 (1 << 2) /* VDD voltage 1.55 - 1.60 */
+#define MMCSD_VDD_160_165 (1 << 3) /* VDD voltage 1.60 - 1.65 */
+#define MMCSD_VDD_165_170 (1 << 4) /* VDD voltage 1.65 - 1.70 */
+#define MMCSD_VDD_17_18 (1 << 5) /* VDD voltage 1.7 - 1.8 */
+#define MMCSD_VDD_18_19 (1 << 6) /* VDD voltage 1.8 - 1.9 */
+#define MMCSD_VDD_19_20 (1 << 7) /* VDD voltage 1.9 - 2.0 */
+#define MMCSD_VDD_20_21 (1 << 8) /* VDD voltage 2.0-2.1 */
+#define MMCSD_VDD_21_22 (1 << 9) /* VDD voltage 2.1-2.2 */
+#define MMCSD_VDD_22_23 (1 << 10) /* VDD voltage 2.2-2.3 */
+#define MMCSD_VDD_23_24 (1 << 11) /* VDD voltage 2.3-2.4 */
+#define MMCSD_VDD_24_25 (1 << 12) /* VDD voltage 2.4-2.5 */
+#define MMCSD_VDD_25_26 (1 << 13) /* VDD voltage 2.5-2.6 */
+#define MMCSD_VDD_26_27 (1 << 14) /* VDD voltage 2.6-2.7 */
+#define MMCSD_VDD_27_28 (1 << 15) /* VDD voltage 2.7-2.8 */
+#define MMCSD_VDD_28_29 (1 << 16) /* VDD voltage 2.8-2.9 */
+#define MMCSD_VDD_29_30 (1 << 17) /* VDD voltage 2.9-3.0 */
+#define MMCSD_VDD_30_31 (1 << 18) /* VDD voltage 3.0-3.1 */
+#define MMCSD_VDD_31_32 (1 << 19) /* VDD voltage 3.1-3.2 */
+#define MMCSD_VDD_32_33 (1 << 20) /* VDD voltage 3.2-3.3 */
+#define MMCSD_VDD_33_34 (1 << 21) /* VDD voltage 3.3-3.4 */
+#define MMCSD_VDD_34_35 (1 << 22) /* VDD voltage 3.4-3.5 */
+#define MMCSD_VDD_35_36 (1 << 23) /* VDD voltage 3.5-3.6 */
+#define MMCSD_R3_HIGHCAPACITY (1 << 30) /* true: Card supports block addressing */
+#define MMCSD_CARD_BUSY (1 << 31) /* Card power-up busy bit */
+
+/* R6 Card Status bit definitions */
+
+#define MMCSD_R6_RCA_SHIFT (16) /* New published RCA */
+#define MMCSD_R6_RCA_MASK (0xffff << MMCSD_R6_RCA_SHIFT)
+#define MMCSD_R6_COMCRCERROR (1 << 15) /* CRC error */
+#define MMCSD_R6_ILLEGALCOMMAND (1 << 14) /* Bad command */
+#define MMCSD_R6_ERROR (1 << 13) /* General error */
+#define MMCSD_R6_STATE_SHIFT (9) /* Current card state */
+#define MMCSD_R6_STATE_MASK (15 << MMCSD_R6_STATE_SHIFT)
+ /* Card identification mode states */
+# define MMCSD_R6_STATE_IDLE (0 << MMCSD_R6_STATE_SHIFT) /* 0=Idle state */
+# define MMCSD_R6_STATE_READY (1 << MMCSD_R6_STATE_SHIFT) /* 1=Ready state */
+# define MMCSD_R6_STATE_IDENT (2 << MMCSD_R6_STATE_SHIFT) /* 2=Identification state */
+ /* Data transfer states */
+# define MMCSD_R6_STATE_STBY (3 << MMCSD_R6_STATE_SHIFT) /* 3=Standby state */
+# define MMCSD_R6_STATE_TRAN (4 << MMCSD_R6_STATE_SHIFT) /* 4=Transfer state */
+# define MMCSD_R6_STATE_DATA (5 << MMCSD_R6_STATE_SHIFT) /* 5=Sending data state */
+# define MMCSD_R6_STATE_RCV (6 << MMCSD_R6_STATE_SHIFT) /* 6=Receiving data state */
+# define MMCSD_R6_STATE_PRG (7 << MMCSD_R6_STATE_SHIFT) /* 7=Programming state */
+# define MMCSD_R6_STATE_DIS (8 << MMCSD_R6_STATE_SHIFT) /* 8=Disconnect state */
+#define MMCSD_R6_ERRORMASK 0x0000e000 /* Error mask */
+
+/* SD Configuration Register (SCR) encoding */
+
+#define MMCSD_SCR_BUSWIDTH_1BIT (1)
+#define MMCSD_SCR_BUSWIDTH_2BIT (2)
+#define MMCSD_SCR_BUSWIDTH_4BIT (4)
+#define MMCSD_SCR_BUSWIDTH_8BIT (8)
+
+/* Last 4 bytes of the 48-bit R7 response */
+
+#define MMCSD_R7VERSION_SHIFT 28 /* Bits 28-31: Command version number */
+#define MMCSD_R7VERSION_MASK (0x0f << MMCSD_R7VERSION_SHIFT)
+#define MMCSD_R7VOLTAGE_SHIFT 8 /* Bits 8-11: Voltage accepted */
+#define MMCSD_R7VOLTAGE_MASK (0x0f << MMCSD_R7VOLTAGE_SHIFT)
+# define MMCSD_R7VOLTAGE_27 (0x01 << MMCSD_R7VOLTAGE_SHIFT) /* 2.7-3.6V */
+#define MMCSD_R7ECHO_SHIFT 0 /* Bits 0-7: Echoed check pattern */
+#define MMCSD_R7ECHO_MASK (0xff << MMCSD_R7ECHO_SHIFT)
+# define MMCSD_R7CHECKPATTERN (0xaa << MMCSD_R7ECHO_SHIFT)
+
+/********************************************************************************************
+ * Public Types
+ ********************************************************************************************/
+
+/* Decoded Card Identification (CID) register */
+
+struct mmcsd_cid_s
+{
+ uint8_t mid; /* 127:120 8-bit Manufacturer ID */
+ uint16_t oid; /* 119:104 16-bit OEM/Application ID (ascii) */
+ uint8_t pnm[6]; /* 103:64 40-bit Product Name (ascii) + null terminator */
+ uint8_t prv; /* 63:56 8-bit Product revision */
+ uint32_t psn; /* 55:24 32-bit Product serial number */
+ /* 23:20 4-bit (reserved) */
+ uint16_t mdt; /* 19:8 12-bit Manufacturing date */
+ uint8_t crc; /* 7:1 7-bit CRC7 */
+ /* 0:0 1-bit (not used) */
+};
+
+/* Decoded Card Specific Data (CSD) register */
+
+struct mmcsd_csd_s
+{
+ uint8_t csdstructure; /* 127:126 CSD structure */
+ uint8_t mmcspecvers; /* 125:122 MMC Spec version (MMC only) */
+
+ struct
+ {
+ uint8_t timeunit; /* 2:0 Time exponent */
+ uint8_t timevalue; /* 6:3 Time mantissa */
+ } taac; /* 119:112 Data read access-time-1 */
+
+ uint8_t nsac; /* 111:104 Data read access-time-2 in CLK cycle(NSAC*100) */
+
+ struct
+ {
+ uint8_t transferrateunit; /* 2:0 Rate exponent */
+ uint8_t timevalue; /* 6:3 Rate mantissa */
+ } transpeed; /* 103:96 Max. data transfer rate */
+
+ uint16_t ccc; /* 95:84 Card command classes */
+ uint8_t readbllen; /* 83:80 Max. read data block length */
+ uint8_t readblpartial; /* 79:79 Partial blocks for read allowed */
+ uint8_t writeblkmisalign; /* 78:78 Write block misalignment */
+ uint8_t readblkmisalign; /* 77:77 Read block misalignment */
+ uint8_t dsrimp; /* 76:76 DSR implemented */
+
+ union
+ {
+#ifdef CONFIG_MMCSD_MMCSUPPORT
+ struct
+ {
+ uint16_t csize; /* 73:62 Device size */
+ uint8_t vddrcurrmin; /* 61:59 Max. read current at Vdd min */
+ uint8_t vddrcurrmax; /* 58:56 Max. read current at Vdd max */
+ uint8_t vddwcurrmin; /* 55:53 Max. write current at Vdd min */
+ uint8_t vddwcurrmax; /* 52:50 Max. write current at Vdd max */
+ uint8_t csizemult; /* 49:47 Device size multiplier */
+
+ union
+ {
+ struct /* MMC system specification version 3.1 */
+ {
+ uint8_t ergrpsize; /* 46:42 Erase group size (MMC 3.1) */
+ uint8_t ergrpmult; /* 41:37 Erase group multiplier (MMC 3.1) */
+ } mmc31;
+ struct /* MMC system specification version 2.2 */
+ {
+ uint8_t sectorsize; /* 46:42 Erase sector size (MMC 2.2) */
+ uint8_t ergrpsize; /* 41:37 Erase group size (MMC 2.2) */
+ } mmc22;
+ } er;
+
+ uint8_t mmcwpgrpsize; /* 36:32 Write protect group size (MMC) */
+ } mmc;
+#endif
+ struct
+ {
+ uint16_t csize; /* 73:62 Device size */
+ uint8_t vddrcurrmin; /* 61:59 Max. read current at Vdd min */
+ uint8_t vddrcurrmax; /* 58:56 Max. read current at Vdd max */
+ uint8_t vddwcurrmin; /* 55:53 Max. write current at Vdd min */
+ uint8_t vddwcurrmax; /* 52:50 Max. write current at Vdd max */
+ uint8_t csizemult; /* 49:47 Device size multiplier */
+ uint8_t sderblen; /* 46:46 Erase single block enable (SD) */
+ uint8_t sdsectorsize; /* 45:39 Erase sector size (SD) */
+ uint8_t sdwpgrpsize; /* 38:32 Write protect group size (SD) */
+ } sdbyte;
+
+ struct
+ {
+ /* 73:70 (reserved) */
+ uint32_t csize; /* 69:48 Device size */
+ /* 47:47 (reserved) */
+ uint8_t sderblen; /* 46:46 Erase single block enable (SD) */
+ uint8_t sdsectorsize; /* 45:39 Erase sector size (SD) */
+ uint8_t sdwpgrpsize; /* 38:32 Write protect group size (SD) */
+ } sdblock;
+ } u;
+
+ uint8_t wpgrpen; /* 31:31 Write protect group enable */
+ uint8_t mmcdfltecc; /* 30:29 Manufacturer default ECC (MMC) */
+ uint8_t r2wfactor; /* 28:26 Write speed factor */
+ uint8_t writebllen; /* 25:22 Max. write data block length */
+ uint8_t writeblpartial; /* 21:21 Partial blocks for write allowed */
+ uint8_t fileformatgrp; /* 15:15 File format group */
+ uint8_t copy; /* 14:14 Copy flag (OTP) */
+ uint8_t permwriteprotect; /* 13:13 Permanent write protection */
+ uint8_t tmpwriteprotect; /* 12:12 Temporary write protection */
+ uint8_t fileformat; /* 10:11 File format */
+ uint8_t mmcecc; /* 9:8 ECC (MMC) */
+ uint8_t crc; /* 7:1 CRC */
+ /* 0:0 Not used */
+};
+
+struct mmcsd_scr_s
+{
+ uint8_t scrversion; /* 63:60 Version of SCR structure */
+ uint8_t sdversion; /* 59:56 SD memory card physical layer version */
+ uint8_t erasestate; /* 55:55 Data state after erase (1 or 0) */
+ uint8_t security; /* 54:52 SD security support */
+ uint8_t buswidth; /* 51:48 DAT bus widthes supported */
+ /* 47:32 SD reserved space */
+ uint32_t mfgdata; /* 31:0 Reserved for manufacturing data */
+};
+
+/********************************************************************************************
+ * Public Data
+ ********************************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C" {
+#else
+#define EXTERN extern
+#endif
+
+/********************************************************************************************
+ * Public Functions
+ ********************************************************************************************/
+
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+#endif /* __DRIVERS_MMCSD_MMCSD_SDIO_H */
diff --git a/nuttx/drivers/mmcsd/mmcsd_spi.c b/nuttx/drivers/mmcsd/mmcsd_spi.c index 896d8515f..5dfe349bc 100644 --- a/nuttx/drivers/mmcsd/mmcsd_spi.c +++ b/nuttx/drivers/mmcsd/mmcsd_spi.c @@ -40,6 +40,8 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <string.h> #include <time.h> @@ -138,24 +140,24 @@ struct mmcsd_slot_s { FAR struct spi_dev_s *spi; /* SPI port bound to this slot */ sem_t sem; /* Assures mutually exclusive accesss to card and SPI */ - ubyte state; /* State of the slot (see MMCSD_SLOTSTATUS_* definitions) */ - ubyte type; /* Disk type */ - ubyte csd[16]; /* Copy of card CSD */ + uint8_t state; /* State of the slot (see MMCSD_SLOTSTATUS_* definitions) */ + uint8_t type; /* Disk type */ + uint8_t csd[16]; /* Copy of card CSD */ #ifndef CONFIG_MMCSD_SECTOR512 - uint16 sectorsize; /* Media block size (in bytes) */ + uint16_t sectorsize; /* Media block size (in bytes) */ #endif - uint32 nsectors; /* Number of blocks on the media */ - uint32 taccess; /* Card access time */ - uint32 twrite; /* Card write time */ - uint32 ocr; /* Last 4 bytes of OCR (R3) */ - uint32 r7; /* Last 4 bytes of R7 */ + uint32_t nsectors; /* Number of blocks on the media */ + uint32_t taccess; /* Card access time */ + uint32_t twrite; /* Card write time */ + uint32_t ocr; /* Last 4 bytes of OCR (R3) */ + uint32_t r7; /* Last 4 bytes of R7 */ }; struct mmcsd_cmdinfo_s { - ubyte cmd; - ubyte resp; - ubyte chksum; + uint8_t cmd; + uint8_t resp; + uint8_t chksum; }; /**************************************************************************** @@ -168,43 +170,48 @@ static void mmcsd_semtake(sem_t *sem); /* Card SPI interface *******************************************************/ -static int mmcsd_waitready(FAR struct mmcsd_slot_s *slot); -static uint32 mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, - const struct mmcsd_cmdinfo_s *cmd, uint32 arg); -static void mmcsd_setblklen(FAR struct mmcsd_slot_s *slot, uint32 length); -static uint32 mmcsd_nsac(FAR struct mmcsd_slot_s *slot, ubyte *csd, uint32 frequency); -static uint32 mmcsd_taac(FAR struct mmcsd_slot_s *slot, ubyte *csd); -static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, ubyte *csd); -static void mmcsd_checkwrprotect(FAR struct mmcsd_slot_s *slot, ubyte *csd); -static int mmcsd_getcardinfo(FAR struct mmcsd_slot_s *slot, ubyte *buffer, - const struct mmcsd_cmdinfo_s *cmd); +static int mmcsd_waitready(FAR struct mmcsd_slot_s *slot); +static uint32_t mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, + const struct mmcsd_cmdinfo_s *cmd, uint32_t arg); +static void mmcsd_setblklen(FAR struct mmcsd_slot_s *slot, + uint32_t length); +static uint32_t mmcsd_nsac(FAR struct mmcsd_slot_s *slot, uint8_t *csd, + uint32_t frequency); +static uint32_t mmcsd_taac(FAR struct mmcsd_slot_s *slot, uint8_t *csd); +static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, uint8_t *csd); +static void mmcsd_checkwrprotect(FAR struct mmcsd_slot_s *slot, + uint8_t *csd); +static int mmcsd_getcardinfo(FAR struct mmcsd_slot_s *slot, + uint8_t *buffer, const struct mmcsd_cmdinfo_s *cmd); #define mmcsd_getcsd(slot, csd) mmcsd_getcardinfo(slot, csd, &g_cmd9); #define mmcsd_getcid(slot, cid) mmcsd_getcardinfo(slot, cid, &g_cmd10); -static int mmcsd_recvblock(FAR struct mmcsd_slot_s *slot, ubyte *buffer, - int nbytes); +static int mmcsd_recvblock(FAR struct mmcsd_slot_s *slot, + uint8_t *buffer, int nbytes); #if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY) -static int mmcsd_xmitblock(FAR struct mmcsd_slot_s *slot, const ubyte *buffer, - int nbytes, ubyte token); +static int mmcsd_xmitblock(FAR struct mmcsd_slot_s *slot, + const uint8_t *buffer, int nbytes, uint8_t token); #endif /* Block driver interfaces **************************************************/ -static int mmcsd_open(FAR struct inode *inode); -static int mmcsd_close(FAR struct inode *inode); -static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer, - size_t start_sector, unsigned int nsectors); +static int mmcsd_open(FAR struct inode *inode); +static int mmcsd_close(FAR struct inode *inode); +static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer, + size_t start_sector, unsigned int nsectors); #if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY) -static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer, - size_t start_sector, unsigned int nsectors); +static ssize_t mmcsd_write(FAR struct inode *inode, + const unsigned char *buffer, size_t start_sector, + unsigned int nsectors); #endif -static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry); +static int mmcsd_geometry(FAR struct inode *inode, + struct geometry *geometry); /* Initialization ***********************************************************/ -static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot); -static void mmcsd_mediachanged(void *arg); +static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot); +static void mmcsd_mediachanged(void *arg); /**************************************************************************** * Private Data @@ -245,7 +252,7 @@ static struct mmcsd_slot_s g_mmcsdslot[CONFIG_MMCSD_NSLOTS]; * correct value is returned in the product */ -static const uint32 g_transpeedru[8] = +static const uint32_t g_transpeedru[8] = { 10000, /* 0: 10 Kbit/sec / 10 */ 100000, /* 1: 1 Mbit/sec / 10 */ @@ -255,7 +262,7 @@ static const uint32 g_transpeedru[8] = 0, 0, 0, 0 /* 4-7: Reserved values */ }; -static const uint32 g_transpeedtu[16] = +static const uint32_t g_transpeedtu[16] = { 0, 10, 12, 13, /* 0-3: Reserved, 1.0, 1.1, 1.2, 1.3 */ 15, 20, 25, 30, /* 4-7: 1.5, 2.0, 2.5, 3.0 */ @@ -278,7 +285,7 @@ static const uint32 g_transpeedtu[16] = */ #define MAX_USTUNDX 2 -static const uint16 g_taactu[8] = +static const uint16_t g_taactu[8] = { /* Units of nanoseconds */ @@ -295,7 +302,7 @@ static const uint16 g_taactu[8] = 10000, /* 7: 10 ms 10,000,000 ns */ }; -static const uint16 g_taactv[] = +static const uint16_t g_taactv[] = { 0x000, 0x100, 0x133, 0x14d, /* 0-3: Reserved, 1.0, 1.2, 1.3 */ 0x180, 0x200, 0x280, 0x300, /* 4-7: 1.5, 2.0, 2.5, 3.0 */ @@ -357,9 +364,9 @@ static void mmcsd_semtake(sem_t *sem) static int mmcsd_waitready(FAR struct mmcsd_slot_s *slot) { FAR struct spi_dev_s *spi = slot->spi; - ubyte response; - uint32 start; - uint32 elapsed; + uint8_t response; + uint32_t start; + uint32_t elapsed; /* Wait until the card is no longer busy (up to 500MS) */ @@ -390,12 +397,12 @@ static int mmcsd_waitready(FAR struct mmcsd_slot_s *slot) * ****************************************************************************/ -static uint32 mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, - const struct mmcsd_cmdinfo_s *cmd, uint32 arg) +static uint32_t mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, + const struct mmcsd_cmdinfo_s *cmd, uint32_t arg) { FAR struct spi_dev_s *spi = slot->spi; - uint32 result; - ubyte response = 0xff; + uint32_t result; + uint8_t response = 0xff; int ret; int i; @@ -445,7 +452,7 @@ static uint32 mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, if ((response & 0x80) != 0) { fdbg("Failed: i=%d response=%02x\n", i, response); - return (uint32)-1; + return (uint32_t)-1; } /* Interpret the response according to the command */ @@ -457,9 +464,9 @@ static uint32 mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, case MMCSD_CMDRESP_R1B: { - uint32 busy = 0; - uint32 start; - uint32 elapsed; + uint32_t busy = 0; + uint32_t start; + uint32_t elapsed; start = START_TIME; do @@ -472,7 +479,7 @@ static uint32 mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, if (busy != 0xff) { fdbg("Failed: card still busy (%02x)\n", busy); - return (uint32)-1; + return (uint32_t)-1; } fvdbg("CMD%d[%08x] R1B=%02x\n", @@ -493,7 +500,7 @@ static uint32 mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, case MMCSD_CMDRESP_R2: { - result = ((uint32)(response & 0xff) << 8); + result = ((uint32_t)(response & 0xff) << 8); result |= SPI_SEND(spi, 0xff) & 0xff; fvdbg("CMD%d[%08x] R2=%04x\n", @@ -505,9 +512,9 @@ static uint32 mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, case MMCSD_CMDRESP_R3: { - slot->ocr = ((uint32)(SPI_SEND(spi, 0xff) & 0xff) << 24); - slot->ocr |= ((uint32)(SPI_SEND(spi, 0xff) & 0xff) << 16); - slot->ocr |= ((uint32)(SPI_SEND(spi, 0xff) & 0xff) << 8); + slot->ocr = ((uint32_t)(SPI_SEND(spi, 0xff) & 0xff) << 24); + slot->ocr |= ((uint32_t)(SPI_SEND(spi, 0xff) & 0xff) << 16); + slot->ocr |= ((uint32_t)(SPI_SEND(spi, 0xff) & 0xff) << 8); slot->ocr |= SPI_SEND(spi, 0xff) & 0xff; fvdbg("CMD%d[%08x] R1=%02x OCR=%08x\n", @@ -518,9 +525,9 @@ static uint32 mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, case MMCSD_CMDRESP_R7: default: { - slot->r7 = ((uint32)(SPI_SEND(spi, 0xff) & 0xff) << 24); - slot->r7 |= ((uint32)(SPI_SEND(spi, 0xff) & 0xff) << 16); - slot->r7 |= ((uint32)(SPI_SEND(spi, 0xff) & 0xff) << 8); + slot->r7 = ((uint32_t)(SPI_SEND(spi, 0xff) & 0xff) << 24); + slot->r7 |= ((uint32_t)(SPI_SEND(spi, 0xff) & 0xff) << 16); + slot->r7 |= ((uint32_t)(SPI_SEND(spi, 0xff) & 0xff) << 8); slot->r7 |= SPI_SEND(spi, 0xff) & 0xff; fvdbg("CMD%d[%08x] R1=%02x R7=%08x\n", @@ -543,9 +550,9 @@ static uint32 mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, * ****************************************************************************/ -static void mmcsd_setblklen(FAR struct mmcsd_slot_s *slot, uint32 length) +static void mmcsd_setblklen(FAR struct mmcsd_slot_s *slot, uint32_t length) { - uint32 response; + uint32_t response; fvdbg("Set block length to %d\n", length); response = mmcsd_sendcmd(slot, &g_cmd16, length); @@ -562,15 +569,16 @@ static void mmcsd_setblklen(FAR struct mmcsd_slot_s *slot, uint32 length) * ****************************************************************************/ -static uint32 mmcsd_nsac(FAR struct mmcsd_slot_s *slot, ubyte *csd, uint32 frequency) +static uint32_t mmcsd_nsac(FAR struct mmcsd_slot_s *slot, uint8_t *csd, + uint32_t frequency) { /* NSAC is 8-bits wide and is in units of 100 clock cycles. Therefore, the * maximum value is 25.5K clock cycles. */ - uint32 nsac = MMCSD_CSD_NSAC(csd) * ((uint32)100*1000); /* 1,000 * NSAC */ - uint32 fhkz = (frequency + 500) / 1000; /* frequency / 1,000 */ - return (nsac + (fhkz >> 1)) / fhkz; /* 1,000,000 * NSAC / frequency */ + uint32_t nsac = MMCSD_CSD_NSAC(csd) * ((uint32_t)100*1000); + uint32_t fhkz = (frequency + 500) / 1000; + return (nsac + (fhkz >> 1)) / fhkz; } /**************************************************************************** @@ -580,7 +588,7 @@ static uint32 mmcsd_nsac(FAR struct mmcsd_slot_s *slot, ubyte *csd, uint32 frequ * ****************************************************************************/ -static uint32 mmcsd_taac(FAR struct mmcsd_slot_s *slot, ubyte *csd) +static uint32_t mmcsd_taac(FAR struct mmcsd_slot_s *slot, uint8_t *csd) { int tundx; @@ -618,14 +626,14 @@ static uint32 mmcsd_taac(FAR struct mmcsd_slot_s *slot, ubyte *csd) * ****************************************************************************/ -static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, ubyte *csd) +static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, uint8_t *csd) { FAR struct spi_dev_s *spi = slot->spi; - uint32 maxfrequency; - uint32 frequency; - uint32 readbllen; - uint32 csizemult; - uint32 csize; + uint32_t maxfrequency; + uint32_t frequency; + uint32_t readbllen; + uint32_t csizemult; + uint32_t csize; /* Calculate SPI max clock */ @@ -663,7 +671,7 @@ static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, ubyte *csd) * First get the access time in microseconds */ - uint32 taccessus = mmcsd_taac(slot, csd) + mmcsd_nsac(slot, csd, frequency); + uint32_t taccessus = mmcsd_taac(slot, csd) + mmcsd_nsac(slot, csd, frequency); /* Then convert to system clock ticks. The maximum read access is 10 times * the tacc value: taccess = 10 * (taccessus / 1,000,000) * CLK_TCK, or @@ -769,7 +777,7 @@ static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, ubyte *csd) * ****************************************************************************/ -static void mmcsd_checkwrprotect(FAR struct mmcsd_slot_s *slot, ubyte *csd) +static void mmcsd_checkwrprotect(FAR struct mmcsd_slot_s *slot, uint8_t *csd) { FAR struct spi_dev_s *spi = slot->spi; @@ -801,12 +809,12 @@ static void mmcsd_checkwrprotect(FAR struct mmcsd_slot_s *slot, ubyte *csd) * ****************************************************************************/ -static int mmcsd_getcardinfo(FAR struct mmcsd_slot_s *slot, ubyte *buffer, +static int mmcsd_getcardinfo(FAR struct mmcsd_slot_s *slot, uint8_t *buffer, const struct mmcsd_cmdinfo_s *cmd) { FAR struct spi_dev_s *spi = slot->spi; - uint32 result; - ubyte response; + uint32_t result; + uint8_t response; int i; SPI_SEND(spi, 0xff); @@ -863,12 +871,12 @@ static int mmcsd_getcardinfo(FAR struct mmcsd_slot_s *slot, ubyte *buffer, * ****************************************************************************/ -static int mmcsd_recvblock(FAR struct mmcsd_slot_s *slot, ubyte *buffer, int nbytes) +static int mmcsd_recvblock(FAR struct mmcsd_slot_s *slot, uint8_t *buffer, int nbytes) { FAR struct spi_dev_s *spi = slot->spi; - uint32 start; - uint32 elapsed; - ubyte token; + uint32_t start; + uint32_t elapsed; + uint8_t token; /* Wait up to the maximum to receive a valid data token. taccess is the * time from when the command is sent until the first byte of data is @@ -907,11 +915,11 @@ static int mmcsd_recvblock(FAR struct mmcsd_slot_s *slot, ubyte *buffer, int nby ****************************************************************************/ #if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY) -static int mmcsd_xmitblock(FAR struct mmcsd_slot_s *slot, const ubyte *buffer, - int nbytes, ubyte token) +static int mmcsd_xmitblock(FAR struct mmcsd_slot_s *slot, const uint8_t *buffer, + int nbytes, uint8_t token) { FAR struct spi_dev_s *spi = slot->spi; - ubyte response; + uint8_t response; /* Start the block transfer: * 1. 0xff (sync) @@ -1007,9 +1015,9 @@ static int mmcsd_open(FAR struct inode *inode) /* Make sure that the card is ready */ - SPI_SELECT(spi, SPIDEV_MMCSD, TRUE); + SPI_SELECT(spi, SPIDEV_MMCSD, true); ret = mmcsd_waitready(slot); - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); } errout_with_sem: @@ -1044,7 +1052,7 @@ static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer, FAR struct spi_dev_s *spi; size_t nbytes; off_t offset; - ubyte response; + uint8_t response; int i; fvdbg("start_sector=%d nsectors=%d\n", start_sector, nsectors); @@ -1108,7 +1116,7 @@ static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer, /* Select the slave */ mmcsd_semtake(&slot->sem); - SPI_SELECT(spi, SPIDEV_MMCSD, TRUE); + SPI_SELECT(spi, SPIDEV_MMCSD, true); /* Single or multiple block read? */ @@ -1165,7 +1173,7 @@ static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer, /* On success, return the number of sectors transfer */ - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); SPI_SEND(spi, 0xff); mmcsd_semgive(&slot->sem); @@ -1174,7 +1182,7 @@ static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer, return nsectors; errout_with_eio: - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); mmcsd_semgive(&slot->sem); return -EIO; } @@ -1195,7 +1203,7 @@ static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer, FAR struct spi_dev_s *spi; size_t nbytes; off_t offset; - ubyte response; + uint8_t response; int ret; int i; @@ -1269,7 +1277,7 @@ static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer, /* Select the slave */ mmcsd_semtake(&slot->sem); - SPI_SELECT(spi, SPIDEV_MMCSD, TRUE); + SPI_SELECT(spi, SPIDEV_MMCSD, true); /* Single or multiple block transfer? */ @@ -1337,7 +1345,7 @@ static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer, /* Wait until the card is no longer busy */ ret = mmcsd_waitready(slot); - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); SPI_SEND(spi, 0xff); mmcsd_semgive(&slot->sem); @@ -1346,7 +1354,7 @@ static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer, return nsectors; errout_with_sem: - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); mmcsd_semgive(&slot->sem); return -EIO; } @@ -1364,7 +1372,7 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry) { FAR struct mmcsd_slot_s *slot; FAR struct spi_dev_s *spi; - ubyte csd[16]; + uint8_t csd[16]; int ret; #ifdef CONFIG_DEBUG @@ -1397,9 +1405,9 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry) /* Re-sample the CSD */ mmcsd_semtake(&slot->sem); - SPI_SELECT(spi, SPIDEV_MMCSD, TRUE); + SPI_SELECT(spi, SPIDEV_MMCSD, true); ret = mmcsd_getcsd(slot, csd); - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); if (ret < 0) { @@ -1422,7 +1430,7 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry) geometry->geo_writeenabled = ((slot->state & MMCSD_SLOTSTATUS_WRPROTECT) == 0); #else - geometry->geo_writeenabled = FALSE; + geometry->geo_writeenabled = false; #endif geometry->geo_nsectors = slot->nsectors; geometry->geo_sectorsize = SECTORSIZE(slot); @@ -1458,10 +1466,10 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry) static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) { FAR struct spi_dev_s *spi = slot->spi; - ubyte csd[16]; - uint32 result = MMCSD_SPIR1_IDLESTATE; - uint32 start; - uint32 elapsed; + uint8_t csd[16]; + uint32_t result = MMCSD_SPIR1_IDLESTATE; + uint32_t start; + uint32_t elapsed; int i, j; /* Assume that the card is not ready (we'll clear this on successful card @@ -1513,7 +1521,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) */ fvdbg("Send CMD0\n"); - SPI_SELECT(spi, SPIDEV_MMCSD, TRUE); + SPI_SELECT(spi, SPIDEV_MMCSD, true); result = mmcsd_sendcmd(slot, &g_cmd0, 0); if (result == MMCSD_SPIR1_IDLESTATE) { @@ -1525,7 +1533,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) /* De-select card and try again */ - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); } /* Verify that we exit the above loop with the card reporting IDLE state */ @@ -1533,7 +1541,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) if (result != MMCSD_SPIR1_IDLESTATE) { fdbg("Send CMD0 failed: R1=%02x\n", result); - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); return -EIO; } @@ -1654,7 +1662,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) if (elapsed >= MMCSD_DELAY_1SEC) { fdbg("Failed to exit IDLE state\n"); - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); return -EIO; } } @@ -1662,7 +1670,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) if (slot->type == MMCSD_CARDTYPE_UNKNOWN) { fdbg("Failed to identify card\n"); - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); return -EIO; } @@ -1673,7 +1681,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) if (result != OK) { fdbg("mmcsd_getcsd(CMD9) failed: %d\n", result); - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); return -EIO; } mmcsd_dmpcsd(csd, slot->type); @@ -1699,7 +1707,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) * of 1024 or 2048. */ - if (!IS_SDV2(slot->type) && slot->nsectors <= ((uint32)4096*12)) + if (!IS_SDV2(slot->type) && slot->nsectors <= ((uint32_t)4096*12)) { /* Don't set the block len on high capacity cards (ver1.x or ver2.x) */ @@ -1715,7 +1723,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) #endif slot->state &= ~MMCSD_SLOTSTATUS_NOTREADY; - SPI_SELECT(spi, SPIDEV_MMCSD, FALSE); + SPI_SELECT(spi, SPIDEV_MMCSD, false); return OK; } @@ -1731,7 +1739,7 @@ static void mmcsd_mediachanged(void *arg) { struct mmcsd_slot_s *slot = (struct mmcsd_slot_s*)arg; FAR struct spi_dev_s *spi; - ubyte oldstate; + uint8_t oldstate; int ret; #ifdef CONFIG_DEBUG diff --git a/nuttx/drivers/mmcsd/mmcsd_spi.h b/nuttx/drivers/mmcsd/mmcsd_spi.h index b7be2182d..4e59296a4 100644 --- a/nuttx/drivers/mmcsd/mmcsd_spi.h +++ b/nuttx/drivers/mmcsd/mmcsd_spi.h @@ -41,7 +41,6 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> /**************************************************************************** * Pre-Processor Definitions diff --git a/nuttx/drivers/mtd/ftl.c b/nuttx/drivers/mtd/ftl.c index 43c4b3aed..1e9ab5ebd 100755 --- a/nuttx/drivers/mtd/ftl.c +++ b/nuttx/drivers/mtd/ftl.c @@ -41,6 +41,8 @@ #include <sys/types.h> #include <sys/ioctl.h> +#include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -71,9 +73,9 @@ struct ftl_struct_s #ifdef CONFIG_FTL_RWBUFFER struct rwbuffer_s rwb; /* Read-ahead/write buffer support */ #endif - uint16 blkper; /* R/W blocks per erase block */ + uint16_t blkper; /* R/W blocks per erase block */ #ifdef CONFIG_FS_WRITABLE - FAR ubyte *eblock; /* One, in-memory erase block */ + FAR uint8_t *eblock; /* One, in-memory erase block */ #endif }; @@ -83,12 +85,12 @@ struct ftl_struct_s static int ftl_open(FAR struct inode *inode); static int ftl_close(FAR struct inode *inode); -static ssize_t ftl_reload(FAR void *priv, FAR ubyte *buffer, +static ssize_t ftl_reload(FAR void *priv, FAR uint8_t *buffer, off_t startblock, size_t nblocks); static ssize_t ftl_read(FAR struct inode *inode, unsigned char *buffer, size_t start_sector, unsigned int nsectors); #ifdef CONFIG_FS_WRITABLE -static ssize_t ftl_flush(FAR void *priv, FAR const ubyte *buffer, +static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer, off_t startblock, size_t nblocks); static ssize_t ftl_write(FAR struct inode *inode, const unsigned char *buffer, size_t start_sector, unsigned int nsectors); @@ -151,7 +153,7 @@ static int ftl_close(FAR struct inode *inode) * ****************************************************************************/ -static ssize_t ftl_reload(FAR void *priv, FAR ubyte *buffer, +static ssize_t ftl_reload(FAR void *priv, FAR uint8_t *buffer, off_t startblock, size_t nblocks) { struct ftl_struct_s *dev = (struct ftl_struct_s *)priv; @@ -199,7 +201,7 @@ static ssize_t ftl_read(FAR struct inode *inode, unsigned char *buffer, ****************************************************************************/ #ifdef CONFIG_FS_WRITABLE -static ssize_t ftl_flush(FAR void *priv, FAR const ubyte *buffer, +static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer, off_t startblock, size_t nblocks) { struct ftl_struct_s *dev = (struct ftl_struct_s *)priv; @@ -387,18 +389,18 @@ static int ftl_geometry(FAR struct inode *inode, struct geometry *geometry) if (geometry) { dev = (struct ftl_struct_s *)inode->i_private; - geometry->geo_available = TRUE; - geometry->geo_mediachanged = FALSE; + geometry->geo_available = true; + geometry->geo_mediachanged = false; #ifdef CONFIG_FS_WRITABLE - geometry->geo_writeenabled = TRUE; + geometry->geo_writeenabled = true; #else - geometry->geo_writeenabled = FALSE; + geometry->geo_writeenabled = false; #endif geometry->geo_nsectors = dev->geo.neraseblocks * dev->blkper; geometry->geo_sectorsize = dev->geo.blocksize; - fvdbg("available: TRUE mediachanged: FALSE writeenabled: %s\n", - geometry->geo_writeenabled ? "TRUE" : "FALSE"); + fvdbg("available: true mediachanged: false writeenabled: %s\n", + geometry->geo_writeenabled ? "true" : "false"); fvdbg("nsectors: %d sectorsize: %d\n", geometry->geo_nsectors, geometry->geo_sectorsize); @@ -449,7 +451,7 @@ static int ftl_ioctl(FAR struct inode *inode, int cmd, unsigned long arg) * ****************************************************************************/ -int ftl_initialize(int minor, ubyte *buffer, FAR struct mtd_dev_s *mtd) +int ftl_initialize(int minor, uint8_t *buffer, FAR struct mtd_dev_s *mtd) { struct ftl_struct_s *dev; char devname[16]; @@ -489,7 +491,7 @@ int ftl_initialize(int minor, ubyte *buffer, FAR struct mtd_dev_s *mtd) /* Allocate one, in-memory erase block buffer */ #ifdef CONFIG_FS_WRITABLE - dev->eblock = (FAR ubyte *)malloc(dev->geo.erasesize); + dev->eblock = (FAR uint8_t *)malloc(dev->geo.erasesize); if (!dev->eblock) { fdbg("Failed to allocate an erase block buffer\n"); diff --git a/nuttx/drivers/mtd/m25px.c b/nuttx/drivers/mtd/m25px.c index e42f05cc9..0899376d6 100644 --- a/nuttx/drivers/mtd/m25px.c +++ b/nuttx/drivers/mtd/m25px.c @@ -41,6 +41,8 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <errno.h> #include <debug.h> @@ -127,10 +129,10 @@ struct m25p_dev_s { struct mtd_dev_s mtd; /* MTD interface */ FAR struct spi_dev_s *dev; /* Saved SPI interface instance */ - ubyte sectorshift; /* 16 or 18 */ - ubyte pageshift; /* 8 */ - uint16 nsectors; /* 128 or 64 */ - uint32 npages; /* 32,768 or 65,536 */ + uint8_t sectorshift; /* 16 or 18 */ + uint8_t pageshift; /* 8 */ + uint16_t nsectors; /* 128 or 64 */ + uint32_t npages; /* 32,768 or 65,536 */ }; /************************************************************************************ @@ -146,18 +148,18 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv); static void m25p_writeenable(struct m25p_dev_s *priv); static inline void m25p_sectorerase(struct m25p_dev_s *priv, off_t offset); static inline int m25p_bulkerase(struct m25p_dev_s *priv); -static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const ubyte *buffer, +static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const uint8_t *buffer, off_t offset); /* MTD driver methods */ static int m25p_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks); static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, - size_t nblocks, FAR ubyte *buf); + size_t nblocks, FAR uint8_t *buf); static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, - size_t nblocks, FAR const ubyte *buf); + size_t nblocks, FAR const uint8_t *buf); static ssize_t m25p_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, - FAR ubyte *buffer); + FAR uint8_t *buffer); static int m25p_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg); /************************************************************************************ @@ -182,7 +184,7 @@ static void m25p_lock(FAR struct spi_dev_s *dev) * the SPI buss. We will retain that exclusive access until the bus is unlocked. */ - (void)SPI_LOCK(dev, TRUE); + (void)SPI_LOCK(dev, true); /* After locking the SPI bus, the we also need call the setfrequency, setbits, and * setmode methods to make sure that the SPI is properly configured for the device. @@ -201,7 +203,7 @@ static void m25p_lock(FAR struct spi_dev_s *dev) static inline void m25p_unlock(FAR struct spi_dev_s *dev) { - (void)SPI_LOCK(dev, FALSE); + (void)SPI_LOCK(dev, false); } /************************************************************************************ @@ -210,16 +212,16 @@ static inline void m25p_unlock(FAR struct spi_dev_s *dev) static inline int m25p_readid(struct m25p_dev_s *priv) { - uint16 manufacturer; - uint16 memory; - uint16 capacity; + uint16_t manufacturer; + uint16_t memory; + uint16_t capacity; fvdbg("priv: %p\n", priv); /* Lock the SPI bus, configure the bus, and select this FLASH part. */ m25p_lock(priv->dev); - SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, true); /* Send the "Read ID (RDID)" command and read the first three ID bytes */ @@ -230,7 +232,7 @@ static inline int m25p_readid(struct m25p_dev_s *priv) /* Deselect the FLASH and unlock the bus */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, false); m25p_unlock(priv->dev); fvdbg("manufacturer: %02x memory: %02x capacity: %02x\n", @@ -271,11 +273,11 @@ static inline int m25p_readid(struct m25p_dev_s *priv) static void m25p_waitwritecomplete(struct m25p_dev_s *priv) { - ubyte status; + uint8_t status; /* Select this FLASH part */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, true); /* Send "Read Status Register (RDSR)" command */ @@ -293,7 +295,7 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv) /* Deselect the FLASH */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, false); fvdbg("Complete\n"); } @@ -305,7 +307,7 @@ static void m25p_writeenable(struct m25p_dev_s *priv) { /* Select this FLASH part */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, true); /* Send "Write Enable (WREN)" command */ @@ -313,7 +315,7 @@ static void m25p_writeenable(struct m25p_dev_s *priv) /* Deselect the FLASH */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, false); fvdbg("Enabled\n"); } @@ -341,7 +343,7 @@ static inline void m25p_sectorerase(struct m25p_dev_s *priv, off_t sector) /* Select this FLASH part */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, true); /* Send the "Sector Erase (SE)" instruction */ @@ -358,7 +360,7 @@ static inline void m25p_sectorerase(struct m25p_dev_s *priv, off_t sector) /* Deselect the FLASH */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, false); fvdbg("Erased\n"); } @@ -384,7 +386,7 @@ static inline int m25p_bulkerase(struct m25p_dev_s *priv) /* Select this FLASH part */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, true); /* Send the "Bulk Erase (BE)" instruction */ @@ -392,7 +394,7 @@ static inline int m25p_bulkerase(struct m25p_dev_s *priv) /* Deselect the FLASH */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, false); fvdbg("Return: OK\n"); return OK; } @@ -401,7 +403,7 @@ static inline int m25p_bulkerase(struct m25p_dev_s *priv) * Name: m25p_pagewrite ************************************************************************************/ -static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const ubyte *buffer, +static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const uint8_t *buffer, off_t page) { off_t offset = page << priv->pageshift; @@ -422,7 +424,7 @@ static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const ubyte *buff /* Select this FLASH part */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, true); /* Send "Page Program (PP)" command */ @@ -440,7 +442,7 @@ static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const ubyte *buff /* Deselect the FLASH: Chip Select high */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, false); fvdbg("Written\n"); } @@ -474,7 +476,7 @@ static int m25p_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblock ************************************************************************************/ static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, - FAR ubyte *buffer) + FAR uint8_t *buffer) { FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev; ssize_t nbytes; @@ -496,7 +498,7 @@ static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nb ************************************************************************************/ static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, - FAR const ubyte *buffer) + FAR const uint8_t *buffer) { FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev; size_t blocksleft = nblocks; @@ -521,7 +523,7 @@ static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t n ************************************************************************************/ static ssize_t m25p_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, - FAR ubyte *buffer) + FAR uint8_t *buffer) { FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev; @@ -538,7 +540,7 @@ static ssize_t m25p_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, /* Lock the SPI bus and select this FLASH part */ m25p_lock(priv->dev); - SPI_SELECT(priv->dev, SPIDEV_FLASH, TRUE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, true); /* Send "Read from Memory " instruction */ @@ -556,7 +558,7 @@ static ssize_t m25p_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, /* Deselect the FLASH and unlock the SPI bus */ - SPI_SELECT(priv->dev, SPIDEV_FLASH, FALSE); + SPI_SELECT(priv->dev, SPIDEV_FLASH, false); m25p_unlock(priv->dev); fvdbg("return nbytes: %d\n", (int)nbytes); return nbytes; @@ -662,7 +664,7 @@ FAR struct mtd_dev_s *m25p_initialize(FAR struct spi_dev_s *dev) /* Deselect the FLASH */ - SPI_SELECT(dev, SPIDEV_FLASH, FALSE); + SPI_SELECT(dev, SPIDEV_FLASH, false); /* Identify the FLASH chip and get its capacity */ diff --git a/nuttx/drivers/mtd/skeleton.c b/nuttx/drivers/mtd/skeleton.c index 78faa20b4..356e318a5 100644 --- a/nuttx/drivers/mtd/skeleton.c +++ b/nuttx/drivers/mtd/skeleton.c @@ -40,6 +40,7 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> #include <errno.h> #include <nuttx/ioctl.h> @@ -73,11 +74,11 @@ struct skel_dev_s static int skel_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks); static ssize_t skel_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, - FAR ubyte *buf); + FAR uint8_t *buf); static ssize_t skel_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, - FAR const ubyte *buf); + FAR const uint8_t *buf); static ssize_t skel_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, - FAR ubyte *buffer); + FAR uint8_t *buffer); static int skel_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg); /**************************************************************************** @@ -117,7 +118,7 @@ static int skel_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblock ****************************************************************************/ static ssize_t skel_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, - FAR ubyte *buf) + FAR uint8_t *buf) { FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; @@ -138,7 +139,7 @@ static ssize_t skel_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nb ****************************************************************************/ static ssize_t skel_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, - FAR const ubyte *buf) + FAR const uint8_t *buf) { FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; @@ -159,7 +160,7 @@ static ssize_t skel_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t n ****************************************************************************/ static ssize_t skel_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes, - FAR ubyte *buffer) + FAR uint8_t *buffer) { FAR struct skel_dev_s *priv = (FAR struct skel_dev_s *)dev; diff --git a/nuttx/drivers/net/cs89x0.c b/nuttx/drivers/net/cs89x0.c index d7ceef233..fc8a60729 100644 --- a/nuttx/drivers/net/cs89x0.c +++ b/nuttx/drivers/net/cs89x0.c @@ -40,6 +40,8 @@ #include <nuttx/config.h> #if defined(CONFIG_NET) && defined(CONFIG_NET_CS89x0) +#include <stdint.h> +#include <stdbool.h> #include <time.h> #include <string.h> #include <debug.h> @@ -104,12 +106,12 @@ static FAR struct cs89x0_driver_s *g_cs89x0[CONFIG_CS89x0_NINTERFACES]; /* CS89x0 register access */ -static uint16 cs89x0_getreg(struct cs89x0_driver_s *cs89x0, int offset); +static uint16_t cs89x0_getreg(struct cs89x0_driver_s *cs89x0, int offset); static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset, - uint16 value); -static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr); + uint16_t value); +static uint16_t cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr); static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, - uint16 value); + uint16_t value); /* Common TX logic */ @@ -119,7 +121,7 @@ static int cs89x0_uiptxpoll(struct uip_driver_s *dev); /* Interrupt handling */ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0); -static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16 isq); +static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16_t isq); #if CONFIG_CS89x0_NINTERFACES > 1 static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq); #endif @@ -127,8 +129,8 @@ static int cs89x0_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static void cs89x0_polltimer(int argc, uint32 arg, ...); -static void cs89x0_txtimeout(int argc, uint32 arg, ...); +static void cs89x0_polltimer(int argc, uint32_t arg, ...); +static void cs89x0_txtimeout(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -157,21 +159,21 @@ static int cs89x0_txavail(struct uip_driver_s *dev); * ****************************************************************************/ -static uint16 cs89x0_getreg(struct cs89x0_driver_s *cs89x0, int offset) +static uint16_t cs89x0_getreg(struct cs89x0_driver_s *cs89x0, int offset) { #ifdef CONFIG_CS89x0_ALIGN16 return getreg16(s89x0->cs_base + offset); #else - return (uint16)getreg32(s89x0->cs_base + offset); + return (uint16_t)getreg32(s89x0->cs_base + offset); #endif } -static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset, uint16 value) +static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset, uint16_t value) { #ifdef CONFIG_CS89x0_ALIGN16 return putreg16(value, s89x0->cs_base + offset); #else - return (uint16)putreg32((uint32)value, s89x0->cs_base + offset); + return (uint16_t)putreg32((uint32_t)value, s89x0->cs_base + offset); #endif } @@ -192,7 +194,7 @@ static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset, uint16 val * ****************************************************************************/ -static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr) +static uint16_t cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr) { /* In memory mode, the CS89x0's internal registers and frame buffers are mapped * into a contiguous 4kb block providing direct access to the internal registers @@ -205,7 +207,7 @@ static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr) #ifdef CONFIG_CS89x0_ALIGN16 return getreg16(s89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); #else - return (uint16)getreg32(s89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); + return (uint16_t)getreg32(s89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); #endif } @@ -217,16 +219,16 @@ static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr) #endif { #ifdef CONFIG_CS89x0_ALIGN16 - putreg16((uint16)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); + putreg16((uint16_t)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); return getreg16(s89x0->cs_base + CS89x0_PDATA_OFFSET); #else - putreg32((uint32)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); - return (uint16)getreg32(s89x0->cs_base + CS89x0_PDATA_OFFSET); + putreg32((uint32_t)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); + return (uint16_t)getreg32(s89x0->cs_base + CS89x0_PDATA_OFFSET); #endif } } -static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, uint16 value) +static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, uint16_t value) { /* In memory mode, the CS89x0's internal registers and frame buffers are mapped * into a contiguous 4kb block providing direct access to the internal registers @@ -239,7 +241,7 @@ static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, uint16 val #ifdef CONFIG_CS89x0_ALIGN16 putreg16(value), cs89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); #else - putreg32((uint32)value, cs89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); + putreg32((uint32_t)value, cs89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); #endif } @@ -251,11 +253,11 @@ static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, uint16 val #endif { #ifdef CONFIG_CS89x0_ALIGN16 - putreg16((uint16)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); + putreg16((uint16_t)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); putreg16(value, cs89x0->cs_base + CS89x0_PDATA_OFFSET); #else - putreg32((uint32)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); - putreg32((uint32)value, cs89x0->cs_base + CS89x0_PDATA_OFFSET); + putreg32((uint32_t)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); + putreg32((uint32_t)value, cs89x0->cs_base + CS89x0_PDATA_OFFSET); #endif } } @@ -296,7 +298,7 @@ static int cs89x0_transmit(struct cs89x0_driver_s *cs89x0) /* Setup the TX timeout watchdog (perhaps restarting the timer) */ - (void)wd_start(cs89x0->cs_txtimeout, CS89x0_TXTIMEOUT, cs89x0_txtimeout, 1, (uint32)cs89x0); + (void)wd_start(cs89x0->cs_txtimeout, CS89x0_TXTIMEOUT, cs89x0_txtimeout, 1, (uint32_t)cs89x0); return OK; } @@ -364,10 +366,10 @@ static int cs89x0_uiptxpoll(struct uip_driver_s *dev) * ****************************************************************************/ -static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16 isq) +static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16_t isq) { - uint16 *dest; - uint16 rxlength; + uint16_t *dest; + uint16_t rxlength; int nbytes; /* Check for errors and update statistics */ @@ -415,8 +417,8 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16 isq) * amount of data in cs89x0->cs_dev.d_len */ - dest = (uint16*)cs89x0->cs_dev.d_buf; - for (nbytes = 0; nbytes < rxlength; nbytes += sizeof(uint16)) + dest = (uint16_t*)cs89x0->cs_dev.d_buf; + for (nbytes = 0; nbytes < rxlength; nbytes += sizeof(uint16_t)) { *dest++ = cs89x0_getreg(PPR_RXFRAMELOCATION); } @@ -476,7 +478,7 @@ static void cs89x0_receive(struct cs89x0_driver_s *cs89x0, uint16 isq) * ****************************************************************************/ -static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16 isq) +static void cs89x0_txdone(struct cs89x0_driver_s *cs89x0, uint16_t isq) { /* Check for errors and update statistics. The lower 6-bits of the ISQ * hold the register address causing the interrupt. We got here because @@ -569,7 +571,7 @@ static inline FAR struct cs89x0_driver_s *cs89x0_mapirq(int irq) static int cs89x0_interrupt(int irq, FAR void *context) { register struct cs89x0_driver_s *cs89x0 = s89x0_mapirq(irq); - uint16 isq; + uint16_t isq; #ifdef CONFIG_DEBUG if (!cs89x0) @@ -645,7 +647,7 @@ static int cs89x0_interrupt(int irq, FAR void *context) * ****************************************************************************/ -static void cs89x0_txtimeout(int argc, uint32 arg, ...) +static void cs89x0_txtimeout(int argc, uint32_t arg, ...) { struct cs89x0_driver_s *cs89x0 = (struct cs89x0_driver_s *)arg; @@ -677,7 +679,7 @@ static void cs89x0_txtimeout(int argc, uint32 arg, ...) * ****************************************************************************/ -static void cs89x0_polltimer(int argc, uint32 arg, ...) +static void cs89x0_polltimer(int argc, uint32_t arg, ...) { struct cs89x0_driver_s *cs89x0 = (struct cs89x0_driver_s *)arg; @@ -723,11 +725,11 @@ static int cs89x0_ifup(struct uip_driver_s *dev) /* Set and activate a timer process */ - (void)wd_start(cs89x0->cs_txpoll, CS89x0_WDDELAY, cs89x0_polltimer, 1, (uint32)cs89x0); + (void)wd_start(cs89x0->cs_txpoll, CS89x0_WDDELAY, cs89x0_polltimer, 1, (uint32_t)cs89x0); /* Enable the Ethernet interrupt */ - cs89x0->cs_bifup = TRUE; + cs89x0->cs_bifup = true; up_enable_irq(CONFIG_CS89x0_IRQ); return OK; } @@ -765,7 +767,7 @@ static int cs89x0_ifdown(struct uip_driver_s *dev) /* Reset the device */ - cs89x0->cs_bifup = FALSE; + cs89x0->cs_bifup = false; irqrestore(flags); return OK; } diff --git a/nuttx/drivers/net/cs89x0.h b/nuttx/drivers/net/cs89x0.h index 2ea664db4..c2073eb98 100755 --- a/nuttx/drivers/net/cs89x0.h +++ b/nuttx/drivers/net/cs89x0.h @@ -40,8 +40,6 @@ * Included Files
****************************************************************************/
-#include <sys/types.h>
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
diff --git a/nuttx/drivers/net/dm90x0.c b/nuttx/drivers/net/dm90x0.c index 27c4e31cc..bc55536ec 100644 --- a/nuttx/drivers/net/dm90x0.c +++ b/nuttx/drivers/net/dm90x0.c @@ -52,6 +52,8 @@ #undef CONFIG_DM9X_NINTERFACES #define CONFIG_DM9X_NINTERFACES 1 +#include <stdint.h> +#include <stdbool.h> #include <time.h> #include <string.h> #include <debug.h> @@ -237,14 +239,14 @@ */ #if defined(CONFIG_DM9X_BUSWIDTH8) -# define DM9X_INDEX *(volatile uint8*)(CONFIG_DM9X_BASE) -# define DM9X_DATA *(volatile uint8*)(CONFIG_DM9X_BASE + 2) +# define DM9X_INDEX *(volatile uint8_t*)(CONFIG_DM9X_BASE) +# define DM9X_DATA *(volatile uint8_t*)(CONFIG_DM9X_BASE + 2) #elif defined(CONFIG_DM9X_BUSWIDTH16) -# define DM9X_INDEX *(volatile uint16*)(CONFIG_DM9X_BASE) -# define DM9X_DATA *(volatile uint16*)(CONFIG_DM9X_BASE + 2) +# define DM9X_INDEX *(volatile uint16_t*)(CONFIG_DM9X_BASE) +# define DM9X_DATA *(volatile uint16_t*)(CONFIG_DM9X_BASE + 2) #elif defined(CONFIG_DM9X_BUSWIDTH32) -# define DM9X_INDEX *(volatile uint32*)(CONFIG_DM9X_BASE) -# define DM9X_DATA *(volatile uint32*)(CONFIG_DM9X_BASE + 2) +# define DM9X_INDEX *(volatile uint32_t*)(CONFIG_DM9X_BASE) +# define DM9X_DATA *(volatile uint32_t*)(CONFIG_DM9X_BASE + 2) #endif /* Phy operating mode. Default is AUTO, but this setting can be overridden @@ -285,7 +287,7 @@ union rx_desc_u { uint8 rx_byte; uint8 rx_status; - uint16 rx_len; + uint16_t rx_len; } desc; }; @@ -295,12 +297,12 @@ union rx_desc_u struct dm9x_driver_s { - boolean dm_bifup; /* TRUE:ifup FALSE:ifdown */ - boolean dm_b100M; /* TRUE:speed == 100M; FALSE:speed == 10M */ + bool dm_bifup; /* true:ifup false:ifdown */ + bool dm_b100M; /* true:speed == 100M; false:speed == 10M */ WDOG_ID dm_txpoll; /* TX poll timer */ WDOG_ID dm_txtimeout; /* TX timeout timer */ - uint8 dm_ntxpending; /* Count of packets pending transmission */ - uint8 ncrxpackets; /* Number of continuous rx packets */ + uint8_t dm_ntxpending; /* Count of packets pending transmission */ + uint8_t ncrxpackets; /* Number of continuous rx packets */ /* Mode-dependent function to move data in 8/16/32 I/O modes */ @@ -309,17 +311,17 @@ struct dm9x_driver_s void (*dm_discard)(int len); #if defined(CONFIG_DM9X_STATS) - uint32 dm_ntxpackets; /* Count of packets sent */ - uint32 dm_ntxbytes; /* Count of bytes sent */ - uint32 dm_ntxerrors; /* Count of TX errors */ - uint32 dm_nrxpackets; /* Count of packets received */ - uint32 dm_nrxbytes; /* Count of bytes received */ - uint32 dm_nrxfifoerrors; /* Count of RX FIFO overflow errors */ - uint32 dm_nrxcrcerrors; /* Count of RX CRC errors */ - uint32 dm_nrxlengtherrors; /* Count of RX length errors */ - uint32 dm_nphyserrors; /* Count of physical layer errors */ - uint32 dm_nresets; /* Counts number of resets */ - uint32 dm_ntxtimeouts; /* Counts resets caused by TX timeouts */ + uint32_t dm_ntxpackets; /* Count of packets sent */ + uint32_t dm_ntxbytes; /* Count of bytes sent */ + uint32_t dm_ntxerrors; /* Count of TX errors */ + uint32_t dm_nrxpackets; /* Count of packets received */ + uint32_t dm_nrxbytes; /* Count of bytes received */ + uint32_t dm_nrxfifoerrors; /* Count of RX FIFO overflow errors */ + uint32_t dm_nrxcrcerrors; /* Count of RX CRC errors */ + uint32_t dm_nrxlengtherrors; /* Count of RX length errors */ + uint32_t dm_nphyserrors; /* Count of physical layer errors */ + uint32_t dm_nresets; /* Counts number of resets */ + uint32_t dm_ntxtimeouts; /* Counts resets caused by TX timeouts */ #endif /* This holds the information visible to uIP/NuttX */ @@ -353,9 +355,9 @@ static void write8(const uint8 *ptr, int len); static void write16(const uint8 *ptr, int len); static void write32(const uint8 *ptr, int len); -/* static uint16 dm9x_readsrom(struct dm9x_driver_s *dm9x, int offset); */ -static uint16 dm9x_phyread(struct dm9x_driver_s *dm9x, int reg); -static void dm9x_phywrite(struct dm9x_driver_s *dm9x, int reg, uint16 value); +/* static uint16_t dm9x_readsrom(struct dm9x_driver_s *dm9x, int offset); */ +static uint16_t dm9x_phyread(struct dm9x_driver_s *dm9x, int reg); +static void dm9x_phywrite(struct dm9x_driver_s *dm9x, int reg, uint16_t value); #if defined(CONFIG_DM9X_STATS) static void dm9x_resetstatistics(struct dm9x_driver_s *dm9x); @@ -370,7 +372,7 @@ static void dm9x_dumpstatistics(struct dm9x_driver_s *dm9x); #endif #if defined(CONFIG_DM9X_CHECKSUM) -static boolean dm9x_rxchecksumready(uint8); +static bool dm9x_rxchecksumready(uint8_t); #else # define dm9x_rxchecksumready(a) ((a) == 0x01) #endif @@ -388,8 +390,8 @@ static int dm9x_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static void dm9x_polltimer(int argc, uint32 arg, ...); -static void dm9x_txtimeout(int argc, uint32 arg, ...); +static void dm9x_polltimer(int argc, uint32_t arg, ...); +static void dm9x_txtimeout(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -463,9 +465,9 @@ static void read8(uint8 *ptr, int len) static void read16(uint8 *ptr, int len) { - register uint16 *ptr16 = (uint16*)ptr; + register uint16_t *ptr16 = (uint16_t*)ptr; nvdbg("Read %d bytes (16-bit mode)\n", len); - for (; len > 0; len -= sizeof(uint16)) + for (; len > 0; len -= sizeof(uint16_t)) { *ptr16++ = DM9X_DATA; } @@ -473,9 +475,9 @@ static void read16(uint8 *ptr, int len) static void read32(uint8 *ptr, int len) { - register uint32 *ptr32 = (uint32*)ptr; + register uint32_t *ptr32 = (uint32_t*)ptr; nvdbg("Read %d bytes (32-bit mode)\n", len); - for (; len > 0; len -= sizeof(uint32)) + for (; len > 0; len -= sizeof(uint32_t)) { *ptr32++ = DM9X_DATA; } @@ -510,7 +512,7 @@ static void discard8(int len) static void discard16(int len) { nvdbg("Discard %d bytes (16-bit mode)\n", len); - for (; len > 0; len -= sizeof(uint16)) + for (; len > 0; len -= sizeof(uint16_t)) { DM9X_DATA; } @@ -519,7 +521,7 @@ static void discard16(int len) static void discard32(int len) { nvdbg("Discard %d bytes (32-bit mode)\n", len); - for (; len > 0; len -= sizeof(uint32)) + for (; len > 0; len -= sizeof(uint32_t)) { DM9X_DATA; } @@ -553,10 +555,10 @@ static void write8(const uint8 *ptr, int len) static void write16(const uint8 *ptr, int len) { - register uint16 *ptr16 = (uint16*)ptr; + register uint16_t *ptr16 = (uint16_t*)ptr; nvdbg("Write %d bytes (16-bit mode)\n", len); - for (; len > 0; len -= sizeof(uint16)) + for (; len > 0; len -= sizeof(uint16_t)) { DM9X_DATA = *ptr16++; } @@ -564,9 +566,9 @@ static void write16(const uint8 *ptr, int len) static void write32(const uint8 *ptr, int len) { - register uint32 *ptr32 = (uint32*)ptr; + register uint32_t *ptr32 = (uint32_t*)ptr; nvdbg("Write %d bytes (32-bit mode)\n", len); - for (; len > 0; len -= sizeof(uint32)) + for (; len > 0; len -= sizeof(uint32_t)) { DM9X_DATA = *ptr32++; } @@ -590,7 +592,7 @@ static void write32(const uint8 *ptr, int len) ****************************************************************************/ #if 0 /* Not used */ -static uint16 dm9x_readsrom(struct dm9x_driver_s *dm9x, int offset) +static uint16_t dm9x_readsrom(struct dm9x_driver_s *dm9x, int offset) { putreg(DM9X_EEPHYA, offset); putreg(DM9X_EEPHYC, DM9X_EEPHYC_ERPRR); @@ -618,7 +620,7 @@ static uint16 dm9x_readsrom(struct dm9x_driver_s *dm9x, int offset) * ****************************************************************************/ -static uint16 dm9x_phyread(struct dm9x_driver_s *dm9x, int reg) +static uint16_t dm9x_phyread(struct dm9x_driver_s *dm9x, int reg) { /* Setup DM9X_EEPHYA, the EEPROM/PHY address register */ @@ -632,10 +634,10 @@ static uint16 dm9x_phyread(struct dm9x_driver_s *dm9x, int reg) /* Return the data from the EEPROM/PHY data register pair */ - return (((uint16)getreg(DM9X_EEPHYDH)) << 8) | (uint16)getreg(DM9X_EEPHYDL); + return (((uint16_t)getreg(DM9X_EEPHYDH)) << 8) | (uint16_t)getreg(DM9X_EEPHYDL); } -static void dm9x_phywrite(struct dm9x_driver_s *dm9x, int reg, uint16 value) +static void dm9x_phywrite(struct dm9x_driver_s *dm9x, int reg, uint16_t value) { /* Setup DM9X_EEPHYA, the EEPROM/PHY address register */ @@ -723,24 +725,24 @@ static void dm9x_dumpstatistics(struct dm9x_driver_s *dm9x) * Function: dm9x_rxchecksumready * * Description: - * Return TRUE if the RX checksum is available + * Return true if the RX checksum is available * * Parameters: * rxbyte * * Returned Value: - * TRUE: checksum is ready + * true: checksum is ready * * Assumptions: * ****************************************************************************/ #if defined(CONFIG_DM9X_CHECKSUM) -static inline boolean dm9x_rxchecksumready(uint8 rxbyte) +static inline bool dm9x_rxchecksumready(uint8 rxbyte) { if ((rxbyte & 0x01) == 0) { - return FALSE; + return false; } return ((rxbyte >> 4) | 0x01) != 0; @@ -810,7 +812,7 @@ static int dm9x_transmit(struct dm9x_driver_s *dm9x) /* Setup the TX timeout watchdog (perhaps restarting the timer) */ - (void)wd_start(dm9x->dm_txtimeout, DM6X_TXTIMEOUT, dm9x_txtimeout, 1, (uint32)dm9x); + (void)wd_start(dm9x->dm_txtimeout, DM6X_TXTIMEOUT, dm9x_txtimeout, 1, (uint32_t)dm9x); return OK; } return -EBUSY; @@ -888,10 +890,10 @@ static int dm9x_uiptxpoll(struct uip_driver_s *dev) static void dm9x_receive(struct dm9x_driver_s *dm9x) { union rx_desc_u rx; - boolean bchecksumready; - uint8 mdrah; - uint8 mdral; - uint8 rxbyte; + bool bchecksumready; + uint8_t mdrah; + uint8_t mdral; + uint8_t rxbyte; nvdbg("Packet received\n"); @@ -903,7 +905,7 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x) mdral = getreg(DM9X_MDRAL); getreg(DM9X_MRCMDX); /* Dummy read */ - rxbyte = (uint8)DM9X_DATA; /* Get the most up-to-date data */ + rxbyte = (uint8_t)DM9X_DATA; /* Get the most up-to-date data */ /* Packet ready for receive check */ @@ -919,7 +921,7 @@ static void dm9x_receive(struct dm9x_driver_s *dm9x) /* Read packet status & length */ - dm9x->dm_read((uint8*)&rx, 4); + dm9x->dm_read((uint8_t*)&rx, 4); /* Check if any errors were reported by the hardware */ @@ -1117,7 +1119,7 @@ static int dm9x_interrupt(int irq, FAR void *context) /* Save previous register address */ - save = (uint8)DM9X_INDEX; + save = (uint8_t)DM9X_INDEX; /* Disable all DM90x0 interrupts */ @@ -1151,11 +1153,11 @@ static int dm9x_interrupt(int irq, FAR void *context) if (dm9x_phyread(dm9x, 0) & 0x2000) { - dm9x->dm_b100M = TRUE; + dm9x->dm_b100M = true; } else { - dm9x->dm_b100M = FALSE; + dm9x->dm_b100M = false; } break; } @@ -1219,7 +1221,7 @@ static int dm9x_interrupt(int irq, FAR void *context) * ****************************************************************************/ -static void dm9x_txtimeout(int argc, uint32 arg, ...) +static void dm9x_txtimeout(int argc, uint32_t arg, ...) { struct dm9x_driver_s *dm9x = (struct dm9x_driver_s *)arg; @@ -1267,7 +1269,7 @@ static void dm9x_txtimeout(int argc, uint32 arg, ...) * ****************************************************************************/ -static void dm9x_polltimer(int argc, uint32 arg, ...) +static void dm9x_polltimer(int argc, uint32_t arg, ...) { struct dm9x_driver_s *dm9x = (struct dm9x_driver_s *)arg; @@ -1315,8 +1317,8 @@ static void dm9x_polltimer(int argc, uint32 arg, ...) static inline void dm9x_phymode(struct dm9x_driver_s *dm9x) { - uint16 phyreg0; - uint16 phyreg4; + uint16_t phyreg0; + uint16_t phyreg4; #if CONFIG_DM9X_MODE == DM9X_MODE_AUTO phyreg0 = 0x1200; /* Auto-negotiation & Restart Auto-negotiation */ @@ -1374,7 +1376,7 @@ static int dm9x_ifup(struct uip_driver_s *dev) /* Check link state and media speed (waiting up to 3s for link OK) */ - dm9x->dm_b100M = FALSE; + dm9x->dm_b100M = false; for (i = 0; i < 3000; i++) { netstatus = getreg(DM9X_NETS); @@ -1386,7 +1388,7 @@ static int dm9x_ifup(struct uip_driver_s *dev) netstatus = getreg(DM9X_NETS); if ((netstatus & DM9X_NETS_SPEED) == 0) { - dm9x->dm_b100M = TRUE; + dm9x->dm_b100M = true; } break; } @@ -1398,11 +1400,11 @@ static int dm9x_ifup(struct uip_driver_s *dev) /* Set and activate a timer process */ - (void)wd_start(dm9x->dm_txpoll, DM6X_WDDELAY, dm9x_polltimer, 1, (uint32)dm9x); + (void)wd_start(dm9x->dm_txpoll, DM6X_WDDELAY, dm9x_polltimer, 1, (uint32_t)dm9x); /* Enable the DM9X interrupt */ - dm9x->dm_bifup = TRUE; + dm9x->dm_bifup = true; up_enable_irq(CONFIG_DM9X_IRQ); return OK; } @@ -1448,7 +1450,7 @@ static int dm9x_ifdown(struct uip_driver_s *dev) putreg(DM9X_RXC, 0x00); /* Disable RX */ putreg(DM9X_ISR, DM9X_INT_ALL); /* Clear interrupt status */ - dm9x->dm_bifup = FALSE; + dm9x->dm_bifup = false; irqrestore(flags); /* Dump statistics */ @@ -1629,7 +1631,7 @@ static void dm9x_reset(struct dm9x_driver_s *dm9x) /* Save previous register address */ - save = (uint8)DM9X_INDEX; + save = (uint8_t)DM9X_INDEX; #if defined(CONFIG_DM9X_STATS) dm9x->dm_nresets++; @@ -1638,14 +1640,14 @@ static void dm9x_reset(struct dm9x_driver_s *dm9x) /* Wait up to 1 second for the link to be OK */ - dm9x->dm_b100M = FALSE; + dm9x->dm_b100M = false; for (i = 0; i < 1000; i++) { if (dm9x_phyread(dm9x,0x1) & 0x4) { if (dm9x_phyread(dm9x, 0) &0x2000) { - dm9x->dm_b100M = TRUE; + dm9x->dm_b100M = true; } break; } @@ -1682,15 +1684,15 @@ static void dm9x_reset(struct dm9x_driver_s *dm9x) int dm9x_initialize(void) { uint8 *mptr; - uint16 vid; - uint16 pid; + uint16_t vid; + uint16_t pid; int i; int j; /* Get the chip vendor ID and product ID */ - vid = (((uint16)getreg(DM9X_VIDH)) << 8) | (uint16)getreg(DM9X_VIDL); - pid = (((uint16)getreg(DM9X_PIDH)) << 8) | (uint16)getreg(DM9X_PIDL); + vid = (((uint16_t)getreg(DM9X_VIDH)) << 8) | (uint16_t)getreg(DM9X_VIDL); + pid = (((uint16_t)getreg(DM9X_PIDH)) << 8) | (uint16_t)getreg(DM9X_PIDL); nlldbg("I/O base: %08x VID: %04x PID: %04x\n", CONFIG_DM9X_BASE, vid, pid); /* Check if a DM90x0 chip is recognized at this I/O base */ diff --git a/nuttx/drivers/net/skeleton.c b/nuttx/drivers/net/skeleton.c index 5a47de221..e5085ebb7 100644 --- a/nuttx/drivers/net/skeleton.c +++ b/nuttx/drivers/net/skeleton.c @@ -40,6 +40,8 @@ #include <nuttx/config.h> #if defined(CONFIG_NET) && defined(CONFIG_skeleton_NET) +#include <stdint.h> +#include <stdbool.h> #include <time.h> #include <string.h> #include <debug.h> @@ -88,7 +90,7 @@ struct skel_driver_s { - boolean sk_bifup; /* TRUE:ifup FALSE:ifdown */ + bool sk_bifup; /* true:ifup false:ifdown */ WDOG_ID sk_txpoll; /* TX poll timer */ WDOG_ID sk_txtimeout; /* TX timeout timer */ @@ -120,8 +122,8 @@ static int skel_interrupt(int irq, FAR void *context); /* Watchdog timer expirations */ -static void skel_polltimer(int argc, uint32 arg, ...); -static void skel_txtimeout(int argc, uint32 arg, ...); +static void skel_polltimer(int argc, uint32_t arg, ...); +static void skel_txtimeout(int argc, uint32_t arg, ...); /* NuttX callback functions */ @@ -164,7 +166,7 @@ static int skel_transmit(struct skel_driver_s *skel) /* Setup the TX timeout watchdog (perhaps restarting the timer) */ - (void)wd_start(skel->sk_txtimeout, skeleton_TXTIMEOUT, skel_txtimeout, 1, (uint32)skel); + (void)wd_start(skel->sk_txtimeout, skeleton_TXTIMEOUT, skel_txtimeout, 1, (uint32_t)skel); return OK; } @@ -370,7 +372,7 @@ static int skel_interrupt(int irq, FAR void *context) * ****************************************************************************/ -static void skel_txtimeout(int argc, uint32 arg, ...) +static void skel_txtimeout(int argc, uint32_t arg, ...) { struct skel_driver_s *skel = (struct skel_driver_s *)arg; @@ -400,7 +402,7 @@ static void skel_txtimeout(int argc, uint32 arg, ...) * ****************************************************************************/ -static void skel_polltimer(int argc, uint32 arg, ...) +static void skel_polltimer(int argc, uint32_t arg, ...) { struct skel_driver_s *skel = (struct skel_driver_s *)arg; @@ -444,11 +446,11 @@ static int skel_ifup(struct uip_driver_s *dev) /* Set and activate a timer process */ - (void)wd_start(skel->sk_txpoll, skeleton_WDDELAY, skel_polltimer, 1, (uint32)skel); + (void)wd_start(skel->sk_txpoll, skeleton_WDDELAY, skel_polltimer, 1, (uint32_t)skel); /* Enable the Ethernet interrupt */ - skel->sk_bifup = TRUE; + skel->sk_bifup = true; up_enable_irq(CONFIG_skeleton_IRQ); return OK; } @@ -486,7 +488,7 @@ static int skel_ifdown(struct uip_driver_s *dev) /* Reset the device */ - skel->sk_bifup = FALSE; + skel->sk_bifup = false; irqrestore(flags); return OK; } diff --git a/nuttx/drivers/pipes/fifo.c b/nuttx/drivers/pipes/fifo.c index bc9f629f5..9e663b4a8 100644 --- a/nuttx/drivers/pipes/fifo.c +++ b/nuttx/drivers/pipes/fifo.c @@ -34,16 +34,13 @@ ****************************************************************************/ /**************************************************************************** - * Compilation Switches - ****************************************************************************/ - -/**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> #include <nuttx/fs.h> #include <errno.h> @@ -52,7 +49,7 @@ #if CONFIG_DEV_PIPE_SIZE > 0 /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nuttx/drivers/pipes/pipe.c b/nuttx/drivers/pipes/pipe.c index 95049b354..541f3bda4 100644 --- a/nuttx/drivers/pipes/pipe.c +++ b/nuttx/drivers/pipes/pipe.c @@ -88,9 +88,9 @@ static const struct file_operations pipe_fops = #endif }; -static sem_t g_pipesem = { 1 }; -static uint32 g_pipeset = 0; -static uint32 g_pipecreated = 0; +static sem_t g_pipesem = { 1 }; +static uint32_t g_pipeset = 0; +static uint32_t g_pipecreated = 0; /**************************************************************************** * Private Functions diff --git a/nuttx/drivers/pipes/pipe_common.c b/nuttx/drivers/pipes/pipe_common.c index 60d028c00..e22678688 100644 --- a/nuttx/drivers/pipes/pipe_common.c +++ b/nuttx/drivers/pipes/pipe_common.c @@ -38,9 +38,11 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <sys/types.h> #include <sys/stat.h> +#include <stdint.h> +#include <stdbool.h> #include <stdlib.h> #include <string.h> #include <sched.h> @@ -198,7 +200,7 @@ int pipecommon_open(FAR struct file *filep) if (dev->d_refs == 0) { - dev->d_buffer = (ubyte*)malloc(CONFIG_DEV_PIPE_SIZE); + dev->d_buffer = (uint8_t*)malloc(CONFIG_DEV_PIPE_SIZE); if (!dev->d_buffer) { (void)sem_post(&dev->d_bfsem); @@ -330,7 +332,7 @@ ssize_t pipecommon_read(FAR struct file *filep, FAR char *buffer, size_t len) struct inode *inode = filep->f_inode; struct pipe_dev_s *dev = inode->i_private; #ifdef CONFIG_DEV_PIPEDUMP - FAR ubyte *start = (ubyte*)buffer; + FAR uint8_t *start = (uint8_t*)buffer; #endif ssize_t nread = 0; int sval; @@ -434,7 +436,7 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, size_t return -ENODEV; } #endif - pipe_dumpbuffer("To PIPE:", (ubyte*)buffer, len); + pipe_dumpbuffer("To PIPE:", (uint8_t*)buffer, len); /* At present, this method cannot be called from interrupt handlers. That is * because it calls sem_wait (via pipecommon_semtake below) and sem_wait cannot @@ -448,7 +450,7 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, size_t * of taking semaphores so that pipes can be written from interupt handlers */ - DEBUGASSERT(up_interrupt_context() == FALSE) + DEBUGASSERT(up_interrupt_context() == false) /* Make sure that we have exclusive access to the device structure */ @@ -544,7 +546,7 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, size_t #ifndef CONFIG_DISABLE_POLL int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds, - boolean setup) + bool setup) { FAR struct inode *inode = filep->f_inode; FAR struct pipe_dev_s *dev = inode->i_private; diff --git a/nuttx/drivers/pipes/pipe_common.h b/nuttx/drivers/pipes/pipe_common.h index cf0d92742..16bf285b5 100644 --- a/nuttx/drivers/pipes/pipe_common.h +++ b/nuttx/drivers/pipes/pipe_common.h @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/pipe/pipe_common.h * - * Copyright (C) 2008i-2009 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 @@ -44,6 +44,7 @@ #include <sys/types.h> #include <stdint.h> +#include <stdbool.h> #include <poll.h> #ifndef CONFIG_DEV_PIPE_SIZE @@ -53,7 +54,7 @@ #if CONFIG_DEV_PIPE_SIZE > 0 /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Maximum number of threads than can be waiting for POLL events */ @@ -126,7 +127,7 @@ EXTERN ssize_t pipecommon_read(FAR struct file *, FAR char *, size_t); EXTERN ssize_t pipecommon_write(FAR struct file *, FAR const char *, size_t); #ifndef CONFIG_DISABLE_POLL EXTERN int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds, - boolean setup); + bool setup); #endif #undef EXTERN diff --git a/nuttx/drivers/ramdisk.c b/nuttx/drivers/ramdisk.c index 1c44589ad..e424459d4 100644 --- a/nuttx/drivers/ramdisk.c +++ b/nuttx/drivers/ramdisk.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/ramdisk.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 @@ -41,6 +41,8 @@ #include <sys/types.h> #include <sys/ioctl.h> +#include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -60,13 +62,13 @@ struct rd_struct_s { - uint32 rd_nsectors; /* Number of sectors on device */ - uint16 rd_sectsize; /* The size of one sector */ + uint32_t rd_nsectors; /* Number of sectors on device */ + uint16_t rd_sectsize; /* The size of one sector */ #ifdef CONFIG_FS_WRITABLE - boolean rd_writeenabled; /* TRUE: can write to ram disk */ - ubyte *rd_buffer; /* RAM disk backup memory */ + bool rd_writeenabled; /* true: can write to ram disk */ + uint8_t *rd_buffer; /* RAM disk backup memory */ #else - const ubyte *rd_buffer; /* ROM disk backup memory */ + const uint8_t *rd_buffer; /* ROM disk backup memory */ #endif }; @@ -218,18 +220,18 @@ static int rd_geometry(FAR struct inode *inode, struct geometry *geometry) if (geometry) { dev = (struct rd_struct_s *)inode->i_private; - geometry->geo_available = TRUE; - geometry->geo_mediachanged = FALSE; + geometry->geo_available = true; + geometry->geo_mediachanged = false; #ifdef CONFIG_FS_WRITABLE geometry->geo_writeenabled = dev->rd_writeenabled; #else - geometry->geo_writeenabled = FALSE; + geometry->geo_writeenabled = false; #endif geometry->geo_nsectors = dev->rd_nsectors; geometry->geo_sectorsize = dev->rd_sectsize; - fvdbg("available: TRUE mediachanged: FALSE writeenabled: %s\n", - geometry->geo_writeenabled ? "TRUE" : "FALSE"); + fvdbg("available: true mediachanged: false writeenabled: %s\n", + geometry->geo_writeenabled ? "true" : "false"); fvdbg("nsectors: %d sectorsize: %d\n", geometry->geo_nsectors, geometry->geo_sectorsize); @@ -279,10 +281,11 @@ static int rd_ioctl(FAR struct inode *inode, int cmd, unsigned long arg) ****************************************************************************/ #ifdef CONFIG_FS_WRITABLE -int ramdisk_register(int minor, ubyte *buffer, uint32 nsectors, uint16 sectsize, - boolean writeenabled) +int ramdisk_register(int minor, uint8_t *buffer, uint32_t nsectors, + uint16_t sectsize, bool writeenabled) #else -int romdisk_register(int minor, ubyte *buffer, uint32 nsectors, uint16 sectsize) +int romdisk_register(int minor, uint8_t *buffer, uint32_t nsectors, + uint16_t sectsize) #endif { struct rd_struct_s *dev; @@ -310,7 +313,7 @@ int romdisk_register(int minor, ubyte *buffer, uint32 nsectors, uint16 sectsize) dev->rd_nsectors = nsectors; /* Number of sectors on device */ dev->rd_sectsize = sectsize; /* The size of one sector */ #ifdef CONFIG_FS_WRITABLE - dev->rd_writeenabled = writeenabled; /* TRUE: can write to ram disk */ + dev->rd_writeenabled = writeenabled; /* true: can write to ram disk */ #endif dev->rd_buffer = buffer; /* RAM disk backup memory */ diff --git a/nuttx/drivers/rwbuffer.c b/nuttx/drivers/rwbuffer.c index 2d78f75ae..91ab7785f 100644 --- a/nuttx/drivers/rwbuffer.c +++ b/nuttx/drivers/rwbuffer.c @@ -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 <time.h> @@ -111,8 +113,8 @@ static void rwb_semtake(sem_t *sem) * Name: rwb_overlap ****************************************************************************/ -static inline boolean rwb_overlap(off_t blockstart1, size_t nblocks1, - off_t blockstart2, size_t nblocks2) +static inline bool rwb_overlap(off_t blockstart1, size_t nblocks1, + off_t blockstart2, size_t nblocks2) { off_t blockend1 = blockstart1 + nblocks1; off_t blockend2 = blockstart2 + nblocks2; @@ -122,11 +124,11 @@ static inline boolean rwb_overlap(off_t blockstart1, size_t nblocks1, if ((blockend1 < blockstart2) || /* Wholly "below" */ (blockstart1 > blockend2)) /* Wholly "above" */ { - return FALSE; + return false; } else { - return TRUE; + return true; } } @@ -228,8 +230,8 @@ static inline void rwb_wrcanceltimeout(struct rwbuffer_s *rwb) #ifdef CONFIG_FS_WRITEBUFFER static ssize_t rwb_writebuffer(FAR struct rwbuffer_s *rwb, - off_t startblock, uint32 nblocks, - FAR const ubyte *wrbuffer) + off_t startblock, uint32_t nblocks, + FAR const uint8_t *wrbuffer) { int ret; @@ -304,7 +306,7 @@ static inline void rwb_resetrhbuffer(struct rwbuffer_s *rwb) #ifdef CONFIG_FS_READAHEAD static inline void rwb_bufferread(struct rwbuffer_s *rwb, off_t startblock, - size_t nblocks, ubyte **rdbuffer) + size_t nblocks, uint8_t **rdbuffer) { /* We assume that (1) the caller holds the readAheadBufferSemphore, and (2) * that the caller already knows that all of the blocks are in the @@ -319,7 +321,7 @@ rwb_bufferread(struct rwbuffer_s *rwb, off_t startblock, /* Get the byte address in the read-ahead buffer */ - ubyte *rhbuffer = rwb->rhbuffer + byteoffset; + uint8_t *rhbuffer = rwb->rhbuffer + byteoffset; /* Copy the data from the read-ahead buffer into the IO buffer */ @@ -386,7 +388,7 @@ static int rwb_rhreload(struct rwbuffer_s *rwb, off_t startblock) int rwb_initialize(FAR struct rwbuffer_s *rwb) { - uint32 allocsize; + uint32_t allocsize; /* Sanity checking */ @@ -492,10 +494,10 @@ void rwb_uninitialize(FAR struct rwbuffer_s *rwb) * Name: rwb_read ****************************************************************************/ -int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32 nblocks, - FAR ubyte *rdbuffer) +int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32_t nblocks, + FAR uint8_t *rdbuffer) { - uint32 remaining; + uint32_t remaining; fvdbg("startblock=%ld nblocks=%ld rdbuffer=%p\n", (long)startblock, (long)nblocks, rdbuffer); @@ -593,7 +595,7 @@ int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32 nblocks, ****************************************************************************/ int rwb_write(FAR struct rwbuffer_s *rwb, off_t startblock, - size_t nblocks, FAR const ubyte *wrbuffer) + size_t nblocks, FAR const uint8_t *wrbuffer) { int ret; diff --git a/nuttx/drivers/serial/serial.c b/nuttx/drivers/serial/serial.c index 5675f1791..3fa3b43d3 100644 --- a/nuttx/drivers/serial/serial.c +++ b/nuttx/drivers/serial/serial.c @@ -40,6 +40,8 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <unistd.h> #include <semaphore.h> #include <string.h> @@ -82,7 +84,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg); #ifndef CONFIG_DISABLE_POLL -static int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup); +static int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup); #endif /************************************************************************************ @@ -179,7 +181,7 @@ static void uart_putxmitchar(FAR uart_dev_t *dev, int ch) { /* Inform the interrupt level logic that we are waiting */ - dev->xmitwaiting = TRUE; + dev->xmitwaiting = true; /* Wait for some characters to be sent from the buffer * with the TX interrupt enabled. When the TX interrupt @@ -374,7 +376,7 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen * with the TX interrupt re-enabled. */ - dev->recvwaiting = TRUE; + dev->recvwaiting = true; uart_enablerxint(dev); uart_takesem(&dev->recvsem); uart_disablerxint(dev); @@ -403,7 +405,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) ****************************************************************************/ #ifndef CONFIG_DISABLE_POLL -int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, boolean setup) +int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) { FAR struct inode *inode = filep->f_inode; FAR uart_dev_t *dev = inode->i_private; @@ -589,7 +591,7 @@ static int uart_open(FAR struct file *filep) { struct inode *inode = filep->f_inode; uart_dev_t *dev = inode->i_private; - ubyte tmp; + uint8_t tmp; int ret = OK; /* If the port is the middle of closing, wait until the close is finished */ @@ -602,7 +604,7 @@ static int uart_open(FAR struct file *filep) tmp = dev->open_count + 1; if (tmp == 0) { - /* More than 255 opens; ubyte overflows to zero */ + /* More than 255 opens; uint8_t overflows to zero */ ret = -EMFILE; goto errout_with_sem; @@ -707,7 +709,7 @@ void uart_datareceived(FAR uart_dev_t *dev) if (dev->recvwaiting) { - dev->recvwaiting = FALSE; + dev->recvwaiting = false; (void)sem_post(&dev->recvsem); } @@ -732,7 +734,7 @@ void uart_datasent(FAR uart_dev_t *dev) { if (dev->xmitwaiting) { - dev->xmitwaiting = FALSE; + dev->xmitwaiting = false; (void)sem_post(&dev->xmitsem); } diff --git a/nuttx/drivers/serial/serialirq.c b/nuttx/drivers/serial/serialirq.c index a4ce80944..bc79adc47 100644 --- a/nuttx/drivers/serial/serialirq.c +++ b/nuttx/drivers/serial/serialirq.c @@ -1,7 +1,7 @@ /************************************************************************************ * drivers/serial/serialirq.c * - * 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 @@ -38,13 +38,15 @@ ************************************************************************************/ #include <nuttx/config.h> + #include <sys/types.h> +#include <stdint.h> #include <semaphore.h> #include <debug.h> #include <nuttx/serial.h> /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /************************************************************************************ @@ -80,7 +82,7 @@ void uart_xmitchars(FAR uart_dev_t *dev) { - uint16 nbytes = 0; + uint16_t nbytes = 0; /* Send while we still have data & room in the fifo */ @@ -133,7 +135,7 @@ void uart_recvchars(FAR uart_dev_t *dev) { unsigned int status; int nexthead = dev->recv.head + 1; - uint16 nbytes = 0; + uint16_t nbytes = 0; if (nexthead >= dev->recv.size) { diff --git a/nuttx/drivers/usbdev/usbdev_scsi.c b/nuttx/drivers/usbdev/usbdev_scsi.c index 75c5b50d3..9ec6d6d67 100644 --- a/nuttx/drivers/usbdev/usbdev_scsi.c +++ b/nuttx/drivers/usbdev/usbdev_scsi.c @@ -56,8 +56,10 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <pthread.h> #include <string.h> #include <errno.h> @@ -73,7 +75,7 @@ #include "usbdev_storage.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -87,58 +89,59 @@ /* Debug ********************************************************************/ #if defined(CONFIG_DEBUG_VERBOSE) && defined (CONFIG_DEBUG_USB) -static void usbstrg_dumpdata(const char *msg, const ubyte *buf, int buflen); +static void usbstrg_dumpdata(const char *msg, const uint8_t *buf, + int buflen); #else # define usbstrg_dumpdata(msg, buf, len) #endif /* Utility Support Functions ************************************************/ -static uint16 usbstrg_getbe16(ubyte *buf); -static uint32 usbstrg_getbe32(ubyte *buf); -static void usbstrg_putbe16(ubyte * buf, uint16 val); -static void usbstrg_putbe24(ubyte *buf, uint32 val); -static void usbstrg_putbe32(ubyte *buf, uint32 val); +static uint16_t usbstrg_getbe16(uint8_t *buf); +static uint32_t usbstrg_getbe32(uint8_t *buf); +static void usbstrg_putbe16(uint8_t * buf, uint16_t val); +static void usbstrg_putbe24(uint8_t *buf, uint32_t val); +static void usbstrg_putbe32(uint8_t *buf, uint32_t val); #if 0 /* not used */ -static uint16 usbstrg_getle16(ubyte *buf); +static uint16_t usbstrg_getle16(uint8_t *buf); #endif -static uint32 usbstrg_getle32(ubyte *buf); +static uint32_t usbstrg_getle32(uint8_t *buf); #if 0 /* not used */ -static void usbstrg_putle16(ubyte * buf, uint16 val); +static void usbstrg_putle16(uint8_t * buf, uint16_t val); #endif -static void usbstrg_putle32(ubyte *buf, uint32 val); +static void usbstrg_putle32(uint8_t *buf, uint32_t val); /* SCSI Command Processing **************************************************/ static inline int usbstrg_cmdtestunitready(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdrequestsense(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf); + FAR uint8_t *buf); static inline int usbstrg_cmdread6(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdwrite6(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdinquiry(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf); + FAR uint8_t *buf); static inline int usbstrg_cmdmodeselect6(FAR struct usbstrg_dev_s *priv); static int usbstrg_modepage(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf, ubyte pcpgcode, int *mdlen); + FAR uint8_t *buf, uint8_t pcpgcode, int *mdlen); static inline int usbstrg_cmdmodesense6(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf); + FAR uint8_t *buf); static inline int usbstrg_cmdstartstopunit(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdpreventmediumremoval(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdreadformatcapacity(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf); + FAR uint8_t *buf); static inline int usbstrg_cmdreadcapacity10(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf); + FAR uint8_t *buf); static inline int usbstrg_cmdread10(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdwrite10(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdverify10(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdsynchronizecache10(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdmodeselect10(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdmodesense10(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf); + FAR uint8_t *buf); static inline int usbstrg_cmdread12(FAR struct usbstrg_dev_s *priv); static inline int usbstrg_cmdwrite12(FAR struct usbstrg_dev_s *priv); -static inline int usbstrg_setupcmd(FAR struct usbstrg_dev_s *priv, ubyte cdblen, - ubyte flags); +static inline int usbstrg_setupcmd(FAR struct usbstrg_dev_s *priv, + uint8_t cdblen, uint8_t flags); /* SCSI Worker Thread *******************************************************/ @@ -166,7 +169,7 @@ static int usbstrg_cmdstatusstate(FAR struct usbstrg_dev_s *priv); ****************************************************************************/ #if defined(CONFIG_DEBUG_VERBOSE) && defined (CONFIG_DEBUG_USB) -static void usbstrg_dumpdata(const char *msg, const ubyte *buf, int buflen) +static void usbstrg_dumpdata(const char *msg, const uint8_t *buf, int buflen) { int i; @@ -191,9 +194,9 @@ static void usbstrg_dumpdata(const char *msg, const ubyte *buf, int buflen) * ****************************************************************************/ -static uint16 usbstrg_getbe16(ubyte *buf) +static uint16_t usbstrg_getbe16(uint8_t *buf) { - return ((uint16)buf[0] << 8) | ((uint16)buf[1]); + return ((uint16_t)buf[0] << 8) | ((uint16_t)buf[1]); } /**************************************************************************** @@ -204,10 +207,10 @@ static uint16 usbstrg_getbe16(ubyte *buf) * ****************************************************************************/ -static uint32 usbstrg_getbe32(ubyte *buf) +static uint32_t usbstrg_getbe32(uint8_t *buf) { - return ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | - ((uint32)buf[2] << 8) | ((uint32)buf[3]); + return ((uint32_t)buf[0] << 24) | ((uint32_t)buf[1] << 16) | + ((uint32_t)buf[2] << 8) | ((uint32_t)buf[3]); } /**************************************************************************** @@ -219,7 +222,7 @@ static uint32 usbstrg_getbe32(ubyte *buf) * ****************************************************************************/ -static void usbstrg_putbe16(ubyte * buf, uint16 val) +static void usbstrg_putbe16(uint8_t * buf, uint16_t val) { buf[0] = val >> 8; buf[1] = val; @@ -234,7 +237,7 @@ static void usbstrg_putbe16(ubyte * buf, uint16 val) * ****************************************************************************/ -static void usbstrg_putbe24(ubyte *buf, uint32 val) +static void usbstrg_putbe24(uint8_t *buf, uint32_t val) { buf[0] = val >> 16; buf[1] = val >> 8; @@ -250,7 +253,7 @@ static void usbstrg_putbe24(ubyte *buf, uint32 val) * ****************************************************************************/ -static void usbstrg_putbe32(ubyte *buf, uint32 val) +static void usbstrg_putbe32(uint8_t *buf, uint32_t val) { buf[0] = val >> 24; buf[1] = val >> 16; @@ -267,9 +270,9 @@ static void usbstrg_putbe32(ubyte *buf, uint32 val) ****************************************************************************/ #if 0 /* not used */ -static uint16 usbstrg_getle16(ubyte *buf) +static uint16_t usbstrg_getle16(uint8_t *buf) { - return ((uint16)buf[1] << 8) | ((uint16)buf[0]); + return ((uint16_t)buf[1] << 8) | ((uint16_t)buf[0]); } #endif @@ -281,10 +284,10 @@ static uint16 usbstrg_getle16(ubyte *buf) * ****************************************************************************/ -static uint32 usbstrg_getle32(ubyte *buf) +static uint32_t usbstrg_getle32(uint8_t *buf) { - return ((uint32)buf[3] << 24) | ((uint32)buf[2] << 16) | - ((uint32)buf[1] << 8) | ((uint32)buf[0]); + return ((uint32_t)buf[3] << 24) | ((uint32_t)buf[2] << 16) | + ((uint32_t)buf[1] << 8) | ((uint32_t)buf[0]); } /**************************************************************************** @@ -297,7 +300,7 @@ static uint32 usbstrg_getle32(ubyte *buf) ****************************************************************************/ #if 0 /* not used */ -static void usbstrg_putle16(ubyte * buf, uint16 val) +static void usbstrg_putle16(uint8_t * buf, uint16_t val) { buf[0] = val; buf[1] = val >> 8; @@ -313,7 +316,7 @@ static void usbstrg_putle16(ubyte * buf, uint16 val) * ****************************************************************************/ -static void usbstrg_putle32(ubyte *buf, uint32 val) +static void usbstrg_putle32(uint8_t *buf, uint32_t val) { buf[0] = val; buf[1] = val >> 8; @@ -351,15 +354,15 @@ static inline int usbstrg_cmdtestunitready(FAR struct usbstrg_dev_s *priv) ****************************************************************************/ static inline int usbstrg_cmdrequestsense(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf) + FAR uint8_t *buf) { FAR struct scsicmd_requestsense_s *request = (FAR struct scsicmd_requestsense_s *)priv->cdb; FAR struct scsiresp_fixedsensedata_s *response = (FAR struct scsiresp_fixedsensedata_s *)buf; FAR struct usbstrg_lun_s *lun; - uint32 sd; - uint32 sdinfo; - ubyte cdblen; - int ret; + uint32_t sd; + uint32_t sdinfo; + uint8_t cdblen; + int ret; /* Extract the host allocation length */ @@ -406,11 +409,11 @@ static inline int usbstrg_cmdrequestsense(FAR struct usbstrg_dev_s *priv, memset(response, 0, SCSIRESP_FIXEDSENSEDATA_SIZEOF); response->code = SCSIRESP_SENSEDATA_RESPVALID|SCSIRESP_SENSEDATA_CURRENTFIXED; - response->flags = (ubyte)(sd >> 16); + response->flags = (uint8_t)(sd >> 16); usbstrg_putbe32(response->info, sdinfo); response->len = SCSIRESP_FIXEDSENSEDATA_SIZEOF - 7; - response->code2 = (ubyte)(sd >> 8); - response->qual2 = (ubyte)sd; + response->code2 = (uint8_t)(sd >> 8); + response->qual2 = (uint8_t)sd; priv->nreqbytes = SCSIRESP_FIXEDSENSEDATA_SIZEOF; ret = OK; @@ -433,7 +436,7 @@ static inline int usbstrg_cmdread6(FAR struct usbstrg_dev_s *priv) FAR struct usbstrg_lun_s *lun = priv->lun; int ret; - priv->u.xfrlen = (uint16)read6->xfrlen; + priv->u.xfrlen = (uint16_t)read6->xfrlen; if (priv->u.xfrlen == 0) { priv->u.xfrlen = 256; @@ -489,7 +492,7 @@ static inline int usbstrg_cmdwrite6(FAR struct usbstrg_dev_s *priv) FAR struct usbstrg_lun_s *lun = priv->lun; int ret; - priv->u.xfrlen = (uint16)write6->xfrlen; + priv->u.xfrlen = (uint16_t)write6->xfrlen; if (priv->u.xfrlen == 0) { priv->u.xfrlen = 256; @@ -549,7 +552,7 @@ static inline int usbstrg_cmdwrite6(FAR struct usbstrg_dev_s *priv) ****************************************************************************/ static inline int usbstrg_cmdinquiry(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf) + FAR uint8_t *buf) { FAR struct scscicmd_inquiry_s *inquiry = (FAR struct scscicmd_inquiry_s *)priv->cdb; FAR struct scsiresp_inquiry_s *response = (FAR struct scsiresp_inquiry_s *)buf; @@ -633,8 +636,8 @@ static inline int usbstrg_cmdmodeselect6(FAR struct usbstrg_dev_s *priv) * ****************************************************************************/ -static int usbstrg_modepage(FAR struct usbstrg_dev_s *priv, FAR ubyte *buf, - ubyte pcpgcode, int *mdlen) +static int usbstrg_modepage(FAR struct usbstrg_dev_s *priv, FAR uint8_t *buf, + uint8_t pcpgcode, int *mdlen) { FAR struct scsiresp_cachingmodepage_s *cmp = (FAR struct scsiresp_cachingmodepage_s *)buf; @@ -691,7 +694,7 @@ static int usbstrg_modepage(FAR struct usbstrg_dev_s *priv, FAR ubyte *buf, ****************************************************************************/ static int inline usbstrg_cmdmodesense6(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf) + FAR uint8_t *buf) { FAR struct scsicmd_modesense6_s *modesense = (FAR struct scsicmd_modesense6_s *)priv->cdb; FAR struct scsiresp_modeparameterhdr6_s *mph = (FAR struct scsiresp_modeparameterhdr6_s *)buf; @@ -809,7 +812,7 @@ static inline int usbstrg_cmdpreventmediumremoval(FAR struct usbstrg_dev_s *priv ****************************************************************************/ static inline int usbstrg_cmdreadformatcapacity(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf) + FAR uint8_t *buf) { FAR struct scsicmd_readformatcapcacities_s *rfc = (FAR struct scsicmd_readformatcapcacities_s *)priv->cdb; FAR struct scsiresp_readformatcapacities_s *hdr; @@ -843,12 +846,12 @@ static inline int usbstrg_cmdreadformatcapacity(FAR struct usbstrg_dev_s *priv, ****************************************************************************/ static int inline usbstrg_cmdreadcapacity10(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf) + FAR uint8_t *buf) { FAR struct scsicmd_readcapacity10_s *rcc = (FAR struct scsicmd_readcapacity10_s *)priv->cdb; FAR struct scsiresp_readcapacity10_s *rcr = (FAR struct scsiresp_readcapacity10_s *)buf; FAR struct usbstrg_lun_s *lun = priv->lun; - uint32 lba; + uint32_t lba; int ret; priv->u.alloclen = SCSIRESP_READCAPACITY10_SIZEOF; /* Fake the allocation length */ @@ -1017,8 +1020,8 @@ static inline int usbstrg_cmdverify10(FAR struct usbstrg_dev_s *priv) { FAR struct scsicmd_verify10_s *verf = (FAR struct scsicmd_verify10_s *)priv->cdb; FAR struct usbstrg_lun_s *lun = priv->lun; - uint32 lba; - uint16 blocks; + uint32_t lba; + uint16_t blocks; size_t sector; ssize_t nread; int ret; @@ -1142,7 +1145,7 @@ static inline int usbstrg_cmdmodeselect10(FAR struct usbstrg_dev_s *priv) ****************************************************************************/ static int inline usbstrg_cmdmodesense10(FAR struct usbstrg_dev_s *priv, - FAR ubyte *buf) + FAR uint8_t *buf) { FAR struct scsicmd_modesense10_s *modesense = (FAR struct scsicmd_modesense10_s *)priv->cdb; FAR struct scsiresp_modeparameterhdr10_s *mph = (FAR struct scsiresp_modeparameterhdr10_s *)buf; @@ -1330,11 +1333,11 @@ static inline int usbstrg_cmdwrite12(FAR struct usbstrg_dev_s *priv) * ****************************************************************************/ -static int inline usbstrg_setupcmd(FAR struct usbstrg_dev_s *priv, ubyte cdblen, ubyte flags) +static int inline usbstrg_setupcmd(FAR struct usbstrg_dev_s *priv, uint8_t cdblen, uint8_t flags) { FAR struct usbstrg_lun_s *lun = NULL; - uint32 datlen; - ubyte dir = flags & USBSTRG_FLAGS_DIRMASK; + uint32_t datlen; + uint8_t dir = flags & USBSTRG_FLAGS_DIRMASK; int ret = OK; /* Verify the LUN and set up the current LUN reference in the @@ -1525,7 +1528,7 @@ static int usbstrg_idlestate(FAR struct usbstrg_dev_s *priv) /* Handle the CBW */ - usbstrg_dumpdata("SCSCI CBW", (ubyte*)cbw, USBSTRG_CBW_SIZEOF - USBSTRG_MAXCDBLEN); + usbstrg_dumpdata("SCSCI CBW", (uint8_t*)cbw, USBSTRG_CBW_SIZEOF - USBSTRG_MAXCDBLEN); usbstrg_dumpdata(" CDB", cbw->cdb, min(cbw->cdblen, USBSTRG_MAXCDBLEN)); /* Check for properly formatted CBW? */ @@ -1609,7 +1612,7 @@ static int usbstrg_idlestate(FAR struct usbstrg_dev_s *priv) if (EP_SUBMIT(priv->epbulkout, req) != OK) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_IDLERDSUBMIT), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_IDLERDSUBMIT), (uint16_t)-ret); } /* Change to the CMDPARSE state and return success */ @@ -1642,7 +1645,7 @@ static int usbstrg_idlestate(FAR struct usbstrg_dev_s *priv) static int usbstrg_cmdparsestate(FAR struct usbstrg_dev_s *priv) { FAR struct usbstrg_req_s *privreq; - FAR ubyte *buf; + FAR uint8_t *buf; int ret = -EINVAL; usbstrg_dumpdata("SCSCI CDB", priv->cdb, priv->cdblen); @@ -1959,8 +1962,8 @@ static int usbstrg_cmdreadstate(FAR struct usbstrg_dev_s *priv) FAR struct usbdev_req_s *req; irqstate_t flags; ssize_t nread; - ubyte *src; - ubyte *dest; + uint8_t *src; + uint8_t *dest; int nbytes; int ret; @@ -2053,7 +2056,7 @@ static int usbstrg_cmdreadstate(FAR struct usbstrg_dev_s *priv) ret = EP_SUBMIT(priv->epbulkin, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDREADSUBMIT), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDREADSUBMIT), (uint16_t)-ret); lun->sd = SCSI_KCQME_UNRRE1; lun->sdinfo = priv->sector; break; @@ -2104,9 +2107,9 @@ static int usbstrg_cmdwritestate(FAR struct usbstrg_dev_s *priv) FAR struct usbstrg_req_s *privreq; FAR struct usbdev_req_s *req; ssize_t nwritten; - uint16 xfrd; - ubyte *src; - ubyte *dest; + uint16_t xfrd; + uint8_t *src; + uint8_t *dest; int nbytes; int ret; @@ -2195,7 +2198,7 @@ static int usbstrg_cmdwritestate(FAR struct usbstrg_dev_s *priv) ret = EP_SUBMIT(priv->epbulkout, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDWRITERDSUBMIT), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDWRITERDSUBMIT), (uint16_t)-ret); } /* Did the host decide to stop early? */ @@ -2289,7 +2292,7 @@ static int usbstrg_cmdfinishstate(FAR struct usbstrg_dev_s *priv) ret = EP_SUBMIT(priv->epbulkin, privreq->req); if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHSUBMIT), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHSUBMIT), (uint16_t)-ret); } } @@ -2297,7 +2300,7 @@ static int usbstrg_cmdfinishstate(FAR struct usbstrg_dev_s *priv) if (priv->residue > 0) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHRESIDUE), (uint16)priv->residue); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHRESIDUE), (uint16_t)priv->residue); (void)EP_STALL(priv->epbulkin); } } @@ -2313,14 +2316,14 @@ static int usbstrg_cmdfinishstate(FAR struct usbstrg_dev_s *priv) flags = irqsave(); if (priv->shortpacket) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHSHORTPKT), (uint16)priv->residue); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHSHORTPKT), (uint16_t)priv->residue); } /* Unprocessed incoming data: STALL and cancel requests. */ else { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINSHSUBMIT), (uint16)priv->residue); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINSHSUBMIT), (uint16_t)priv->residue); EP_STALL(priv->epbulkout); } @@ -2365,8 +2368,8 @@ static int usbstrg_cmdstatusstate(FAR struct usbstrg_dev_s *priv) FAR struct usbdev_req_s *req; FAR struct usbstrg_csw_s *csw; irqstate_t flags; - uint32 sd; - ubyte status = USBSTRG_CSWSTATUS_PASS; + uint32_t sd; + uint8_t status = USBSTRG_CSWSTATUS_PASS; int ret; /* Take a request from the wrreqlist */ @@ -2425,7 +2428,7 @@ static int usbstrg_cmdstatusstate(FAR struct usbstrg_dev_s *priv) usbstrg_putle32(csw->residue, priv->residue); csw->status = status; - usbstrg_dumpdata("SCSCI CSW", (ubyte*)csw, USBSTRG_CSW_SIZEOF); + usbstrg_dumpdata("SCSCI CSW", (uint8_t*)csw, USBSTRG_CSW_SIZEOF); req->len = USBSTRG_CSW_SIZEOF; req->callback = usbstrg_wrcomplete; @@ -2435,7 +2438,7 @@ static int usbstrg_cmdstatusstate(FAR struct usbstrg_dev_s *priv) ret = EP_SUBMIT(priv->epbulkin, req); if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_SNDSTATUSSUBMIT), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_SNDSTATUSSUBMIT), (uint16_t)-ret); flags = irqsave(); (void)sq_addlast((sq_entry_t*)privreq, &priv->wrreqlist); irqrestore(flags); @@ -2465,7 +2468,7 @@ void *usbstrg_workerthread(void *arg) { struct usbstrg_dev_s *priv = (struct usbstrg_dev_s *)arg; irqstate_t flags; - uint16 eventset; + uint16_t eventset; int ret; /* This thread is started before the USB storage class is fully initialized. @@ -2555,7 +2558,7 @@ void *usbstrg_workerthread(void *arg) if ((eventset & (USBSTRG_EVENT_RESET|USBSTRG_EVENT_CFGCHANGE|USBSTRG_EVENT_IFCHANGE)) != 0) { - usbstrg_deferredresponse(priv, FALSE); + usbstrg_deferredresponse(priv, false); } /* For all of these events... terminate any transactions in progress */ diff --git a/nuttx/drivers/usbdev/usbdev_serial.c b/nuttx/drivers/usbdev/usbdev_serial.c index 9987ceb0f..8eae62e24 100644 --- a/nuttx/drivers/usbdev/usbdev_serial.c +++ b/nuttx/drivers/usbdev/usbdev_serial.c @@ -40,8 +40,10 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -58,7 +60,7 @@ #include <nuttx/usbdev_trace.h> /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ @@ -249,13 +251,13 @@ struct usbser_dev_s FAR struct uart_dev_s serdev; /* Serial device structure */ FAR struct usbdev_s *usbdev; /* usbdev driver pointer */ - ubyte config; /* Configuration number */ - ubyte nwrq; /* Number of queue write requests (in reqlist)*/ - ubyte nrdq; /* Number of queue read requests (in epbulkout) */ - ubyte open : 1; /* 1: Driver has been opened */ - ubyte rxenabled : 1; /* 1: UART RX "interrupts" enabled */ - ubyte linest[7]; /* Fake line status */ - sint16 rxhead; /* Working head; used when rx int disabled */ + uint8_t config; /* Configuration number */ + uint8_t nwrq; /* Number of queue write requests (in reqlist)*/ + uint8_t nrdq; /* Number of queue read requests (in epbulkout) */ + uint8_t open : 1; /* 1: Driver has been opened */ + uint8_t rxenabled : 1; /* 1: UART RX "interrupts" enabled */ + uint8_t linest[7]; /* Fake line status */ + int16_t rxhead; /* Working head; used when rx int disabled */ FAR struct usbdev_ep_s *epintin; /* Interrupt IN endpoint structure */ FAR struct usbdev_ep_s *epbulkin; /* Bulk IN endpoint structure */ @@ -299,32 +301,32 @@ struct usbser_alloc_s /* Transfer helpers *********************************************************/ -static uint16 usbclass_fillrequest(FAR struct usbser_dev_s *priv, - ubyte *reqbuf, uint16 reqlen); +static uint16_t usbclass_fillrequest(FAR struct usbser_dev_s *priv, + uint8_t *reqbuf, uint16_t reqlen); static int usbclass_sndpacket(FAR struct usbser_dev_s *priv); static inline int usbclass_recvpacket(FAR struct usbser_dev_s *priv, - ubyte *reqbuf, uint16 reqlen); + uint8_t *reqbuf, uint16_t reqlen); /* Request helpers *********************************************************/ static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep, - uint16 len); + uint16_t len); static void usbclass_freereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req); /* Configuration ***********************************************************/ -static int usbclass_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc); +static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc); #ifdef CONFIG_USBDEV_DUALSPEED static void usbclass_mkepbulkdesc(const struct up_epdesc *indesc, - uint16 mxpacket, struct usb_epdesc_s *outdesc) -static sint16 usbclass_mkcfgdesc(ubyte *buf, ubyte speed); + uint16_t mxpacket, struct usb_epdesc_s *outdesc) +static int16_t usbclass_mkcfgdesc(uint8_t *buf, uint8_t speed); #else -static sint16 usbclass_mkcfgdesc(ubyte *buf); +static int16_t usbclass_mkcfgdesc(uint8_t *buf); #endif static void usbclass_resetconfig(FAR struct usbser_dev_s *priv); static int usbclass_setconfig(FAR struct usbser_dev_s *priv, - ubyte config); + uint8_t config); /* Completion event handlers ***********************************************/ @@ -350,9 +352,9 @@ static int usbser_setup(FAR struct uart_dev_s *dev); static void usbser_shutdown(FAR struct uart_dev_s *dev); static int usbser_attach(FAR struct uart_dev_s *dev); static void usbser_detach(FAR struct uart_dev_s *dev); -static void usbser_rxint(FAR struct uart_dev_s *dev, boolean enable); -static void usbser_txint(FAR struct uart_dev_s *dev, boolean enable); -static boolean usbser_txempty(FAR struct uart_dev_s *dev); +static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable); +static void usbser_txint(FAR struct uart_dev_s *dev, bool enable); +static bool usbser_txempty(FAR struct uart_dev_s *dev); /**************************************************************************** * Private Variables @@ -502,12 +504,13 @@ static const struct usb_qualdesc_s g_qualdesc = * ************************************************************************************/ -static uint16 usbclass_fillrequest(FAR struct usbser_dev_s *priv, ubyte *reqbuf, uint16 reqlen) +static uint16_t usbclass_fillrequest(FAR struct usbser_dev_s *priv, uint8_t *reqbuf, + uint16_t reqlen) { FAR uart_dev_t *serdev = &priv->serdev; FAR struct uart_buffer_s *xmit = &serdev->xmit; irqstate_t flags; - uint16 nbytes = 0; + uint16_t nbytes = 0; /* Disable interrupts */ @@ -618,7 +621,7 @@ static int usbclass_sndpacket(FAR struct usbser_dev_s *priv) ret = EP_SUBMIT(ep, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL), (uint16_t)-ret); break; } } @@ -646,13 +649,13 @@ static int usbclass_sndpacket(FAR struct usbser_dev_s *priv) ************************************************************************************/ static inline int usbclass_recvpacket(FAR struct usbser_dev_s *priv, - ubyte *reqbuf, uint16 reqlen) + uint8_t *reqbuf, uint16_t reqlen) { FAR uart_dev_t *serdev = &priv->serdev; FAR struct uart_buffer_s *recv = &serdev->recv; - uint16 currhead; - uint16 nexthead; - uint16 nbytes = 0; + uint16_t currhead; + uint16_t nexthead; + uint16_t nbytes = 0; /* Get the next head index. During the time that RX interrupts are disabled, the * the serial driver will be extracting data from the circular buffer and modifying @@ -748,7 +751,8 @@ static inline int usbclass_recvpacket(FAR struct usbser_dev_s *priv, * ****************************************************************************/ -static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep, uint16 len) +static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep, + uint16_t len) { FAR struct usbdev_req_s *req; @@ -795,7 +799,7 @@ static void usbclass_freereq(FAR struct usbdev_ep_s *ep, * ****************************************************************************/ -static int usbclass_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc) +static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc) { const char *str; int len; @@ -861,7 +865,7 @@ static int usbclass_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc) #ifdef CONFIG_USBDEV_DUALSPEED static inline void usbclass_mkepbulkdesc(const FAR struct up_epdesc *indesc, - uint16 mxpacket, + uint16_t mxpacket, FAR struct usb_epdesc_s *outdesc) { /* Copy the canned descriptor */ @@ -884,17 +888,17 @@ static inline void usbclass_mkepbulkdesc(const FAR struct up_epdesc *indesc, ****************************************************************************/ #ifdef CONFIG_USBDEV_DUALSPEED -static sint16 usbclass_mkcfgdesc(ubyte *buf, ubyte speed) +static int16_t usbclass_mkcfgdesc(uint8_t *buf, uint8_t speed) #else -static sint16 usbclass_mkcfgdesc(ubyte *buf) +static int16_t usbclass_mkcfgdesc(uint8_t *buf) #endif { FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf; #ifdef CONFIG_USBDEV_DUALSPEED - boolean highspeed = (speed == USB_SPEED_HIGH); - uint16 bulkmxpacket; + bool highspeed = (speed == USB_SPEED_HIGH); + uint16_t bulkmxpacket; #endif - uint16 totallen; + uint16_t totallen; /* This is the total length of the configuration (not necessarily the * size that we will be sending now. @@ -991,12 +995,12 @@ static void usbclass_resetconfig(FAR struct usbser_dev_s *priv) * ****************************************************************************/ -static int usbclass_setconfig(FAR struct usbser_dev_s *priv, ubyte config) +static int usbclass_setconfig(FAR struct usbser_dev_s *priv, uint8_t config) { FAR struct usbdev_req_s *req; #ifdef CONFIG_USBDEV_DUALSPEED struct usb_epdesc_s epdesc; - uint16 bulkmxpacket; + uint16_t bulkmxpacket; #endif int i; int ret = 0; @@ -1039,7 +1043,7 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, ubyte config) /* Configure the IN interrupt endpoint */ - ret = EP_CONFIGURE(priv->epintin, &g_epintindesc, FALSE); + ret = EP_CONFIGURE(priv->epintin, &g_epintindesc, false); if (ret < 0) { usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINCONFIGFAIL), 0); @@ -1060,9 +1064,9 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, ubyte config) } usbclass_mkepbulkdesc(&g_epbulkindesc, bulkmxpacket, &epdesc); - ret = EP_CONFIGURE(priv->epbulkin, &epdesc, FALSE); + ret = EP_CONFIGURE(priv->epbulkin, &epdesc, false); #else - ret = EP_CONFIGURE(priv->epbulkin, &g_epbulkindesc, FALSE); + ret = EP_CONFIGURE(priv->epbulkin, &g_epbulkindesc, false); #endif if (ret < 0) { @@ -1076,9 +1080,9 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, ubyte config) #ifdef CONFIG_USBDEV_DUALSPEED usbclass_mkepbulkdesc(&g_epbulkoutdesc, bulkmxpacket, &epdesc); - ret = EP_CONFIGURE(priv->epbulkout, &epdesc, TRUE); + ret = EP_CONFIGURE(priv->epbulkout, &epdesc, true); #else - ret = EP_CONFIGURE(priv->epbulkout, &g_epbulkoutdesc, TRUE); + ret = EP_CONFIGURE(priv->epbulkout, &g_epbulkoutdesc, true); #endif if (ret < 0) { @@ -1098,7 +1102,7 @@ static int usbclass_setconfig(FAR struct usbser_dev_s *priv, ubyte config) ret = EP_SUBMIT(priv->epbulkout, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-ret); goto errout; } priv->nrdq++; @@ -1125,7 +1129,7 @@ static void usbclass_ep0incomplete(FAR struct usbdev_ep_s *ep, { if (req->result || req->xfrd != req->len) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_REQRESULT), (uint16)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_REQRESULT), (uint16_t)-req->result); } } @@ -1176,7 +1180,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep, return; default: /* Some other error occurred */ - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED), (uint16)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED), (uint16_t)-req->result); break; }; @@ -1191,7 +1195,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep, ret = EP_SUBMIT(ep, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-req->result); } irqrestore(flags); } @@ -1250,7 +1254,7 @@ static void usbclass_wrcomplete(FAR struct usbdev_ep_s *ep, break; default: /* Some other error occurred */ - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRUNEXPECTED), (uint16)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRUNEXPECTED), (uint16_t)-req->result); break; } } @@ -1272,7 +1276,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver FAR struct usbser_dev_s *priv = ((struct usbser_driver_s*)driver)->dev; FAR struct usbser_req_s *reqcontainer; irqstate_t flags; - uint16 reqlen; + uint16_t reqlen; int ret; int i; @@ -1303,7 +1307,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver /* Pre-allocate the IN interrupt endpoint */ - priv->epintin = DEV_ALLOCEP(dev, USBSER_EPINTIN_ADDR, TRUE, USB_EP_ATTR_XFER_INT); + priv->epintin = DEV_ALLOCEP(dev, USBSER_EPINTIN_ADDR, true, USB_EP_ATTR_XFER_INT); if (!priv->epintin) { usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINALLOCFAIL), 0); @@ -1314,7 +1318,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver /* Pre-allocate the IN bulk endpoint */ - priv->epbulkin = DEV_ALLOCEP(dev, USBSER_EPINBULK_ADDR, TRUE, USB_EP_ATTR_XFER_BULK); + priv->epbulkin = DEV_ALLOCEP(dev, USBSER_EPINBULK_ADDR, true, USB_EP_ATTR_XFER_BULK); if (!priv->epbulkin) { usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKINALLOCFAIL), 0); @@ -1325,7 +1329,7 @@ static int usbclass_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver /* Pre-allocate the OUT bulk endpoint */ - priv->epbulkout = DEV_ALLOCEP(dev, USBSER_EPOUTBULK_ADDR, FALSE, USB_EP_ATTR_XFER_BULK); + priv->epbulkout = DEV_ALLOCEP(dev, USBSER_EPOUTBULK_ADDR, false, USB_EP_ATTR_XFER_BULK); if (!priv->epbulkout) { usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKOUTALLOCFAIL), 0); @@ -1531,9 +1535,9 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * { FAR struct usbser_dev_s *priv; FAR struct usbdev_req_s *ctrlreq; - uint16 value; - uint16 index; - uint16 len; + uint16_t value; + uint16_t index; + uint16_t len; int ret = -EOPNOTSUPP; #ifdef CONFIG_DEBUG @@ -1643,7 +1647,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * { if (ctrl->type == USB_DIR_IN) { - *(ubyte*)ctrlreq->buf = priv->config; + *(uint8_t*)ctrlreq->buf = priv->config; ret = 1; } } @@ -1676,7 +1680,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * } else { - *(ubyte*) ctrlreq->buf = USBSER_ALTINTERFACEID; + *(uint8_t*) ctrlreq->buf = USBSER_ALTINTERFACEID; ret = 1; } } @@ -1738,7 +1742,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * { if ((ctrl->type & USB_DIR_IN) != 0) { - *(uint32*)ctrlreq->buf = 0xdeadbeef; + *(uint32_t*)ctrlreq->buf = 0xdeadbeef; ret = 4; } else @@ -1770,7 +1774,7 @@ static int usbclass_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s * ret = EP_SUBMIT(dev->ep0, ctrlreq); if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPRESPQ), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPRESPQ), (uint16_t)-ret); ctrlreq->result = OK; usbclass_ep0incomplete(dev->ep0, ctrlreq); } @@ -1881,7 +1885,7 @@ static int usbser_setup(FAR struct uart_dev_s *dev) * This method is called when the serial port is closed. This operation * is very simple for the USB serial backend because the serial driver * has already assured that the TX data has full drained -- it calls - * usbser_txempty() until that function returns TRUE before calling this + * usbser_txempty() until that function returns true before calling this * function. * ****************************************************************************/ @@ -1959,22 +1963,22 @@ static void usbser_detach(FAR struct uart_dev_s *dev) * course, have no RX interrupts but must behave consistently. This method * is called under the conditions: * - * 1. With enable==TRUE when the port is opened (just after usbser_setup + * 1. With enable==true when the port is opened (just after usbser_setup * and usbser_attach are called called) - * 2. With enable==FALSE while transferring data from the RX buffer - * 2. With enable==TRUE while waiting for more incoming data - * 3. With enable==FALSE when the port is closed (just before usbser_detach + * 2. With enable==false while transferring data from the RX buffer + * 2. With enable==true while waiting for more incoming data + * 3. With enable==false when the port is closed (just before usbser_detach * and usbser_shutdown are called). * ****************************************************************************/ -static void usbser_rxint(FAR struct uart_dev_s *dev, boolean enable) +static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable) { FAR struct usbser_dev_s *priv; FAR uart_dev_t *serdev; irqstate_t flags; - usbtrace(USBSER_CLASSAPI_RXINT, (uint16)enable); + usbtrace(USBSER_CLASSAPI_RXINT, (uint16_t)enable); /* Sanity check */ @@ -2055,17 +2059,17 @@ static void usbser_rxint(FAR struct uart_dev_s *dev, boolean enable) * course, have no TX interrupts but must behave consistently. Initially, * TX interrupts are disabled. This method is called under the conditions: * - * 1. With enable==FALSE while transferring data into the TX buffer - * 2. With enable==TRUE when data may be taken from the buffer. - * 3. With enable==FALSE when the TX buffer is empty + * 1. With enable==false while transferring data into the TX buffer + * 2. With enable==true when data may be taken from the buffer. + * 3. With enable==false when the TX buffer is empty * ****************************************************************************/ -static void usbser_txint(FAR struct uart_dev_s *dev, boolean enable) +static void usbser_txint(FAR struct uart_dev_s *dev, bool enable) { FAR struct usbser_dev_s *priv; - usbtrace(USBSER_CLASSAPI_TXINT, (uint16)enable); + usbtrace(USBSER_CLASSAPI_TXINT, (uint16_t)enable); /* Sanity checks */ @@ -2098,15 +2102,15 @@ static void usbser_txint(FAR struct uart_dev_s *dev, boolean enable) * Name: usbser_txempty * * Description: - * Return TRUE when all data has been sent. This is called from the + * Return true when all data has been sent. This is called from the * serial driver when the driver is closed. It will call this API - * periodically until it reports TRUE. NOTE that the serial driver takes all + * periodically until it reports true. NOTE that the serial driver takes all * responsibility for flushing TX data through the hardware so we can be * a bit sloppy about that. * ****************************************************************************/ -static boolean usbser_txempty(FAR struct uart_dev_s *dev) +static bool usbser_txempty(FAR struct uart_dev_s *dev) { FAR struct usbser_dev_s *priv = (FAR struct usbser_dev_s*)dev->priv; @@ -2116,7 +2120,7 @@ static boolean usbser_txempty(FAR struct uart_dev_s *dev) if (!priv) { usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_INVALIDARG), 0); - return TRUE; + return true; } #endif @@ -2200,18 +2204,18 @@ int usbdev_serialinitialize(int minor) ret = usbdev_register(&drvr->drvr); if (ret) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_DEVREGISTER), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_DEVREGISTER), (uint16_t)-ret); goto errout_with_alloc; } /* Register the USB serial console */ #ifdef CONFIG_USBSER_CONSOLE - g_usbserialport.isconsole = TRUE; + g_usbserialport.isconsole = true; ret = uart_register("/dev/console", &pri->serdev); if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_CONSOLEREGISTER), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_CONSOLEREGISTER), (uint16_t)-ret); goto errout_with_class; } #endif @@ -2222,7 +2226,7 @@ int usbdev_serialinitialize(int minor) ret = uart_register(devname, &priv->serdev); if (ret) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UARTREGISTER), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UARTREGISTER), (uint16_t)-ret); goto errout_with_class; } return OK; diff --git a/nuttx/drivers/usbdev/usbdev_storage.c b/nuttx/drivers/usbdev/usbdev_storage.c index 79b037478..3713e8dcf 100644 --- a/nuttx/drivers/usbdev/usbdev_storage.c +++ b/nuttx/drivers/usbdev/usbdev_storage.c @@ -59,8 +59,10 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -80,7 +82,7 @@ #include "usbdev_storage.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -112,14 +114,14 @@ struct usbstrg_alloc_s static void usbstrg_ep0incomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req); static struct usbdev_req_s *usbstrg_allocreq(FAR struct usbdev_ep_s *ep, - uint16 len); + uint16_t len); static void usbstrg_freereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req); -static int usbstrg_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc); +static int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc); #ifdef CONFIG_USBDEV_DUALSPEED -static sint16 usbstrg_mkcfgdesc(ubyte *buf, ubyte speed); +static int16_t usbstrg_mkcfgdesc(uint8_t *buf, uint8_t speed); #else -static sint16 usbstrg_mkcfgdesc(ubyte *buf); +static int16_t usbstrg_mkcfgdesc(uint8_t *buf); #endif /* Class Driver Operations (most at interrupt level) ************************/ @@ -296,7 +298,8 @@ static void usbstrg_ep0incomplete(FAR struct usbdev_ep_s *ep, { if (req->result || req->xfrd != req->len) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_REQRESULT), (uint16)-req->result); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_REQRESULT), + (uint16_t)-req->result); } } @@ -308,7 +311,8 @@ static void usbstrg_ep0incomplete(FAR struct usbdev_ep_s *ep, * ****************************************************************************/ -static struct usbdev_req_s *usbstrg_allocreq(FAR struct usbdev_ep_s *ep, uint16 len) +static struct usbdev_req_s *usbstrg_allocreq(FAR struct usbdev_ep_s *ep, + uint16_t len) { FAR struct usbdev_req_s *req; @@ -354,7 +358,7 @@ static void usbstrg_freereq(FAR struct usbdev_ep_s *ep, struct usbdev_req_s *req * ****************************************************************************/ -static int usbstrg_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc) +static int usbstrg_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc) { const char *str; int len; @@ -419,18 +423,18 @@ static int usbstrg_mkstrdesc(ubyte id, struct usb_strdesc_s *strdesc) ****************************************************************************/ #ifdef CONFIG_USBDEV_DUALSPEED -static sint16 usbstrg_mkcfgdesc(ubyte *buf, ubyte speed) +static int16_t usbstrg_mkcfgdesc(uint8_t *buf, uint8_t speed) #else -static sint16 usbstrg_mkcfgdesc(ubyte *buf) +static int16_t usbstrg_mkcfgdesc(uint8_t *buf) #endif { FAR struct usb_cfgdesc_s *cfgdesc = (struct usb_cfgdesc_s*)buf; #ifdef CONFIG_USBDEV_DUALSPEED FAR struct usb_epdesc_s *epdesc; - boolean hispeed = (speed == USB_SPEED_HIGH); - uint16 bulkmxpacket; + bool hispeed = (speed == USB_SPEED_HIGH); + uint16_t bulkmxpacket; #endif - uint16 totallen; + uint16_t totallen; /* This is the total length of the configuration (not necessarily the * size that we will be sending now. @@ -534,7 +538,7 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_ /* Pre-allocate the IN bulk endpoint */ - priv->epbulkin = DEV_ALLOCEP(dev, USBSTRG_EPINBULK_ADDR, TRUE, USB_EP_ATTR_XFER_BULK); + priv->epbulkin = DEV_ALLOCEP(dev, USBSTRG_EPINBULK_ADDR, true, USB_EP_ATTR_XFER_BULK); if (!priv->epbulkin) { usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_EPBULKINALLOCFAIL), 0); @@ -545,7 +549,7 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_ /* Pre-allocate the OUT bulk endpoint */ - priv->epbulkout = DEV_ALLOCEP(dev, USBSTRG_EPOUTBULK_ADDR, FALSE, USB_EP_ATTR_XFER_BULK); + priv->epbulkout = DEV_ALLOCEP(dev, USBSTRG_EPOUTBULK_ADDR, false, USB_EP_ATTR_XFER_BULK); if (!priv->epbulkout) { usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_EPBULKOUTALLOCFAIL), 0); @@ -562,7 +566,8 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_ reqcontainer->req = usbstrg_allocreq(priv->epbulkout, CONFIG_USBSTRG_BULKOUTREQLEN); if (reqcontainer->req == NULL) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDALLOCREQ), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDALLOCREQ), + (uint16_t)-ret); ret = -ENOMEM; goto errout; } @@ -578,7 +583,8 @@ static int usbstrg_bind(FAR struct usbdev_s *dev, FAR struct usbdevclass_driver_ reqcontainer->req = usbstrg_allocreq(priv->epbulkin, CONFIG_USBSTRG_BULKINREQLEN); if (reqcontainer->req == NULL) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_WRALLOCREQ), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_WRALLOCREQ), + (uint16_t)-ret); ret = -ENOMEM; goto errout; } @@ -723,13 +729,14 @@ static void usbstrg_unbind(FAR struct usbdev_s *dev) * ****************************************************************************/ -static int usbstrg_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *ctrl) +static int usbstrg_setup(FAR struct usbdev_s *dev, + FAR const struct usb_ctrlreq_s *ctrl) { FAR struct usbstrg_dev_s *priv; FAR struct usbdev_req_s *ctrlreq; - uint16 value; - uint16 index; - uint16 len; + uint16_t value; + uint16_t index; + uint16_t len; int ret = -EOPNOTSUPP; #ifdef CONFIG_DEBUG @@ -980,7 +987,7 @@ static int usbstrg_setup(FAR struct usbdev_s *dev, const struct usb_ctrlreq_s *c ret = EP_SUBMIT(dev->ep0, ctrlreq); if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_EPRESPQ), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_EPRESPQ), (uint16_t)-ret); #if 0 /* Not necessary */ ctrlreq->result = OK; usbstrg_ep0incomplete(dev->ep0, ctrlreq); @@ -1077,13 +1084,13 @@ static void usbstrg_lununinitialize(struct usbstrg_lun_s *lun) * ****************************************************************************/ -int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config) +int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, uint8_t config) { FAR struct usbstrg_req_s *privreq; FAR struct usbdev_req_s *req; #ifdef CONFIG_USBDEV_DUALSPEED struct usb_epdesc_s *epdesc; - uint16 bulkmxpacket; + uint16_t bulkmxpacket; #endif int i; int ret = 0; @@ -1129,9 +1136,9 @@ int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config) #ifdef CONFIG_USBDEV_DUALSPEED bulkmxpacket = USBSTRG_BULKMAXPACKET(hispeed); epdesc = USBSTRG_EPBULKINDESC(hispeed); - ret = EP_CONFIGURE(priv->epbulkin, epdesc, FALSE); + ret = EP_CONFIGURE(priv->epbulkin, epdesc, false); #else - ret = EP_CONFIGURE(priv->epbulkin, &g_fsepbulkindesc, FALSE); + ret = EP_CONFIGURE(priv->epbulkin, &g_fsepbulkindesc, false); #endif if (ret < 0) { @@ -1145,9 +1152,9 @@ int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config) #ifdef CONFIG_USBDEV_DUALSPEED epdesc = USBSTRG_EPBULKINDESC(hispeed); - ret = EP_CONFIGURE(priv->epbulkout, epdesc, TRUE); + ret = EP_CONFIGURE(priv->epbulkout, epdesc, true); #else - ret = EP_CONFIGURE(priv->epbulkout, &g_fsepbulkoutdesc, TRUE); + ret = EP_CONFIGURE(priv->epbulkout, &g_fsepbulkoutdesc, true); #endif if (ret < 0) { @@ -1169,7 +1176,7 @@ int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config) ret = EP_SUBMIT(priv->epbulkout, req); if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDSUBMIT), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDSUBMIT), (uint16_t)-ret); goto errout; } } @@ -1258,7 +1265,8 @@ void usbstrg_wrcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req break; default: /* Some other error occurred */ - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_WRUNEXPECTED), (uint16)-req->result); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_WRUNEXPECTED), + (uint16_t)-req->result); break; }; @@ -1330,7 +1338,8 @@ void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req default: /* Some other error occurred */ { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDUNEXPECTED), (uint16)-req->result); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDUNEXPECTED), + (uint16_t)-req->result); /* Return the read request to the bulk out endpoint for re-filling */ @@ -1341,7 +1350,8 @@ void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req ret = EP_SUBMIT(priv->epbulkout, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDCOMPLETERDSUBMIT), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_RDCOMPLETERDSUBMIT), + (uint16_t)-ret); } } break; @@ -1366,11 +1376,11 @@ void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req * * Input parameters: * priv - Private state structure for this USB storage instance - * stall - TRUE is the action failed and a stall is required + * stall - true is the action failed and a stall is required * ****************************************************************************/ -void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, boolean failed) +void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, bool failed) { FAR struct usbdev_s *dev; FAR struct usbdev_req_s *ctrlreq; @@ -1398,7 +1408,8 @@ void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, boolean failed) ret = EP_SUBMIT(dev->ep0, ctrlreq); if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_DEFERREDRESPSUBMIT), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_DEFERREDRESPSUBMIT), + (uint16_t)-ret); #if 0 /* Not necessary */ ctrlreq->result = OK; usbstrg_ep0incomplete(dev->ep0, ctrlreq); @@ -1526,7 +1537,7 @@ errout: int usbstrg_bindlun(FAR void *handle, FAR const char *drvrpath, unsigned int lunno, off_t startsector, size_t nsectors, - boolean readonly) + bool readonly) { FAR struct usbstrg_alloc_s *alloc = (FAR struct usbstrg_alloc_s *)handle; FAR struct usbstrg_dev_s *priv; @@ -1616,7 +1627,7 @@ int usbstrg_bindlun(FAR void *handle, FAR const char *drvrpath, if (!priv->iobuffer) { - priv->iobuffer = (ubyte*)malloc(geo.geo_sectorsize); + priv->iobuffer = (uint8_t*)malloc(geo.geo_sectorsize); if (!priv->iobuffer) { usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_ALLOCIOBUFFER), geo.geo_sectorsize); @@ -1627,14 +1638,14 @@ int usbstrg_bindlun(FAR void *handle, FAR const char *drvrpath, else if (priv->iosize < geo.geo_sectorsize) { void *tmp; - tmp = (ubyte*)realloc(priv->iobuffer, geo.geo_sectorsize); + tmp = (uint8_t*)realloc(priv->iobuffer, geo.geo_sectorsize); if (!tmp) { usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_REALLOCIOBUFFER), geo.geo_sectorsize); return -ENOMEM; } - priv->iobuffer = (ubyte*)tmp; + priv->iobuffer = (uint8_t*)tmp; priv->iosize = geo.geo_sectorsize; } @@ -1647,7 +1658,7 @@ int usbstrg_bindlun(FAR void *handle, FAR const char *drvrpath, if (!inode->u.i_bops->write) { - lun->readonly = TRUE; + lun->readonly = true; } return OK; } @@ -1772,7 +1783,7 @@ int usbstrg_exportluns(FAR void *handle) #endif if (ret != OK) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_THREADCREATE), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_THREADCREATE), (uint16_t)-ret); goto errout_with_mutex; } @@ -1781,7 +1792,7 @@ int usbstrg_exportluns(FAR void *handle) ret = usbdev_register(&drvr->drvr); if (ret != OK) { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_DEVREGISTER), (uint16)-ret); + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_DEVREGISTER), (uint16_t)-ret); goto errout_with_mutex; } diff --git a/nuttx/drivers/usbdev/usbdev_storage.h b/nuttx/drivers/usbdev/usbdev_storage.h index 9d874c166..9ae25b4a6 100644 --- a/nuttx/drivers/usbdev/usbdev_storage.h +++ b/nuttx/drivers/usbdev/usbdev_storage.h @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/usbdev/usbdev_storage.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> * * Mass storage class device. Bulk-only with SCSI subclass. @@ -43,8 +43,10 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <sys/types.h> +#include <sys/types.h> +#include <stdint.h> +#include <stdbool.h> #include <pthread.h> #include <queue.h> @@ -351,12 +353,12 @@ struct usbstrg_req_s struct usbstrg_lun_s { struct inode *inode; /* Inode structure of open'ed block driver */ - ubyte readonly:1; /* Media is read-only */ - ubyte locked:1; /* Media removal is prevented */ - uint16 sectorsize; /* The size of one sector */ - uint32 sd; /* Sense data */ - uint32 sdinfo; /* Sense data information */ - uint32 uad; /* Unit needs attention data */ + uint8_t readonly:1; /* Media is read-only */ + uint8_t locked:1; /* Media removal is prevented */ + uint16_t sectorsize; /* The size of one sector */ + uint32_t sd; /* Sense data */ + uint32_t sdinfo; /* Sense data information */ + uint32_t uad; /* Unit needs attention data */ off_t startsector; /* Sector offset to start of partition */ size_t nsectors; /* Number of sectors in the partition */ }; @@ -372,14 +374,14 @@ struct usbstrg_dev_s pthread_t thread; /* The worker thread */ pthread_mutex_t mutex; /* Mutually exclusive access to resources*/ pthread_cond_t cond; /* Used to signal worker thread */ - volatile ubyte thstate; /* State of the worker thread */ - volatile uint16 theventset; /* Set of pending events signaled to worker thread */ - volatile ubyte thvalue; /* Value passed with the event (must persist) */ + volatile uint8_t thstate; /* State of the worker thread */ + volatile uint16_t theventset; /* Set of pending events signaled to worker thread */ + volatile uint8_t thvalue; /* Value passed with the event (must persist) */ /* Storage class configuration and state */ - ubyte nluns:4; /* Number of LUNs */ - ubyte config; /* Configuration number */ + uint8_t nluns:4; /* Number of LUNs */ + uint8_t config; /* Configuration number */ /* Endpoints */ @@ -391,25 +393,25 @@ struct usbstrg_dev_s struct usbstrg_lun_s *lun; /* Currently selected LUN */ struct usbstrg_lun_s *luntab; /* Allocated table of all LUNs */ - ubyte cdb[USBSTRG_MAXCDBLEN]; /* Command data (cdb[]) from CBW */ - ubyte phaseerror:1; /* Need to send phase sensing status */ - ubyte shortpacket:1; /* Host transmission stopped unexpectedly */ - ubyte cbwdir:2; /* Direction from CBW. See USBSTRG_FLAGS_DIR* definitions */ - ubyte cdblen; /* Length of cdb[] from CBW */ - ubyte cbwlun; /* LUN from the CBW */ - uint16 nsectbytes; /* Bytes buffered in iobuffer[] */ - uint16 nreqbytes; /* Bytes buffered in head write requests */ - uint16 iosize; /* Size of iobuffer[] */ - uint32 cbwlen; /* Length of data from CBW */ - uint32 cbwtag; /* Tag from the CBW */ + uint8_t cdb[USBSTRG_MAXCDBLEN]; /* Command data (cdb[]) from CBW */ + uint8_t phaseerror:1; /* Need to send phase sensing status */ + uint8_t shortpacket:1; /* Host transmission stopped unexpectedly */ + uint8_t cbwdir:2; /* Direction from CBW. See USBSTRG_FLAGS_DIR* definitions */ + uint8_t cdblen; /* Length of cdb[] from CBW */ + uint8_t cbwlun; /* LUN from the CBW */ + uint16_t nsectbytes; /* Bytes buffered in iobuffer[] */ + uint16_t nreqbytes; /* Bytes buffered in head write requests */ + uint16_t iosize; /* Size of iobuffer[] */ + uint32_t cbwlen; /* Length of data from CBW */ + uint32_t cbwtag; /* Tag from the CBW */ union { - uint32 xfrlen; /* Read/Write: Sectors remaining to be transferred */ - uint32 alloclen; /* Other device-to-host: Host allocation length */ + uint32_t xfrlen; /* Read/Write: Sectors remaining to be transferred */ + uint32_t alloclen; /* Other device-to-host: Host allocation length */ } u; - uint32 sector; /* Current sector (relative to lun->startsector) */ - uint32 residue; /* Untransferred amount reported in the CSW */ - ubyte *iobuffer; /* Buffer for data transfers */ + uint32_t sector; /* Current sector (relative to lun->startsector) */ + uint32_t residue; /* Untransferred amount reported in the CSW */ + uint8_t *iobuffer; /* Buffer for data transfers */ /* Write request list */ @@ -468,7 +470,7 @@ EXTERN void *usbstrg_workerthread(void *arg); * ****************************************************************************/ -EXTERN int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config); +EXTERN int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, uint8_t config); /**************************************************************************** * Name: usbstrg_resetconfig @@ -522,11 +524,11 @@ EXTERN void usbstrg_rdcomplete(FAR struct usbdev_ep_s *ep, * * Input parameters: * priv - Private state structure for this USB storage instance - * stall - TRUE is the action failed and a stall is required + * stall - true is the action failed and a stall is required * ****************************************************************************/ -EXTERN void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, boolean failed); +EXTERN void usbstrg_deferredresponse(FAR struct usbstrg_dev_s *priv, bool failed); #undef EXTERN #if defined(__cplusplus) diff --git a/nuttx/drivers/usbdev/usbdev_trace.c b/nuttx/drivers/usbdev/usbdev_trace.c index 10779aa70..3bb396c39 100644 --- a/nuttx/drivers/usbdev/usbdev_trace.c +++ b/nuttx/drivers/usbdev/usbdev_trace.c @@ -40,6 +40,7 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> #include <errno.h> #include <debug.h> @@ -75,8 +76,8 @@ #ifdef CONFIG_USBDEV_TRACE static struct usbtrace_s g_trace[CONFIG_USBDEV_TRACE_NRECORDS]; -static uint16 g_head = 0; -static uint16 g_tail = 0; +static uint16_t g_head = 0; +static uint16_t g_tail = 0; #endif #if defined(CONFIG_USBDEV_TRACE) || (defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_USB)) @@ -137,7 +138,7 @@ usbtrace_idset_t usbtrace_enable(usbtrace_idset_t idset) *******************************************************************************/ #if defined(CONFIG_USBDEV_TRACE) || (defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_USB)) -void usbtrace(uint16 event, uint16 value) +void usbtrace(uint16_t event, uint16_t value) { irqstate_t flags; @@ -190,8 +191,8 @@ void usbtrace(uint16 event, uint16 value) #ifdef CONFIG_USBDEV_TRACE int usbtrace_enumerate(trace_callback_t callback, void *arg) { - uint16 ndx; - uint32 idset; + uint16_t ndx; + uint32_t idset; int ret = OK; /* Temporarily disable tracing */ diff --git a/nuttx/drivers/usbdev/usbdev_trprintf.c b/nuttx/drivers/usbdev/usbdev_trprintf.c index 8dd61dadf..78335a1f2 100755 --- a/nuttx/drivers/usbdev/usbdev_trprintf.c +++ b/nuttx/drivers/usbdev/usbdev_trprintf.c @@ -40,6 +40,7 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdint.h> #include <debug.h> #include <nuttx/usbdev_trace.h> @@ -76,7 +77,7 @@ * *******************************************************************************/ -void usbtrace_trprintf(trprintf_t trprintf, uint16 event, uint16 value) +void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value) { switch (event) { @@ -129,11 +130,11 @@ void usbtrace_trprintf(trprintf_t trprintf, uint16 event, uint16 value) break; case TRACE_EPSTALL: - trprintf("Endpoint stall(TRUE): %04x\n", value); + trprintf("Endpoint stall(true): %04x\n", value); break; case TRACE_EPRESUME: - trprintf("Endpoint stall(FALSE): %04x\n", value); + trprintf("Endpoint stall(false): %04x\n", value); break; case TRACE_DEVALLOCEP: |