INF2004-Project v0.1
 
Loading...
Searching...
No Matches
ir_sensor.c File Reference

Driver code for the IR sensor driver. More...

#include <stdint.h>
#include <sys/types.h>
#include "hardware/gpio.h"
#include "hardware/adc.h"
#include "irline/ir_sensor.h"
#include "irline/barcode.h"
Include dependency graph for ir_sensor.c:

Functions

uint16_t ir_find_wall_directions (uint gpio_pin_left, uint gpio_pin_right)
 This returns the information of the walls in the node. More...
 
barcode_line_type_t ir_read_barcode (void)
 This function reads the barcode and determines the colour and the thickness. More...
 
uint16_t ir_read_line (uint gpio_pin_in)
 Detects line. More...
 
void ir_setup_adc_pin (uint adc_pin)
 Initalises the analog pins for the IR sensor to ADC. More...
 
void ir_setup_gpio_pin (uint gpio_pin)
 Initialises the digital pin for the IR sensor. More...
 
void ir_update_left_flag (ir_flags_t *p_flag)
 Indicates whether there is a left wall. More...
 
void ir_update_top_flag (ir_flags_t *p_flag)
 Indicates whether there is a top wall. More...
 

Detailed Description

Driver code for the IR sensor driver.

Author
Ang Jia Yu
Version
0.1
Date
2023-10-29

Function Documentation

◆ ir_find_wall_directions()

uint16_t ir_find_wall_directions ( uint  gpio_pin_left,
uint  gpio_pin_right 
)

This returns the information of the walls in the node.

Parameters
[in]gpio_pin_leftGPIO pin for the left sensor
[in]gpio_pin_rightGPIO pin for the front sensor
Returns
uint16_t Returns wall directions as a bitfield.
See also
maze_wall_direction_t

References ir_read_line().

Here is the call graph for this function:

◆ ir_read_barcode()

barcode_line_type_t ir_read_barcode ( void  )

This function reads the barcode and determines the colour and the thickness.

Returns
barcode_line_type_t Returns the barcode line type.
See also
barcode_line_type

References BARCODE_LINE_BLACK_THICK, BARCODE_LINE_BLACK_THIN, BARCODE_LINE_NONE, BARCODE_LINE_WHITE_THICK, and BARCODE_LINE_WHITE_THIN.

◆ ir_read_line()

uint16_t ir_read_line ( uint  gpio_pin_in)

Detects line.

Parameters
[in]gpio_pin_inGPIO pin for the IR sensor
Returns
uint16_t Returns 1 if line is detected, 0 otherwise
Here is the caller graph for this function:

◆ ir_setup_adc_pin()

void ir_setup_adc_pin ( uint  adc_pin)

Initalises the analog pins for the IR sensor to ADC.

Parameters
[in]adc_pinADC pin for the IR sensor.

◆ ir_setup_gpio_pin()

void ir_setup_gpio_pin ( uint  gpio_pin)

Initialises the digital pin for the IR sensor.

Parameters
[in]gpio_pinGPIO pin for the IR sensor

◆ ir_update_left_flag()

void ir_update_left_flag ( ir_flags_t p_flag)

Indicates whether there is a left wall.

Parameters
[out]p_flagPointer to the indicator for the walls.

References ir_flags::left_wall.

◆ ir_update_top_flag()

void ir_update_top_flag ( ir_flags_t p_flag)

Indicates whether there is a top wall.

Parameters
[out]p_flagPointer to the indicator for the walls.

References ir_flags::top_wall.