-
Notifications
You must be signed in to change notification settings - Fork 0
/
modules.h
123 lines (103 loc) · 2.25 KB
/
modules.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* modules.h
*
*/
#ifndef MODULES_H
#define MODULES_H
#include "lpc_types.h"
/* Serial.c
*
* Initialises UART3 for MBED to 3pi interface
*/
void serputc(uint8_t tmp);
uint8_t sergetc(void);
void m3pi_init();
/* TIMER0 INITIALISATION
*
* Initialise timer0
*/
void timer0_init();
/* ADC
*
* Initialises adc channel 0 for sensor to MBED interface
*
* NOTE: Sharp GP2Y0A21YK0F has timing 38.3ms ± 9.6ms
*/
void adc_init (uint8_t portNum, uint8_t pinNum, uint8_t funcNum, uint8_t channelNum);
/* digital GPIO
*
* Initialises a GPIO for a digital sensor
*/
void digital_init (uint8_t port, uint8_t pinNum);
/* i2c compass Initialisation
*
* Initialises a I2C for a compass (accelerometer, gyroscope, magnetometer)
*
* Uses external interrupt 3, rising edge
*
* @param GPIO pin number
* @param GPIO pin port
*/
void i2c_init( void );
uint8_t _i2c_write(uint16_t address, char *send, uint8_t length);
uint8_t _i2c_read(uint16_t address, char *receive, uint8_t length);
/* Initialise system tick
*
* @param time interval in milliseconds
* @param counter functional state, ENABLE / DISABLE
* @param interrupt functional state, ENABLE / DISABLE
*/
void systick_init( void );
/* Delay in ms
*/
void delay_ms(uint32_t tick);
/*
* Sleep in seconds
*/
void sleep(uint8_t t);
/* Return milliseconds
*/
uint64_t millis(void);
/* LED GPIO
*
* Initialises a GPIO for a LED
*
* @param GPIO port number
* @param GPIO pin(s) number/map
*/
void led_init(uint8_t port, uint32_t pins);
/* LED on/off
*
* Switches MBED LED on/off
*
* @param LED pin
* @param GPIO pin(s) number/map
* @param boolean 1 - ON ; 0 - OFF
*/
void led(uint8_t port, uint32_t pins, uint8_t state);
/* Read Analogue sensor value
*
* Start ADC conversion, poll and return result
*
* @param ADC channel, 0-7
* @return unsigned int 32 bit resolution
*/
uint32_t read_analog (uint8_t channelNum);
/* Align robot with horizontal line
*
* Called only when one of sensors 0/4 is on a horizontal line
*/
void align (void);
/* Move to next horizontal line
*
*
*
*/
void nextLine (void);
/* Follow Wall PID
*
*
* @param channelA, ADC channel to read first sensor
* @param channelB, ADC channel to read second sensor
*/
void wallFollow(uint8_t channelA, uint8_t channelB);
#endif