Add API for the merge sensor.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "reset_button.h"
|
||||
#include "i2c.h"
|
||||
#include "led_driver.h"
|
||||
#include "merge_sensor.h"
|
||||
|
||||
void InitI2c() {
|
||||
port_pin_config_t pinConfig = {
|
||||
@@ -45,6 +46,7 @@ void InitI2c() {
|
||||
void InitPeripherials(void)
|
||||
{
|
||||
InitResetButton();
|
||||
InitMergeSensor();
|
||||
InitTestLed();
|
||||
InitI2c();
|
||||
}
|
||||
|
||||
8
right/src/merge_sensor.c
Normal file
8
right/src/merge_sensor.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "merge_sensor.h"
|
||||
#include "fsl_port.h"
|
||||
|
||||
void InitMergeSensor() {
|
||||
CLOCK_EnableClock(MERGE_SENSOR_CLOCK);
|
||||
PORT_SetPinConfig(MERGE_SENSOR_PORT, MERGE_SENSOR_PIN,
|
||||
&(port_pin_config_t){.pullSelect=kPORT_PullUp, .mux=kPORT_MuxAsGpio});
|
||||
}
|
||||
23
right/src/merge_sensor.h
Normal file
23
right/src/merge_sensor.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef __MERGE_SENSOR_H__
|
||||
#define __MERGE_SENSOR_H__
|
||||
|
||||
// Includes:
|
||||
|
||||
#include "fsl_gpio.h"
|
||||
|
||||
// Macros:
|
||||
|
||||
#define MERGE_SENSOR_GPIO GPIOB
|
||||
#define MERGE_SENSOR_PORT PORTB
|
||||
#define MERGE_SENSOR_CLOCK kCLOCK_PortB
|
||||
#define MERGE_SENSOR_PIN 2
|
||||
#define MERGE_SENSOR_IRQ PORTB_IRQn
|
||||
#define MERGE_SENSOR_IRQ_HANDLER PORTB_IRQHandler
|
||||
|
||||
#define MERGE_SENSOR_IS_MERGED !GPIO_ReadPinInput(MERGE_SENSOR_GPIO, MERGE_SENSOR_PIN)
|
||||
|
||||
// Functions:
|
||||
|
||||
extern void InitMergeSensor();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user