Ignore:
Timestamp:
Jul 3, 2020, 7:19:17 PM (4 years ago)
Author:
coas-nagasima
Message:

ASP3, TINET, mbed を更新

Location:
EcnlProtoTool/trunk/asp3_dcre/mbed
Files:
176 added
4 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/asp3_dcre/mbed/Makefile.mbed

    r321 r429  
    1414#
    1515INCLUDES := $(INCLUDES)\
    16         -I$(MBEDDIR)/api\
     16        -I$(MBEDDIR)\
     17        -I$(MBEDDIR)/cmsis\
     18        -I$(MBEDDIR)/cmsis/TARGET_CORTEX_A\
    1719        -I$(MBEDDIR)/hal\
    18         -I$(MBEDDIR)/targets/cmsis\
    19         -I$(MBEDDIR)/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H\
    20         -I$(MBEDDIR)/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc\
    21         -I$(MBEDDIR)/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/inc/iodefines\
    22         -I$(MBEDDIR)/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H\
    23         -I$(MBEDDIR)/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H/TARGET_MBED_MBRZA1H
     20        -I$(MBEDDIR)/platform\
     21        -I$(MBEDDIR)/targets/TARGET_RENESAS\
     22        -I$(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX\
     23        -I$(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/TARGET_RZ_A1H\
     24        -I$(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/TARGET_RZ_A1H/TARGET_MBED_MBRZA1H\
     25        -I$(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/TARGET_RZ_A1H/device\
     26        -I$(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/TARGET_RZ_A1H/device/inc\
     27        -I$(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/TARGET_RZ_A1H/device/inc/iobitmasks\
     28        -I$(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/TARGET_RZ_A1H/device/inc/iodefines\
     29        -I$(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/common\
     30        -I$(MBEDDIR)/rtos/TARGET_CORTEX
    2431COPTS := $(COPTS)\
    2532  -mthumb\
     
    3946  -mno-unaligned-access
    4047CDEFS := $(CDEFS)\
    41         -DTARGET_RZ_A1H\
    42         -DTARGET_MBRZA1H\
    43         -DTOOLCHAIN_GCC_ARM\
    44         -DTOOLCHAIN_GCC\
    45         -DTARGET_CORTEX_A\
    46         -DMBED_BUILD_TIMESTAMP=1460441486.52\
    47         -DTARGET_RENESAS\
    48         -D__FPU_PRESENT
     48        -DARM_MATH_CA9 \
     49        -DDEVICE_ANALOGIN=1 \
     50        -DDEVICE_CAN=1 \
     51        -DDEVICE_EMAC=1 \
     52        -DDEVICE_ETHERNET=1 \
     53        -DDEVICE_FLASH=1 \
     54        -DDEVICE_I2C=1 \
     55        -DDEVICE_I2CSLAVE=1 \
     56        -DDEVICE_I2C_ASYNCH=1 \
     57        -DDEVICE_INTERRUPTIN=1 \
     58        -DDEVICE_LPTICKER=1 \
     59        -DDEVICE_PORTIN=1 \
     60        -DDEVICE_PORTINOUT=1 \
     61        -DDEVICE_PORTOUT=1 \
     62        -DDEVICE_PWMOUT=1 \
     63        -DDEVICE_RTC=1 \
     64        -DDEVICE_SEMIHOST=1 \
     65        -DDEVICE_SERIAL=1 \
     66        -DDEVICE_SERIAL_ASYNCH=1 \
     67        -DDEVICE_SERIAL_FC=1 \
     68        -DDEVICE_SLEEP=1 \
     69        -DDEVICE_SPI=1 \
     70        -DDEVICE_SPISLAVE=1 \
     71        -DDEVICE_SPI_ASYNCH=1 \
     72        -DDEVICE_STDIO_MESSAGES=1 \
     73        -DDEVICE_USTICKER=1 \
     74        -DMBED_BUILD_TIMESTAMP=1550103323.92 \
     75        -DTARGET_A9 \
     76        -DTARGET_CORTEX \
     77        -DTARGET_CORTEX_A \
     78        -DTARGET_FF_ARDUINO \
     79        -DTARGET_LIKE_CORTEX_A9 \
     80        -DTARGET_LIKE_MBED \
     81        -DTARGET_MBRZA1H \
     82        -DTARGET_RELEASE \
     83        -DTARGET_RENESAS \
     84        -DTARGET_RZA1H \
     85        -DTARGET_RZ_A1H \
     86        -DTARGET_RZ_A1XX \
     87        -DTARGET_RZ_A1_EMAC \
     88        -DTOOLCHAIN_GCC \
     89        -DTOOLCHAIN_GCC_ARM \
     90        -DTOOLCHAIN_object \
     91        -D__CMSIS_RTOS \
     92        -D__CORTEX_A9 \
     93        -D__EVAL \
     94        -D__FPU_PRESENT=1 \
     95        -D__MBED_CMSIS_RTOS_CA9 \
     96        -D__MBED__=1 \
     97        -DIRQ_GIC_LINE_COUNT=587 \
     98        #-DDEVICE_STDIO_MESSAGES=1
    4999
    50100#
     
    52102#
    53103SYSSVC_DIRS := $(SYSSVC_DIRS)\
    54         $(MBEDDIR)/common\
    55         $(MBEDDIR)/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H\
    56         $(MBEDDIR)/targets/cmsis/TARGET_RENESAS/TARGET_RZ_A1H/TOOLCHAIN_GCC_ARM\
    57         $(MBEDDIR)/targets/cmsis/TOOLCHAIN_GCC/TARGET_CORTEX_A\
    58         $(MBEDDIR)/targets/hal/TARGET_RENESAS/TARGET_RZ_A1H
    59 SYSSVC_ASMOBJS := $(SYSSVC_ASMOBJS)\
    60         cache.o
    61 START_OBJS = startup_RZ1AH.o
     104        $(MBEDDIR)\
     105        $(MBEDDIR)/hal\
     106        $(MBEDDIR)/platform\
     107        $(MBEDDIR)/cmsis/TARGET_CORTEX_A\
     108        $(MBEDDIR)/targets/TARGET_RENESAS\
     109        $(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX\
     110        $(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/TARGET_RZ_A1H\
     111        $(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/TARGET_RZ_A1H/TARGET_MBED_MBRZA1H\
     112        $(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/TARGET_RZ_A1H/device\
     113        $(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/TARGET_RZ_A1H/device/TOOLCHAIN_GCC_ARM\
     114        $(MBEDDIR)/targets/TARGET_RENESAS/TARGET_RZA1XX/common
     115SYSSVC_ASMOBJS := $(SYSSVC_ASMOBJS)
     116START_OBJS := startup_RZ1AH.o
     117START_OBJS := $(addprefix $(OBJDIR)/, $(START_OBJS))
    62118SYSSVC_COBJS := $(SYSSVC_COBJS)\
    63         assert.o board.o gpio.o lp_ticker_api.o mbed_interface.o\
    64         pinmap_common.o rtc_time.o semihost_api.o ticker_api.o us_ticker_api.o\
    65         RZ_A1_Init.o cmsis_nvic.o gic.o mbed_sf_boot.o mmu_Renesas_RZ_A1.o\
    66         nvic_wrapper.o pl310.o rza_io_regrw.o system_MBRZA1H.o\
    67         analogin_api.o can_api.o ethernet_api.o gpio_api.o gpio_irq_api.o i2c_api.o\
    68         pinmap.o port_api.o pwmout_api.o rtc_api.o serial_api.o spi_api.o
    69         #wait_api.o us_ticker.o
    70 CFG_DMY := cfg_dmy.o mmu_Renesas_RZ_A1.o mbed_sf_boot.o RZ_A1_Init.o system_MBRZA1H.o cache.o pl310.o gic.o
     119        mbed_critical_section_api.o mbed_flash_api.o mbed_gpio.o mbed_lp_ticker_api.o\
     120        mbed_lp_ticker_wrapper.o mbed_pinmap_common.o mbed_sleep_manager.o mbed_mktime.o\
     121        mbed_ticker_api.o mbed_us_ticker_api.o mbed_assert.o mbed_board.o\
     122        mbed_critical.o mbed_error.o mbed_error_hist.o mbed_interface.o\
     123        mbed_rtc_time.o mbed_semihost_api.o mbed_stats.o\
     124        PeripheralPins.o RZ_A1_Init.o mbed_sf_boot.o mmu_RZ_A1H.o\
     125        system_RZ_A1H.o trng_api_esp32.o analogin_api.o can_api.o cmsis_nvic.o\
     126        irq_ctrl_gic.o nvic_wrapper.o rza_io_regrw.o ethernet_api.o flash_api.o\
     127        gpio_api.o gpio_irq_api.o i2c_api.o lp_ticker.o mtu2.o pinmap.o port_api.o\
     128        pwmout_api.o rtc_api.o serial_api.o sleep.o spi_api.o trng_api.o us_ticker.o
     129        #mbed_wait_api_no_rtos.o
     130CFG_DMY := cfg_dmy.o mmu_RZ_A1H.o mbed_sf_boot.o RZ_A1_Init.o system_RZ_A1H.o irq_ctrl_gic.o
    71131
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/analogin_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    2528#endif
    2629
     30/** Analogin hal structure. analogin_s is declared in the target's hal
     31 */
    2732typedef struct analogin_s analogin_t;
    2833
    29 void     analogin_init    (analogin_t *obj, PinName pin);
    30 float    analogin_read    (analogin_t *obj);
     34/**
     35 * \defgroup hal_analogin Analogin hal functions
     36 * @{
     37 */
     38
     39/** Initialize the analogin peripheral
     40 *
     41 * Configures the pin used by analogin.
     42 * @param obj The analogin object to initialize
     43 * @param pin The analogin pin name
     44 */
     45void analogin_init(analogin_t *obj, PinName pin);
     46
     47/** Read the input voltage, represented as a float in the range [0.0, 1.0]
     48 *
     49 * @param obj The analogin object
     50 * @return A floating value representing the current input voltage
     51 */
     52float analogin_read(analogin_t *obj);
     53
     54/** Read the value from analogin pin, represented as an unsigned 16bit value
     55 *
     56 * @param obj The analogin object
     57 * @return An unsigned 16bit value representing the current input voltage
     58 */
    3159uint16_t analogin_read_u16(analogin_t *obj);
     60
     61/**@}*/
    3262
    3363#ifdef __cplusplus
     
    3868
    3969#endif
     70
     71/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/analogout_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    2528#endif
    2629
     30/** Analogout hal structure. dac_s is declared in the target's hal
     31 */
    2732typedef struct dac_s dac_t;
    2833
    29 void     analogout_init     (dac_t *obj, PinName pin);
    30 void     analogout_free     (dac_t *obj);
    31 void     analogout_write    (dac_t *obj, float value);
    32 void     analogout_write_u16(dac_t *obj, uint16_t value);
    33 float    analogout_read     (dac_t *obj);
    34 uint16_t analogout_read_u16 (dac_t *obj);
     34/**
     35 * \defgroup hal_analogout Analogout hal functions
     36 * @{
     37 */
     38
     39/** Initialize the analogout peripheral
     40 *
     41 * Configures the pin used by analogout.
     42 * @param obj The analogout object to initialize
     43 * @param pin The analogout pin name
     44 */
     45void analogout_init(dac_t *obj, PinName pin);
     46
     47/** Release the analogout object
     48 *
     49 * Note: This is not currently used in the mbed-drivers
     50 * @param obj The analogout object
     51 */
     52void analogout_free(dac_t *obj);
     53
     54/** Set the output voltage, specified as a percentage (float)
     55 *
     56 * @param obj The analogin object
     57 * @param value The floating-point output voltage to be set
     58 */
     59void analogout_write(dac_t *obj, float value);
     60
     61/** Set the output voltage, specified as unsigned 16-bit
     62 *
     63 * @param obj The analogin object
     64 * @param value The unsigned 16-bit output voltage to be set
     65 */
     66void analogout_write_u16(dac_t *obj, uint16_t value);
     67
     68/** Read the current voltage value on the pin
     69 *
     70 * @param obj The analogin object
     71 * @return A floating-point value representing the current voltage on the pin,
     72 *     measured as a percentage
     73 */
     74float analogout_read(dac_t *obj);
     75
     76/** Read the current voltage value on the pin, as a normalized unsigned 16bit value
     77 *
     78 * @param obj The analogin object
     79 * @return An unsigned 16-bit value representing the current voltage on the pin
     80 */
     81uint16_t analogout_read_u16(dac_t *obj);
     82
     83/**@}*/
    3584
    3685#ifdef __cplusplus
     
    4190
    4291#endif
     92
     93/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/buffer.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2014-2015 ARM Limited
     
    2932
    3033#endif
     34
     35/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/can_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    2  * Copyright (c) 2006-2013 ARM Limited
     5 * Copyright (c) 2006-2016 ARM Limited
    36 *
    47 * Licensed under the Apache License, Version 2.0 (the "License");
     
    2326#include "PinNames.h"
    2427#include "PeripheralNames.h"
    25 #include "can_helper.h"
     28#include "hal/can_helper.h"
    2629
    2730#ifdef __cplusplus
     
    5659
    5760void          can_init     (can_t *obj, PinName rd, PinName td);
     61void          can_init_freq(can_t *obj, PinName rd, PinName td, int hz);
    5862void          can_free     (can_t *obj);
    5963int           can_frequency(can_t *obj, int hz);
     
    7983
    8084#endif
     85
     86/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/dma_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2014-2015 ARM Limited
     
    4447
    4548#endif
     49
     50/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/ethernet_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    4245int ethernet_send(void);
    4346
    44 // recieve from ethernet buffer, returning packet size, or 0 if no packet
     47// receive from ethernet buffer, returning packet size, or 0 if no packet
    4548int ethernet_receive(void);
    4649
     
    6669#endif
    6770
     71
     72/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/gpio_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    1720#define MBED_GPIO_API_H
    1821
     22#include <stdint.h>
    1923#include "device.h"
    2024
     
    2327#endif
    2428
    25 /* Set the given pin as GPIO
     29/**
     30 * \defgroup hal_gpio GPIO HAL functions
     31 * @{
     32 */
     33
     34/** Set the given pin as GPIO
     35 *
    2636 * @param pin The pin to be set as GPIO
    2737 * @return The GPIO port mask for this pin
    2838 **/
    2939uint32_t gpio_set(PinName pin);
    30 
    3140/* Checks if gpio object is connected (pin was not initialized with NC)
    3241 * @param pin The pin to be set as GPIO
     
    3544int gpio_is_connected(const gpio_t *obj);
    3645
    37 /* GPIO object */
     46/** Initialize the GPIO pin
     47 *
     48 * @param obj The GPIO object to initialize
     49 * @param pin The GPIO pin to initialize
     50 */
    3851void gpio_init(gpio_t *obj, PinName pin);
    3952
    40 void gpio_mode (gpio_t *obj, PinMode mode);
    41 void gpio_dir  (gpio_t *obj, PinDirection direction);
     53/** Set the input pin mode
     54 *
     55 * @param obj  The GPIO object
     56 * @param mode The pin mode to be set
     57 */
     58void gpio_mode(gpio_t *obj, PinMode mode);
    4259
     60/** Set the pin direction
     61 *
     62 * @param obj       The GPIO object
     63 * @param direction The pin direction to be set
     64 */
     65void gpio_dir(gpio_t *obj, PinDirection direction);
     66
     67/** Set the output value
     68 *
     69 * @param obj   The GPIO object
     70 * @param value The value to be set
     71 */
    4372void gpio_write(gpio_t *obj, int value);
    44 int  gpio_read (gpio_t *obj);
    4573
    46 // the following set of functions are generic and are implemented in the common gpio.c file
     74/** Read the input value
     75 *
     76 * @param obj The GPIO object
     77 * @return An integer value 1 or 0
     78 */
     79int gpio_read(gpio_t *obj);
     80
     81// the following functions are generic and implemented in the common gpio.c file
     82// TODO: fix, will be moved to the common gpio header file
     83
     84/** Init the input pin and set mode to PullDefault
     85 *
     86 * @param gpio The GPIO object
     87 * @param pin The pin name
     88 */
    4789void gpio_init_in(gpio_t* gpio, PinName pin);
     90
     91/** Init the input pin and set the mode
     92 *
     93 * @param gpio  The GPIO object
     94 * @param pin  The pin name
     95 * @param mode The pin mode to be set
     96 */
    4897void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode);
     98
     99/** Init the output pin as an output, with predefined output value 0
     100 *
     101 * @param gpio The GPIO object
     102 * @param pin The pin name
     103 * @return An integer value 1 or 0
     104 */
    49105void gpio_init_out(gpio_t* gpio, PinName pin);
     106
     107/** Init the pin as an output and set the output value
     108 *
     109 * @param gpio  The GPIO object
     110 * @param pin   The pin name
     111 * @param value The value to be set
     112 */
    50113void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value);
     114
     115/** Init the pin to be in/out
     116 *
     117 * @param gpio      The GPIO object
     118 * @param pin       The pin name
     119 * @param direction The pin direction to be set
     120 * @param mode      The pin mode to be set
     121 * @param value     The value to be set for an output pin
     122 */
    51123void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value);
     124
     125/**@}*/
    52126
    53127#ifdef __cplusplus
     
    56130
    57131#endif
     132
     133/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/gpio_irq_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    2528#endif
    2629
     30/** GPIO IRQ events
     31 */
    2732typedef enum {
    2833    IRQ_NONE,
     
    3136} gpio_irq_event;
    3237
     38/** GPIO IRQ HAL structure. gpio_irq_s is declared in the target's HAL
     39 */
    3340typedef struct gpio_irq_s gpio_irq_t;
    3441
    3542typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
    3643
    37 int  gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
     44/**
     45 * \defgroup hal_gpioirq GPIO IRQ HAL functions
     46 * @{
     47 */
     48
     49/** Initialize the GPIO IRQ pin
     50 *
     51 * @param obj     The GPIO object to initialize
     52 * @param pin     The GPIO pin name
     53 * @param handler The handler to be attached to GPIO IRQ
     54 * @param id      The object ID (id != 0, 0 is reserved)
     55 * @return -1 if pin is NC, 0 otherwise
     56 */
     57int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
     58
     59/** Release the GPIO IRQ PIN
     60 *
     61 * @param obj The gpio object
     62 */
    3863void gpio_irq_free(gpio_irq_t *obj);
    39 void gpio_irq_set (gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
     64
     65/** Enable/disable pin IRQ event
     66 *
     67 * @param obj    The GPIO object
     68 * @param event  The GPIO IRQ event
     69 * @param enable The enable flag
     70 */
     71void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
     72
     73/** Enable GPIO IRQ
     74 *
     75 * This is target dependent, as it might enable the entire port or just a pin
     76 * @param obj The GPIO object
     77 */
    4078void gpio_irq_enable(gpio_irq_t *obj);
     79
     80/** Disable GPIO IRQ
     81 *
     82 * This is target dependent, as it might disable the entire port or just a pin
     83 * @param obj The GPIO object
     84 */
    4185void gpio_irq_disable(gpio_irq_t *obj);
     86
     87/**@}*/
    4288
    4389#ifdef __cplusplus
     
    4894
    4995#endif
     96
     97/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/i2c_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2015 ARM Limited
     
    1821
    1922#include "device.h"
    20 #include "buffer.h"
     23#include "hal/buffer.h"
     24
     25#if DEVICE_I2C_ASYNCH
     26#include "hal/dma_api.h"
     27#endif
    2128
    2229#if DEVICE_I2C
    2330
    2431/**
    25  * @defgroup I2CEvents I2C Events Macros
     32 * @defgroup hal_I2CEvents I2C Events Macros
    2633 *
    2734 * @{
     
    3643
    3744#if DEVICE_I2C_ASYNCH
    38 /** Asynch i2c hal structure
     45/** Asynch I2C HAL structure
    3946 */
    4047typedef struct {
    41     struct i2c_s    i2c;     /**< Target specific i2c structure */
     48    struct i2c_s    i2c;     /**< Target specific I2C structure */
    4249    struct buffer_s tx_buff; /**< Tx buffer */
    4350    struct buffer_s rx_buff; /**< Rx buffer */
     
    4552
    4653#else
    47 /** Non-asynch i2c hal structure
     54/** Non-asynch I2C HAL structure
    4855 */
    4956typedef struct i2c_s i2c_t;
     
    6168
    6269/**
    63  * \defgroup GeneralI2C I2C Configuration Functions
     70 * \defgroup hal_GeneralI2C I2C Configuration Functions
    6471 * @{
    6572 */
    6673
    6774/** Initialize the I2C peripheral. It sets the default parameters for I2C
    68  *  peripheral, and configure its specifieds pins.
    69  *  @param obj  The i2c object
     75 *  peripheral, and configures its specifieds pins.
     76 * 
     77 *  @param obj  The I2C object
    7078 *  @param sda  The sda pin
    7179 *  @param scl  The scl pin
     
    7381void i2c_init(i2c_t *obj, PinName sda, PinName scl);
    7482
    75 /** Configure the I2C frequency.
    76  *  @param obj The i2c object
     83/** Configure the I2C frequency
     84 *
     85 *  @param obj The I2C object
    7786 *  @param hz  Frequency in Hz
    7887 */
    7988void i2c_frequency(i2c_t *obj, int hz);
    8089
    81 /** Send START command.
    82  *  @param obj The i2c object
     90/** Send START command
     91 *
     92 *  @param obj The I2C object
    8393 */
    8494int  i2c_start(i2c_t *obj);
    8595
    86 /** Send STOP command.
    87  *  @param obj The i2c object
     96/** Send STOP command
     97 *
     98 *  @param obj The I2C object
    8899 */
    89100int  i2c_stop(i2c_t *obj);
    90101
    91 /** Blocking reading data.
    92  *  @param obj     The i2c object
     102/** Blocking reading data
     103 *
     104 *  @param obj     The I2C object
    93105 *  @param address 7-bit address (last bit is 1)
    94106 *  @param data    The buffer for receiving
     
    97109 *  @return Number of read bytes
    98110 */
    99 int  i2c_read(i2c_t *obj, int address, char *data, int length, int stop);
    100 
    101 /** Blocking sending data.
    102  *  @param obj     The i2c object
     111int i2c_read(i2c_t *obj, int address, char *data, int length, int stop);
     112
     113/** Blocking sending data
     114 *
     115 *  @param obj     The I2C object
    103116 *  @param address 7-bit address (last bit is 0)
    104117 *  @param data    The buffer for sending
    105  *  @param length  Number of bytes to wrte
     118 *  @param length  Number of bytes to write
    106119 *  @param stop    Stop to be generated after the transfer is done
    107  *  @return Number of written bytes
    108  */
    109 int  i2c_write(i2c_t *obj, int address, const char *data, int length, int stop);
    110 
    111 /** Reset I2C peripheral. TODO: The action here. Most of the implementation sends stop().
    112  *  @param obj The i2c object
     120 *  @return
     121 *      zero or non-zero - Number of written bytes
     122 *      negative - I2C_ERROR_XXX status
     123 */
     124int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop);
     125
     126/** Reset I2C peripheral. TODO: The action here. Most of the implementation sends stop()
     127 *
     128 *  @param obj The I2C object
    113129 */
    114130void i2c_reset(i2c_t *obj);
    115131
    116 /** Read one byte.
    117  *  @param obj The i2c object
     132/** Read one byte
     133 *
     134 *  @param obj The I2C object
    118135 *  @param last Acknoledge
    119136 *  @return The read byte
    120137 */
    121 int  i2c_byte_read(i2c_t *obj, int last);
    122 
    123 /** Write one byte.
    124  *  @param obj The i2c object
     138int i2c_byte_read(i2c_t *obj, int last);
     139
     140/** Write one byte
     141 *
     142 *  @param obj The I2C object
    125143 *  @param data Byte to be written
    126  *  @return 1 if NAK was received, 0 if ACK was received, 2 for timeout.
    127  */
    128 int  i2c_byte_write(i2c_t *obj, int data);
     144 *  @return 0 if NAK was received, 1 if ACK was received, 2 for timeout.
     145 */
     146int i2c_byte_write(i2c_t *obj, int data);
    129147
    130148/**@}*/
     
    139157/** Configure I2C as slave or master.
    140158 *  @param obj The I2C object
     159 *  @param enable_slave Enable i2c hardware so you can receive events with ::i2c_slave_receive
    141160 *  @return non-zero if a value is available
    142161 */
     
    152171/** Configure I2C as slave or master.
    153172 *  @param obj The I2C object
     173 *  @param data    The buffer for receiving
     174 *  @param length  Number of bytes to read
    154175 *  @return non-zero if a value is available
    155176 */
     
    158179/** Configure I2C as slave or master.
    159180 *  @param obj The I2C object
     181 *  @param data    The buffer for sending
     182 *  @param length  Number of bytes to write
    160183 *  @return non-zero if a value is available
    161184 */
     
    177200
    178201/**
    179  * \defgroup AsynchI2C Asynchronous I2C Hardware Abstraction Layer
    180  * @{
    181  */
    182 
    183 /** Start i2c asynchronous transfer.
     202 * \defgroup hal_AsynchI2C Asynchronous I2C Hardware Abstraction Layer
     203 * @{
     204 */
     205
     206/** Start I2C asynchronous transfer
     207 *
    184208 *  @param obj       The I2C object
    185  *  @param tx        The buffer to send
    186  *  @param tx_length The number of words to transmit
    187  *  @param rx        The buffer to receive
    188  *  @param rx_length The number of words to receive
    189  *  @param address   The address to be set - 7bit or 9 bit
     209 *  @param tx        The transmit buffer
     210 *  @param tx_length The number of bytes to transmit
     211 *  @param rx        The receive buffer
     212 *  @param rx_length The number of bytes to receive
     213 *  @param address   The address to be set - 7bit or 9bit
    190214 *  @param stop      If true, stop will be generated after the transfer is done
    191215 *  @param handler   The I2C IRQ handler to be set
     216 *  @param event     Event mask for the transfer. See \ref hal_I2CEvents
    192217 *  @param hint      DMA hint usage
    193218 */
     
    195220
    196221/** The asynchronous IRQ handler
     222 *
    197223 *  @param obj The I2C object which holds the transfer information
    198  *  @return event flags if a transfer termination condition was met or 0 otherwise.
     224 *  @return Event flags if a transfer termination condition was met, otherwise return 0.
    199225 */
    200226uint32_t i2c_irq_handler_asynch(i2c_t *obj);
    201227
    202 /** Attempts to determine if I2C peripheral is already in use.
    203  *  @param obj The I2C object
    204  *  @return non-zero if the I2C module is active or zero if it is not
     228/** Attempts to determine if the I2C peripheral is already in use
     229 *
     230 *  @param obj The I2C object
     231 *  @return Non-zero if the I2C module is active or zero if it is not
    205232 */
    206233uint8_t i2c_active(i2c_t *obj);
    207234
    208 /** Abort ongoing asynchronous transaction.
     235/** Abort asynchronous transfer
     236 *
     237 *  This function does not perform any check - that should happen in upper layers.
    209238 *  @param obj The I2C object
    210239 */
     
    222251
    223252#endif
     253
     254/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/lp_ticker_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2015 ARM Limited
     
    1922#include "device.h"
    2023
    21 #if DEVICE_LOWPOWERTIMER
    22 
    23 #include "ticker_api.h"
     24#if DEVICE_LPTICKER
     25
     26#include "hal/ticker_api.h"
    2427
    2528#ifdef __cplusplus
     
    2831
    2932/**
    30  * \defgroup LpTicker Low Power Ticker Functions
     33 * \defgroup hal_lp_ticker Low Power Ticker
     34 * Low level interface to the low power ticker of a target
     35 *
     36 * # Defined behavior
     37 * * Has a reported frequency between 4KHz and 64KHz - verified by ::lp_ticker_info_test
     38 * * Has a counter that is at least 12 bits wide - verified by ::lp_ticker_info_test
     39 * * Continues operating in deep sleep mode - verified by ::lp_ticker_deepsleep_test
     40 * * All behavior defined by the @ref hal_ticker_shared "ticker specification"
     41 *
     42 * # Undefined behavior
     43 * * See the @ref hal_ticker_shared "ticker specification"
     44 * * Calling any function other than lp_ticker_init after calling lp_ticker_free
     45 *
     46 * # Potential bugs
     47 * * Glitches due to ripple counter - Verified by ::lp_ticker_glitch_test
     48 *
     49 * @see hal_lp_ticker_tests
     50 *
    3151 * @{
    3252 */
    3353
     54/**
     55 * \defgroup hal_lp_ticker_tests Low Power Ticker tests
     56 * Tests to validate the proper implementation of the low power ticker
     57 *
     58 * To run the low power ticker hal tests use the command:
     59 *
     60 *     mbed test -t <toolchain> -m <target> -n tests-mbed_hal-common_ticker*,tests-mbed_hal-lp_ticker*
     61 *
     62 */
     63
     64typedef void (*ticker_irq_handler_type)(const ticker_data_t *const);
     65
     66/** Set low power ticker IRQ handler
     67 *
     68 * @param ticker_irq_handler IRQ handler to be connected
     69 *
     70 * @return previous ticker IRQ handler
     71 *
     72 * @note by default IRQ handler is set to ::ticker_irq_handler
     73 * @note this function is primarily for testing purposes and it's not required part of HAL implementation
     74 *
     75 */
     76ticker_irq_handler_type set_lp_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler);
     77
    3478/** Get low power ticker's data
    3579 *
    3680 * @return The low power ticker data
    3781 */
    38 const ticker_data_t* get_lp_ticker_data(void);
     82const ticker_data_t *get_lp_ticker_data(void);
    3983
    4084/** The wrapper for ticker_irq_handler, to pass lp ticker's data
     
    4791/** Initialize the low power ticker
    4892 *
     93 * Initialize or re-initialize the ticker. This resets all the
     94 * clocking and prescaler registers, along with disabling
     95 * the compare interrupt.
     96 *
     97 * Pseudo Code:
     98 * @code
     99 * void lp_ticker_init()
     100 * {
     101 *     // Enable clock gate so processor can read LPTMR registers
     102 *     POWER_CTRL |= POWER_CTRL_LPTMR_Msk;
     103 *
     104 *     // Disable the timer and ensure it is powered down
     105 *     LPTMR_CTRL &= ~(LPTMR_CTRL_ENABLE_Msk | LPTMR_CTRL_COMPARE_ENABLE_Msk);
     106 *
     107 *     // Configure divisors - no division necessary
     108 *     LPTMR_PRESCALE = 0;
     109 *     LPTMR_CTRL |= LPTMR_CTRL_ENABLE_Msk;
     110 *
     111 *     // Install the interrupt handler
     112 *     NVIC_SetVector(LPTMR_IRQn, (uint32_t)lp_ticker_irq_handler);
     113 *     NVIC_EnableIRQ(LPTMR_IRQn);
     114 * }
     115 * @endcode
    49116 */
    50117void lp_ticker_init(void);
    51118
    52 /** Read the current counter
    53  *
    54  * @return The current timer's counter value in microseconds
     119/** Deinitialize the lower power ticker
     120 *
     121 * Powerdown the lp ticker in preparation for sleep, powerdown, or reset.
     122 *
     123 * After calling this function no other ticker functions should be called except
     124 * lp_ticker_init(). Calling any function other than init after freeing is
     125 * undefined.
     126 *
     127 * @note This function stops the ticker from counting.
     128 */
     129void lp_ticker_free(void);
     130
     131/** Read the current tick
     132 *
     133 * If no rollover has occurred, the seconds passed since lp_ticker_init()
     134 * was called can be found by dividing the ticks returned by this function
     135 * by the frequency returned by ::lp_ticker_get_info.
     136 *
     137 * @return The current timer's counter value in ticks
     138 *
     139 * Pseudo Code:
     140 * @code
     141 * uint32_t lp_ticker_read()
     142 * {
     143 *     uint16_t count;
     144 *     uint16_t last_count;
     145 *
     146 *     // Loop until the same tick is read twice since this
     147 *     // is ripple counter on a different clock domain.
     148 *     count = LPTMR_COUNT;
     149 *     do {
     150 *         last_count = count;
     151 *         count = LPTMR_COUNT;
     152 *     } while (last_count != count);
     153 *
     154 *     return count;
     155 * }
     156 * @endcode
    55157 */
    56158uint32_t lp_ticker_read(void);
     
    58160/** Set interrupt for specified timestamp
    59161 *
    60  * @param timestamp The time in microseconds to be set
     162 * @param timestamp The time in ticks to be set
     163 *
     164 * @note no special handling needs to be done for times in the past
     165 * as the common timer code will detect this and call
     166 * lp_ticker_fire_interrupt() if this is the case
     167 *
     168 * @note calling this function with timestamp of more than the supported
     169 * number of bits returned by ::lp_ticker_get_info results in undefined
     170 * behavior.
     171 *
     172 * Pseudo Code:
     173 * @code
     174 * void lp_ticker_set_interrupt(timestamp_t timestamp)
     175 * {
     176 *     LPTMR_COMPARE = timestamp;
     177 *     LPTMR_CTRL |= LPTMR_CTRL_COMPARE_ENABLE_Msk;
     178 * }
     179 * @endcode
    61180 */
    62181void lp_ticker_set_interrupt(timestamp_t timestamp);
     
    64183/** Disable low power ticker interrupt
    65184 *
     185 * Pseudo Code:
     186 * @code
     187 * void lp_ticker_disable_interrupt(void)
     188 * {
     189 *     // Disable the compare interrupt
     190 *     LPTMR_CTRL &= ~LPTMR_CTRL_COMPARE_ENABLE_Msk;
     191 * }
     192 * @endcode
    66193 */
    67194void lp_ticker_disable_interrupt(void);
     
    69196/** Clear the low power ticker interrupt
    70197 *
     198 * Pseudo Code:
     199 * @code
     200 * void lp_ticker_clear_interrupt(void)
     201 * {
     202 *     // Write to the ICR (interrupt clear register) of the LPTMR
     203 *     LPTMR_ICR = LPTMR_ICR_COMPARE_Msk;
     204 * }
     205 * @endcode
    71206 */
    72207void lp_ticker_clear_interrupt(void);
     208
     209/** Set pending interrupt that should be fired right away.
     210 *
     211 * Pseudo Code:
     212 * @code
     213 * void lp_ticker_fire_interrupt(void)
     214 * {
     215 *     NVIC_SetPendingIRQ(LPTMR_IRQn);
     216 * }
     217 * @endcode
     218 */
     219void lp_ticker_fire_interrupt(void);
     220
     221/** Get frequency and counter bits of this ticker.
     222 *
     223 * Pseudo Code:
     224 * @code
     225 * const ticker_info_t* lp_ticker_get_info()
     226 * {
     227 *     static const ticker_info_t info = {
     228 *         32768,      // 32KHz
     229 *         16          // 16 bit counter
     230 *     };
     231 *     return &info;
     232 * }
     233 * @endcode
     234 */
     235const ticker_info_t *lp_ticker_get_info(void);
    73236
    74237/**@}*/
     
    81244
    82245#endif
     246
     247/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/pinmap.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    4447
    4548#endif
     49
     50/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/port_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    2528#endif
    2629
     30/** Port HAL structure. port_s is declared in the target's HAL
     31 */
    2732typedef struct port_s port_t;
    2833
     34/**
     35 * \defgroup hal_port Port HAL functions
     36 * @{
     37 */
     38
     39/** Get the pin name from the port's pin number
     40 *
     41 * @param port  The port name
     42 * @param pin_n The pin number within the specified port
     43 * @return The pin name for the port's pin number
     44 */
    2945PinName port_pin(PortName port, int pin_n);
    3046
    31 void port_init (port_t *obj, PortName port, int mask, PinDirection dir);
    32 void port_mode (port_t *obj, PinMode mode);
    33 void port_dir  (port_t *obj, PinDirection dir);
     47/** Initilize the port
     48 *
     49 * @param obj  The port object to initialize
     50 * @param port The port name
     51 * @param mask The bitmask to identify which bits in the port should be included (0 - ignore)
     52 * @param dir  The port direction
     53 */
     54void port_init(port_t *obj, PortName port, int mask, PinDirection dir);
     55
     56/** Set the input port mode
     57 *
     58 * @param obj  The port object
     59 * @param mode THe port mode to be set
     60 */
     61void port_mode(port_t *obj, PinMode mode);
     62
     63/** Set port direction (in/out)
     64 *
     65 * @param obj The port object
     66 * @param dir The port direction to be set
     67 */
     68void port_dir(port_t *obj, PinDirection dir);
     69
     70/** Write value to the port
     71 *
     72 * @param obj   The port object
     73 * @param value The value to be set
     74 */
    3475void port_write(port_t *obj, int value);
    35 int  port_read (port_t *obj);
     76
     77/** Read the current value on the port
     78 *
     79 * @param obj The port object
     80 * @return An integer with each bit corresponding to an associated port pin setting
     81 */
     82int port_read(port_t *obj);
     83
     84/**@}*/
    3685
    3786#ifdef __cplusplus
     
    4190
    4291#endif
     92
     93/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/pwmout_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    2528#endif
    2629
     30/** Pwmout hal structure. pwmout_s is declared in the target's hal
     31 */
    2732typedef struct pwmout_s pwmout_t;
    2833
    29 void pwmout_init         (pwmout_t* obj, PinName pin);
    30 void pwmout_free         (pwmout_t* obj);
     34/**
     35 * \defgroup hal_pwmout Pwmout hal functions
     36 * @{
     37 */
    3138
    32 void  pwmout_write       (pwmout_t* obj, float percent);
    33 float pwmout_read        (pwmout_t* obj);
     39/** Initialize the pwm out peripheral and configure the pin
     40 *
     41 * @param obj The pwmout object to initialize
     42 * @param pin The pwmout pin to initialize
     43 */
     44void pwmout_init(pwmout_t *obj, PinName pin);
    3445
    35 void pwmout_period       (pwmout_t* obj, float seconds);
    36 void pwmout_period_ms    (pwmout_t* obj, int ms);
    37 void pwmout_period_us    (pwmout_t* obj, int us);
     46/** Deinitialize the pwmout object
     47 *
     48 * @param obj The pwmout object
     49 */
     50void pwmout_free(pwmout_t *obj);
    3851
    39 void pwmout_pulsewidth   (pwmout_t* obj, float seconds);
    40 void pwmout_pulsewidth_ms(pwmout_t* obj, int ms);
    41 void pwmout_pulsewidth_us(pwmout_t* obj, int us);
     52/** Set the output duty-cycle in range <0.0f, 1.0f>
     53 *
     54 * Value 0.0f represents 0 percentage, 1.0f represents 100 percent.
     55 * @param obj     The pwmout object
     56 * @param percent The floating-point percentage number
     57 */
     58void pwmout_write(pwmout_t *obj, float percent);
     59
     60/** Read the current float-point output duty-cycle
     61 *
     62 * @param obj The pwmout object
     63 * @return A floating-point output duty-cycle
     64 */
     65float pwmout_read(pwmout_t *obj);
     66
     67/** Set the PWM period specified in seconds, keeping the duty cycle the same
     68 *
     69 * Periods smaller than microseconds (the lowest resolution) are set to zero.
     70 * @param obj     The pwmout object
     71 * @param seconds The floating-point seconds period
     72 */
     73void pwmout_period(pwmout_t *obj, float seconds);
     74
     75/** Set the PWM period specified in miliseconds, keeping the duty cycle the same
     76 *
     77 * @param obj The pwmout object
     78 * @param ms  The milisecond period
     79 */
     80void pwmout_period_ms(pwmout_t *obj, int ms);
     81
     82/** Set the PWM period specified in microseconds, keeping the duty cycle the same
     83 *
     84 * @param obj The pwmout object
     85 * @param us  The microsecond period
     86 */
     87void pwmout_period_us(pwmout_t *obj, int us);
     88
     89/** Set the PWM pulsewidth specified in seconds, keeping the period the same.
     90 *
     91 * @param obj     The pwmout object
     92 * @param seconds The floating-point pulsewidth in seconds
     93 */
     94void pwmout_pulsewidth(pwmout_t *obj, float seconds);
     95
     96/** Set the PWM pulsewidth specified in miliseconds, keeping the period the same.
     97 *
     98 * @param obj The pwmout object
     99 * @param ms  The floating-point pulsewidth in miliseconds
     100 */
     101void pwmout_pulsewidth_ms(pwmout_t *obj, int ms);
     102
     103/** Set the PWM pulsewidth specified in microseconds, keeping the period the same.
     104 *
     105 * @param obj The pwmout object
     106 * @param us  The floating-point pulsewidth in microseconds
     107 */
     108void pwmout_pulsewidth_us(pwmout_t *obj, int us);
     109
     110/**@}*/
    42111
    43112#ifdef __cplusplus
     
    48117
    49118#endif
     119
     120/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/rtc_api.h

    r321 r429  
    1414 * limitations under the License.
    1515 */
     16
     17/** \addtogroup hal */
     18/** @{*/
     19
    1620#ifndef MBED_RTC_API_H
    1721#define MBED_RTC_API_H
    1822
    1923#include "device.h"
    20 
    21 #if DEVICE_RTC
    2224
    2325#include <time.h>
     
    2729#endif
    2830
     31/**
     32 * \defgroup hal_rtc RTC hal
     33 *
     34 * The RTC hal provides a low level interface to the Real Time Counter (RTC) of a
     35 * target.
     36 *
     37 * # Defined behaviour
     38 * * The function ::rtc_init is safe to call repeatedly - Verified by test ::rtc_init_test.
     39 * * RTC accuracy is at least 10% - Verified by test ::rtc_accuracy_test.
     40 * * Init/free doesn't stop RTC from counting - Verified by test ::rtc_persist_test.
     41 * * Software reset doesn't stop RTC from counting - Verified by test ::rtc_reset_test.
     42 * * Sleep modes don't stop RTC from counting - Verified by test ::rtc_sleep_test.
     43 * * Shutdown mode doesn't stop RTC from counting - Not verified.
     44 * * The functions ::rtc_write/::rtc_read provides availability to set/get RTC time
     45 * - Verified by test ::rtc_write_read_test.
     46 * * The functions ::rtc_isenabled returns 1 if the RTC is counting and the time has been set,
     47 * 0 otherwise - Verified by test ::rtc_enabled_test.
     48 *
     49 * # Undefined behaviour
     50 * * Calling any function other than ::rtc_init before the initialisation of the RTC
     51 *
     52 * # Potential bugs
     53 * * Incorrect overflow handling - Verified by ::rtc_range_test
     54 * * Glitches due to ripple counter - Verified by ::rtc_glitch_test
     55 *
     56 * @see hal_rtc_tests
     57 *
     58 * @{
     59 */
     60
     61/**
     62 * \defgroup hal_rtc_tests RTC hal tests
     63 * The RTC test validate proper implementation of the RTC hal.
     64 *
     65 * To run the RTC hal tests use the command:
     66 *
     67 *     mbed test -t <toolchain> -m <target> -n tests-mbed_hal-rtc*
     68 */
     69
     70
     71/** Initialize the RTC peripheral
     72 *
     73 * Powerup the RTC in perpetration for access. This function must be called
     74 * before any other RTC functions ares called. This does not change the state
     75 * of the RTC. It just enables access to it.
     76 *
     77 * @note This function is safe to call repeatedly - Tested by ::rtc_init_test
     78 *
     79 * Example Implementation Pseudo Code:
     80 * @code
     81 * void rtc_init()
     82 * {
     83 *     // Enable clock gate so processor can read RTC registers
     84 *     POWER_CTRL |= POWER_CTRL_RTC_Msk;
     85 *
     86 *     // See if the RTC is already setup
     87 *     if (!(RTC_STATUS & RTC_STATUS_COUNTING_Msk)) {
     88 *
     89 *         // Setup the RTC clock source
     90 *         RTC_CTRL |= RTC_CTRL_CLK32_Msk;
     91 *     }
     92 * }
     93 * @endcode
     94 */
    2995void rtc_init(void);
     96
     97/** Deinitialize RTC
     98 *
     99 * Powerdown the RTC in preparation for sleep, powerdown or reset. That should only
     100 * affect the CPU domain and not the time keeping logic.
     101 * After this function is called no other RTC functions should be called
     102 * except for ::rtc_init.
     103 *
     104 * @note This function does not stop the RTC from counting - Tested by ::rtc_persist_test
     105 *
     106 * Example Implementation Pseudo Code:
     107 * @code
     108 * void rtc_free()
     109 * {
     110 *     // Disable clock gate since processor no longer needs to read RTC registers
     111 *     POWER_CTRL &= ~POWER_CTRL_RTC_Msk;
     112 * }
     113 * @endcode
     114 */
    30115void rtc_free(void);
     116
     117/** Check if the RTC has the time set and is counting
     118 *
     119 * @retval 0 The time reported by the RTC is not valid
     120 * @retval 1 The time has been set the RTC is counting
     121 *
     122 * Example Implementation Pseudo Code:
     123 * @code
     124 * int rtc_isenabled()
     125 * {
     126 *     if (RTC_STATUS & RTC_STATUS_COUNTING_Msk) {
     127 *         return 1;
     128 *     } else {
     129 *         return 0;
     130 *     }
     131 * }
     132 * @endcode
     133 */
    31134int rtc_isenabled(void);
    32135
     136/** Get the current time from the RTC peripheral
     137 *
     138 * @return The current time in seconds
     139 *
     140 * @note Some RTCs are not synchronized with the main clock. If
     141 * this is the case with your RTC then you must read the RTC time
     142 * in a loop to prevent reading the wrong time due to a glitch.
     143 * The test ::rtc_glitch_test is intended to catch this bug.
     144 *
     145 * Example implementation for an unsynchronized ripple counter:
     146 * @code
     147 * time_t rtc_read()
     148 * {
     149 *     uint32_t val;
     150 *     uint32_t last_val;
     151 *
     152 *     // Loop until the same value is read twice
     153 *     val = RTC_SECONDS;
     154 *     do {
     155 *         last_val = val;
     156 *         val = RTC_SECONDS;
     157 *     } while (last_val != val);
     158 *
     159 *     return (time_t)val;
     160 * }
     161 * @endcode
     162 */
    33163time_t rtc_read(void);
     164
     165/** Write the current time in seconds to the RTC peripheral
     166 *
     167 * @param t The current time to be set in seconds.
     168 *
     169 * Example Implementation Pseudo Code:
     170 * @code
     171 * void rtc_write(time_t t)
     172 * {
     173 *     RTC_SECONDS = t;
     174 * }
     175 * @endcode
     176 */
    34177void rtc_write(time_t t);
     178
     179/**@}*/
    35180
    36181#ifdef __cplusplus
     
    40185#endif
    41186
    42 #endif
     187/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/serial_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    1821
    1922#include "device.h"
    20 #include "buffer.h"
    21 #include "dma_api.h"
     23#include "hal/buffer.h"
     24#include "hal/dma_api.h"
    2225
    2326#if DEVICE_SERIAL
     
    8184
    8285#if DEVICE_SERIAL_ASYNCH
    83 /** Asynch serial hal structure
     86/** Asynch serial HAL structure
    8487 */
    8588typedef struct {
    8689    struct serial_s serial;  /**< Target specific serial structure */
    87     struct buffer_s tx_buff; /**< Tx buffer */
    88     struct buffer_s rx_buff; /**< Rx buffer */
     90    struct buffer_s tx_buff; /**< TX buffer */
     91    struct buffer_s rx_buff; /**< RX buffer */
    8992    uint8_t char_match;      /**< Character to be matched */
    9093    uint8_t char_found;      /**< State of the matched character */
     
    9295
    9396#else
    94 /** Non-asynch serial hal structure
     97/** Non-asynch serial HAL structure
    9598 */
    9699typedef struct serial_s serial_t;
     
    103106
    104107/**
    105  * \defgroup GeneralSerial Serial Configuration Functions
     108 * \defgroup hal_GeneralSerial Serial Configuration Functions
    106109 * @{
    107110 */
    108111
    109112/** Initialize the serial peripheral. It sets the default parameters for serial
    110  *  peripheral, and configure its specifieds pins.
    111  *
    112  * @param obj The serial object
    113  * @param tx  The TX pin
    114  * @param rx  The RX pin
     113 *  peripheral, and configures its specifieds pins.
     114 *
     115 * @param obj The serial object
     116 * @param tx  The TX pin name
     117 * @param rx  The RX pin name
    115118 */
    116119void serial_init(serial_t *obj, PinName tx, PinName rx);
     
    139142void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits);
    140143
    141 /** The serial interrupt handler registration.
     144/** The serial interrupt handler registration
    142145 *
    143146 * @param obj     The serial object
    144  * @param handler The interrupt handler which will be invoked when interrupt fires.
     147 * @param handler The interrupt handler which will be invoked when the interrupt fires
    145148 * @param id      The SerialBase object
    146149 */
     
    161164int  serial_getc(serial_t *obj);
    162165
    163 /** Put a character. This is a blocking call, waiting for a peripheral to be available
     166/** Send a character. This is a blocking call, waiting for a peripheral to be available
    164167 *  for writing
    165168 *
     
    172175 *
    173176 * @param obj The serial object
    174  * @return Non-zero value if a character can be read, 0 if nothing to read.
     177 * @return Non-zero value if a character can be read, 0 if nothing to read
    175178 */
    176179int  serial_readable(serial_t *obj);
     
    203206/** Configure the TX pin for UART function.
    204207 *
    205  * @param tx The pin used for TX
     208 * @param tx The pin name used for TX
    206209 */
    207210void serial_pinout_tx(PinName tx);
     
    212215 * @param obj    The serial object
    213216 * @param type   The type of the flow control. Look at the available FlowControl types.
    214  * @param rxflow The tx pin
    215  * @param txflow The rx pin
     217 * @param rxflow The TX pin name
     218 * @param txflow The RX pin name
    216219 */
    217220void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow);
     
    222225
    223226/**
    224  * \defgroup AsynchSerial Asynchronous Serial Hardware Abstraction Layer
     227 * \defgroup hal_AsynchSerial Asynchronous Serial Hardware Abstraction Layer
    225228 * @{
    226229 */
     
    230233 *
    231234 * @param obj       The serial object
    232  * @param tx        The buffer for sending
    233  * @param tx_length The number of words to transmit
    234  * @param tx_width  The bit width of buffer word
     235 * @param tx        The transmit buffer
     236 * @param tx_length The number of bytes to transmit
     237 * @param tx_width  Deprecated argument
    235238 * @param handler   The serial handler
    236239 * @param event     The logical OR of events to be registered
    237240 * @param hint      A suggestion for how to use DMA with this transfer
    238  * @return Returns number of data transfered, or 0 otherwise
     241 * @return Returns number of data transfered, otherwise returns 0
    239242 */
    240243int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx_width, uint32_t handler, uint32_t event, DMAUsage hint);
     
    244247 *
    245248 * @param obj        The serial object
    246  * @param rx         The buffer for sending
    247  * @param rx_length  The number of words to transmit
    248  * @param rx_width   The bit width of buffer word
     249 * @param rx         The receive buffer
     250 * @param rx_length  The number of bytes to receive
     251 * @param rx_width   Deprecated argument
    249252 * @param handler    The serial handler
    250253 * @param event      The logical OR of events to be registered
     
    272275 *
    273276 * @param obj The serial object
    274  * @return Returns event flags if a RX transfer termination condition was met or 0 otherwise
     277 * @return Returns event flags if an RX transfer termination condition was met; otherwise returns 0
    275278 */
    276279int serial_irq_handler_asynch(serial_t *obj);
    277280
    278281/** Abort the ongoing TX transaction. It disables the enabled interupt for TX and
    279  *  flush TX hardware buffer if TX FIFO is used
     282 *  flushes the TX hardware buffer if TX FIFO is used
    280283 *
    281284 * @param obj The serial object
     
    283286void serial_tx_abort_asynch(serial_t *obj);
    284287
    285 /** Abort the ongoing RX transaction It disables the enabled interrupt for RX and
    286  *  flush RX hardware buffer if RX FIFO is used
     288/** Abort the ongoing RX transaction. It disables the enabled interrupt for RX and
     289 *  flushes the RX hardware buffer if RX FIFO is used
    287290 *
    288291 * @param obj The serial object
     
    301304
    302305#endif
     306
     307/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/sleep_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    2528#endif
    2629
     30/**
     31 * \defgroup hal_sleep sleep hal requirements
     32 * Low level interface to the sleep mode of a target.
     33 *
     34 * # Defined behaviour
     35 *
     36 * * Sleep mode
     37 *   * wake-up time should be less than 10 us - Verified by sleep_usticker_test().
     38 *   * the processor can be woken up by any internal peripheral interrupt  - Verified by sleep_usticker_test().
     39 *   * all peripherals operate as in run mode - not verified.
     40 *   * the processor can be woken up by external pin interrupt - not verified.
     41 * * Deep sleep
     42 *   * the wake-up time should be less than 10 ms - Verified by deepsleep_lpticker_test().
     43 *   * lp ticker should wake up a target from this mode - Verified by deepsleep_lpticker_test().
     44 *   * RTC should wake up a target from this mode - not verified.
     45 *   * an external interrupt on a pin should wake up a target from this mode - not verified.
     46 *   * a watchdog timer should wake up a target from this mode - not verified.
     47 *   * High-speed clocks are turned off - Verified by deepsleep_high_speed_clocks_turned_off_test().
     48 *   * RTC keeps time - Verified by rtc_sleep_test().
     49 *
     50 * # Undefined behaviour
     51 *
     52 * * peripherals aside from RTC, GPIO and lp ticker result in undefined behaviour in deep sleep.
     53 * @{
     54 */
     55
     56/**
     57 * \defgroup hal_sleep_tests sleep hal tests
     58 * The sleep HAL tests ensure driver conformance to defined behaviour.
     59 *
     60 * To run the sleep hal tests use the command:
     61 *
     62 *     mbed test -t <toolchain> -m <target> -n tests-mbed_hal-sleep*
     63 *
     64 */
     65
    2766/** Send the microcontroller to sleep
    2867 *
    29  * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
     68 * The processor is setup ready for sleep, and sent to sleep. In this mode, the
    3069 * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
    3170 * dynamic power used by the processor, memory systems and buses. The processor, peripheral and
     
    3473 * The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
    3574 *
    36  * @note
    37  *  The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
    38  * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
    39  * able to access the LocalFileSystem
     75 * The wake-up time shall be less than 10 us.
     76 *
    4077 */
    41 void sleep(void);
     78void hal_sleep(void);
    4279
    4380/** Send the microcontroller to deep sleep
    4481 *
    4582 * This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode
    46  * has the same sleep features as sleep plus it powers down peripherals and clocks. All state
    47  * is still maintained.
     83 * has the same sleep features as sleep plus it powers down peripherals and high frequency clocks.
     84 * All state is still maintained.
    4885 *
    49  * The processor can only be woken up by an external interrupt on a pin or a watchdog timer.
     86 * The processor can only be woken up by low power ticker, RTC, an external interrupt on a pin or a watchdog timer.
    5087 *
    51  * @note
    52  *  The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
    53  * Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
    54  * able to access the LocalFileSystem
     88 * The wake-up time shall be less than 10 ms.
    5589 */
    56 void deepsleep(void);
     90void hal_deepsleep(void);
     91
     92/**@}*/
    5793
    5894#ifdef __cplusplus
     
    6399
    64100#endif
     101
     102/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/spi_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2013 ARM Limited
     
    1821
    1922#include "device.h"
    20 #include "dma_api.h"
    21 #include "buffer.h"
     23#include "hal/dma_api.h"
     24#include "hal/buffer.h"
    2225
    2326#if DEVICE_SPI
     
    2831#define SPI_EVENT_ALL         (SPI_EVENT_ERROR | SPI_EVENT_COMPLETE | SPI_EVENT_RX_OVERFLOW)
    2932
    30 #define SPI_EVENT_INTERNAL_TRANSFER_COMPLETE (1 << 30) // internal flag to report an event occurred
     33#define SPI_EVENT_INTERNAL_TRANSFER_COMPLETE (1 << 30) // Internal flag to report that an event occurred
    3134
    3235#define SPI_FILL_WORD         (0xFFFF)
     36#define SPI_FILL_CHAR         (0xFF)
    3337
    3438#if DEVICE_SPI_ASYNCH
    35 /** Asynch spi hal structure
     39/** Asynch SPI HAL structure
    3640 */
    3741typedef struct {
    38     struct spi_s spi;        /**< Target specific spi structure */
     42    struct spi_s spi;        /**< Target specific SPI structure */
    3943    struct buffer_s tx_buff; /**< Tx buffer */
    4044    struct buffer_s rx_buff; /**< Rx buffer */
     
    4246
    4347#else
    44 /** Non-asynch spi hal structure
     48/** Non-asynch SPI HAL structure
    4549 */
    4650typedef struct spi_s spi_t;
     
    5357
    5458/**
    55  * \defgroup GeneralSPI SPI Configuration Functions
     59 * \defgroup hal_GeneralSPI SPI Configuration Functions
    5660 * @{
    5761 */
     
    8286/** Configure the SPI format
    8387 *
    84  * Set the number of bits per frame, configure clock polarity and phase, shift order and master/slave mode
     88 * Set the number of bits per frame, configure clock polarity and phase, shift order and master/slave mode.
     89 * The default bit order is MSB.
    8590 * @param[in,out] obj   The SPI object to configure
    8691 * @param[in]     bits  The number of bits per frame
     
    113118int  spi_master_write(spi_t *obj, int value);
    114119
     120/** Write a block out in master mode and receive a value
     121 *
     122 *  The total number of bytes sent and received will be the maximum of
     123 *  tx_length and rx_length. The bytes written will be padded with the
     124 *  value 0xff.
     125 *
     126 * @param[in] obj        The SPI peripheral to use for sending
     127 * @param[in] tx_buffer  Pointer to the byte-array of data to write to the device
     128 * @param[in] tx_length  Number of bytes to write, may be zero
     129 * @param[in] rx_buffer  Pointer to the byte-array of data to read from the device
     130 * @param[in] rx_length  Number of bytes to read, may be zero
     131 * @param[in] write_fill Default data transmitted while performing a read
     132 * @returns
     133 *      The number of bytes written and read from the device. This is
     134 *      maximum of tx_length and rx_length.
     135 */
     136int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, char write_fill);
     137
    115138/** Check if a value is available to read
    116139 *
     
    160183/** Begin the SPI transfer. Buffer pointers and lengths are specified in tx_buff and rx_buff
    161184 *
    162  * @param[in] obj       The SPI object which holds the transfer information
    163  * @param[in] tx        The buffer to send
    164  * @param[in] tx_length The number of words to transmit
    165  * @param[in] rx        The buffer to receive
    166  * @param[in] rx_length The number of words to receive
     185 * @param[in] obj       The SPI object that holds the transfer information
     186 * @param[in] tx        The transmit buffer
     187 * @param[in] tx_length The number of bytes to transmit
     188 * @param[in] rx        The receive buffer
     189 * @param[in] rx_length The number of bytes to receive
    167190 * @param[in] bit_width The bit width of buffer words
    168191 * @param[in] event     The logical OR of events to be registered
     
    176199 * Reads the received values out of the RX FIFO, writes values into the TX FIFO and checks for transfer termination
    177200 * conditions, such as buffer overflows or transfer complete.
    178  * @param[in] obj     The SPI object which holds the transfer information
    179  * @return event flags if a transfer termination condition was met or 0 otherwise.
     201 * @param[in] obj     The SPI object that holds the transfer information
     202 * @return Event flags if a transfer termination condition was met; otherwise 0.
    180203 */
    181204uint32_t spi_irq_handler_asynch(spi_t *obj);
    182205
    183 /** Attempts to determine if the SPI peripheral is already in use.
     206/** Attempts to determine if the SPI peripheral is already in use
    184207 *
    185208 * If a temporary DMA channel has been allocated, peripheral is in use.
     
    190213 * there are any bytes in the FIFOs.
    191214 * @param[in] obj The SPI object to check for activity
    192  * @return non-zero if the SPI port is active or zero if it is not.
     215 * @return Non-zero if the SPI port is active or zero if it is not.
    193216 */
    194217uint8_t spi_active(spi_t *obj);
     
    212235
    213236#endif // MBED_SPI_API_H
     237
     238/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/ticker_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2015 ARM Limited
     
    1720#define MBED_TICKER_API_H
    1821
     22#include <stdint.h>
     23#include <stdbool.h>
    1924#include "device.h"
    2025
     26/**
     27 * Legacy format representing a timestamp in us.
     28 * Given it is modeled as a 32 bit integer, this type can represent timestamp
     29 * up to 4294 seconds (71 minutes).
     30 * Prefer using us_timestamp_t which store timestamp as 64 bits integer.
     31 */
    2132typedef uint32_t timestamp_t;
    2233
     34/**
     35 * A us timestamp stored in a 64 bit integer.
     36 * Can store timestamp up to 584810 years.
     37 */
     38typedef uint64_t us_timestamp_t;
     39
    2340/** Ticker's event structure
    2441 */
    2542typedef struct ticker_event_s {
    26     timestamp_t            timestamp; /**< Event's timestamp */
     43    us_timestamp_t         timestamp; /**< Event's timestamp */
    2744    uint32_t               id;        /**< TimerEvent object */
    2845    struct ticker_event_s *next;      /**< Next event in the queue */
     
    3047
    3148typedef void (*ticker_event_handler)(uint32_t id);
     49
     50/** Information about the ticker implementation
     51 */
     52typedef struct {
     53    uint32_t frequency;                           /**< Frequency in Hz this ticker runs at */
     54    uint32_t bits;                                /**< Number of bits this ticker supports */
     55} ticker_info_t;
     56
    3257
    3358/** Ticker's interface structure - required API for a ticker
     
    3964    void (*clear_interrupt)(void);                /**< Clear interrupt function */
    4065    void (*set_interrupt)(timestamp_t timestamp); /**< Set interrupt function */
     66    void (*fire_interrupt)(void);                 /**< Fire interrupt right-away */
     67    void (*free)(void);                           /**< Disable function */
     68    const ticker_info_t *(*get_info)(void);       /**< Return info about this ticker's implementation */
    4169} ticker_interface_t;
    4270
    43 /** Tickers events queue structure
     71/** Ticker's event queue structure
    4472 */
    4573typedef struct {
    4674    ticker_event_handler event_handler; /**< Event handler */
    4775    ticker_event_t *head;               /**< A pointer to head */
     76    uint32_t frequency;                 /**< Frequency of the timer in Hz */
     77    uint32_t bitmask;                   /**< Mask to be applied to time values read */
     78    uint32_t max_delta;                 /**< Largest delta in ticks that can be used when scheduling */
     79    uint64_t max_delta_us;              /**< Largest delta in us that can be used when scheduling */
     80    uint32_t tick_last_read;            /**< Last tick read */
     81    uint64_t tick_remainder;            /**< Ticks that have not been added to base_time */
     82    us_timestamp_t present_time;        /**< Store the timestamp used for present time */
     83    bool initialized;                   /**< Indicate if the instance is initialized */
     84    bool dispatching;                   /**< The function ticker_irq_handler is dispatching */
     85    bool suspended;                     /**< Indicate if the instance is suspended */
     86    uint8_t frequency_shifts;           /**< If frequency is a value of 2^n, this is n, otherwise 0 */
    4887} ticker_event_queue_t;
    4988
    50 /** Tickers data structure
     89/** Ticker's data structure
    5190 */
    5291typedef struct {
    5392    const ticker_interface_t *interface; /**< Ticker's interface */
    54     ticker_event_queue_t *queue;         /**< Ticker's events queue */
     93    ticker_event_queue_t *queue;         /**< Ticker's event queue */
    5594} ticker_data_t;
    5695
     
    5998#endif
    6099
    61 /** Initialize a ticker and sets the event handler
    62  *
    63  * @param data    The ticker's data
     100/**
     101 * \defgroup hal_ticker Ticker HAL functions
     102 * @{
     103 */
     104
     105/** Initialize a ticker and set the event handler
     106 *
     107 * @param ticker The ticker object.
    64108 * @param handler A handler to be set
    65109 */
    66 void ticker_set_handler(const ticker_data_t *const data, ticker_event_handler handler);
    67 
    68 /** Irq handler which goes through the events to trigger events in the past.
    69  *
    70  * @param data    The ticker's data
    71  */
    72 void ticker_irq_handler(const ticker_data_t *const data);
     110void ticker_set_handler(const ticker_data_t *const ticker, ticker_event_handler handler);
     111
     112/** IRQ handler that goes through the events to trigger overdue events.
     113 *
     114 * @param ticker The ticker object.
     115 */
     116void ticker_irq_handler(const ticker_data_t *const ticker);
    73117
    74118/** Remove an event from the queue
    75119 *
    76  * @param data The ticker's data
    77  * @param obj  The event's queue to be removed
    78  */
    79 void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj);
    80 
    81 /** Insert an event from the queue
    82  *
    83  * @param data      The ticker's data
    84  * @param obj       The event's queue to be removed
     120 * @param ticker The ticker object.
     121 * @param obj  The event object to be removed from the queue
     122 */
     123void ticker_remove_event(const ticker_data_t *const ticker, ticker_event_t *obj);
     124
     125/** Insert an event to the queue
     126 *
     127 * The event will be executed in timestamp - ticker_read().
     128 *
     129 * @warning This function does not consider timestamp in the past. If an event
     130 * is inserted with a timestamp less than the current timestamp then the event
     131 * will be executed in timestamp - ticker_read() us.
     132 * The internal counter wrap very quickly it is hard to decide weither an
     133 * event is in the past or in 1 hour.
     134 *
     135 * @note prefer the use of ticker_insert_event_us which allows registration of
     136 * absolute timestamp.
     137 *
     138 * @param ticker    The ticker object.
     139 * @param obj       The event object to be inserted to the queue
    85140 * @param timestamp The event's timestamp
    86141 * @param id        The event object
    87142 */
    88 void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, timestamp_t timestamp, uint32_t id);
    89 
    90 /** Read the current ticker's timestamp
    91  *
    92  * @param data The ticker's data
     143void ticker_insert_event(const ticker_data_t *const ticker, ticker_event_t *obj, timestamp_t timestamp, uint32_t id);
     144
     145/** Insert an event to the queue
     146 *
     147 * The event will be executed in timestamp - ticker_read_us() us.
     148 *
     149 * @note If an event is inserted with a timestamp less than the current
     150 * timestamp then the event will be scheduled immediately resulting in
     151 * an instant call to event handler.
     152 *
     153 * @param ticker    The ticker object.
     154 * @param obj       The event object to be inserted to the queue
     155 * @param timestamp The event's timestamp
     156 * @param id        The event object
     157 */
     158void ticker_insert_event_us(const ticker_data_t *const ticker, ticker_event_t *obj, us_timestamp_t timestamp, uint32_t id);
     159
     160/** Read the current (relative) ticker's timestamp
     161 *
     162 * @warning Return a relative timestamp because the counter wrap every 4294
     163 * seconds.
     164 *
     165 * @param ticker The ticker object.
    93166 * @return The current timestamp
    94167 */
    95 timestamp_t ticker_read(const ticker_data_t *const data);
     168timestamp_t ticker_read(const ticker_data_t *const ticker);
     169
     170/** Read the current (absolute) ticker's timestamp
     171 *
     172 * @warning Return an absolute timestamp counting from the initialization of the
     173 * ticker.
     174 *
     175 * @param ticker The ticker object.
     176 * @return The current timestamp
     177 */
     178us_timestamp_t ticker_read_us(const ticker_data_t *const ticker);
    96179
    97180/** Read the next event's timestamp
    98181 *
    99  * @param data The ticker's data
     182 * @param ticker        The ticker object.
     183 * @param timestamp     The timestamp object.
    100184 * @return 1 if timestamp is pending event, 0 if there's no event pending
    101185 */
    102 int ticker_get_next_timestamp(const ticker_data_t *const data, timestamp_t *timestamp);
     186int ticker_get_next_timestamp(const ticker_data_t *const ticker, timestamp_t *timestamp);
     187
     188/** Suspend this ticker
     189 *
     190 * When suspended reads will always return the same time and no
     191 * events will be dispatched. When suspended the common layer
     192 * will only ever call the interface function clear_interrupt()
     193 * and that is only if ticker_irq_handler is called.
     194 *
     195 *
     196 * @param ticker        The ticker object.
     197 */
     198void ticker_suspend(const ticker_data_t *const ticker);
     199
     200/** Resume this ticker
     201 *
     202 * When resumed the ticker will ignore any time that has passed
     203 * and continue counting up where it left off.
     204 *
     205 * @param ticker        The ticker object.
     206 */
     207void ticker_resume(const ticker_data_t *const ticker);
     208
     209/* Private functions
     210 *
     211 * @cond PRIVATE
     212 *
     213 */
     214
     215int _ticker_match_interval_passed(timestamp_t prev_tick, timestamp_t cur_tick, timestamp_t match_tick);
     216
     217/*
     218 * @endcond PRIVATE
     219 *
     220 */
     221
     222/**@}*/
    103223
    104224#ifdef __cplusplus
     
    107227
    108228#endif
     229
     230/** @}*/
  • EcnlProtoTool/trunk/asp3_dcre/mbed/hal/us_ticker_api.h

    r321 r429  
     1
     2/** \addtogroup hal */
     3/** @{*/
    14/* mbed Microcontroller Library
    25 * Copyright (c) 2006-2015 ARM Limited
     
    1821
    1922#include <stdint.h>
    20 #include "ticker_api.h"
     23#include "hal/ticker_api.h"
    2124
    2225#ifdef __cplusplus
     
    2528
    2629/**
    27  * \defgroup UsTicker Microseconds Ticker Functions
     30 * \defgroup hal_us_ticker Microsecond Ticker
     31 * Low level interface to the microsecond ticker of a target
     32 *
     33 * # Defined behavior
     34 * * Has a reported frequency between 250KHz and 8MHz - Verified by test ::us_ticker_info_test
     35 * * Has a counter that is at least 16 bits wide - Verified by test ::us_ticker_info_test
     36 * * All behavior defined by the @ref hal_ticker_shared "ticker specification"
     37 *
     38 * # Undefined behavior
     39 * * See the @ref hal_ticker_shared "ticker specification"
     40 *
     41 * @see hal_us_ticker_tests
     42 *
    2843 * @{
    2944 */
    3045
     46/**
     47 * \defgroup hal_us_ticker_tests Microsecond Ticker tests
     48 * Tests to validate the proper implementation of the microsecond ticker
     49 *
     50 * To run the microsecond ticker hal tests use the command:
     51 *
     52 *     mbed test -t <toolchain> -m <target> -n tests-mbed_hal-common_ticker*,tests-mbed_hal-us_ticker*
     53 *
     54 * @see hal_ticker_tests
     55 *
     56 */
     57
     58/**
     59 * \defgroup hal_ticker_shared Ticker Hal
     60 * Low level interface to the ticker of a target
     61 *
     62 * # Defined behavior
     63 * * The function ticker_init is safe to call repeatedly - Verified by test ::ticker_init_test
     64 * * The function ticker_init allows the ticker to keep counting and disables the ticker interrupt - Verified by test ::ticker_init_test
     65 * * Ticker frequency is non-zero and counter is at least 8 bits - Verified by ::ticker_info_test
     66 * * The ticker rolls over at (1 << bits) and continues counting starting from 0 - Verified by ::ticker_overflow_test
     67 * * The ticker counts at the specified frequency +- 10% - Verified by ::ticker_frequency_test
     68 * * The ticker increments by 1 each tick - Verified by ::ticker_increment_test
     69 * * The ticker interrupt fires only when the ticker times increments to or past the value set by ticker_set_interrupt.
     70 * Verified by ::ticker_interrupt_test and ::ticker_past_test
     71 * * It is safe to call ticker_set_interrupt repeatedly before the handler is called - Verified by ::ticker_repeat_reschedule_test
     72 * * The function ticker_fire_interrupt causes ticker_irq_handler to be called immediately from interrupt context -
     73 * Verified by ::ticker_fire_now_test
     74 * * The ticker operations ticker_read, ticker_clear_interrupt, ticker_set_interrupt and ticker_fire_interrupt
     75 * take less than 20us to complete - Verified by ::ticker_speed_test
     76 *
     77 * # Undefined behavior
     78 * * Calling any function other than ticker_init before the initialization of the ticker
     79 * * Whether ticker_irq_handler is called a second time if the time wraps and matches the value set by ticker_set_interrupt again
     80 * * Calling ticker_set_interrupt with a value that has more than the supported number of bits
     81 * * Calling any function other than us_ticker_init after calling us_ticker_free
     82 *
     83 * # Potential bugs
     84 * * Drift due to reschedule - Verified by ::ticker_repeat_reschedule_test
     85 * * Incorrect overflow handling of timers - Verified by ::ticker_overflow_test
     86 * * Interrupting at a time of 0 - Verified by ::ticker_overflow_test
     87 * * Interrupt triggered more than once - Verified by ::ticker_interrupt_test
     88 *
     89 * @ingroup hal_us_ticker
     90 * @ingroup hal_lp_ticker
     91 */
     92
     93/**
     94 * \defgroup hal_ticker_tests Ticker Tests
     95 * Tests to validate the proper implementation of a ticker
     96 *
     97 * To run the ticker hal tests use the command:
     98 *
     99 *     mbed test -t <toolchain> -m <target> -n tests-mbed_hal-common_ticker*
     100 *
     101 * @ingroup hal_us_ticker
     102 * @ingroup hal_lp_ticker
     103 */
     104
     105
     106typedef void (*ticker_irq_handler_type)(const ticker_data_t *const);
     107
     108/** Set ticker IRQ handler
     109 *
     110 * @param ticker_irq_handler IRQ handler to be connected
     111 *
     112 * @return previous ticker IRQ handler
     113 *
     114 * @note by default IRQ handler is set to ::ticker_irq_handler
     115 * @note this function is primarily for testing purposes and it's not required part of HAL implementation
     116 *
     117 */
     118ticker_irq_handler_type set_us_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler);
     119
    31120/** Get ticker's data
    32121 *
    33  * @return The low power ticker data
    34  */
    35 const ticker_data_t* get_us_ticker_data(void);
     122 * @return The microsecond ticker data
     123 */
     124const ticker_data_t *get_us_ticker_data(void);
    36125
    37126
     
    45134/** Initialize the ticker
    46135 *
     136 * Initialize or re-initialize the ticker. This resets all the
     137 * clocking and prescaler registers, along with disabling
     138 * the compare interrupt.
     139 *
     140 * @note Initialization properties tested by ::ticker_init_test
     141 *
     142 * Pseudo Code:
     143 * @code
     144 * void us_ticker_init()
     145 * {
     146 *     // Enable clock gate so processor can read TIMER registers
     147 *     POWER_CTRL |= POWER_CTRL_TIMER_Msk;
     148 *
     149 *     // Disable the timer and ensure it is powered down
     150 *     TIMER_CTRL &= ~(TIMER_CTRL_ENABLE_Msk | TIMER_CTRL_COMPARE_ENABLE_Msk);
     151 *
     152 *     // Configure divisors
     153 *     uint32_t prescale = SystemCoreClock / 1000000;
     154 *     TIMER_PRESCALE = prescale - 1;
     155 *     TIMER_CTRL |= TIMER_CTRL_ENABLE_Msk;
     156 *
     157 *     // Install the interrupt handler
     158 *     NVIC_SetVector(TIMER_IRQn, (uint32_t)us_ticker_irq_handler);
     159 *     NVIC_EnableIRQ(TIMER_IRQn);
     160 * }
     161 * @endcode
    47162 */
    48163void us_ticker_init(void);
    49164
     165/** Deinitialize the us ticker
     166 *
     167 * Powerdown the us ticker in preparation for sleep, powerdown, or reset.
     168 *
     169 * After this function is called, no other ticker functions should be called
     170 * except us_ticker_init(), calling any function other than init is undefined.
     171 *
     172 * @note This function stops the ticker from counting.
     173 *
     174 * Pseudo Code:
     175 * @code
     176 * uint32_t us_ticker_free()
     177 * {
     178 *     // Disable timer
     179 *     TIMER_CTRL &= ~TIMER_CTRL_ENABLE_Msk;
     180 *
     181 *     // Disable the compare interrupt
     182 *     TIMER_CTRL &= ~TIMER_CTRL_COMPARE_ENABLE_Msk;
     183 *
     184 *     // Disable timer interrupt
     185 *     NVIC_DisableIRQ(TIMER_IRQn);
     186 *
     187 *     // Disable clock gate so processor cannot read TIMER registers
     188 *     POWER_CTRL &= ~POWER_CTRL_TIMER_Msk;
     189 * }
     190 * @endcode
     191 *
     192 */
     193void us_ticker_free(void);
     194
    50195/** Read the current counter
    51196 *
    52  * @return The current timer's counter value in microseconds
     197 * Read the current counter value without performing frequency conversions.
     198 * If no rollover has occurred, the seconds passed since us_ticker_init()
     199 * was called can be found by dividing the ticks returned by this function
     200 * by the frequency returned by ::us_ticker_get_info.
     201 *
     202 * @return The current timer's counter value in ticks
     203 *
     204 * Pseudo Code:
     205 * @code
     206 * uint32_t us_ticker_read()
     207 * {
     208 *     return TIMER_COUNT;
     209 * }
     210 * @endcode
    53211 */
    54212uint32_t us_ticker_read(void);
     
    56214/** Set interrupt for specified timestamp
    57215 *
    58  * @param timestamp The time in microseconds to be set
     216 * @param timestamp The time in ticks to be set
     217 *
     218 * @note no special handling needs to be done for times in the past
     219 * as the common timer code will detect this and call
     220 * us_ticker_fire_interrupt() if this is the case
     221 *
     222 * @note calling this function with timestamp of more than the supported
     223 * number of bits returned by ::us_ticker_get_info results in undefined
     224 * behavior.
     225 *
     226 * Pseudo Code:
     227 * @code
     228 * void us_ticker_set_interrupt(timestamp_t timestamp)
     229 * {
     230 *     TIMER_COMPARE = timestamp;
     231 *     TIMER_CTRL |= TIMER_CTRL_COMPARE_ENABLE_Msk;
     232 * }
     233 * @endcode
    59234 */
    60235void us_ticker_set_interrupt(timestamp_t timestamp);
     
    62237/** Disable us ticker interrupt
    63238 *
     239 * Pseudo Code:
     240 * @code
     241 * void us_ticker_disable_interrupt(void)
     242 * {
     243 *     // Disable the compare interrupt
     244 *     TIMER_CTRL &= ~TIMER_CTRL_COMPARE_ENABLE_Msk;
     245 * }
     246 * @endcode
    64247 */
    65248void us_ticker_disable_interrupt(void);
     
    67250/** Clear us ticker interrupt
    68251 *
     252 * Pseudo Code:
     253 * @code
     254 * void us_ticker_clear_interrupt(void)
     255 * {
     256 *     // Write to the ICR (interrupt clear register) of the TIMER
     257 *     TIMER_ICR = TIMER_ICR_COMPARE_Msk;
     258 * }
     259 * @endcode
    69260 */
    70261void us_ticker_clear_interrupt(void);
     262
     263/** Set pending interrupt that should be fired right away.
     264 *
     265 * The ticker should be initialized prior calling this function.
     266 *
     267 * Pseudo Code:
     268 * @code
     269 * void us_ticker_fire_interrupt(void)
     270 * {
     271 *     NVIC_SetPendingIRQ(TIMER_IRQn);
     272 * }
     273 * @endcode
     274 */
     275void us_ticker_fire_interrupt(void);
     276
     277/** Get frequency and counter bits of this ticker.
     278 *
     279 * Pseudo Code:
     280 * @code
     281 * const ticker_info_t* us_ticker_get_info()
     282 * {
     283 *     static const ticker_info_t info = {
     284 *         1000000,    // 1 MHz
     285 *         32          // 32 bit counter
     286 *     };
     287 *     return &info;
     288 * }
     289 * @endcode
     290 */
     291const ticker_info_t *us_ticker_get_info(void);
    71292
    72293/**@}*/
     
    77298
    78299#endif
     300
     301/** @}*/
Note: See TracChangeset for help on using the changeset viewer.