Skip to content

Commit

Permalink
drv/ioport_lpf2: move out of autostart processes
Browse files Browse the repository at this point in the history
This continues the work of getting rid of the autostart processes by
changing the LPF2 I/O port driver to use an init function like most
other drivers.
  • Loading branch information
dlech committed Jun 29, 2021
1 parent 7fe0e06 commit 434d599
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 12 deletions.
4 changes: 3 additions & 1 deletion lib/pbio/drv/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "battery/battery.h"
#include "bluetooth/bluetooth.h"
#include "counter/counter.h"
#include "ioport/ioport.h"
#include "led/led_array.h"
#include "led/led.h"
#include "pwm/pwm.h"
Expand All @@ -24,8 +25,9 @@ void pbdrv_init(void) {
pbdrv_battery_init();
pbdrv_bluetooth_init();
pbdrv_counter_init();
pbdrv_led_init();
pbdrv_ioport_init();
pbdrv_led_array_init();
pbdrv_led_init();
pbdrv_pwm_init();
pbdrv_reset_init();
pbdrv_sound_init();
Expand Down
26 changes: 26 additions & 0 deletions lib/pbio/drv/ioport/ioport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 The Pybricks Authors

#ifndef _INTERNAL_PBDRV_IOPORT_H_
#define _INTERNAL_PBDRV_IOPORT_H_

#include <pbdrv/config.h>

#if PBDRV_CONFIG_IOPORT

#include "ioport_lpf2.h"

/**
* Initializes the ioport driver.
*/
static inline void pbdrv_ioport_init(void) {
pbdrv_ioport_lpf2_init();
}

#else // PBDRV_CONFIG_IOPORT

#define pbdrv_ioport_init()

#endif // PBDRV_CONFIG_IOPORT

#endif // _INTERNAL_PBDRV_IOPORT_H_
4 changes: 4 additions & 0 deletions lib/pbio/drv/ioport/ioport_lpf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ PROCESS(pbdrv_ioport_lpf2_process, "I/O port");

static ioport_dev_t ioport_devs[PBDRV_CONFIG_IOPORT_LPF2_NUM_PORTS];

void pbdrv_ioport_lpf2_init(void) {
process_start(&pbdrv_ioport_lpf2_process, NULL);
}

static void ioport_enable_uart(ioport_dev_t *ioport) {
const pbdrv_ioport_lpf2_port_platform_data_t *pdata = ioport->pdata;

Expand Down
13 changes: 10 additions & 3 deletions lib/pbio/drv/ioport/ioport_lpf2.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2020 The Pybricks Authors
// Copyright (c) 2018-2021 The Pybricks Authors

#ifndef _INTERNAL_PBDRV_IOPORT_LPF2_H_
#define _INTERNAL_PBDRV_IOPORT_LPF2_H_

#include <stdint.h>

#include <pbdrv/config.h>

#if PBDRV_CONFIG_IOPORT_LPF2

#include <stdint.h>
#include <pbdrv/gpio.h>

// GPIOs associated with ID1 and ID2 pins
Expand Down Expand Up @@ -40,4 +42,9 @@ typedef struct {
// This is defined in platform/*/platform.c
extern const pbdrv_ioport_lpf2_platform_data_t pbdrv_ioport_lpf2_platform_data;

void pbdrv_ioport_lpf2_init(void);
#else // PBDRV_CONFIG_IOPORT_LPF2
#define pbdrv_ioport_lpf2_init()
#endif // PBDRV_CONFIG_IOPORT_LPF2

#endif // _INTERNAL_PBDRV_IOPORT_LPF2_H_
3 changes: 0 additions & 3 deletions lib/pbio/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ AUTOSTART_PROCESSES(
#if PBDRV_CONFIG_ADC
&pbdrv_adc_process,
#endif
#if PBDRV_CONFIG_IOPORT_LPF2
&pbdrv_ioport_lpf2_process,
#endif
#if PBDRV_CONFIG_UART
&pbdrv_uart_process,
#endif
Expand Down
5 changes: 0 additions & 5 deletions lib/pbio/src/processes.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
PROCESS_NAME(pbdrv_adc_process);
#endif


#if PBDRV_CONFIG_IOPORT_LPF2
PROCESS_NAME(pbdrv_ioport_lpf2_process);
#endif

#if PBDRV_CONFIG_UART
PROCESS_NAME(pbdrv_uart_process);
#endif
Expand Down

0 comments on commit 434d599

Please sign in to comment.