IRPyro API  (sKEMLIB1)
Collection of routines and data structures covering the functionality of the IRPyro sensor
Micro_controller_template.c File Reference

Micro controller specific code to access the IRPyro sensor. More...

Include dependency graph for Micro_controller_template.c:

Go to the source code of this file.

Data Structures

struct  I2C_Config
 IRPyro Analog Front End (AFE) register structure definition. More...
 

Macros

#define CLOCK_CYCLES_PER_INSTRUCTION   1
 
#define CLOCK_FREQ   72
 
#define I2C_CLK_TIMING_DEFAULT   0x00A00D26
 
#define I2C_PORT   GPIOB
 
#define I2C_SCL_PIN   GPIO_Pin_7
 
#define I2C_SCL_SRC   GPIO_PinSource7
 
#define I2C_SDA_PIN   GPIO_Pin_6
 
#define I2C_SDA_SRC   GPIO_PinSource6
 
#define I2C_TIMEOUT_DEFAULT   50
 
#define LED_READY_OFF   GPIO_SetBits(GPIOA,GPIO_Pin_0) ;
 
#define LED_READY_ON   GPIO_ResetBits(GPIOA,GPIO_Pin_0) ;
 
#define LED_RUN_OFF   GPIO_SetBits(GPIOA,GPIO_Pin_1);
 
#define LED_RUN_ON   GPIO_ResetBits(GPIOA,GPIO_Pin_1);
 
#define PACKET_SIZE   19
 
#define SATURATION_FLAG(CH, POS)   ((CH & SATURATION_MASK) >> (7 - POS))
 
#define SATURATION_MASK   0x80
 

Typedefs

typedef struct I2C_Config I2C_Config_Type
 

Enumerations

enum  Status { Error = 0, Success = !Error }
 

Functions

void CS_pin_set (uint8_t port, uint8_t pin, uint8_t value)
 ON/OFF control from the MCU to the IRPyro sensor. More...
 
static void Emitter_configure_as_input (void)
 Configuration when the EXTERNAL emitter is selected. More...
 
static void Emitter_configure_as_output (void)
 Configuration when the INTERNAL emitter is selected. More...
 
void Emitter_control (uint8_t *EmitterStatus, uint8_t EmitterONTime, uint8_t EmitterOFFTime)
 Changes Emitter status and applies timing parameters. More...
 
static void Emitter_status_and_timer_set (uint8_t *EmitterStatus, uint8_t EmitterONTime)
 
static void Emitter_status_and_timer_update (uint8_t *EmitterStatus, uint8_t EmitterONTime, uint8_t EmitterOFFTime)
 
static uint8_t Emitter_status_evaluate (uint8_t EmitterStatus)
 
static void Emitter_toggle (uint8_t *EmitterStatus, uint8_t EmitterONTime, uint8_t EmitterOFFTime)
 
static void EXTernal_Callback_Disable (void)
 Ends function callbacks. More...
 
static void EXTernal_Callback_Enable (EXTernal_callback Callback)
 Starts function callbacks. More...
 
void EXTernal_Callback_Setup (EXTernal_callback Callback)
 Configures function callbacks. More...
 
static void EXTI4_Config (void)
 Configure Sensor 1 INT line in interrupt mode. More...
 
void EXTI4_IRQHandler (void)
 This function handles external line 4 interrupt request. More...
 
static void EXTI9_5_Config (void)
 Configure Sensor 2,3, and 4 INT line in interrupt mode. More...
 
void EXTI9_5_IRQHandler (void)
 This function handles external lines 5 to 9 interrupt request. More...
 
uint8_t EXTI_detected (uint8_t exti_line)
 This function access the status of the interrupt lines for the wake up event. More...
 
static void GPIO_structure_init (uint32_t GPIO_Pin_x, GPIOMode_TypeDef GPIO_Mode, GPIOOType_TypeDef Output_Type, GPIOSpeed_TypeDef Speed, GPIOPuPd_TypeDef PuPd, GPIO_TypeDef *GPIOx)
 Populates and initializes GPIO structures. More...
 
static void i2c_Init (I2C_Config_Type *External_Config)
 Initializes the I2C Hardware (I2C1). More...
 
uint8_t i2c_Read (uint8_t DeviceAddr, uint8_t Command, uint8_t *pBuffer, uint16_t len)
 Reads data via I2C port. More...
 
uint8_t i2c_Write (uint8_t DeviceAddr, uint8_t Command, uint8_t *pBuffer, uint8_t len)
 Sends data via I2C port. More...
 
uint8_t INT_pin_read (uint8_t port, uint8_t pin)
 Reads the status of the pin assigned to the INT line of IRPyro. More...
 
void LED_READY (uint8_t LED_ready)
 Control for the READY led state. More...
 
static void LED_RUN (uint8_t LED_run)
 Controls RUN led state. More...
 
uint32_t Micro_controller_delay_get (void)
 Retrieves the tick counter. More...
 
void Micro_controller_delay_ms (uint32_t time_ms)
 Example of delay function. More...
 
void Micro_controller_delay_set (uint32_t delay)
 Sets the tick counter. More...
 
void Micro_controller_delay_us (uint32_t time_us)
 Example of delay function in micro seconds. Refer to section "12.8 Device Power Up and Reset" in the Reference Manual. More...
 
static void Micro_controller_External_interrupt_init (void)
 Initializes the USART 2 on the STM32F303K8 PORT A and pins 2,15 are used. Refer to STM document RM0316 section 29 and the stm32f30x_usart.c. More...
 
static void Micro_controller_GPIO_init (void)
 Example of board initialization to set up all the ports and peripherals. (Read_Me.txt) More...
 
static void Micro_controller_I2C_init (void)
 Calls I2C initialization. See Read_Me.txt. More...
 
