mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
Add the beginning of an STM32 CAN driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4209 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -2286,5 +2286,7 @@
|
|||||||
* drivers/mtd/mp25x.c: Add ability to use different SPI modes and different
|
* drivers/mtd/mp25x.c: Add ability to use different SPI modes and different
|
||||||
manufacturers codes. Fix a error in the wait for not busy (submitted by
|
manufacturers codes. Fix a error in the wait for not busy (submitted by
|
||||||
Mohammad Elwakeel.
|
Mohammad Elwakeel.
|
||||||
|
* arch/arm/src/stm32/stm32_can.c. Add a low-level STM32 CAN driver. (Initial
|
||||||
|
check is incomplete).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<h1><big><font color="#3c34ec">
|
<h1><big><font color="#3c34ec">
|
||||||
<i>NuttX RTOS Porting Guide</i>
|
<i>NuttX RTOS Porting Guide</i>
|
||||||
</font></big></h1>
|
</font></big></h1>
|
||||||
<p>Last Updated: December 19, 2011</p>
|
<p>Last Updated: December 21, 2011</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -127,7 +127,8 @@
|
|||||||
<a href="#usbhostdrivers">6.3.9 USB Host-Side Drivers</a><br>
|
<a href="#usbhostdrivers">6.3.9 USB Host-Side Drivers</a><br>
|
||||||
<a href="#usbdevdrivers">6.3.10 USB Device-Side Drivers</a><br>
|
<a href="#usbdevdrivers">6.3.10 USB Device-Side Drivers</a><br>
|
||||||
<a href="#analogdrivers">6.3.11 Analog (ADC/DAC) Drivers</a><br>
|
<a href="#analogdrivers">6.3.11 Analog (ADC/DAC) Drivers</a><br>
|
||||||
<a href="#pwmdrivers">6.3.12 PWM Drivers</a>
|
<a href="#pwmdrivers">6.3.12 PWM Drivers</a><br>
|
||||||
|
<a href="#candrivers">6.3.13 CAN Drivers</a>
|
||||||
</ul>
|
</ul>
|
||||||
<a href="#pwrmgmt">6.4 Power Management</a>
|
<a href="#pwrmgmt">6.4 Power Management</a>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -3212,23 +3213,55 @@ extern void up_ledoff(int led);
|
|||||||
A "lower half", platform-specific driver that implements the low-level timer controls to implement the PWM functionality.
|
A "lower half", platform-specific driver that implements the low-level timer controls to implement the PWM functionality.
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
<p>
|
||||||
|
Files supporting PWM can be found in the following locations:
|
||||||
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li><b>Interface Definition</b>.
|
||||||
The header file for the NuttX PWM driver reside at <code>include/nuttx/pwm.h</code>.
|
The header file for the NuttX PWM driver reside at <code>include/nuttx/pwm.h</code>.
|
||||||
This header file includes both the application level interface to the PWM driver as well as the interface between the "upper half" and "lower half" drivers.
|
This header file includes both the application level interface to the PWM driver as well as the interface between the "upper half" and "lower half" drivers.
|
||||||
The PWM module uses a standard character driver framework.
|
The PWM module uses a standard character driver framework.
|
||||||
However, since the PWM driver is a devices control interface and not a data transfer interface,
|
However, since the PWM driver is a devices control interface and not a data transfer interface,
|
||||||
the majority of the functionality available to the application is implemented in driver ioctl calls.
|
the majority of the functionality available to the application is implemented in driver ioctl calls.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><b>"Upper Half" Driver</b>.
|
||||||
The generic, "upper half" PWM driver resides at <code>drivers/pwm.c</code>.
|
The generic, "upper half" PWM driver resides at <code>drivers/pwm.c</code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li><b>"Lower Half" Drivers</b>.
|
||||||
Platform-specific PWM drivers reside in <code>arch/</code><i><architecture></i><code>/src/</code><i><chip></i> directory for the specific processor <i><architecture></i> and for the specific <i><chip></i> analog peripheral devices.
|
Platform-specific PWM drivers reside in <code>arch/</code><i><architecture></i><code>/src/</code><i><chip></i> directory for the specific processor <i><architecture></i> and for the specific <i><chip></i> PWM peripheral devices.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<h3><a name="candrivers">6.3.13 CAN Drivers</a></h3>
|
||||||
|
<p>
|
||||||
|
NuttX supports only a very low-level CAN driver.
|
||||||
|
This driver supports only the data exchange and does not include any high-level CAN protocol.
|
||||||
|
The NuttX CAN driver is split into two parts:
|
||||||
|
</p>
|
||||||
|
<ol>
|
||||||
|
<li>
|
||||||
|
An "upper half", generic driver that provides the comman CAN interface to application level code, and
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
A "lower half", platform-specific driver that implements the low-level timer controls to implement the CAN functionality.
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<p>
|
||||||
|
Files supporting CAN can be found in the following locations:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li><b>Interface Definition</b>.
|
||||||
|
The header file for the NuttX CAN driver reside at <code>include/nuttx/can.h</code>.
|
||||||
|
This header file includes both the application level interface to the CAN driver as well as the interface between the "upper half" and "lower half" drivers.
|
||||||
|
The CAN module uses a standard character driver framework.
|
||||||
|
</li>
|
||||||
|
<li><b>"Upper Half" Driver</b>.
|
||||||
|
The generic, "upper half" CAN driver resides at <code>drivers/can.c</code>.
|
||||||
|
</li>
|
||||||
|
<li><b>"Lower Half" Drivers</b>.
|
||||||
|
Platform-specific CAN drivers reside in <code>arch/</code><i><architecture></i><code>/src/</code><i><chip></i> directory for the specific processor <i><architecture></i> and for the specific <i><chip></i> CAN peripheral devices.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h2><a name="pwrmgmt">6.4 Power Management</a></h2>
|
<h2><a name="pwrmgmt">6.4 Power Management</a></h2>
|
||||||
|
|
||||||
@@ -4332,6 +4365,19 @@ build
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<h3>CAN driver</h3>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_CAN</code>: Enables CAN support
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_CAN_FIFOSIZE</code>: The size of the circular buffer of CAN messages. Default: 8
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_CAN_NPENDINGRTR</code>: The size of the list of pending RTR requests. Default: 4
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h3>SPI driver</h3>
|
<h3>SPI driver</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# arch/arm/src/lpc17xx/Make.defs
|
# arch/arm/src/lpc17xx/Make.defs
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -57,10 +57,9 @@ endif
|
|||||||
# Required LPC17xx files
|
# Required LPC17xx files
|
||||||
|
|
||||||
CHIP_ASRCS =
|
CHIP_ASRCS =
|
||||||
CHIP_CSRCS = lpc17_allocateheap.c lpc17_can.c lpc17_clockconfig.c \
|
CHIP_CSRCS = lpc17_allocateheap.c lpc17_clockconfig.c lpc17_clrpend.c \
|
||||||
lpc17_clrpend.c lpc17_gpio.c lpc17_i2c.c lpc17_idle.c lpc17_irq.c \
|
lpc17_gpio.c lpc17_i2c.c lpc17_idle.c lpc17_irq.c lpc17_lowputc.c \
|
||||||
lpc17_lowputc.c lpc17_serial.c lpc17_spi.c lpc17_ssp.c lpc17_start.c \
|
lpc17_serial.c lpc17_spi.c lpc17_ssp.c lpc17_start.c lpc17_timerisr.c
|
||||||
lpc17_timerisr.c
|
|
||||||
|
|
||||||
# Configuration-dependent LPC17xx files
|
# Configuration-dependent LPC17xx files
|
||||||
|
|
||||||
@@ -90,6 +89,10 @@ CHIP_CSRCS += lpc17_ethernet.c
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_CAN),y)
|
||||||
|
CHIP_CSRCS += lpc17_can.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_LPC17_ADC),y)
|
ifeq ($(CONFIG_LPC17_ADC),y)
|
||||||
CHIP_CSRCS += lpc17_adc.c
|
CHIP_CSRCS += lpc17_adc.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# arch/arm/src/stm32/Make.defs
|
# arch/arm/src/stm32/Make.defs
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -87,6 +87,10 @@ ifeq ($(CONFIG_PWM),y)
|
|||||||
CHIP_CSRCS += stm32_pwm.c
|
CHIP_CSRCS += stm32_pwm.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_CAN),y)
|
||||||
|
CHIP_CSRCS += stm32_can.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_DEBUG),y)
|
ifeq ($(CONFIG_DEBUG),y)
|
||||||
CHIP_CSRCS += stm32_dumpgpio.c
|
CHIP_CSRCS += stm32_dumpgpio.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
Executable
+761
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
|||||||
* arch/arm/src/stm32/stm32_pwm.c
|
* arch/arm/src/stm32/stm32_pwm.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -633,6 +633,15 @@ defconfig -- This is a configuration file similar to the Linux
|
|||||||
CONFIG_RTC_ALARM - Enable if the RTC hardware supports setting of an
|
CONFIG_RTC_ALARM - Enable if the RTC hardware supports setting of an
|
||||||
alarm. A callback function will be executed when the alarm goes off
|
alarm. A callback function will be executed when the alarm goes off
|
||||||
|
|
||||||
|
CAN driver
|
||||||
|
|
||||||
|
CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or
|
||||||
|
CONFIG_STM32_CAN2 must also be defined)
|
||||||
|
CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
|
||||||
|
Default: 8
|
||||||
|
CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
|
||||||
|
Default: 4
|
||||||
|
|
||||||
SPI driver
|
SPI driver
|
||||||
|
|
||||||
CONFIG_SPI_OWNBUS - Set if there is only one active device
|
CONFIG_SPI_OWNBUS - Set if there is only one active device
|
||||||
|
|||||||
@@ -487,6 +487,16 @@ HY-Mini specific Configuration Options
|
|||||||
CONFIG_MMCSD_HAVECARDDETECT - Select if SDIO driver card detection
|
CONFIG_MMCSD_HAVECARDDETECT - Select if SDIO driver card detection
|
||||||
is 100% accurate (it is on the HY-MiniSTM32V)
|
is 100% accurate (it is on the HY-MiniSTM32V)
|
||||||
|
|
||||||
|
HY-MiniSTM32V CAN Configuration
|
||||||
|
|
||||||
|
CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or
|
||||||
|
CONFIG_STM32_CAN2 must also be defined)
|
||||||
|
CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
|
||||||
|
Default: 8
|
||||||
|
CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
|
||||||
|
Default: 4
|
||||||
|
CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN1 is defined.
|
||||||
|
CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN2 is defined.
|
||||||
|
|
||||||
HY-MiniSTM32V LCD Hardware Configuration (SSD1289 controler)
|
HY-MiniSTM32V LCD Hardware Configuration (SSD1289 controler)
|
||||||
|
|
||||||
|
|||||||
@@ -575,6 +575,17 @@ STM3210E-EVAL-specific Configuration Options
|
|||||||
CONFIG_SDIO_WIDTH_D1_ONLY - Select 1-bit transfer mode. Default:
|
CONFIG_SDIO_WIDTH_D1_ONLY - Select 1-bit transfer mode. Default:
|
||||||
4-bit transfer mode.
|
4-bit transfer mode.
|
||||||
|
|
||||||
|
STM3210E-EVAL CAN Configuration
|
||||||
|
|
||||||
|
CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or
|
||||||
|
CONFIG_STM32_CAN2 must also be defined)
|
||||||
|
CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
|
||||||
|
Default: 8
|
||||||
|
CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
|
||||||
|
Default: 4
|
||||||
|
CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN1 is defined.
|
||||||
|
CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN2 is defined.
|
||||||
|
|
||||||
STM3210E-EVAL LCD Hardware Configuration
|
STM3210E-EVAL LCD Hardware Configuration
|
||||||
|
|
||||||
CONFIG_LCD_LANDSCAPE - Define for 320x240 display "landscape"
|
CONFIG_LCD_LANDSCAPE - Define for 320x240 display "landscape"
|
||||||
|
|||||||
@@ -481,6 +481,17 @@ STM3240G-EVAL-specific Configuration Options
|
|||||||
CONFIG_STM32_ETH_PTP - Precision Time Protocol (PTP). Not supported
|
CONFIG_STM32_ETH_PTP - Precision Time Protocol (PTP). Not supported
|
||||||
but some hooks are indicated with this condition.
|
but some hooks are indicated with this condition.
|
||||||
|
|
||||||
|
STM3240G-EVAL CAN Configuration
|
||||||
|
|
||||||
|
CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or
|
||||||
|
CONFIG_STM32_CAN2 must also be defined)
|
||||||
|
CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
|
||||||
|
Default: 8
|
||||||
|
CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
|
||||||
|
Default: 4
|
||||||
|
CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN1 is defined.
|
||||||
|
CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN2 is defined.
|
||||||
|
|
||||||
STM3240G-EVAL LCD Hardware Configuration
|
STM3240G-EVAL LCD Hardware Configuration
|
||||||
|
|
||||||
Configurations
|
Configurations
|
||||||
|
|||||||
@@ -256,6 +256,24 @@ CONFIG_SSI1_DISABLE=y
|
|||||||
CONFIG_SSI_POLLWAIT=y
|
CONFIG_SSI_POLLWAIT=y
|
||||||
#CONFIG_SSI_TXLIMIT=4
|
#CONFIG_SSI_TXLIMIT=4
|
||||||
|
|
||||||
|
#
|
||||||
|
# STM32F40xxx specific CAN device driver settings
|
||||||
|
#
|
||||||
|
# CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or
|
||||||
|
# CONFIG_STM32_CAN2 must also be defined)
|
||||||
|
# CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
|
||||||
|
# Default: 8
|
||||||
|
# CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
|
||||||
|
# Default: 4
|
||||||
|
# CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN1 is defined.
|
||||||
|
# CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN2 is defined.
|
||||||
|
#
|
||||||
|
CONFIG_CAN=n
|
||||||
|
#CONFIG_CAN_FIFOSIZE
|
||||||
|
#CONFIG_CAN_NPENDINGRTR
|
||||||
|
CONFIG_CAN1_BAUD=115200
|
||||||
|
CONFIG_CAN2_BAUD=115200
|
||||||
|
|
||||||
#
|
#
|
||||||
# STM32F40xxx Ethernet device driver settings
|
# STM32F40xxx Ethernet device driver settings
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -256,6 +256,24 @@ CONFIG_SSI1_DISABLE=y
|
|||||||
CONFIG_SSI_POLLWAIT=y
|
CONFIG_SSI_POLLWAIT=y
|
||||||
#CONFIG_SSI_TXLIMIT=4
|
#CONFIG_SSI_TXLIMIT=4
|
||||||
|
|
||||||
|
#
|
||||||
|
# STM32F40xxx specific CAN device driver settings
|
||||||
|
#
|
||||||
|
# CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or
|
||||||
|
# CONFIG_STM32_CAN2 must also be defined)
|
||||||
|
# CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
|
||||||
|
# Default: 8
|
||||||
|
# CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
|
||||||
|
# Default: 4
|
||||||
|
# CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN1 is defined.
|
||||||
|
# CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN2 is defined.
|
||||||
|
#
|
||||||
|
CONFIG_CAN=n
|
||||||
|
#CONFIG_CAN_FIFOSIZE
|
||||||
|
#CONFIG_CAN_NPENDINGRTR
|
||||||
|
CONFIG_CAN1_BAUD=115200
|
||||||
|
CONFIG_CAN2_BAUD=115200
|
||||||
|
|
||||||
#
|
#
|
||||||
# STM32F40xxx Ethernet device driver settings
|
# STM32F40xxx Ethernet device driver settings
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -256,6 +256,24 @@ CONFIG_SSI1_DISABLE=y
|
|||||||
CONFIG_SSI_POLLWAIT=y
|
CONFIG_SSI_POLLWAIT=y
|
||||||
#CONFIG_SSI_TXLIMIT=4
|
#CONFIG_SSI_TXLIMIT=4
|
||||||
|
|
||||||
|
#
|
||||||
|
# STM32F40xxx specific CAN device driver settings
|
||||||
|
#
|
||||||
|
# CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or
|
||||||
|
# CONFIG_STM32_CAN2 must also be defined)
|
||||||
|
# CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
|
||||||
|
# Default: 8
|
||||||
|
# CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
|
||||||
|
# Default: 4
|
||||||
|
# CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN1 is defined.
|
||||||
|
# CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN2 is defined.
|
||||||
|
#
|
||||||
|
CONFIG_CAN=n
|
||||||
|
#CONFIG_CAN_FIFOSIZE
|
||||||
|
#CONFIG_CAN_NPENDINGRTR
|
||||||
|
CONFIG_CAN1_BAUD=115200
|
||||||
|
CONFIG_CAN2_BAUD=115200
|
||||||
|
|
||||||
#
|
#
|
||||||
# STM32F40xxx Ethernet device driver settings
|
# STM32F40xxx Ethernet device driver settings
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -256,6 +256,24 @@ CONFIG_SSI1_DISABLE=y
|
|||||||
CONFIG_SSI_POLLWAIT=y
|
CONFIG_SSI_POLLWAIT=y
|
||||||
#CONFIG_SSI_TXLIMIT=4
|
#CONFIG_SSI_TXLIMIT=4
|
||||||
|
|
||||||
|
#
|
||||||
|
# STM32F40xxx specific CAN device driver settings
|
||||||
|
#
|
||||||
|
# CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or
|
||||||
|
# CONFIG_STM32_CAN2 must also be defined)
|
||||||
|
# CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages.
|
||||||
|
# Default: 8
|
||||||
|
# CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests.
|
||||||
|
# Default: 4
|
||||||
|
# CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN1 is defined.
|
||||||
|
# CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN2 is defined.
|
||||||
|
#
|
||||||
|
CONFIG_CAN=n
|
||||||
|
#CONFIG_CAN_FIFOSIZE
|
||||||
|
#CONFIG_CAN_NPENDINGRTR
|
||||||
|
CONFIG_CAN1_BAUD=115200
|
||||||
|
CONFIG_CAN2_BAUD=115200
|
||||||
|
|
||||||
#
|
#
|
||||||
# STM32F40xxx Ethernet device driver settings
|
# STM32F40xxx Ethernet device driver settings
|
||||||
#
|
#
|
||||||
|
|||||||
+5
-2
@@ -2,7 +2,7 @@
|
|||||||
# drivers/Makefile
|
# drivers/Makefile
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -64,10 +64,13 @@ include usbhost/Make.defs
|
|||||||
include wireless/Make.defs
|
include wireless/Make.defs
|
||||||
|
|
||||||
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||||
CSRCS += dev_null.c dev_zero.c loop.c can.c
|
CSRCS += dev_null.c dev_zero.c loop.c
|
||||||
ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
|
ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
|
||||||
CSRCS += ramdisk.c rwbuffer.c
|
CSRCS += ramdisk.c rwbuffer.c
|
||||||
endif
|
endif
|
||||||
|
ifneq ($(CONFIG_CAN),y)
|
||||||
|
CSRCS += can.c
|
||||||
|
endif
|
||||||
ifeq ($(CONFIG_PWM),y)
|
ifeq ($(CONFIG_PWM),y)
|
||||||
CSRCS += pwm.c
|
CSRCS += pwm.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
+22
-7
@@ -1,8 +1,8 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/can.c
|
* drivers/can.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -33,10 +33,6 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Compilation Switches
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -60,9 +56,27 @@
|
|||||||
|
|
||||||
#include <arch/irq.h>
|
#include <arch/irq.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
/* Debug ********************************************************************/
|
||||||
|
/* Non-standard debug that may be enabled just for testing CAN */
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_CAN
|
||||||
|
# define candbg dbg
|
||||||
|
# define canvdbg vdbg
|
||||||
|
# define canlldbg lldbg
|
||||||
|
# define canllvdbg llvdbg
|
||||||
|
#else
|
||||||
|
# define candbg(x...)
|
||||||
|
# define canvdbg(x...)
|
||||||
|
# define canlldbg(x...)
|
||||||
|
# define canllvdbg(x...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Timing Definitions *******************************************************/
|
||||||
|
|
||||||
#define HALF_SECOND_MSEC 500
|
#define HALF_SECOND_MSEC 500
|
||||||
#define HALF_SECOND_USEC 500000L
|
#define HALF_SECOND_USEC 500000L
|
||||||
@@ -619,7 +633,7 @@ int can_register(FAR const char *path, FAR struct can_dev_s *dev)
|
|||||||
|
|
||||||
/* Register the CAN device */
|
/* Register the CAN device */
|
||||||
|
|
||||||
dbg("Registering %s\n", path);
|
canvdbg("Registering %s\n", path);
|
||||||
return register_driver(path, &g_canops, 0666, dev);
|
return register_driver(path, &g_canops, 0666, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,3 +782,4 @@ int can_txdone(FAR struct can_dev_s *dev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_CAN */
|
||||||
|
|||||||
+14
-9
@@ -1,8 +1,8 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* include/nuttx/can.h
|
* include/nuttx/can.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008, 2009, 2011 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -33,8 +33,8 @@
|
|||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifndef __NUTTX_CAN_H
|
#ifndef _INCLUDE_NUTTX_CAN_H
|
||||||
#define __NUTTX_CAN_H
|
#define _INCLUDE_NUTTX_CAN_H
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
@@ -46,14 +46,18 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
/* Default configuration settings that may be overridden in the board configuration.
|
/* Default configuration settings that may be overridden in the NuttX configuration
|
||||||
* file. The configured size is limited to 255 to fit into a uint8_t.
|
* file or in the board configuration file. The configured size is limited to 255
|
||||||
|
* to fit into a uint8_t.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(CONFIG_CAN_FIFOSIZE)
|
#if !defined(CONFIG_CAN_FIFOSIZE)
|
||||||
@@ -165,8 +169,8 @@ struct can_ops_s
|
|||||||
|
|
||||||
/* Configure the CAN. This method is called the first time that the CAN
|
/* Configure the CAN. This method is called the first time that the CAN
|
||||||
* device is opened. This will occur when the port is first opened.
|
* device is opened. This will occur when the port is first opened.
|
||||||
* This setup includes configuring and attaching CAN interrupts. Interrupts
|
* This setup includes configuring and attaching CAN interrupts. All CAN
|
||||||
* are all disabled upon return.
|
* interrupts are disabled upon return.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CODE int (*co_setup)(FAR struct can_dev_s *dev);
|
CODE int (*co_setup)(FAR struct can_dev_s *dev);
|
||||||
@@ -305,4 +309,5 @@ EXTERN int can_txdone(FAR struct can_dev_s *dev);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __NUTTX_CAN_H */
|
#endif /* CONFIG_CAN */
|
||||||
|
#endif /* _INCLUDE_NUTTX_CAN_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user