-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fwxv 211 write uv cutoff smoke tests #196
Changes from 31 commits
f08c10e
846d7f0
0031dbf
f0b7bb8
c385f7a
e598d03
be4182d
d2f7f36
fa25204
645f09d
885badb
1201d86
b82110e
55146db
a0a2834
9f41013
89e883e
11ef0b1
806b845
a212c6d
1a4b898
24d2328
c744062
5908678
fff6c95
182048a
d3f4b0d
73f80d0
53a5264
25d1e67
125c69f
1722a49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ typedef enum UVCutoffState { | |
UV_CUTOFF_ACTIVE = 0, | ||
UV_CUTOFF_DISCONNECTED, | ||
} UVCutoffState; | ||
|
||
void uv_ligc() {} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"libs": [ | ||
"FreeRTOS", | ||
"ms-common" | ||
], | ||
"include": [ | ||
"#/projects/uv_cutoff/inc" | ||
], | ||
"can": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
#include <stdio.h> | ||
|
||
#include "can.h" | ||
#include "assert.h" | ||
#include "gpio.h" | ||
#include "can_board_ids.h" | ||
#include "delay.h" | ||
#include "interrupt.h" | ||
#include "log.h" | ||
#include "misc.h" | ||
#include "soft_timer.h" | ||
#include "tasks.h" | ||
#include "uv_cutoff.h" | ||
#include "uv_cutoff_getters.h" | ||
#include "uv_cutoff_setters.h" | ||
|
||
// TODO(devAdhiraj): update with actual ports and pins | ||
#define UV_CUTOFF_PORT GPIO_PORT_A | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should look at the UV cutoff schematic to find out these pins. If you can't, then just put random ones for now to get your test passing though. |
||
#define UV_CUTOFF_PIN 4 | ||
|
||
#define HORN_PORT GPIO_PORT_B | ||
#define HORN_PIN 14 | ||
|
||
#define LIGHTS_PORT GPIO_PORT_B | ||
#define LIGHTS_PIN 13 | ||
|
||
static const GpioAddress uv_status = { .port = UV_CUTOFF_PORT, .pin = UV_CUTOFF_PIN }; | ||
|
||
static const GpioAddress horn = { .port = HORN_PORT, .pin = HORN_PIN }; | ||
|
||
static const GpioAddress lights = { .port = LIGHTS_PORT, .pin = LIGHTS_PIN }; | ||
|
||
StatusCode status; | ||
GpioState state_val; | ||
int lights_check = 0; | ||
|
||
static UVCutoffState state = UV_CUTOFF_ACTIVE; | ||
|
||
void uv_smoke_logic() { | ||
GpioState uv_value; | ||
|
||
if (gpio_get_state(&uv_status, &uv_value) != STATUS_CODE_OK) { | ||
LOG_CRITICAL("Error reading UV_cutoff pin!\n"); | ||
return; | ||
} | ||
if (uv_value == GPIO_STATE_LOW) { | ||
state = UV_CUTOFF_DISCONNECTED; | ||
} else { | ||
state = UV_CUTOFF_ACTIVE; | ||
} | ||
|
||
set_uv_cutoff_notification_signal1(state); | ||
|
||
if (state == UV_CUTOFF_DISCONNECTED) { | ||
return; | ||
} | ||
|
||
if (get_horn_and_lights_horn_state()) { | ||
status = gpio_set_state(&horn, GPIO_STATE_LOW); | ||
if (status == STATUS_CODE_OK) { | ||
gpio_get_state(&horn, &state_val); | ||
} | ||
} else { | ||
status = gpio_set_state(&horn, GPIO_STATE_HIGH); | ||
if (status == STATUS_CODE_OK) { | ||
gpio_get_state(&horn, &state_val); | ||
} | ||
|
||
} | ||
|
||
if(lights_check) { | ||
if (get_horn_and_lights_lights_state()) { | ||
status = gpio_set_state(&lights, GPIO_STATE_LOW); | ||
if (status == STATUS_CODE_OK) { | ||
gpio_get_state(&lights, &state_val); | ||
} | ||
|
||
} else { | ||
status = gpio_set_state(&lights, GPIO_STATE_HIGH); | ||
if (status == STATUS_CODE_OK) { | ||
gpio_get_state(&lights, &state_val); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
TASK(smoke_task, TASK_MIN_STACK_SIZE) { | ||
// | ||
//TEST 1 - Disconnected UV status | ||
LOG_DEBUG("Running test for UV Disconnected state\n"); | ||
gpio_set_state(&uv_status,GPIO_STATE_LOW); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also if you could add a LOG_DEBUG before every test just so we know which test is being run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haven't pushed it yet. |
||
uv_smoke_logic(); | ||
assert( g_tx_struct.uv_cutoff_notification_signal1 == UV_CUTOFF_DISCONNECTED ); | ||
LOG_DEBUG("uv_cutoff notification signal set to 'UV_CUTOFF_DISCONNECTED'\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also can you add a 1s delay after ever test? Makes it easier to see in hw There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, made this change. Yet to push it. |
||
delay_ms(1000); | ||
//TEST 2 - Active UV status | ||
LOG_DEBUG("Running test for UV Active state\n"); | ||
gpio_set_state(&uv_status,GPIO_STATE_HIGH); | ||
uv_smoke_logic(); | ||
assert( g_tx_struct.uv_cutoff_notification_signal1 == UV_CUTOFF_ACTIVE ); | ||
LOG_DEBUG("uv_cutoff notification signal set to 'UV_CUTOFF_ACTIVE'\n"); | ||
delay_ms(1000); | ||
//TEST 3 - Horn state HIGH | ||
LOG_DEBUG("Running test for Horn in state HIGH\n"); | ||
gpio_set_state(&uv_status,GPIO_STATE_HIGH); | ||
gpio_set_state(&horn,GPIO_STATE_HIGH); | ||
g_rx_struct.horn_and_lights_horn_state = GPIO_STATE_HIGH; | ||
lights_check = 0; | ||
uv_smoke_logic(); | ||
assert(status == STATUS_CODE_OK); | ||
assert(state_val == GPIO_STATE_LOW); | ||
LOG_DEBUG("horn state set to LOW\n"); | ||
delay_ms(1000); | ||
//TEST 4 - Lights state HIGH | ||
LOG_DEBUG("Running test for Lights in state HIGH\n"); | ||
gpio_set_state(&uv_status,GPIO_STATE_HIGH); | ||
gpio_set_state(&lights,GPIO_STATE_HIGH); | ||
g_rx_struct.horn_and_lights_lights_state = GPIO_STATE_HIGH; | ||
lights_check = 1; | ||
uv_smoke_logic(); | ||
assert(status == STATUS_CODE_OK); | ||
assert(state_val == GPIO_STATE_LOW); | ||
LOG_DEBUG("lights state set to LOW\n"); | ||
delay_ms(1000); | ||
//TEST 5 - Horn state LOW | ||
LOG_DEBUG("Running test for Horn in state LOW\n"); | ||
gpio_set_state(&uv_status,GPIO_STATE_HIGH); | ||
gpio_set_state(&horn,GPIO_STATE_LOW); | ||
g_rx_struct.horn_and_lights_horn_state = GPIO_STATE_LOW; | ||
lights_check = 0; | ||
uv_smoke_logic(); | ||
assert(status == STATUS_CODE_OK); | ||
assert(state_val == GPIO_STATE_HIGH); | ||
LOG_DEBUG("horn state set to HIGH\n"); | ||
delay_ms(1000); | ||
//TEST 6 - Lights state LOW | ||
LOG_DEBUG("Running test for Lights in state LOW\n"); | ||
gpio_set_state(&uv_status,GPIO_STATE_HIGH); | ||
gpio_set_state(&lights,GPIO_STATE_LOW); | ||
g_rx_struct.horn_and_lights_lights_state = GPIO_STATE_LOW; | ||
lights_check = 1; | ||
uv_smoke_logic(); | ||
assert(status == STATUS_CODE_OK); | ||
assert(state_val == GPIO_STATE_HIGH); | ||
LOG_DEBUG("lights state set to HIGH\n"); | ||
delay_ms(1000); | ||
LOG_DEBUG("All tasks completed!\n"); | ||
} | ||
|
||
int main() { | ||
tasks_init(); | ||
log_init(); | ||
|
||
gpio_init(); | ||
|
||
//IT SHOULD BE GPIO_INPUT_PULL_UP BUT CHANGED FOR TESTING PURPOSES ONLY | ||
gpio_init_pin(&uv_status, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_HIGH); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Write a comment here saying that is should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed :) |
||
gpio_init_pin(&horn, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); | ||
gpio_init_pin(&lights, GPIO_OUTPUT_PUSH_PULL, GPIO_STATE_LOW); | ||
|
||
tasks_init_task(smoke_task, TASK_PRIORITY(1), NULL); | ||
|
||
tasks_start(); | ||
|
||
LOG_DEBUG("UV cutoff task!\n"); | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed a backspace after uv_ligc to resolve an error which scons lint threw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry what was the error? I don't think
uv_ligc
is used anywhereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed uv_ligc () {} -> uv_ligc() {}.
scons lint said to remove an extra space after uv_ligc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an entirely new line. It shouldn't be here if you're not using it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should just delete this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had forgot to make this change, it'll be their in the new PR.