re structured
This commit is contained in:
parent
376453398a
commit
b80e3bf7a9
|
@ -1,4 +1,29 @@
|
|||
include(FreeRTOS_Kernel_import.cmake)
|
||||
|
||||
add_subdirectory(car)
|
||||
add_subdirectory(wheel)
|
||||
add_subdirectory(line_sensor)
|
||||
|
||||
add_executable(rtos_car rtos_car.c)
|
||||
|
||||
target_compile_definitions(rtos_car PRIVATE
|
||||
WIFI_SSID=\"${WIFI_SSID}\"
|
||||
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
|
||||
NO_SYS=0 # don't want NO_SYS (generally this would be in your lwipopts.h)
|
||||
LWIP_SOCKET=1 # we need the socket API (generally this would be in your lwipopts.h)
|
||||
PING_USE_SOCKETS=1
|
||||
)
|
||||
target_include_directories(rtos_car PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}/wheel
|
||||
${CMAKE_CURRENT_LIST_DIR}/line_sensor
|
||||
)
|
||||
target_link_libraries(rtos_car
|
||||
pico_cyw43_arch_lwip_sys_freertos
|
||||
pico_stdlib
|
||||
pico_lwip_iperf
|
||||
FreeRTOS-Kernel-Heap4 # FreeRTOS kernel and dynamic heap
|
||||
hardware_adc
|
||||
hardware_pwm
|
||||
)
|
||||
pico_enable_stdio_usb(rtos_car 1)
|
||||
pico_add_extra_outputs(rtos_car)
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
add_executable(rtos_car
|
||||
rtos_car.c
|
||||
)
|
||||
target_compile_definitions(rtos_car PRIVATE
|
||||
WIFI_SSID=\"${WIFI_SSID}\"
|
||||
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
|
||||
NO_SYS=0 # don't want NO_SYS (generally this would be in your lwipopts.h)
|
||||
LWIP_SOCKET=1 # we need the socket API (generally this would be in your lwipopts.h)
|
||||
PING_USE_SOCKETS=1
|
||||
)
|
||||
target_include_directories(rtos_car PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
${CMAKE_CURRENT_LIST_DIR}/../.. # for our common lwipopts
|
||||
)
|
||||
target_link_libraries(rtos_car
|
||||
pico_cyw43_arch_lwip_sys_freertos
|
||||
pico_stdlib
|
||||
pico_lwip_iperf
|
||||
FreeRTOS-Kernel-Heap4 # FreeRTOS kernel and dynamic heap
|
||||
hardware_adc
|
||||
hardware_pwm
|
||||
)
|
||||
pico_enable_stdio_usb(rtos_car 1)
|
||||
pico_add_extra_outputs(rtos_car)
|
|
@ -68,9 +68,9 @@ line_sensor_setup() {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the car's initial state
|
||||
* @brief Initialize the wheel's initial state
|
||||
*
|
||||
* @return The initialized car state
|
||||
* @return The initialized wheel state
|
||||
*/
|
||||
car_state_t
|
||||
initialize_car_state() {
|
||||
|
@ -86,9 +86,9 @@ initialize_car_state() {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Update the map based on the car's state
|
||||
* @brief Update the map based on the wheel's state
|
||||
*
|
||||
* @param car_state The current car state
|
||||
* @param car_state The current wheel state
|
||||
*/
|
||||
static inline void
|
||||
update_map(car_state_t car_state) {
|
||||
|
@ -99,14 +99,14 @@ update_map(car_state_t car_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Handle forward movement of the car
|
||||
* @brief Handle forward movement of the wheel
|
||||
*
|
||||
* @param car_state The current car state
|
||||
* @param car_state The current wheel state
|
||||
*/
|
||||
static void
|
||||
handle_forward_movement(car_state_t *car_state) {
|
||||
printf("FORWARD, ");
|
||||
// TODO: Check car's actual forward movement
|
||||
// TODO: Check wheel's actual forward movement
|
||||
switch (car_state->orientation) {
|
||||
case NORTH:
|
||||
printf("NORTH\n");
|
||||
|
@ -128,11 +128,11 @@ handle_forward_movement(car_state_t *car_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Handle a right turn of the car
|
||||
* @brief Handle a right turn of the wheel
|
||||
*
|
||||
* Note: Bitwise AND with 0x03 to ensure that the orientation
|
||||
* is always between 0 and 3
|
||||
* @param car_state The current car state
|
||||
* @param car_state The current wheel state
|
||||
*/
|
||||
static inline void
|
||||
handle_right_turn(car_state_t *car_state) {
|
||||
|
@ -140,9 +140,9 @@ handle_right_turn(car_state_t *car_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Handle a left turn of the car
|
||||
* @brief Handle a left turn of the wheel
|
||||
*
|
||||
* @param car_state The current car state
|
||||
* @param car_state The current wheel state
|
||||
*/
|
||||
static inline void
|
||||
handle_left_turn(car_state_t *car_state) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
|
||||
//
|
||||
// This example uses a common include to avoid repetition
|
||||
#include "../lwipopts_examples_common.h"
|
||||
#include "lwipopts_examples_common.h"
|
||||
|
||||
#if !NO_SYS
|
||||
#define TCPIP_THREAD_STACKSIZE 1024
|
|
@ -18,6 +18,7 @@
|
|||
#include "semphr.h"
|
||||
|
||||
#include "wheel.h"
|
||||
#include "line_sensor.h"
|
||||
|
||||
#define READ_LEFT_WHEEL_SPEED_PRIO (tskIDLE_PRIORITY + 1UL)
|
||||
#define READ_RIGHT_WHEEL_SPEED_PRIO (tskIDLE_PRIORITY + 1UL)
|
||||
|
@ -25,6 +26,9 @@
|
|||
void
|
||||
launch()
|
||||
{
|
||||
|
||||
|
||||
|
||||
// isr to detect right wheel slot
|
||||
gpio_set_irq_enabled(SPEED_PIN_RIGHT, GPIO_IRQ_EDGE_FALL, true);
|
||||
gpio_add_raw_irq_handler(SPEED_PIN_RIGHT,
|
|
@ -0,0 +1 @@
|
|||
|
Loading…
Reference in New Issue