STM32 fixes for F4 32-bit timers

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4300 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-01-13 02:49:10 +00:00
parent 10cc67fe13
commit 247096fede
6 changed files with 615 additions and 409 deletions

View File

@ -2312,7 +2312,7 @@
* configs/olimex-lpc1766stk/src/up_leds.c: Add new interfaces so that is
CONFIG_ARCH_LEDS are not set, the LEDs may be controlled from application
logic.
* configs/olimex-lpc1766stk/src/up_buttons.c: Add support form the buttons
* configs/olimex-lpc1766stk/src/up_buttons.c: Add support for the buttons
on the Olimex LPC1766-STK board.
* Makefile: Added 'apps_clean' and 'apps_distclean' target to simplify
managing the state of the application directory while in the NuttX directory
@ -2361,4 +2361,7 @@
(Contributed by Mike Smith).
* fs/fat/fs_fat32util.c: On a failure to recognize a FAT file system, the
mount logic should return -EINVAL, not -ENODEV.
* arch/arm/src/stm32/stm32_tim.c: Support for STM32 F4 32-bit timers
(Contributed by Mikhail Bychek)
* lib/stdio/lib_vsprintf.c: Add support for fixed-size fields with floating
point numbers (Contributed by Mikhail Bychek)

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
*
* With modifications and updates by:
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -92,7 +92,7 @@ struct stm32_tim_dev_s
typedef enum
{
STM32_TIM_MODE_UNUSED = -1,
/* One of the following */
STM32_TIM_MODE_MASK = 0x0310,
@ -101,7 +101,7 @@ typedef enum
STM32_TIM_MODE_DOWN = 0x0110,
STM32_TIM_MODE_UPDOWN = 0x0200,
STM32_TIM_MODE_PULSE = 0x0300,
/* One of the following */
STM32_TIM_MODE_CK_INT = 0x0000,
@ -116,9 +116,9 @@ typedef enum
//STM32_TIM_MODE_CK_CH2 = 0x0002,
//STM32_TIM_MODE_CK_CH3 = 0x0003,
//STM32_TIM_MODE_CK_CH4 = 0x0004
/* Todo: external trigger block */
} stm32_tim_mode_t;
/* TIM Channel Modes */
@ -126,26 +126,26 @@ typedef enum
typedef enum
{
STM32_TIM_CH_DISABLED = 0x00,
/* Common configuration */
STM32_TIM_CH_POLARITY_POS = 0x00,
STM32_TIM_CH_POLARITY_NEG = 0x01,
/* MODES: */
STM32_TIM_CH_MODE_MASK = 0x06,
/* Output Compare Modes */
STM32_TIM_CH_OUTPWM = 0x04, /** Enable standard PWM mode, active high when counter < compare */
//STM32_TIM_CH_OUTCOMPARE = 0x06,
// TODO other modes ... as PWM capture, ENCODER and Hall Sensor
//STM32_TIM_CH_INCAPTURE = 0x10,
//STM32_TIM_CH_INPWM = 0x20
//STM32_TIM_CH_DRIVE_OC -- open collector mode
} stm32_tim_channel_t;
/* TIM Operations */
@ -156,12 +156,12 @@ struct stm32_tim_ops_s
int (*setmode)(FAR struct stm32_tim_dev_s *dev, stm32_tim_mode_t mode);
int (*setclock)(FAR struct stm32_tim_dev_s *dev, uint32_t freq);
void (*setperiod)(FAR struct stm32_tim_dev_s *dev, uint16_t period);
void (*setperiod)(FAR struct stm32_tim_dev_s *dev, uint32_t period);
/* General and Advanced Timers Adds */
int (*setchannel)(FAR struct stm32_tim_dev_s *dev, uint8_t channel, stm32_tim_channel_t mode);
int (*setcompare)(FAR struct stm32_tim_dev_s *dev, uint8_t channel, uint16_t compare);
int (*setcompare)(FAR struct stm32_tim_dev_s *dev, uint8_t channel, uint32_t compare);
int (*getcapture)(FAR struct stm32_tim_dev_s *dev, uint8_t channel);
int (*setisr)(FAR struct stm32_tim_dev_s *dev, int (*handler)(int irq, void *context), int source);

View File

@ -257,13 +257,13 @@ static void tsc2007_notify(FAR struct tsc2007_dev_s *priv)
if (priv->nwaiters > 0)
{
/* After posting this semaphore, we need to exit because the TSC2007
* is no longer avaialable.
* is no longer available.
*/
sem_post(&priv->waitsem);
}
/* If there are threads waiting on poll() for TSC2007 data to become availabe,
/* If there are threads waiting on poll() for TSC2007 data to become available,
* then wake them up now. NOTE: we wake up all waiting threads because we
* do not know that they are going to do. If they all try to read the data,
* then some make end up blocking after all.

View File

@ -144,12 +144,12 @@ EXTERN unsigned long long strtoull(const char *, char **, int);
#endif
EXTERN double_t strtod(const char *, char **);
#define atoi(nptr) strtol((nptr), NULL, 10);
#define atol(nptr) strtol((nptr), NULL, 10);
#define atoi(nptr) strtol((nptr), NULL, 10)
#define atol(nptr) strtol((nptr), NULL, 10)
#ifdef CONFIG_HAVE_LONG_LONG
#define atoll(nptr) strtoll((nptr), NULL, 10);
#define atoll(nptr) strtoll((nptr), NULL, 10)
#endif
#define atof(nptr) strtod((nptr), NULL);
#define atof(nptr) strtod((nptr), NULL)
/* Memory Management */

View File

@ -529,6 +529,21 @@ static int getusize(uint8_t fmt, uint8_t flags, unsigned int n)
utoascii(&nulloutstream, fmt, flags, n);
return nulloutstream.nput;
}
/****************************************************************************
* Name: getdblsize
****************************************************************************/
#ifdef CONFIG_LIBC_FLOATINGPOINT
static int getdblsize(uint8_t fmt, int trunc, uint8_t flags, double n)
{
struct lib_outstream_s nulloutstream;
lib_nulloutstream(&nulloutstream);
lib_dtoa(&nulloutstream, fmt, trunc, flags, n);
return nulloutstream.nput;
}
#endif
#endif /* CONFIG_NOPRINTF_FIELDWIDTH */
#ifdef CONFIG_LONG_IS_NOT_INT
@ -1535,9 +1550,30 @@ int lib_vsprintf(FAR struct lib_outstream_s *obj, FAR const char *src, va_list a
else if (strchr("eEfgG", FMT_CHAR))
{
double dblval = va_arg(ap, double);
#ifndef CONFIG_NOPRINTF_FIELDWIDTH
int dblsize;
/* Get the width of the output */
dblsize = getdblsize(FMT_CHAR, trunc, flags, dblval);
/* Perform left field justification actions */
prejustify(obj, fmt, flags, width, dblsize);
#endif
/* Output the number */
lib_dtoa(obj, FMT_CHAR, trunc, flags, dblval);
#ifndef CONFIG_NOPRINTF_FIELDWIDTH
/* Perform right field justification actions */
postjustify(obj, fmt, flags, width, dblsize);
}
#endif
#endif /* CONFIG_LIBC_FLOATINGPOINT */
}
return obj->nput;