static void Micro_controller_LED_configure (void)
 configures and enables status LED's on the backplane boards More...
 
uint32_t Micro_controller_sample_period_timer_get (void)
 
void Micro_controller_sample_period_timer_set (uint32_t count_value)
 
static void Micro_controller_Systick_init (uint16_t frequency)
 Example of board timer initialization to set a delay. More...
 
void Micro_controller_template_init (void)
 Groups all required initialization in one function. More...
 
static void Micro_controller_TIM_init (void)
 Configuration for hardware timer for emitter control. More...
 
uint32_t Micro_controller_timeout_get (void)
 Recovers the tick_down value to check is not expired. More...
 
void Micro_controller_timeout_set (uint32_t timeout)
 Sets the tick_down to monitor a time out. More...
 
static void Micro_controller_UART_init (void)
 Initializes the USART 2 on the STM32F303K8 PORT A and pins 2,15 are used. Refer to STM document RM0316 section 29 and the stm32f30x_usart.c. More...
 
void power_set (uint8_t port, uint8_t pin)
 Power sequence from the MCU to the IRPyro sensor. More...
 
void SysTick_Handler (void)
 Updates the both tick counters on a Systick interrupt every millisecond. More...
 
static uint32_t SysTick_millis (void)
 return the system clock as milliseconds More...
 
void TIM3_IRQHandler (void)
 Interrupt timer for running LED on backplane boards. More...
 
static void TIM_Callback_Disable (void)
 Ends function callbacks. More...
 
static void TIM_Callback_Enable (EXTernal_callback Callback)
 Starts function callbacks. More...
 
void TIM_Callback_Setup (TIM_callback Callback)
 Configures function callbacks. More...
 
uint8_t UART_byte_get ()
 Interface to acces uart_byte. More...
 
static void UART_display_write (char const *format,...)
 Formats output and sends to USART as a string. More...
 
void UART_PutChar (USART_TypeDef *USARTx, uint8_t ch)
 Puts a char in the USART. More...
 
void UART_PutNumber (USART_TypeDef *USARTx, uint32_t number)
 Puts a number in the USART. More...
 
void UART_PutString (USART_TypeDef *USARTx, uint8_t *str)
 Puts a string in the USART. More...
 
void UART_stream_binary_send (uint8_t *DataS)
 Builds a binary data packet for the channels of the sensor, frame counter and saturation byte. More...
 
void UART_stream_char_send (uint32_t *channel_value, uint8_t channel_saturation)
 Plain text data for the active channels of the sensor including, frame counter and saturation byte. More...
 
void USART2_IRQHandler ()
 Handles incomming char from the USART and stores it in global uart_byte. More...
 
static void USART_Callback_Rx_Disable (void)
 Ends function callbacks. More...
 
static void USART_Callback_Rx_Enable (USART_callback Callback)
 
void USART_Callback_Rx_Setup (USART_callback Callback)
 Configures function callbacks. More...
 
static void USART_Callback_Tx_Disable (void)
 Ends function callbacks. More...
 
static void USART_Callback_Tx_Enable (USART_callback Callback)
 Starts function callbacks. More...
 
void USART_Callback_Tx_Setup (USART_callback Callback)
 Configures function callbacks. More...
 

Variables

static I2C_Config_Type Config = {0}
 Configuration Structure for the I2C Module. More...
 
static uint8_t Config_Valid_Flag =0
 Configuration valid flag indicating module has been configured. More...
 
static volatile uint16_t EmitterTimer
 
static EXTernal_callback EXTI_Callback_Fn = NULL
 
volatile uint8_t EXTI_line_record [4] = {0}
 
volatile uint8_t led_ready_value = 0
 
volatile uint8_t led_run_value = 0
 
volatile uint32_t sample_period_timer = 0
 
static volatile uint32_t ticks
 
static volatile uint32_t ticks_down
 
volatile uint16_t tim3_counter = 0
 
static TIM_callback TIM_Callback_Fn = NULL
 
volatile uint8_t uart_byte
 
static USART_callback USARTCallback_Rx_Fn = NULL
 
static USART_callback USARTCallback_Tx_Fn = NULL
 

Detailed Description

Micro controller specific code to access the IRPyro sensor.

Author
_KEMET, Ltd
Date
March 2018
Version
Release 1.0.6
Attention

© COPYRIGHT 2018 _KEMET, Ltd

    Copyright (c) 2018, _KEMET, Ltd
    All rights reserved.
    THIS SOFTWARE IS PROVIDED BY _KEMET, Ltd ''AS IS'' AND ANY
    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL _KEMET, Ltd BE LIABLE FOR ANY
    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file Micro_controller_template.c.

Macro Definition Documentation

◆ CLOCK_CYCLES_PER_INSTRUCTION

#define CLOCK_CYCLES_PER_INSTRUCTION   1

◆ CLOCK_FREQ

#define CLOCK_FREQ   72

◆ LED_READY_OFF

#define LED_READY_OFF   GPIO_SetBits(GPIOA,GPIO_Pin_0) ;

◆ LED_READY_ON

#define LED_READY_ON   GPIO_ResetBits(GPIOA,GPIO_Pin_0) ;

◆ LED_RUN_OFF

#define LED_RUN_OFF   GPIO_SetBits(GPIOA,GPIO_Pin_1);

◆ LED_RUN_ON

#define LED_RUN_ON   GPIO_ResetBits(GPIOA,GPIO_Pin_1);

◆ PACKET_SIZE

#define PACKET_SIZE   19

◆ SATURATION_FLAG

#define SATURATION_FLAG (   CH,
  POS 
)    ((CH & SATURATION_MASK) >> (7 - POS))

◆ SATURATION_MASK

#define SATURATION_MASK   0x80