Skip to content

Commit 33fc9d4

Browse files
committed
feat(vacuum-module): add vacuum module project
1 parent 55f1614 commit 33fc9d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+5705
-20
lines changed

CMakePresets.json

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@
7676
"configurePreset": "stm32-cross",
7777
"jobs": 8,
7878
"targets": [
79+
"reference-module",
7980
"thermocycler-gen2",
8081
"heater-shaker",
8182
"tempdeck-gen3",
8283
"flex-stacker",
83-
"reference-module"
84+
"vacuum-module"
8485
]
8586
},
8687
{
@@ -90,11 +91,32 @@
9091
"configurePreset": "stm32-host",
9192
"jobs": 8,
9293
"targets": [
94+
"reference-module-build-and-test",
9395
"thermocycler-gen2-build-and-test",
9496
"heater-shaker-build-and-test",
9597
"tempdeck-gen3-build-and-test",
9698
"flex-stacker-build-and-test",
97-
"reference-module-build-and-test"
99+
"vacuum-module-build-and-test"
100+
]
101+
},
102+
{
103+
"name": "reference-module-binary",
104+
"displayName": "reference-module binary",
105+
"description": "Build the reference-module cross binary",
106+
"configurePreset": "stm32-cross",
107+
"jobs": 4,
108+
"targets": [
109+
"reference-module"
110+
]
111+
},
112+
{
113+
"name": "reference-module-debug",
114+
"displayName": "reference-module debug",
115+
"description": "Build the reference-module cross debug",
116+
"configurePreset": "stm32-cross",
117+
"jobs": 4,
118+
"targets": [
119+
"reference-module-debug"
98120
]
99121
},
100122
{
@@ -177,23 +199,23 @@
177199
]
178200
},
179201
{
180-
"name": "reference-module-binary",
181-
"displayName": "reference-module binary",
182-
"description": "Build the reference-module cross binary",
202+
"name": "vacuum-module-binary",
203+
"displayName": "vacuum-module binary",
204+
"description": "Build the vacuum-module cross binary",
183205
"configurePreset": "stm32-cross",
184206
"jobs": 4,
185207
"targets": [
186-
"reference-module"
208+
"vacuum-module"
187209
]
188210
},
189211
{
190-
"name": "reference-module-debug",
191-
"displayName": "reference-module debug",
192-
"description": "Build the reference-module cross debug",
212+
"name": "vacuum-module-debug",
213+
"displayName": "vacuum-module debug",
214+
"description": "Build the vacuum-module cross debug",
193215
"configurePreset": "stm32-cross",
194216
"jobs": 4,
195217
"targets": [
196-
"reference-module-debug"
218+
"vacuum-module-debug"
197219
]
198220
},
199221
{
@@ -203,12 +225,13 @@
203225
"configurePreset": "stm32-cross",
204226
"jobs": 4,
205227
"targets": [
228+
"reference-module-lint",
206229
"heater-shaker-lint",
207230
"common-lint",
208231
"thermocycler-gen2-lint",
209232
"tempdeck-gen3-lint",
210233
"flex-stacker-lint",
211-
"reference-module-lint"
234+
"vacuum-module-lint"
212235
]
213236
},
214237
{
@@ -218,12 +241,13 @@
218241
"configurePreset": "stm32-cross",
219242
"jobs": 4,
220243
"targets": [
244+
"reference-module-format",
221245
"heater-shaker-format",
222246
"common-format",
223247
"thermocycler-gen2-format",
224248
"tempdeck-gen3-format",
225249
"flex-stacker-format",
226-
"reference-module-format"
250+
"vacuum-module-format"
227251
]
228252
},
229253
{
@@ -233,12 +257,13 @@
233257
"configurePreset": "stm32-host",
234258
"jobs": 4,
235259
"targets": [
260+
"reference-module-format",
236261
"heater-shaker-format",
237262
"common-format",
238263
"thermocycler-gen2-format",
239264
"tempdeck-gen3-format",
240265
"flex-stacker-format",
241-
"reference-module-format"
266+
"vacuum-module-format"
242267
]
243268
},
244269
{
@@ -248,11 +273,12 @@
248273
"configurePreset": "stm32-host",
249274
"jobs": 4,
250275
"targets": [
276+
"reference-module-simulator",
251277
"heater-shaker-simulator",
252278
"thermocycler-gen2-simulator",
253279
"tempdeck-gen3-simulator",
254280
"flex-stacker-simulator",
255-
"reference-module-simulator"
281+
"vacuum-module-simulator"
256282
]
257283
},
258284
{
@@ -262,11 +288,11 @@
262288
"configurePreset": "stm32-host-gcc10",
263289
"jobs": 4,
264290
"targets": [
291+
"reference-module-simulator",
265292
"heater-shaker-simulator",
266293
"thermocycler-gen2-simulator",
267294
"tempdeck-gen3-simulator",
268-
"flex-stacker-simulator",
269-
"reference-module-simulator"
295+
"vacuum-module-simulator"
270296
]
271297
},
272298
{
@@ -276,11 +302,22 @@
276302
"configurePreset": "stm32-host",
277303
"jobs": 4,
278304
"targets": [
305+
"reference-module-build-and-test",
279306
"heater-shaker-build-and-test",
280307
"common-build-and-test",
281308
"thermocycler-gen2-build-and-test",
282309
"tempdeck-gen3-build-and-test",
283310
"flex-stacker-build-and-test",
311+
"vacuum-module-build-and-test"
312+
]
313+
},
314+
{
315+
"name": "reference-module-tests",
316+
"displayName": "tests",
317+
"description": "Runs build-and-test target for reference-module",
318+
"configurePreset": "stm32-host",
319+
"jobs": 4,
320+
"targets": [
284321
"reference-module-build-and-test"
285322
]
286323
},
@@ -325,13 +362,13 @@
325362
]
326363
},
327364
{
328-
"name": "reference-module-tests",
365+
"name": "vacuum-module-tests",
329366
"displayName": "tests",
330-
"description": "Runs build-and-test target for reference-module",
367+
"description": "Runs build-and-test target for vacuum-module",
331368
"configurePreset": "stm32-host",
332369
"jobs": 4,
333370
"targets": [
334-
"reference-module-build-and-test"
371+
"vacuum-module-build-and-test"
335372
]
336373
},
337374
{

stm32-modules/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ execute_process(COMMAND
4646
)
4747

4848
add_subdirectory(common)
49+
add_subdirectory(reference-module)
4950
add_subdirectory(heater-shaker)
5051
add_subdirectory(thermocycler-gen2)
5152
add_subdirectory(tempdeck-gen3)
5253
add_subdirectory(flex-stacker)
53-
add_subdirectory(reference-module)
54+
add_subdirectory(vacuum-module)
5455

5556
coverage_evaluate()

stm32-modules/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ All the CMake stuff in here should be done according to https://cliutils.gitlab.
99
- `./heater-shaker` contains all of the code specific to the heater/shaker module
1010
- `./thermocycler-gen2` contains all of the code specific to the thermocycler-gen2 module
1111
- `./include` contains all the headers, sorted by subdirectory - e.g. `include/common/` is where include files common to all modules live. Within each base `include/` directory, files are sorted into further subdirectories based off of their use - for example, `include/heater-shaker/firmware` contains files specific to the heater/shaker cross-compile build. This is done (rather than the reverse, `firmware/include`) so that code can have liens like `#include "firmware/whatever.hpp"`, which makes it apparent in the code itself what domain the header is in.
12+
13+
## Reference Module
14+
15+
The `./reference-module` is a barebones implementation of an stm32 module that is used
16+
as a starting point when adding new modules. It sets up the bootloader, main application,
17+
usb connectivity, status LED, and i2c.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @file firmware_tasks.hpp
3+
* @brief Expands on generic tasks.hpp to provide specific typedefs
4+
* for the firmware build
5+
*/
6+
#pragma once
7+
8+
#include "firmware/freertos_message_queue.hpp"
9+
#include "vacuum-module/tasks.hpp"
10+
11+
namespace tasks {
12+
13+
using FirmwareTasks = Tasks<FreeRTOSMessageQueue>;
14+
15+
constexpr size_t COMMS_STACK_SIZE = 2048;
16+
constexpr uint8_t COMMS_TASK_PRIORITY = 1;
17+
18+
constexpr size_t SYSTEM_STACK_SIZE = 256;
19+
constexpr uint8_t SYSTEM_TASK_PRIORITY = 1;
20+
21+
constexpr size_t UI_STACK_SIZE = 256;
22+
constexpr uint8_t UI_TASK_PRIORITY = 1;
23+
} // namespace tasks
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include "FreeRTOS.h"
4+
#include "firmware/firmware_tasks.hpp"
5+
#include "firmware/freertos_message_queue.hpp"
6+
#include "firmware/i2c_comms.hpp"
7+
#include "task.h"
8+
9+
namespace ui_control_task {
10+
11+
// Actual function that runs in the task
12+
auto run(tasks::FirmwareTasks::QueueAggregator* aggregator,
13+
i2c::hardware::I2C* i2c_comms) -> void;
14+
} // namespace ui_control_task
15+
16+
namespace host_comms_control_task {
17+
// Actual function that runs in the task
18+
auto run(tasks::FirmwareTasks::QueueAggregator* aggregator) -> void;
19+
} // namespace host_comms_control_task
20+
21+
namespace system_control_task {
22+
// Actual function that runs in the task
23+
auto run(tasks::FirmwareTasks::QueueAggregator* aggregator) -> void;
24+
} // namespace system_control_task
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
#include <optional>
5+
#include <tuple>
6+
7+
using std::size_t;
8+
static constexpr size_t MESSAGE_LEN = 5;
9+
using MessageT = std::array<uint8_t, MESSAGE_LEN>;
10+
11+
namespace i2c::hardware {
12+
using RxTxReturn = uint8_t;
13+
class I2CBase {
14+
public:
15+
I2CBase() = default;
16+
virtual ~I2CBase() = default;
17+
I2CBase(const I2CBase&) = default;
18+
auto operator=(const I2CBase&) -> I2CBase& = default;
19+
I2CBase(I2CBase&&) = default;
20+
auto operator=(I2CBase&&) -> I2CBase& = default;
21+
22+
virtual auto i2c_read(uint16_t dev_addr, uint16_t reg, uint8_t* data,
23+
uint16_t size) -> RxTxReturn;
24+
virtual auto i2c_write(uint16_t dev_addr, uint16_t reg, uint8_t* data,
25+
uint16_t size) -> RxTxReturn;
26+
};
27+
28+
} // namespace i2c::hardware
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#pragma once
2+
3+
#include <algorithm>
4+
#include <cstdint>
5+
#include <optional>
6+
7+
#include "firmware/hardware_iface.hpp"
8+
#include "firmware/i2c_hardware.h"
9+
#include "systemwide.h"
10+
11+
namespace i2c::hardware {
12+
class I2C : public I2CBase {
13+
public:
14+
explicit I2C() = default;
15+
~I2C() final = default;
16+
I2C(const I2C &) = delete;
17+
I2C(const I2C &&) = delete;
18+
auto operator=(const I2C &) = delete;
19+
auto operator=(const I2C &&) = delete;
20+
21+
auto i2c_read(uint16_t dev_addr, uint16_t reg, uint8_t *data, uint16_t size)
22+
-> RxTxReturn final;
23+
auto i2c_write(uint16_t dev_addr, uint16_t reg, uint8_t *data,
24+
uint16_t size) -> RxTxReturn final;
25+
auto set_handle(HAL_I2C_HANDLE i2c_handle, I2C_BUS bus) -> void;
26+
27+
private:
28+
I2C_BUS bus = NO_BUS;
29+
HAL_I2C_HANDLE handle = nullptr;
30+
};
31+
} // namespace i2c::hardware
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#pragma once
2+
3+
#include <stdbool.h>
4+
#include <stdint.h>
5+
6+
#include "systemwide.h"
7+
8+
#ifdef __cplusplus
9+
extern "C" {
10+
#endif // __cplusplus
11+
12+
typedef enum I2C_BUS {
13+
I2C_BUS_2,
14+
I2C_BUS_3,
15+
NO_BUS,
16+
} I2C_BUS;
17+
18+
typedef void *HAL_I2C_HANDLE;
19+
20+
typedef struct HandlerStruct {
21+
HAL_I2C_HANDLE i2c2;
22+
HAL_I2C_HANDLE i2c3;
23+
} I2CHandlerStruct;
24+
25+
void i2c_hardware_init(I2CHandlerStruct *i2c_handles);
26+
bool i2c_register_handle(HAL_I2C_HANDLE handle, I2C_BUS bus);
27+
uint8_t hal_i2c_write(I2C_BUS bus, uint16_t DevAddress, uint8_t reg,
28+
uint8_t *data, uint16_t size);
29+
uint8_t hal_i2c_read(I2C_BUS bus, uint16_t DevAddress, uint16_t reg,
30+
uint8_t *data, uint16_t size);
31+
32+
#ifdef __cplusplus
33+
} // extern "C"
34+
#endif // __cplusplus
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef SYSTEM_HARDWARE_H__
2+
#define SYSTEM_HARDWARE_H__
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif // __cplusplus
6+
7+
#include <stdbool.h>
8+
#include <stdint.h>
9+
10+
/**
11+
* @brief Enter the bootloader. This function never returns.
12+
*/
13+
void system_hardware_enter_bootloader(void);
14+
void system_hardware_gpio_init(void);
15+
uint16_t system_hardware_reset_reason(void);
16+
void enable_eeprom_write(bool enable);
17+
18+
#ifdef __cplusplus
19+
} // extern "C"
20+
#endif // __cplusplus
21+
#endif // _SYSTEM_HARDWARE_H__

0 commit comments

Comments
 (0)