overhauled documentation

includes minor refactoring in example code and modification of how the
generic and the tinygecko specific vector.h go together (bringing it in
line with stm32/f1's memorymap.h)
This commit is contained in:
chrysn
2012-02-26 03:40:18 +01:00
parent 08918902ab
commit 2275ed7b0c
10 changed files with 132 additions and 38 deletions

View File

@@ -17,17 +17,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* this interface correspons to the description in
* d0034_efm32tg_reference_manual.pdf section 11. */
/** @file
*
* Definitions for the CMU (Clock Management Unit).
*
* This corresponds to the description in d0034_efm32tg_reference_manual.pdf
* section 11.
*
* @see CMU_registers
*/
/* FIXME: i'd prefer not to @see CMU_registers but have some direct link placed
* automatically from a file to its groups */
#ifndef LIBOPENCM3_EFM32_TINYGECKO_CMU_H
#define LIBOPENCM3_EFM32_TINYGECKO_CMU_H
#include <libopencm3/cm3/common.h>
#define CMU_BASE 0x400C8000 /* according to d0034_efm32tg_reference_manual.pdf figure 5.2 */
#define CMU_BASE 0x400C8000 /**< Register base address for the CMU according to d0034_efm32tg_reference_manual.pdf figure 5.2. */
/* this is d0034_efm32tg_reference_manual.pdf section 11.4 */
/** These definitions reflect d0034_efm32tg_reference_manual.pdf section 11.4.
*
* @defgroup CMU_registers CMU registers
* @{ */
#define CMU_CTRL MMIO32(CMU_BASE + 0x000)
#define CMU_HFCORECLKDIV MMIO32(CMU_BASE + 0x004)
@@ -58,8 +70,14 @@
#define CMU_ROUTE MMIO32(CMU_BASE + 0x080)
#define CMU_LOCK MMIO32(CMU_BASE + 0x084)
/* this is incomplete because i'm impatient and want a working result
* quickly */
/** @} */
/**
* This section is incomplete because i'm impatient and want a working result
* quickly
*
* @todo Include all bits and bit groups from the manual.
*/
#define CMU_HFPERCLKEN0_GPIO (1<<6)

View File

@@ -1,3 +1,7 @@
/* FIXME: proper documentation, see where this fits, if we need this at all
* etc. this was just a first attempt at implementing something easy with
* MMIO32. */
/* this implements d0034_efm32tg_reference_manual.pdf's 7.3.4 "Device Revision"
* section */

View File

@@ -17,18 +17,36 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* this interface corresponds to the description in
* d0034_efm32tg_reference_manual.pdf section 28. the interface tries to be
* close to stm32/f1's gpio interface. */
/** @file
*
* Definitions for the GPIO subsystem (General Purpose Input Output).
*
* This corresponds to the description in d0034_efm32tg_reference_manual.pdf
* section 28.
*
* @see GPIO_registers
* @see GPIO_MODE_values
*/
/* FIXME: i'd prefer not to @see CMU_registers but have some direct link placed
* automatically from a file to its groups */
#ifndef LIBOPENCM3_EFM32_TINYGECKO_GPIO_H
#define LIBOPENCM3_EFM32_TINYGECKO_GPIO_H
#include <libopencm3/cm3/common.h>
#define GPIO_BASE 0x40006000 /* according to d0034_efm32tg_reference_manual.pdf figure 5.2 */
#define GPIO_BASE 0x40006000 /**< Register base address for the GPIO according to d0034_efm32tg_reference_manual.pdf figure 5.2. */
/* this is rather straight forward d0034_efm32tg_reference_manual.pdf section 28.4 */
/** These definitions reflect d0034_efm32tg_reference_manual.pdf section 28.4
*
* The bulk of the registers defined here (like GPIO_PA_CTRL) will not be used
* inside the convenience functions, but are provided for direct access.
*
* @todo This section could profit from bit-banding.
*
* @defgroup GPIO_registers GPIO registers
* @{
*/
#define GPIO_Px_CTRL_OFFSET 0x000
#define GPIO_Px_MODEL_OFFSET 0x004
#define GPIO_Px_MODEH_OFFSET 0x008
@@ -122,10 +140,24 @@
#define GPIO_EM4WUPOL MMIO32(GPIO_BASE + 0x138)
#define GPIO_EM4WUCAUSE MMIO32(GPIO_BASE + 0x13C)
/* these are the modes defined for the MODEx fields in the MODEL/MODEH
* registers, named as in d0034_efm32tg_reference_manual.pdf's sections
* 28.5.2/28.5.3. for explanations of what they really do, rather see section
* 28.3.1. */
/** @} */
/** These are the modes defined for the MODEx fields in the MODEL/MODEH
* registers.
*
* For example, to set the mode for the 3rd pin of port A to pushpull, set
* `GPIO_PA_MODEL = GPIO_MODE_PUSHPULL << (3*4);`.
*
* @todo Update the example as soon as there are convenience functions to do
* this properly.
*
* They are named as in d0034_efm32tg_reference_manual.pdf's sections
* 28.5.2/28.5.3. For explanations of what they really do, rather see section
* 28.3.1.
*
* @defgroup GPIO_MODE_values GPIO MODE values
* @{
*/
#define GPIO_MODE_DISABLED 0
#define GPIO_MODE_INPUT 1
@@ -144,6 +176,8 @@
#define GPIO_MODE_WIREDANDDRIVEPULLUP 14
#define GPIO_MODE_WIREDANDDRIVEPULLUPFILTER 15
/** @} */
//void gpio_set(u32 gpioport, u16 gpios);
//void gpio_clear(u32 gpioport, u16 gpios);
//void gpio_toggle(u32 gpioport, u16 gpios);

View File

@@ -1,11 +1,15 @@
/* this implements d0002_efm32_cortex-m3_reference_manual.pdf's table 1.1's "number of interrupts" line. */
/** @file
*
* Definitions for vector tables on Tiny Gecko systems.
*
* @see include/libopencm3/efm32/vector.h
*
* @todo The definitions of the individual IRQs will go here too.
* */
#ifndef LIBOPENCM3_EFM32_TINYGECKO_VECTOR_H
#define LIBOPENCM3_EFM32_TINYGECKO_VECTOR_H
#define EFM32_VECTOR_NIRQ 23
#include "../vector.h"
#define EFM32_VECTOR_NIRQ 23 /**< See d0002_efm32_cortex-m3_reference_manual.pdf's table 1.1's "number of interrupts" line */
#endif

View File

@@ -1,21 +1,29 @@
/* this implements d0002_efm32_cortex-m3_reference_manual.pdf's figure 2.2.
/** @file
*
* the structure of the vector table is implemented independently of the vector
* table, as it can be relocated to other memory locations too.
* Definitions for handling vector tables.
*
* don't include this file directly; rather, include the family's vector.h
* file, which defines the number of interrupts (EFM_VECTOR_NIRQ) from table
* 1.1 */
* This implements d0002_efm32_cortex-m3_reference_manual.pdf's figure 2.2.
*
* The structure of the vector table is implemented independently of the system
* vector table starting at memory position 0x0, as it can be relocated to
* other memory locations too.
*/
#ifndef LIBOPENCM3_EFM32_VECTOR_H
#define LIBOPENCM3_EFM32_VECTOR_H
#include <libopencm3/cm3/common.h>
typedef void (*efm32_vector_table_entry_t)(void);
#ifdef TINYGECKO
# include <libopencm3/efm32/tinygecko/vector.h>
#else
# error "efm32 family not defined."
#endif
typedef void (*efm32_vector_table_entry_t)(void); /**< Type of an interrupt function. Only used to avoid hard-to-read function pointers in the efm32_vector_table_t struct. */
typedef struct {
unsigned int *initial_sp_value;
unsigned int *initial_sp_value; /**< The value the stack pointer is set to initially */
efm32_vector_table_entry_t reset;
efm32_vector_table_entry_t nmi;
efm32_vector_table_entry_t hard_fault;