Changeset 429 for EcnlProtoTool/trunk/asp3_dcre/mbed
- Timestamp:
- Jul 3, 2020, 7:19:17 PM (4 years ago)
- 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 14 14 # 15 15 INCLUDES := $(INCLUDES)\ 16 -I$(MBEDDIR)/api\ 16 -I$(MBEDDIR)\ 17 -I$(MBEDDIR)/cmsis\ 18 -I$(MBEDDIR)/cmsis/TARGET_CORTEX_A\ 17 19 -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 24 31 COPTS := $(COPTS)\ 25 32 -mthumb\ … … 39 46 -mno-unaligned-access 40 47 CDEFS := $(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 49 99 50 100 # … … 52 102 # 53 103 SYSSVC_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 115 SYSSVC_ASMOBJS := $(SYSSVC_ASMOBJS) 116 START_OBJS := startup_RZ1AH.o 117 START_OBJS := $(addprefix $(OBJDIR)/, $(START_OBJS)) 62 118 SYSSVC_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 130 CFG_DMY := cfg_dmy.o mmu_RZ_A1H.o mbed_sf_boot.o RZ_A1_Init.o system_RZ_A1H.o irq_ctrl_gic.o 71 131 -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/analogin_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 25 28 #endif 26 29 30 /** Analogin hal structure. analogin_s is declared in the target's hal 31 */ 27 32 typedef struct analogin_s analogin_t; 28 33 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 */ 45 void 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 */ 52 float 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 */ 31 59 uint16_t analogin_read_u16(analogin_t *obj); 60 61 /**@}*/ 32 62 33 63 #ifdef __cplusplus … … 38 68 39 69 #endif 70 71 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/analogout_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 25 28 #endif 26 29 30 /** Analogout hal structure. dac_s is declared in the target's hal 31 */ 27 32 typedef struct dac_s dac_t; 28 33 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 */ 45 void 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 */ 52 void 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 */ 59 void 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 */ 66 void 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 */ 74 float 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 */ 81 uint16_t analogout_read_u16(dac_t *obj); 82 83 /**@}*/ 35 84 36 85 #ifdef __cplusplus … … 41 90 42 91 #endif 92 93 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/buffer.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2014-2015 ARM Limited … … 29 32 30 33 #endif 34 35 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/can_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 * Copyright (c) 2006-201 3ARM Limited5 * Copyright (c) 2006-2016 ARM Limited 3 6 * 4 7 * Licensed under the Apache License, Version 2.0 (the "License"); … … 23 26 #include "PinNames.h" 24 27 #include "PeripheralNames.h" 25 #include " can_helper.h"28 #include "hal/can_helper.h" 26 29 27 30 #ifdef __cplusplus … … 56 59 57 60 void can_init (can_t *obj, PinName rd, PinName td); 61 void can_init_freq(can_t *obj, PinName rd, PinName td, int hz); 58 62 void can_free (can_t *obj); 59 63 int can_frequency(can_t *obj, int hz); … … 79 83 80 84 #endif 85 86 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/dma_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2014-2015 ARM Limited … … 44 47 45 48 #endif 49 50 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/ethernet_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 42 45 int ethernet_send(void); 43 46 44 // rec ieve from ethernet buffer, returning packet size, or 0 if no packet47 // receive from ethernet buffer, returning packet size, or 0 if no packet 45 48 int ethernet_receive(void); 46 49 … … 66 69 #endif 67 70 71 72 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/gpio_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 17 20 #define MBED_GPIO_API_H 18 21 22 #include <stdint.h> 19 23 #include "device.h" 20 24 … … 23 27 #endif 24 28 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 * 26 36 * @param pin The pin to be set as GPIO 27 37 * @return The GPIO port mask for this pin 28 38 **/ 29 39 uint32_t gpio_set(PinName pin); 30 31 40 /* Checks if gpio object is connected (pin was not initialized with NC) 32 41 * @param pin The pin to be set as GPIO … … 35 44 int gpio_is_connected(const gpio_t *obj); 36 45 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 */ 38 51 void gpio_init(gpio_t *obj, PinName pin); 39 52 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 */ 58 void gpio_mode(gpio_t *obj, PinMode mode); 42 59 60 /** Set the pin direction 61 * 62 * @param obj The GPIO object 63 * @param direction The pin direction to be set 64 */ 65 void 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 */ 43 72 void gpio_write(gpio_t *obj, int value); 44 int gpio_read (gpio_t *obj);45 73 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 */ 79 int 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 */ 47 89 void 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 */ 48 97 void 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 */ 49 105 void 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 */ 50 113 void 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 */ 51 123 void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value); 124 125 /**@}*/ 52 126 53 127 #ifdef __cplusplus … … 56 130 57 131 #endif 132 133 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/gpio_irq_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 25 28 #endif 26 29 30 /** GPIO IRQ events 31 */ 27 32 typedef enum { 28 33 IRQ_NONE, … … 31 36 } gpio_irq_event; 32 37 38 /** GPIO IRQ HAL structure. gpio_irq_s is declared in the target's HAL 39 */ 33 40 typedef struct gpio_irq_s gpio_irq_t; 34 41 35 42 typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event); 36 43 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 */ 57 int 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 */ 38 63 void 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 */ 71 void 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 */ 40 78 void 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 */ 41 85 void gpio_irq_disable(gpio_irq_t *obj); 86 87 /**@}*/ 42 88 43 89 #ifdef __cplusplus … … 48 94 49 95 #endif 96 97 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/i2c_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2015 ARM Limited … … 18 21 19 22 #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 21 28 22 29 #if DEVICE_I2C 23 30 24 31 /** 25 * @defgroup I2CEvents I2C Events Macros32 * @defgroup hal_I2CEvents I2C Events Macros 26 33 * 27 34 * @{ … … 36 43 37 44 #if DEVICE_I2C_ASYNCH 38 /** Asynch i2c halstructure45 /** Asynch I2C HAL structure 39 46 */ 40 47 typedef struct { 41 struct i2c_s i2c; /**< Target specific i2cstructure */48 struct i2c_s i2c; /**< Target specific I2C structure */ 42 49 struct buffer_s tx_buff; /**< Tx buffer */ 43 50 struct buffer_s rx_buff; /**< Rx buffer */ … … 45 52 46 53 #else 47 /** Non-asynch i2c halstructure54 /** Non-asynch I2C HAL structure 48 55 */ 49 56 typedef struct i2c_s i2c_t; … … 61 68 62 69 /** 63 * \defgroup GeneralI2C I2C Configuration Functions70 * \defgroup hal_GeneralI2C I2C Configuration Functions 64 71 * @{ 65 72 */ 66 73 67 74 /** 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 70 78 * @param sda The sda pin 71 79 * @param scl The scl pin … … 73 81 void i2c_init(i2c_t *obj, PinName sda, PinName scl); 74 82 75 /** Configure the I2C frequency. 76 * @param obj The i2c object 83 /** Configure the I2C frequency 84 * 85 * @param obj The I2C object 77 86 * @param hz Frequency in Hz 78 87 */ 79 88 void i2c_frequency(i2c_t *obj, int hz); 80 89 81 /** Send START command. 82 * @param obj The i2c object 90 /** Send START command 91 * 92 * @param obj The I2C object 83 93 */ 84 94 int i2c_start(i2c_t *obj); 85 95 86 /** Send STOP command. 87 * @param obj The i2c object 96 /** Send STOP command 97 * 98 * @param obj The I2C object 88 99 */ 89 100 int i2c_stop(i2c_t *obj); 90 101 91 /** Blocking reading data. 92 * @param obj The i2c object 102 /** Blocking reading data 103 * 104 * @param obj The I2C object 93 105 * @param address 7-bit address (last bit is 1) 94 106 * @param data The buffer for receiving … … 97 109 * @return Number of read bytes 98 110 */ 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 111 int 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 103 116 * @param address 7-bit address (last bit is 0) 104 117 * @param data The buffer for sending 105 * @param length Number of bytes to wr te118 * @param length Number of bytes to write 106 119 * @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 */ 124 int 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 113 129 */ 114 130 void i2c_reset(i2c_t *obj); 115 131 116 /** Read one byte. 117 * @param obj The i2c object 132 /** Read one byte 133 * 134 * @param obj The I2C object 118 135 * @param last Acknoledge 119 136 * @return The read byte 120 137 */ 121 int i2c_byte_read(i2c_t *obj, int last); 122 123 /** Write one byte. 124 * @param obj The i2c object 138 int i2c_byte_read(i2c_t *obj, int last); 139 140 /** Write one byte 141 * 142 * @param obj The I2C object 125 143 * @param data Byte to be written 126 * @return 1 if NAK was received, 0if ACK was received, 2 for timeout.127 */ 128 int 144 * @return 0 if NAK was received, 1 if ACK was received, 2 for timeout. 145 */ 146 int i2c_byte_write(i2c_t *obj, int data); 129 147 130 148 /**@}*/ … … 139 157 /** Configure I2C as slave or master. 140 158 * @param obj The I2C object 159 * @param enable_slave Enable i2c hardware so you can receive events with ::i2c_slave_receive 141 160 * @return non-zero if a value is available 142 161 */ … … 152 171 /** Configure I2C as slave or master. 153 172 * @param obj The I2C object 173 * @param data The buffer for receiving 174 * @param length Number of bytes to read 154 175 * @return non-zero if a value is available 155 176 */ … … 158 179 /** Configure I2C as slave or master. 159 180 * @param obj The I2C object 181 * @param data The buffer for sending 182 * @param length Number of bytes to write 160 183 * @return non-zero if a value is available 161 184 */ … … 177 200 178 201 /** 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 * 184 208 * @param obj The I2C object 185 * @param tx The buffer to send186 * @param tx_length The number of words to transmit187 * @param rx The buffer to receive188 * @param rx_length The number of words to receive189 * @param address The address to be set - 7bit or 9 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 190 214 * @param stop If true, stop will be generated after the transfer is done 191 215 * @param handler The I2C IRQ handler to be set 216 * @param event Event mask for the transfer. See \ref hal_I2CEvents 192 217 * @param hint DMA hint usage 193 218 */ … … 195 220 196 221 /** The asynchronous IRQ handler 222 * 197 223 * @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. 199 225 */ 200 226 uint32_t i2c_irq_handler_asynch(i2c_t *obj); 201 227 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 205 232 */ 206 233 uint8_t i2c_active(i2c_t *obj); 207 234 208 /** Abort ongoing asynchronous transaction. 235 /** Abort asynchronous transfer 236 * 237 * This function does not perform any check - that should happen in upper layers. 209 238 * @param obj The I2C object 210 239 */ … … 222 251 223 252 #endif 253 254 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/lp_ticker_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2015 ARM Limited … … 19 22 #include "device.h" 20 23 21 #if DEVICE_L OWPOWERTIMER22 23 #include " ticker_api.h"24 #if DEVICE_LPTICKER 25 26 #include "hal/ticker_api.h" 24 27 25 28 #ifdef __cplusplus … … 28 31 29 32 /** 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 * 31 51 * @{ 32 52 */ 33 53 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 64 typedef 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 */ 76 ticker_irq_handler_type set_lp_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler); 77 34 78 /** Get low power ticker's data 35 79 * 36 80 * @return The low power ticker data 37 81 */ 38 const ticker_data_t *get_lp_ticker_data(void);82 const ticker_data_t *get_lp_ticker_data(void); 39 83 40 84 /** The wrapper for ticker_irq_handler, to pass lp ticker's data … … 47 91 /** Initialize the low power ticker 48 92 * 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 49 116 */ 50 117 void lp_ticker_init(void); 51 118 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 */ 129 void 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 55 157 */ 56 158 uint32_t lp_ticker_read(void); … … 58 160 /** Set interrupt for specified timestamp 59 161 * 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 61 180 */ 62 181 void lp_ticker_set_interrupt(timestamp_t timestamp); … … 64 183 /** Disable low power ticker interrupt 65 184 * 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 66 193 */ 67 194 void lp_ticker_disable_interrupt(void); … … 69 196 /** Clear the low power ticker interrupt 70 197 * 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 71 206 */ 72 207 void 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 */ 219 void 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 */ 235 const ticker_info_t *lp_ticker_get_info(void); 73 236 74 237 /**@}*/ … … 81 244 82 245 #endif 246 247 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/pinmap.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 44 47 45 48 #endif 49 50 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/port_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 25 28 #endif 26 29 30 /** Port HAL structure. port_s is declared in the target's HAL 31 */ 27 32 typedef struct port_s port_t; 28 33 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 */ 29 45 PinName port_pin(PortName port, int pin_n); 30 46 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 */ 54 void 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 */ 61 void 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 */ 68 void 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 */ 34 75 void 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 */ 82 int port_read(port_t *obj); 83 84 /**@}*/ 36 85 37 86 #ifdef __cplusplus … … 41 90 42 91 #endif 92 93 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/pwmout_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 25 28 #endif 26 29 30 /** Pwmout hal structure. pwmout_s is declared in the target's hal 31 */ 27 32 typedef struct pwmout_s pwmout_t; 28 33 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 */ 31 38 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 */ 44 void pwmout_init(pwmout_t *obj, PinName pin); 34 45 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 */ 50 void pwmout_free(pwmout_t *obj); 38 51 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 */ 58 void 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 */ 65 float 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 */ 73 void 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 */ 80 void 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 */ 87 void 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 */ 94 void 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 */ 101 void 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 */ 108 void pwmout_pulsewidth_us(pwmout_t *obj, int us); 109 110 /**@}*/ 42 111 43 112 #ifdef __cplusplus … … 48 117 49 118 #endif 119 120 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/rtc_api.h
r321 r429 14 14 * limitations under the License. 15 15 */ 16 17 /** \addtogroup hal */ 18 /** @{*/ 19 16 20 #ifndef MBED_RTC_API_H 17 21 #define MBED_RTC_API_H 18 22 19 23 #include "device.h" 20 21 #if DEVICE_RTC22 24 23 25 #include <time.h> … … 27 29 #endif 28 30 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 */ 29 95 void 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 */ 30 115 void 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 */ 31 134 int rtc_isenabled(void); 32 135 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 */ 33 163 time_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 */ 34 177 void rtc_write(time_t t); 178 179 /**@}*/ 35 180 36 181 #ifdef __cplusplus … … 40 185 #endif 41 186 42 #endif 187 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/serial_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 18 21 19 22 #include "device.h" 20 #include " buffer.h"21 #include " dma_api.h"23 #include "hal/buffer.h" 24 #include "hal/dma_api.h" 22 25 23 26 #if DEVICE_SERIAL … … 81 84 82 85 #if DEVICE_SERIAL_ASYNCH 83 /** Asynch serial halstructure86 /** Asynch serial HAL structure 84 87 */ 85 88 typedef struct { 86 89 struct serial_s serial; /**< Target specific serial structure */ 87 struct buffer_s tx_buff; /**< T xbuffer */88 struct buffer_s rx_buff; /**< R xbuffer */90 struct buffer_s tx_buff; /**< TX buffer */ 91 struct buffer_s rx_buff; /**< RX buffer */ 89 92 uint8_t char_match; /**< Character to be matched */ 90 93 uint8_t char_found; /**< State of the matched character */ … … 92 95 93 96 #else 94 /** Non-asynch serial halstructure97 /** Non-asynch serial HAL structure 95 98 */ 96 99 typedef struct serial_s serial_t; … … 103 106 104 107 /** 105 * \defgroup GeneralSerial Serial Configuration Functions108 * \defgroup hal_GeneralSerial Serial Configuration Functions 106 109 * @{ 107 110 */ 108 111 109 112 /** 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 115 118 */ 116 119 void serial_init(serial_t *obj, PinName tx, PinName rx); … … 139 142 void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits); 140 143 141 /** The serial interrupt handler registration .144 /** The serial interrupt handler registration 142 145 * 143 146 * @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 145 148 * @param id The SerialBase object 146 149 */ … … 161 164 int serial_getc(serial_t *obj); 162 165 163 /** Puta character. This is a blocking call, waiting for a peripheral to be available166 /** Send a character. This is a blocking call, waiting for a peripheral to be available 164 167 * for writing 165 168 * … … 172 175 * 173 176 * @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 175 178 */ 176 179 int serial_readable(serial_t *obj); … … 203 206 /** Configure the TX pin for UART function. 204 207 * 205 * @param tx The pin used for TX208 * @param tx The pin name used for TX 206 209 */ 207 210 void serial_pinout_tx(PinName tx); … … 212 215 * @param obj The serial object 213 216 * @param type The type of the flow control. Look at the available FlowControl types. 214 * @param rxflow The tx pin215 * @param txflow The rx pin217 * @param rxflow The TX pin name 218 * @param txflow The RX pin name 216 219 */ 217 220 void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow); … … 222 225 223 226 /** 224 * \defgroup AsynchSerial Asynchronous Serial Hardware Abstraction Layer227 * \defgroup hal_AsynchSerial Asynchronous Serial Hardware Abstraction Layer 225 228 * @{ 226 229 */ … … 230 233 * 231 234 * @param obj The serial object 232 * @param tx The buffer for sending233 * @param tx_length The number of words to transmit234 * @param tx_width The bit width of buffer word235 * @param tx The transmit buffer 236 * @param tx_length The number of bytes to transmit 237 * @param tx_width Deprecated argument 235 238 * @param handler The serial handler 236 239 * @param event The logical OR of events to be registered 237 240 * @param hint A suggestion for how to use DMA with this transfer 238 * @return Returns number of data transfered, o r 0 otherwise241 * @return Returns number of data transfered, otherwise returns 0 239 242 */ 240 243 int 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); … … 244 247 * 245 248 * @param obj The serial object 246 * @param rx The buffer for sending247 * @param rx_length The number of words to transmit248 * @param rx_width The bit width of buffer word249 * @param rx The receive buffer 250 * @param rx_length The number of bytes to receive 251 * @param rx_width Deprecated argument 249 252 * @param handler The serial handler 250 253 * @param event The logical OR of events to be registered … … 272 275 * 273 276 * @param obj The serial object 274 * @return Returns event flags if a RX transfer termination condition was met or 0 otherwise277 * @return Returns event flags if an RX transfer termination condition was met; otherwise returns 0 275 278 */ 276 279 int serial_irq_handler_asynch(serial_t *obj); 277 280 278 281 /** Abort the ongoing TX transaction. It disables the enabled interupt for TX and 279 * flush TX hardware buffer if TX FIFO is used282 * flushes the TX hardware buffer if TX FIFO is used 280 283 * 281 284 * @param obj The serial object … … 283 286 void serial_tx_abort_asynch(serial_t *obj); 284 287 285 /** Abort the ongoing RX transaction It disables the enabled interrupt for RX and286 * flush RX hardware buffer if RX FIFO is used288 /** Abort the ongoing RX transaction. It disables the enabled interrupt for RX and 289 * flushes the RX hardware buffer if RX FIFO is used 287 290 * 288 291 * @param obj The serial object … … 301 304 302 305 #endif 306 307 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/sleep_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 25 28 #endif 26 29 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 27 66 /** Send the microcontroller to sleep 28 67 * 29 * The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the68 * The processor is setup ready for sleep, and sent to sleep. In this mode, the 30 69 * system clock to the core is stopped until a reset or an interrupt occurs. This eliminates 31 70 * dynamic power used by the processor, memory systems and buses. The processor, peripheral and … … 34 73 * The processor can be woken up by any internal peripheral interrupt or external pin interrupt. 35 74 * 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 * 40 77 */ 41 void sleep(void);78 void hal_sleep(void); 42 79 43 80 /** Send the microcontroller to deep sleep 44 81 * 45 82 * 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 state47 * 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. 48 85 * 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. 50 87 * 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. 55 89 */ 56 void deepsleep(void); 90 void hal_deepsleep(void); 91 92 /**@}*/ 57 93 58 94 #ifdef __cplusplus … … 63 99 64 100 #endif 101 102 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/spi_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2013 ARM Limited … … 18 21 19 22 #include "device.h" 20 #include " dma_api.h"21 #include " buffer.h"23 #include "hal/dma_api.h" 24 #include "hal/buffer.h" 22 25 23 26 #if DEVICE_SPI … … 28 31 #define SPI_EVENT_ALL (SPI_EVENT_ERROR | SPI_EVENT_COMPLETE | SPI_EVENT_RX_OVERFLOW) 29 32 30 #define SPI_EVENT_INTERNAL_TRANSFER_COMPLETE (1 << 30) // internal flag to report an event occurred33 #define SPI_EVENT_INTERNAL_TRANSFER_COMPLETE (1 << 30) // Internal flag to report that an event occurred 31 34 32 35 #define SPI_FILL_WORD (0xFFFF) 36 #define SPI_FILL_CHAR (0xFF) 33 37 34 38 #if DEVICE_SPI_ASYNCH 35 /** Asynch spi halstructure39 /** Asynch SPI HAL structure 36 40 */ 37 41 typedef struct { 38 struct spi_s spi; /**< Target specific spistructure */42 struct spi_s spi; /**< Target specific SPI structure */ 39 43 struct buffer_s tx_buff; /**< Tx buffer */ 40 44 struct buffer_s rx_buff; /**< Rx buffer */ … … 42 46 43 47 #else 44 /** Non-asynch spi halstructure48 /** Non-asynch SPI HAL structure 45 49 */ 46 50 typedef struct spi_s spi_t; … … 53 57 54 58 /** 55 * \defgroup GeneralSPI SPI Configuration Functions59 * \defgroup hal_GeneralSPI SPI Configuration Functions 56 60 * @{ 57 61 */ … … 82 86 /** Configure the SPI format 83 87 * 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. 85 90 * @param[in,out] obj The SPI object to configure 86 91 * @param[in] bits The number of bits per frame … … 113 118 int spi_master_write(spi_t *obj, int value); 114 119 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 */ 136 int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, char write_fill); 137 115 138 /** Check if a value is available to read 116 139 * … … 160 183 /** Begin the SPI transfer. Buffer pointers and lengths are specified in tx_buff and rx_buff 161 184 * 162 * @param[in] obj The SPI object whichholds the transfer information163 * @param[in] tx The buffer to send164 * @param[in] tx_length The number of words to transmit165 * @param[in] rx The buffer to receive166 * @param[in] rx_length The number of words to receive185 * @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 167 190 * @param[in] bit_width The bit width of buffer words 168 191 * @param[in] event The logical OR of events to be registered … … 176 199 * Reads the received values out of the RX FIFO, writes values into the TX FIFO and checks for transfer termination 177 200 * conditions, such as buffer overflows or transfer complete. 178 * @param[in] obj The SPI object whichholds the transfer information179 * @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. 180 203 */ 181 204 uint32_t spi_irq_handler_asynch(spi_t *obj); 182 205 183 /** Attempts to determine if the SPI peripheral is already in use .206 /** Attempts to determine if the SPI peripheral is already in use 184 207 * 185 208 * If a temporary DMA channel has been allocated, peripheral is in use. … … 190 213 * there are any bytes in the FIFOs. 191 214 * @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. 193 216 */ 194 217 uint8_t spi_active(spi_t *obj); … … 212 235 213 236 #endif // MBED_SPI_API_H 237 238 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/ticker_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2015 ARM Limited … … 17 20 #define MBED_TICKER_API_H 18 21 22 #include <stdint.h> 23 #include <stdbool.h> 19 24 #include "device.h" 20 25 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 */ 21 32 typedef uint32_t timestamp_t; 22 33 34 /** 35 * A us timestamp stored in a 64 bit integer. 36 * Can store timestamp up to 584810 years. 37 */ 38 typedef uint64_t us_timestamp_t; 39 23 40 /** Ticker's event structure 24 41 */ 25 42 typedef struct ticker_event_s { 26 timestamp_ttimestamp; /**< Event's timestamp */43 us_timestamp_t timestamp; /**< Event's timestamp */ 27 44 uint32_t id; /**< TimerEvent object */ 28 45 struct ticker_event_s *next; /**< Next event in the queue */ … … 30 47 31 48 typedef void (*ticker_event_handler)(uint32_t id); 49 50 /** Information about the ticker implementation 51 */ 52 typedef 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 32 57 33 58 /** Ticker's interface structure - required API for a ticker … … 39 64 void (*clear_interrupt)(void); /**< Clear interrupt function */ 40 65 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 */ 41 69 } ticker_interface_t; 42 70 43 /** Ticker s eventsqueue structure71 /** Ticker's event queue structure 44 72 */ 45 73 typedef struct { 46 74 ticker_event_handler event_handler; /**< Event handler */ 47 75 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 */ 48 87 } ticker_event_queue_t; 49 88 50 /** Ticker s data structure89 /** Ticker's data structure 51 90 */ 52 91 typedef struct { 53 92 const ticker_interface_t *interface; /**< Ticker's interface */ 54 ticker_event_queue_t *queue; /**< Ticker's event squeue */93 ticker_event_queue_t *queue; /**< Ticker's event queue */ 55 94 } ticker_data_t; 56 95 … … 59 98 #endif 60 99 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. 64 108 * @param handler A handler to be set 65 109 */ 66 void ticker_set_handler(const ticker_data_t *const data, ticker_event_handler handler);67 68 /** I rq handler which goes through the events to trigger events in the past.69 * 70 * @param data The ticker's data71 */ 72 void ticker_irq_handler(const ticker_data_t *const data);110 void 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 */ 116 void ticker_irq_handler(const ticker_data_t *const ticker); 73 117 74 118 /** Remove an event from the queue 75 119 * 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 */ 123 void 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 85 140 * @param timestamp The event's timestamp 86 141 * @param id The event object 87 142 */ 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 143 void 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 */ 158 void 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. 93 166 * @return The current timestamp 94 167 */ 95 timestamp_t ticker_read(const ticker_data_t *const data); 168 timestamp_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 */ 178 us_timestamp_t ticker_read_us(const ticker_data_t *const ticker); 96 179 97 180 /** Read the next event's timestamp 98 181 * 99 * @param data The ticker's data 182 * @param ticker The ticker object. 183 * @param timestamp The timestamp object. 100 184 * @return 1 if timestamp is pending event, 0 if there's no event pending 101 185 */ 102 int ticker_get_next_timestamp(const ticker_data_t *const data, timestamp_t *timestamp); 186 int 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 */ 198 void 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 */ 207 void ticker_resume(const ticker_data_t *const ticker); 208 209 /* Private functions 210 * 211 * @cond PRIVATE 212 * 213 */ 214 215 int _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 /**@}*/ 103 223 104 224 #ifdef __cplusplus … … 107 227 108 228 #endif 229 230 /** @}*/ -
EcnlProtoTool/trunk/asp3_dcre/mbed/hal/us_ticker_api.h
r321 r429 1 2 /** \addtogroup hal */ 3 /** @{*/ 1 4 /* mbed Microcontroller Library 2 5 * Copyright (c) 2006-2015 ARM Limited … … 18 21 19 22 #include <stdint.h> 20 #include " ticker_api.h"23 #include "hal/ticker_api.h" 21 24 22 25 #ifdef __cplusplus … … 25 28 26 29 /** 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 * 28 43 * @{ 29 44 */ 30 45 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 106 typedef 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 */ 118 ticker_irq_handler_type set_us_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler); 119 31 120 /** Get ticker's data 32 121 * 33 * @return The low powerticker data34 */ 35 const ticker_data_t *get_us_ticker_data(void);122 * @return The microsecond ticker data 123 */ 124 const ticker_data_t *get_us_ticker_data(void); 36 125 37 126 … … 45 134 /** Initialize the ticker 46 135 * 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 47 162 */ 48 163 void us_ticker_init(void); 49 164 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 */ 193 void us_ticker_free(void); 194 50 195 /** Read the current counter 51 196 * 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 53 211 */ 54 212 uint32_t us_ticker_read(void); … … 56 214 /** Set interrupt for specified timestamp 57 215 * 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 59 234 */ 60 235 void us_ticker_set_interrupt(timestamp_t timestamp); … … 62 237 /** Disable us ticker interrupt 63 238 * 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 64 247 */ 65 248 void us_ticker_disable_interrupt(void); … … 67 250 /** Clear us ticker interrupt 68 251 * 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 69 260 */ 70 261 void 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 */ 275 void 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 */ 291 const ticker_info_t *us_ticker_get_info(void); 71 292 72 293 /**@}*/ … … 77 298 78 299 #endif 300 301 /** @}*/
Note:
See TracChangeset
for help on using the changeset viewer.