mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 11:59:17 +08:00
Fix ENC28J60 chip enable issue
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5153 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -765,10 +765,18 @@ Where <subdir> is one of the following:
|
|||||||
contains support for some built-in applications that can be enabled by making
|
contains support for some built-in applications that can be enabled by making
|
||||||
some additional minor change to the configuration file.
|
some additional minor change to the configuration file.
|
||||||
|
|
||||||
NOTE: This configuration uses to the mconf configuration tool to control
|
Reconfiguring: This configuration uses to the mconf configuration tool to control
|
||||||
the configuration. See the section entitled "NuttX Configuration Tool"
|
the configuration. See the section entitled "NuttX Configuration Tool"
|
||||||
in the top-level README.txt file.
|
in the top-level README.txt file.
|
||||||
|
|
||||||
|
Start Delays: If no SD card is present in the slot, or if the network is not
|
||||||
|
connected, then there will be long start-up delays before you get the NSH
|
||||||
|
prompt. If I am focused on ENC28J60 debug, I usually disable MMC/SD so that
|
||||||
|
I don't have to bother with the SD card:
|
||||||
|
|
||||||
|
CONFIG_STM32_SDIO=n
|
||||||
|
CONFIG_MMCSD=n
|
||||||
|
|
||||||
STATUS: The board port is basically functional. Not all features have been
|
STATUS: The board port is basically functional. Not all features have been
|
||||||
verified. The ENC28J60 network is not yet functional. Networking is
|
verified. The ENC28J60 network is not yet functional. Networking is
|
||||||
enabled by default in this configuration for testing purposes. To use this
|
enabled by default in this configuration for testing purposes. To use this
|
||||||
|
|||||||
@@ -289,8 +289,8 @@ CONFIG_NAME_MAX=32
|
|||||||
CONFIG_PREALLOC_MQ_MSGS=4
|
CONFIG_PREALLOC_MQ_MSGS=4
|
||||||
CONFIG_MQ_MAXMSGSIZE=32
|
CONFIG_MQ_MAXMSGSIZE=32
|
||||||
CONFIG_MAX_WDOGPARMS=2
|
CONFIG_MAX_WDOGPARMS=2
|
||||||
CONFIG_PREALLOC_WDOGS=4
|
CONFIG_PREALLOC_WDOGS=16
|
||||||
CONFIG_PREALLOC_TIMERS=4
|
CONFIG_PREALLOC_TIMERS=8
|
||||||
|
|
||||||
#
|
#
|
||||||
# Stack and heap information
|
# Stack and heap information
|
||||||
@@ -387,12 +387,17 @@ CONFIG_USART2_BITS=8
|
|||||||
CONFIG_USART2_PARITY=0
|
CONFIG_USART2_PARITY=0
|
||||||
CONFIG_USART2_2STOP=0
|
CONFIG_USART2_2STOP=0
|
||||||
CONFIG_USBDEV=y
|
CONFIG_USBDEV=y
|
||||||
# CONFIG_USBDEV_COMPOSITE is not set
|
|
||||||
|
#
|
||||||
|
# Device Controller Driver Options
|
||||||
|
#
|
||||||
# CONFIG_USBDEV_ISOCHRONOUS is not set
|
# CONFIG_USBDEV_ISOCHRONOUS is not set
|
||||||
# CONFIG_USBDEV_DUALSPEED is not set
|
# CONFIG_USBDEV_DUALSPEED is not set
|
||||||
CONFIG_USBDEV_SELFPOWERED=y
|
CONFIG_USBDEV_SELFPOWERED=y
|
||||||
# CONFIG_USBDEV_BUSPOWERED is not set
|
# CONFIG_USBDEV_BUSPOWERED is not set
|
||||||
|
# CONFIG_USBDEV_DMA is not set
|
||||||
# CONFIG_USBDEV_TRACE is not set
|
# CONFIG_USBDEV_TRACE is not set
|
||||||
|
# CONFIG_USBDEV_COMPOSITE is not set
|
||||||
# CONFIG_PL2303 is not set
|
# CONFIG_PL2303 is not set
|
||||||
# CONFIG_CDCACM is not set
|
# CONFIG_CDCACM is not set
|
||||||
CONFIG_USBMSC=y
|
CONFIG_USBMSC=y
|
||||||
@@ -521,142 +526,142 @@ CONFIG_NAMEDAPP=y
|
|||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# ADC example
|
# ADC Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_ADC is not set
|
# CONFIG_EXAMPLES_ADC is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Buttons example
|
# Buttons Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_BUTTONS is not set
|
# CONFIG_EXAMPLES_BUTTONS is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# CAN example
|
# CAN Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_CAN is not set
|
# CONFIG_EXAMPLES_CAN is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# USB CDC/ACM class driver example
|
# USB CDC/ACM Class Driver Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_CDCACM is not set
|
# CONFIG_EXAMPLES_CDCACM is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# USB composite class driver example
|
# USB composite Class Driver Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_COMPOSITE is not set
|
# CONFIG_EXAMPLES_COMPOSITE is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# DHCP server example
|
# DHCP Server Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_DHCPD is not set
|
# CONFIG_EXAMPLES_DHCPD is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# FTP client example
|
# FTP Client Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_FTPC is not set
|
# CONFIG_EXAMPLES_FTPC is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# FTP server example
|
# FTP Server Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_FTPD is not set
|
# CONFIG_EXAMPLES_FTPD is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# "Hello, World!" example
|
# "Hello, World!" Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_HELLO is not set
|
# CONFIG_EXAMPLES_HELLO is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# "Hello, World!" C++ example
|
# "Hello, World!" C++ Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_HELLOXX is not set
|
# CONFIG_EXAMPLES_HELLOXX is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# USB HID keyboard example
|
# USB HID Keyboard Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_HIDKBD is not set
|
# CONFIG_EXAMPLES_HIDKBD is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# IGMP example
|
# IGMP Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_IGMP is not set
|
# CONFIG_EXAMPLES_IGMP is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# LCD read/write example
|
# LCD Read/Write Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_LCDRW is not set
|
# CONFIG_EXAMPLES_LCDRW is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Memory management example
|
# Memory Management Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_MM is not set
|
# CONFIG_EXAMPLES_MM is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# File system mount example
|
# File System Mount Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_MOUNT is not set
|
# CONFIG_EXAMPLES_MOUNT is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# FreeModBus example
|
# FreeModBus Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_MODBUS is not set
|
# CONFIG_EXAMPLES_MODBUS is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Network test example
|
# Network Test Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_NETTEST is not set
|
# CONFIG_EXAMPLES_NETTEST is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# NuttShell (NSH) example
|
# NuttShell (NSH) Example
|
||||||
#
|
#
|
||||||
CONFIG_EXAMPLES_NSH=y
|
CONFIG_EXAMPLES_NSH=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# NULL example
|
# NULL Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_NULL is not set
|
# CONFIG_EXAMPLES_NULL is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# NX graphics example
|
# NX Graphics Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_NX is not set
|
# CONFIG_EXAMPLES_NX is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# NxConsole example
|
# NxConsole Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_NXCONSOLE is not set
|
# CONFIG_EXAMPLES_NXCONSOLE is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# NXFFS file system example
|
# NXFFS File System Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_NXFFS is not set
|
# CONFIG_EXAMPLES_NXFFS is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# NXFLAT example
|
# NXFLAT Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_NXFLAT is not set
|
# CONFIG_EXAMPLES_NXFLAT is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# NX graphics "Hello, World!" example
|
# NX Graphics "Hello, World!" Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_NXHELLO is not set
|
# CONFIG_EXAMPLES_NXHELLO is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# NX graphics image example
|
# NX Graphics image Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_NXIMAGE is not set
|
# CONFIG_EXAMPLES_NXIMAGE is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# NX graphics lines example
|
# NX Graphics lines Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_NXLINES is not set
|
# CONFIG_EXAMPLES_NXLINES is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# NX graphics text example
|
# NX Graphics Text Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_NXTEXT is not set
|
# CONFIG_EXAMPLES_NXTEXT is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# OS test example
|
# OS Test Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_OSTEST is not set
|
# CONFIG_EXAMPLES_OSTEST is not set
|
||||||
|
|
||||||
@@ -666,81 +671,86 @@ CONFIG_EXAMPLES_NSH=y
|
|||||||
# CONFIG_EXAMPLES_PASHELLO is not set
|
# CONFIG_EXAMPLES_PASHELLO is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Pipe example
|
# Pipe Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_PIPE is not set
|
# CONFIG_EXAMPLES_PIPE is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Poll example
|
# Poll Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_POLL is not set
|
# CONFIG_EXAMPLES_POLL is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Pulse width modulation (PWM) example
|
# Pulse Width Modulation (PWM) Example
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# Quadrature encoder example
|
# Quadrature Encoder Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_QENCODER is not set
|
# CONFIG_EXAMPLES_QENCODER is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# RGMP example
|
# RGMP Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_RGMP is not set
|
# CONFIG_EXAMPLES_RGMP is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# ROMFS example
|
# ROMFS Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_ROMFS is not set
|
# CONFIG_EXAMPLES_ROMFS is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# sendmail example
|
# sendmail Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_SENDMAIL is not set
|
# CONFIG_EXAMPLES_SENDMAIL is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Serial loopback example
|
# Serial Loopback Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_SERLOOP is not set
|
# CONFIG_EXAMPLES_SERLOOP is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Telnet daemon example
|
# Telnet Daemon Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_TELNETD is not set
|
# CONFIG_EXAMPLES_TELNETD is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# THTTPD web server example
|
# THTTPD Web Server Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_THTTPD is not set
|
# CONFIG_EXAMPLES_THTTPD is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# TIFF generation example
|
# TIFF Generation Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_TIFF is not set
|
# CONFIG_EXAMPLES_TIFF is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Touchscreen example
|
# Touchscreen Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_TOUCHSCREEN is not set
|
# CONFIG_EXAMPLES_TOUCHSCREEN is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# UDP example
|
# UDP Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_UDP is not set
|
# CONFIG_EXAMPLES_UDP is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# uIP web server example
|
# UDP Discovery Daemon Example
|
||||||
|
#
|
||||||
|
# CONFIG_EXAMPLE_DISCOVER is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# uIP Web Server Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_UIP is not set
|
# CONFIG_EXAMPLES_UIP is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# USB serial test example
|
# USB Serial Test Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_USBSERIAL is not set
|
# CONFIG_EXAMPLES_USBSERIAL is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# USB mass storage class example
|
# USB Mass Storage Class Example
|
||||||
#
|
#
|
||||||
CONFIG_EXAMPLES_USBMSC=y
|
CONFIG_EXAMPLES_USBMSC=y
|
||||||
CONFIG_EXAMPLES_USBMSC_BUILTIN=y
|
CONFIG_EXAMPLES_USBMSC_BUILTIN=y
|
||||||
@@ -759,25 +769,29 @@ CONFIG_EXAMPLES_USBMSC_DEVPATH3="/dev/mmcsd2"
|
|||||||
# CONFIG_EXAMPLES_USBMSC_TRACEINTERRUPTS is not set
|
# CONFIG_EXAMPLES_USBMSC_TRACEINTERRUPTS is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# USB serial terminal example
|
# USB Serial Terminal Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_USBTERM is not set
|
# CONFIG_EXAMPLES_USBTERM is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Watchdog timer example
|
# Watchdog timer Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_WATCHDOG is not set
|
# CONFIG_EXAMPLES_WATCHDOG is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# wget example
|
# wget Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_WGET is not set
|
# CONFIG_EXAMPLES_WGET is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# WLAN example
|
# WLAN Example
|
||||||
#
|
#
|
||||||
# CONFIG_EXAMPLES_WLAN is not set
|
# CONFIG_EXAMPLES_WLAN is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# XML RPC Example
|
||||||
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# Interpreters
|
# Interpreters
|
||||||
#
|
#
|
||||||
@@ -857,6 +871,16 @@ CONFIG_NETUTILS_WEBCLIENT=y
|
|||||||
#
|
#
|
||||||
# CONFIG_NETUTILS_WEBSERVER is not set
|
# CONFIG_NETUTILS_WEBSERVER is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# UDP Discovery Utility
|
||||||
|
#
|
||||||
|
# CONFIG_NETUTILS_DISCOVER is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# XML-RPC library
|
||||||
|
#
|
||||||
|
# CONFIG_NETUTILS_XMLRPC is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# ModBus
|
# ModBus
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include <nuttx/sdio.h>
|
#include <nuttx/sdio.h>
|
||||||
#include <nuttx/mmcsd.h>
|
#include <nuttx/mmcsd.h>
|
||||||
|
|
||||||
|
#include "stm32_sdio.h"
|
||||||
#include "fire-internal.h"
|
#include "fire-internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* drivers/mtd/m25px.c
|
* drivers/mtd/sst25.c
|
||||||
* Driver for SPI-based SST25 FLASH.
|
* Driver for SPI-based SST25 FLASH.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
|||||||
@@ -652,14 +652,14 @@ static uint8_t enc_rdbreg(FAR struct enc_driver_s *priv, uint8_t ctrlreg)
|
|||||||
|
|
||||||
DEBUGASSERT(priv && priv->spi);
|
DEBUGASSERT(priv && priv->spi);
|
||||||
|
|
||||||
/* Select ENC28J60 chip */
|
|
||||||
|
|
||||||
enc_select(priv);
|
|
||||||
|
|
||||||
/* Set the bank */
|
/* Set the bank */
|
||||||
|
|
||||||
enc_setbank(priv, GETBANK(ctrlreg));
|
enc_setbank(priv, GETBANK(ctrlreg));
|
||||||
|
|
||||||
|
/* Select ENC28J60 chip */
|
||||||
|
|
||||||
|
enc_select(priv);
|
||||||
|
|
||||||
/* Send the RCR command and collect the data. How we collect the data
|
/* Send the RCR command and collect the data. How we collect the data
|
||||||
* depends on if this is a PHY/CAN or not. The normal sequence requires
|
* depends on if this is a PHY/CAN or not. The normal sequence requires
|
||||||
* 16-clocks: 8 to clock out the cmd and 8 to clock in the data.
|
* 16-clocks: 8 to clock out the cmd and 8 to clock in the data.
|
||||||
|
|||||||
@@ -92,11 +92,10 @@ extern "C" {
|
|||||||
* Set up one granule allocator instance. Allocations will be aligned to
|
* Set up one granule allocator instance. Allocations will be aligned to
|
||||||
* the alignment size (log2align; allocations will be in units of the
|
* the alignment size (log2align; allocations will be in units of the
|
||||||
* granule size (log2gran). Larger granules will give better performance
|
* granule size (log2gran). Larger granules will give better performance
|
||||||
* and less overhead but more losses of memory due to alignment
|
* and less overhead but more losses of memory due to quantization waste.
|
||||||
* quantization waste. Additional memory waste can occur form alignment;
|
* Additional memory waste can occur from alignment; log2align should be
|
||||||
* log2align should be set to 0 unless you are using the granule allocator
|
* set to 0 unless you are using the granule allocator to manage DMA memory
|
||||||
* to manage DMA memory and your hardware has specific memory alignment
|
* and your hardware has specific memory alignment requirements.
|
||||||
* requirements.
|
|
||||||
*
|
*
|
||||||
* Geneneral Usage Summary. This is an example using the GCC section
|
* Geneneral Usage Summary. This is an example using the GCC section
|
||||||
* attribute to position a DMA heap in memory (logic in the linker script
|
* attribute to position a DMA heap in memory (logic in the linker script
|
||||||
|
|||||||
+28
-7
@@ -46,8 +46,8 @@ This directory contains the NuttX memory management logic. This include:
|
|||||||
|
|
||||||
3) Granule Allocator. A non-standard granule allocator is also available
|
3) Granule Allocator. A non-standard granule allocator is also available
|
||||||
in this directory The granule allocator allocates memory in units
|
in this directory The granule allocator allocates memory in units
|
||||||
of a fixed sized block ("granule"). All memory is aligned to the size
|
of a fixed sized block ("granule"). Allocations may be aligned to a user-
|
||||||
of one granule.
|
provided address boundary.
|
||||||
|
|
||||||
The granule allocator interfaces are defined in nuttx/include/nuttx/gran.h.
|
The granule allocator interfaces are defined in nuttx/include/nuttx/gran.h.
|
||||||
The granule allocator consists of these files in this directory:
|
The granule allocator consists of these files in this directory:
|
||||||
@@ -59,13 +59,34 @@ This directory contains the NuttX memory management logic. This include:
|
|||||||
as of this writing. The intent of the granule allocator is to provide
|
as of this writing. The intent of the granule allocator is to provide
|
||||||
a tool to support platform-specific management of aligned DMA memory.
|
a tool to support platform-specific management of aligned DMA memory.
|
||||||
|
|
||||||
NOTE: Because each granule is aligned to the granule size and each
|
NOTE: Because each granule may be aligned and each allocation is in
|
||||||
allocations is in units of the granule size, selection of the granule
|
units of the granule size, selection of the granule size is important:
|
||||||
size is important: Larger granules will give better performance and
|
Larger granules will give better performance and less overhead but more
|
||||||
less overhead but more losses of memory due to alignment and quantization
|
losses of memory due to quantization waste. Additional memory waste
|
||||||
waste.
|
can occur from alignment; Of course, heap alignment should no be
|
||||||
|
used unless (a) you are using the granule allocator to manage DMA memory
|
||||||
|
and (b) your hardware has specific memory alignment requirements.
|
||||||
|
|
||||||
The current implementation also restricts the maximum allocation size
|
The current implementation also restricts the maximum allocation size
|
||||||
to 32 granules. That restriction could be eliminated with some
|
to 32 granules. That restriction could be eliminated with some
|
||||||
additional coding effort, but currently requires larger granule
|
additional coding effort, but currently requires larger granule
|
||||||
sizes for larger allocations.
|
sizes for larger allocations.
|
||||||
|
|
||||||
|
Geneneral Usage Example. This is an example using the GCC section
|
||||||
|
attribute to position a DMA heap in memory (logic in the linker script
|
||||||
|
would assign the section .dmaheap to the DMA memory.
|
||||||
|
|
||||||
|
FAR uint32_t g_dmaheap[DMAHEAP_SIZE] __attribute__((section(.dmaheap)));
|
||||||
|
|
||||||
|
The heap is created by calling gran_initialize. Here the granual size
|
||||||
|
is set to 64 bytes and the alignment to 16 bytes:
|
||||||
|
|
||||||
|
GRAN_HANDLE handle = gran_initialize(g_dmaheap, DMAHEAP_SIZE, 6, 4);
|
||||||
|
|
||||||
|
Then the GRAN_HANDLE can be used to allocate memory (There is no
|
||||||
|
GRAN_HANDLE if CONFIG_GRAN_SINGLE=y):
|
||||||
|
|
||||||
|
FAR uint8_t *dma_memory = (FAR uint8_t *)gran_alloc(handle, 47);
|
||||||
|
|
||||||
|
The actual memory allocates will be 64 byte (wasting 17 bytes) and
|
||||||
|
will be aligned at least to (1 << log2align).
|
||||||
|
|||||||
@@ -158,11 +158,10 @@ gran_common_initialize(FAR void *heapstart, size_t heapsize, uint8_t log2gran,
|
|||||||
* Set up one granule allocator instance. Allocations will be aligned to
|
* Set up one granule allocator instance. Allocations will be aligned to
|
||||||
* the alignment size (log2align; allocations will be in units of the
|
* the alignment size (log2align; allocations will be in units of the
|
||||||
* granule size (log2gran). Larger granules will give better performance
|
* granule size (log2gran). Larger granules will give better performance
|
||||||
* and less overhead but more losses of memory due to alignment
|
* and less overhead but more losses of memory due to quantization waste.
|
||||||
* quantization waste. Additional memory waste can occur form alignment;
|
* Additional memory waste can occur from alignment; log2align should be
|
||||||
* log2align should be set to 0 unless you are using the granule allocator
|
* set to 0 unless you are using the granule allocator to manage DMA memory
|
||||||
* to manage DMA memory and your hardware has specific memory alignment
|
* and your hardware has specific memory alignment requirements.
|
||||||
* requirements.
|
|
||||||
*
|
*
|
||||||
* Geneneral Usage Summary. This is an example using the GCC section
|
* Geneneral Usage Summary. This is an example using the GCC section
|
||||||
* attribute to position a DMA heap in memory (logic in the linker script
|
* attribute to position a DMA heap in memory (logic in the linker script
|
||||||
|
|||||||
Reference in New Issue
Block a user