Skip to content

Commit

Permalink
Merge pull request #360 from kaluma-project/develop/rpi-pico-update
Browse files Browse the repository at this point in the history
Develop/rpi pico update
  • Loading branch information
communix authored Mar 17, 2021
2 parents 979a01c + 8d856c2 commit a4e56ea
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ struct km_io_loop_s {

/* loop functions */

void io_init();
void io_run();
void km_io_init();
void km_io_run();

/* general handle functions */

Expand Down
4 changes: 2 additions & 2 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void km_io_handle_closing() {

/* loop functions */

void io_init() {
void km_io_init() {
loop.stop_flag = false;
km_list_init(&loop.tty_handles);
km_list_init(&loop.timer_handles);
Expand All @@ -112,7 +112,7 @@ void io_init() {
km_list_init(&loop.closing_handles);
}

void io_run() {
void km_io_run() {
while (loop.stop_flag == false) {
io_update_time();
km_io_timer_run();
Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ int main(void) {
km_system_init();
load = km_running_script_check();
km_tty_init();
io_init();
km_io_init();
km_repl_init();
km_runtime_init(load, true);
io_run();
km_io_run();
}
1 change: 1 addition & 0 deletions targets/rpi-pico/include/rpi_pico.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
#define ADC_RESOLUTION_BIT 12
#define PWM_CLK_REF 1250
#define I2C_MAX_CLOCK 1000000
#define SCR_LOAD_GPIO 22 // GPIO 22
#endif /* __RPI_PICO_H */
5 changes: 4 additions & 1 deletion targets/rpi-pico/src/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ static int __check_gpio(uint8_t pin)
}

void km_gpio_init() {
gpio_init_mask(0xFFFFFFFF); // init all the GPIOs
for(uint i = 0; i < 30; i++) {
gpio_init(i);
gpio_set_pulls(i, false, false);
}
}

void km_gpio_cleanup() {
Expand Down
8 changes: 7 additions & 1 deletion targets/rpi-pico/src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "spi.h"
#include "uart.h"
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "rpi_pico.h"

const char km_system_arch[] = "cortex-m0-plus";
const char km_system_platform[] = "unknown";
Expand Down Expand Up @@ -86,5 +88,9 @@ void km_system_cleanup() {
}

uint8_t km_running_script_check() {
return true;
gpio_set_pulls(SCR_LOAD_GPIO, true, false);
sleep_us(100);
bool load_state = gpio_get(SCR_LOAD_GPIO);
gpio_set_pulls(SCR_LOAD_GPIO, false, false);
return load_state;
}

0 comments on commit a4e56ea

Please sign in to comment.