Skip to content

Commit 10089dd

Browse files
Camera works kinda
1 parent 4949f90 commit 10089dd

File tree

10 files changed

+53
-7
lines changed

10 files changed

+53
-7
lines changed

FprimeZephyrReference/Components/CameraManager/CameraManager.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "FprimeZephyrReference/Components/CameraManager/CameraManager.hpp"
88

9-
namespace FprimeZephyrReference {
9+
namespace Components {
1010

1111
// ----------------------------------------------------------------------
1212
// Component construction and destruction
@@ -21,10 +21,16 @@ CameraManager ::~CameraManager() {}
2121
// ----------------------------------------------------------------------
2222

2323
void CameraManager ::TAKE_IMAGE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
24+
2425
// Prepare the "snap" command to send over UART via out_port
25-
Fw::Buffer snapBuffer(0, reinterpret_cast<U64>(snap_cmd), sizeof(snap_cmd) - 1); // exclude null terminator
26+
const U8 size = sizeof(this->snapArray);
27+
28+
// Create a buffer that references this array
29+
Fw::Buffer snapBuffer(this->snapArray, size);
30+
2631
// Send the buffer via out_port, check/send status if needed
2732
Drv::ByteStreamStatus sendStatus = this->out_port_out(0, snapBuffer);
33+
2834
if (sendStatus != Drv::ByteStreamStatus::OP_OK) {
2935
this->log_WARNING_HI_TakeImageError();
3036
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
@@ -33,6 +39,7 @@ void CameraManager ::TAKE_IMAGE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
3339
else {
3440
this->log_ACTIVITY_HI_PictureTaken();
3541
}
42+
3643
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
3744
}
3845

FprimeZephyrReference/Components/CameraManager/CameraManager.fpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module FprimeZephyrReference {
1+
module Components {
22
@ Manager for Nicla Vision
3-
active component CameraManager {
3+
passive component CameraManager {
44

55
# One async command/port is required for active components
66
# This should be overridden by the developers with a useful command/port
77
@ TODO
8-
async command TAKE_IMAGE
8+
sync command TAKE_IMAGE
99

1010
event TakeImageError() severity warning high format "Failed to take picture"
1111

FprimeZephyrReference/Components/CameraManager/CameraManager.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "FprimeZephyrReference/Components/CameraManager/CameraManagerComponentAc.hpp"
1111

12-
namespace FprimeZephyrReference {
12+
namespace Components {
1313

1414
class CameraManager final : public CameraManagerComponentBase {
1515
public:
@@ -24,7 +24,7 @@ class CameraManager final : public CameraManagerComponentBase {
2424
//! Destroy CameraManager object
2525
~CameraManager();
2626

27-
const char snap_cmd[4] = {'s', 'n', 'a', 'p'};
27+
U8 snapArray[5] = {'s', 'n', 'a', 'p', '\n'};
2828

2929
private:
3030
// ----------------------------------------------------------------------

FprimeZephyrReference/ReferenceDeployment/Main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
const struct device* serial = DEVICE_DT_GET(DT_NODELABEL(cdc_acm_uart0));
1414
const struct device* lora = DEVICE_DT_GET(DT_NODELABEL(lora0));
15+
const struct device* peripheral_uart = DEVICE_DT_GET(DT_NODELABEL(uart0));
1516

1617
int main(int argc, char* argv[]) {
1718
// ** DO NOT REMOVE **//
@@ -26,6 +27,10 @@ int main(int argc, char* argv[]) {
2627
inputs.uartDevice = serial;
2728
inputs.baudRate = 115200;
2829

30+
// For the uart peripheral config
31+
inputs.peripheralBaudRate = 115200; // Minimum is 19200
32+
inputs.peripheralUart = peripheral_uart;
33+
2934
// Setup, cycle, and teardown topology
3035
ReferenceDeployment::setupTopology(inputs);
3136
ReferenceDeployment::startRateGroups(); // Program loop

FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ void setupTopology(const TopologyState& state) {
8787
// for over-the-air communications.
8888
lora.start(state.loraDevice, Zephyr::TransmitState::DISABLED);
8989
comDriver.configure(state.uartDevice, state.baudRate);
90+
91+
// UART from the board to the payload
92+
peripheralUartDriver.configure(state.peripheralUart, state.peripheralBaudRate);
9093
}
9194

9295
void startRateGroups() {

FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopologyDefs.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ struct TopologyState {
7474
U32 baudRate; //!< Baud rate for UART communication
7575
CdhCore::SubtopologyState cdhCore; //!< Subtopology state for CdhCore
7676
ComCcsds::SubtopologyState comCcsds; //!< Subtopology state for ComCcsds
77+
const device* peripheralUart;
78+
U32 peripheralBaudRate;
7779
};
7880

7981
namespace PingEntries = ::PingEntries;

FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,10 @@ module ReferenceDeployment {
8989
instance antennaDeployer: Components.AntennaDeployer base id 0x10029000
9090

9191
instance fsSpace: Components.FsSpace base id 0x10030000
92+
93+
instance camera: Components.CameraManager base id 0x10031000
94+
95+
instance peripheralUartDriver: Zephyr.ZephyrUartDriver base id 0x10032000
96+
97+
9298
}

FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ module ReferenceDeployment {
4444
# For UART sideband communication
4545
instance comDriver
4646
instance fsSpace
47+
instance camera
48+
instance peripheralUartDriver
4749

4850

4951
# ----------------------------------------------------------------------
@@ -161,5 +163,9 @@ module ReferenceDeployment {
161163
imuManager.magneticFieldGet -> lis2mdlManager.magneticFieldGet
162164
imuManager.temperatureGet -> lsm6dsoManager.temperatureGet
163165
}
166+
167+
connections Camera {
168+
camera.out_port -> peripheralUartDriver.$send
169+
}
164170
}
165171
}

boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5-pinctrl.dtsi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
input-enable;
1212
};
1313
};
14+
uart0_default: uart0_default {
15+
group1 {
16+
pinmux = <UART0_TX_P0>;
17+
};
18+
19+
group2 {
20+
pinmux = <UART0_RX_P1>;
21+
input-enable;
22+
};
23+
};
1424
spi1_default: spi1_default {
1525
group1 {
1626
pinmux = <SPI1_SCK_P10>, <SPI1_TX_P11>;

boards/bronco_space/proves_flight_control_board_v5/proves_flight_control_board_v5.dtsi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ zephyr_udc0: &usbd {
100100
status = "okay";
101101
};
102102

103+
&uart0 {
104+
status = "okay";
105+
pinctrl-0 = <&uart0_default>;
106+
current-speed = <115200>;
107+
pinctrl-names = "default";
108+
};
109+
103110
&spi0 {
104111
status = "okay";
105112
cs-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;

0 commit comments

Comments
 (0)