Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 01dc1ccb5034822ace8c6c6477b0e964dc5ebdbc
Author: Ethan Chee <ethancheez@gmail.com>
Date:   Tue Jul 18 15:37:08 2023 -0700

    Move setup_arduino_libraries call for i2c linking

commit 98ada04b3903b5fb61ac5ce28e5bbf7f0da0a42e
Author: Ethan Chee <61472206+ethancheez@users.noreply.github.com>
Date:   Mon Jul 17 22:41:54 2023 -0700

    Fix I2cDriver Wire.h linking error

commit 2f35207ff70904782ab98d034404b550757f736c
Author: Ethan Chee <ethancheez@gmail.com>
Date:   Fri Jun 23 10:20:25 2023 -0700

    teensy32 cmake compile options

commit 91d43b0456ba9b560a0af0abf63befc5ea86aa10
Author: Ethan Chee <ethancheez@gmail.com>
Date:   Tue Jun 20 09:46:21 2023 -0700

    I2C Driver requires Wire library

commit cd6aa4cca01d6492d8cd1dd10e0927ca6be80a76
Author: Ethan Chee <ethancheez@gmail.com>
Date:   Thu Jun 15 17:39:42 2023 -0700

    Restrict platform ArduinoFw

commit 625a6f488c4b432c5fd81457c80d9411c8c0e459
Author: Ethan Chee <ethancheez@gmail.com>
Date:   Mon Jun 12 14:14:22 2023 -0700

    cleanup

commit 59273b4f89274a9c5b66668a7edd90ad61e5ed18
Author: Ethan Chee <ethancheez@gmail.com>
Date:   Thu Jun 8 08:53:28 2023 -0700

    Add I2cDriver.close() / Wire.end()

commit 2cb7fca1c57ec5a886c98c75f176875ca797397d
Author: Ethan Chee <ethancheez@gmail.com>
Date:   Wed Jun 7 17:30:16 2023 -0700

    Arduino I2cDriver

commit 91ac63cd11ae2d13f2dfbf636e5d3a9478c4871e
Author: Ethan Chee <ethancheez@gmail.com>
Date:   Wed May 31 15:30:11 2023 -0700

    compile bug fixes for featherM0 and teensy41

commit 8d77126e8df261223b3d3eb190718013f31f7ffe
Merge: 068d725 36588d2
Author: Ethan Chee <61472206+ethancheez@users.noreply.github.com>
Date:   Wed May 31 15:20:47 2023 -0700

    Merge pull request #2 from SterlingPeet/mbed-work

    Mbed work

commit 36588d25ebb26375f05d6d47ea46d82f6898004d
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed May 31 12:31:27 2023 -0700

    Fixing multiple target definitions when using multiple deployments

commit e58ed092cec5c98d047aa7d21d7f2b53c5ab37b0
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed May 31 12:12:27 2023 -0700

    Bug fixes for stream driver work

commit e3c5ca4fa4504451cb10fed6896c0dc3450a5d51
Author: M Starch <LeStarch@googlemail.com>
Date:   Sun May 28 14:37:20 2023 -0700

    Adding featherrp20404rfm

commit 91f7d214d839a5f2c35d5eaa03cf760287d41e83
Author: M Starch <LeStarch@googlemail.com>
Date:   Sun May 28 14:36:45 2023 -0700

    Changing serial driver to stream driver

commit cb6a9a211234427440074953eeb9603d04bc47c5
Author: M Starch <LeStarch@googlemail.com>
Date:   Thu May 25 09:46:03 2023 -0700

    Working rp2040 builds

commit 109f23748726f2e91ddbc15aae37edacda3c4b6e
Merge: b498ed3 068d725
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed May 24 18:48:10 2023 -0700

    Merge pull request #7 from ethancheez/mbed++

    support for feather

commit 068d725ae3f56c15662faada6f2b4a73d936489d
Author: Ethan Chee <ethancheez@gmail.com>
Date:   Wed May 24 17:54:29 2023 -0700

    support for feather

commit b498ed378676fb10644a070f0fd63eb357850966
Author: M Starch <LeStarch@googlemail.com>
Date:   Thu May 18 13:16:22 2023 -0700

    Fixing rate driver to drive

commit fb7e074ba1fd5c92a9a3107628422d7ab18679b4
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed May 17 11:11:08 2023 -0700

    Minor fixes to post-command and C++ improvements

commit b5e93fc8afd788445c487940b7bcef9bbd71b010
Author: M Starch <LeStarch@googlemail.com>
Date:   Fri May 12 20:10:04 2023 -0700

    Initial work with external script

commit 8c22756077c51e4a103718823694bc07e5ccb9a2
Author: M Starch <LeStarch@googlemail.com>
Date:   Sat Feb 25 00:07:40 2023 -0800

    initial mbed work

commit b833e631bae74d352e6ac0006f3474eca1828b23
Author: M Starch <LeStarch@googlemail.com>
Date:   Fri Dec 16 17:29:17 2022 -0800

    cleaned up arduino library support

commit 1caa5310d72f15f01343a206b22eb757ad4f17b6
Author: M Starch <LeStarch@googlemail.com>
Date:   Fri Dec 16 15:57:31 2022 -0800

    library support working for teensy41

commit 36cdc56c628641670df680abdc47732b2baba042
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed Dec 14 12:00:36 2022 -0800

    adding SPI.h

commit af11d22d449b37f939d7a7c542858c86b6679738
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed Dec 14 02:22:47 2022 -0800

    fixing .hex copy

commit 0c16693ace157ca3f9ecfe71f87698584b2664cd
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed Dec 14 02:02:43 2022 -0800

    adding .hex file to install

commit 69cfe2edd6f157762c48e8557e3f09e53b34c8bf
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed Dec 14 01:51:01 2022 -0800

    updating to handle archiving and ranlib

commit 2bf1ba487197fa9cd6ea4d61bed923e7396fb12e
Author: M Starch <LeStarch@googlemail.com>
Date:   Tue Dec 13 23:23:13 2022 -0800

    adding wire library

commit 63ad8f163d0633d44922c386c5c64e34b88beb98
Author: M Starch <LeStarch@googlemail.com>
Date:   Tue Dec 13 11:07:03 2022 -0800

    fixing serial driver to report ready

commit b4ff7fb685e9135f10b1db8be086fea2d0a370c0
Author: M Starch <LeStarch@googlemail.com>
Date:   Tue Dec 13 09:11:49 2022 -0800

    fixing serial driver, gpio driver, stream log

commit 207fa6e42e27f19acab5240bed1a1e3da64d7bb5
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed Dec 7 21:27:43 2022 -0800

    lestarch: working on teensy32

commit 7421568bad4cd0ceb02662db22c8a6df66286985
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed Dec 7 19:18:29 2022 -0800

    removing old arduino support

commit 2c891be4e95cb373974d8f1702061ebcba175288
Author: M Starch <LeStarch@googlemail.com>
Date:   Wed Dec 7 19:04:44 2022 -0800

    lestarch: adding teensy 4 toolchains

commit 106e2fe22618e8da22ffda61b5399514b2a7cd3e
Author: M Starch <LeStarch@googlemail.com>
Date:   Sun Oct 16 13:07:10 2022 -0700

    lestarch: cleaning up linking command

commit 3b8720b7319be4166d947a0e44f226743452a18c
Author: M Starch <LeStarch@googlemail.com>
Date:   Sun Oct 16 12:37:37 2022 -0700

    lestarch: updating components for fprime 3, fixing linking

commit 042e0a745e850dd253c4e0a24f148d11f78dcf4c
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Sun Oct 16 11:13:45 2022 -0500

    WIP: Kludge to update HardwareRateDriver without config

commit d97e366966d5a09b82d8c11188247a76fec6421a
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Sun Oct 16 10:52:55 2022 -0500

    Kludge to remove configuration from Serial Driver that is not accessible

commit 4d919fab594cacadf52bdf250b94f235dafa9e3d
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Sat Oct 15 12:10:31 2022 -0500

    Add kludgy support for TimerOne library, to be generalized later...

commit 824115ef41668d8787e0482b103fd68e1519b437
Author: M Starch <LeStarch@googlemail.com>
Date:   Fri Oct 14 13:24:32 2022 -0700

    lestarch: more AVR fixes

commit 8ff13c4a81998532b3d4a13696fcda4894f6431c
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Fri Oct 14 14:30:47 2022 -0400

    Add new header for OS tasks

commit dea454604830a1724b2d53d50a3ac788425be625
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Fri Oct 14 14:16:19 2022 -0400

    First pass at ATmega128 support

commit 054dae63d75e6bf7d14c91deffea398a55b87d32
Author: M Starch <LeStarch@googlemail.com>
Date:   Thu Oct 13 09:01:00 2022 -0700

    lestarch: gpio driver rework

commit c85d1831b2ad4b938a3be073746a6ba20e512b23
Author: M Starch <LeStarch@googlemail.com>
Date:   Fri Oct 7 16:45:25 2022 -0700

    lestarch: adding gpio driver and refactoring types

commit d9b932cff4a1f58be42565901c6cd953db3e3393
Author: M Starch <LeStarch@googlemail.com>
Date:   Fri Oct 7 13:46:28 2022 -0700

    lestarch: refactoring standard components

commit cafcad69a53f9fea8c817ddb29dc38a604d3f6ac
Author: M Starch <LeStarch@googlemail.com>
Date:   Sat Oct 1 09:33:22 2022 -0700

    lestarch: arduino package WIP

commit b95919382c4f627f27b2d099f9f37b8f7a28bd7f
Author: M Starch <LeStarch@googlemail.com>
Date:   Mon Sep 26 17:53:01 2022 -0700

    lestarch: rearranging former Arduino packages

commit 72e5a5e6c0d01708aa0801a501e495ad22d1507b
Author: M Starch <LeStarch@googlemail.com>
Date:   Mon Sep 26 17:44:35 2022 -0700

    lestarch: arduino-cli passes cmake compile checks

commit 379c1ff8110fc06a32179ddd914f29a776b39e6e
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Wed Nov 10 16:16:07 2021 -0500

    missed slashes

commit 99cdf44b8a110f8f3ecbc8c5c5f37c04c5813e2a
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Wed Nov 10 16:14:22 2021 -0500

    fix file paths

commit 7191510d58ed51e2cddd31c2a53788a7877ca6ea
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Wed Nov 10 16:12:09 2021 -0500

    dont print all that

commit 04d4288c2847f9fa9c7938edfcd86308ae414d44
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Wed Nov 10 14:24:09 2021 -0500

    Fix missing definitions

commit fba21d0319626bd985dfd7b68b1556da2cfe24d6
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Wed Nov 10 08:55:19 2021 -0500

    add init to HardwareRateDriver and fix path to TimerOne library

commit f7cc6e19c6687a35527e6f4cd2be0673d9a36dae
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Wed Nov 10 00:49:58 2021 -0500

    fix HardwareRateDriver paths

commit fc28e79069316afb481138eb6c9eb3366992b341
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Wed Nov 10 00:08:46 2021 -0500

    Update paths in AssertReset

commit 29bb59b03ffb8b5c597427e34d823297d1ef20b4
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Tue Nov 9 23:55:36 2021 -0500

    ATmega Types

commit 88b334ee22c03cb88f343e721a36c2cba7b5041f
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Tue Nov 9 23:44:07 2021 -0500

    cmake generation works, not building yet

commit b0f7e63d46c3ce3f6098c82047badb327125de76
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Tue Nov 9 22:41:18 2021 -0500

    Add ATmega folders and components

commit 08eefead00fdb7028ab2daa88d17199f0333a357
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Sun Oct 24 21:49:38 2021 -0400

    Add starting point for toolchain and platform files

commit b80102df98e466c9c4d30dac6761d0d943e34dd2
Author: Sterling Peet <sterling.peet@ae.gatech.edu>
Date:   Sun Oct 24 20:07:52 2021 -0400

    add some things to get started
  • Loading branch information
ethancheez committed Jul 18, 2023
1 parent d86c918 commit d2d3450
Show file tree
Hide file tree
Showing 24 changed files with 597 additions and 55 deletions.
3 changes: 0 additions & 3 deletions Arduino/Drv/HardwareRateDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ if (NOT FPRIME_ARDUINO)
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/HardwareRateDriverLinux.cpp")
elseif (IS_TEENSY)
target_use_arduino_libraries("IntervalTimer")
list(APPEND MOD_DEPS "IntervalTimer")
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/HardwareRateDriverTeensy.cpp")
elseif (IS_ATMEGA)
target_use_arduino_libraries("TimerOne")
list(APPEND MOD_DEPS "TimerOne")
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/HardwareRateDriverAvr.cpp")
elseif (IS_MBED)
target_use_arduino_libraries("mbed")
list(APPEND MOD_DEPS "mbed")
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/HardwareRateDriverMbed.cpp")
else()
set(COMPILE_DEFINITIONS "USE_BASIC_TIMER")
Expand Down
19 changes: 19 additions & 0 deletions Arduino/Drv/I2cDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
####
# F prime CMakeLists.txt:
#
# SOURCE_FILES: combined list of source and autocoding files
# MOD_DEPS: (optional) module dependencies
# UT_SOURCE_FILES: list of source files for unit tests
#
####
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/I2cDriver.fpp"
"${CMAKE_CURRENT_LIST_DIR}/I2cDriver.cpp"
)
if(FPRIME_ARDUINO)
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/I2cDriverArduino.cpp")
target_use_arduino_libraries("Wire")
else()
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/I2cDriverLinux.cpp")
endif()
register_fprime_module()
63 changes: 63 additions & 0 deletions Arduino/Drv/I2cDriver/I2cDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// ======================================================================
// \title I2cDriver.cpp
// \author ethanchee
// \brief cpp file for I2cDriver component implementation class
// ======================================================================


#include <Arduino/Drv/I2cDriver/I2cDriver.hpp>
#include <FpConfig.hpp>
#include "Fw/Types/Assert.hpp"

namespace Arduino {

// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

I2cDriver ::
I2cDriver(
const char *const compName
) : I2cDriverComponentBase(compName),
m_port_pointer(static_cast<POINTER_CAST>(NULL))
{

}

I2cDriver ::
~I2cDriver()
{

}

// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------

Drv::I2cStatus I2cDriver ::
read_handler(
const NATIVE_INT_TYPE portNum,
U32 addr,
Fw::Buffer &serBuffer
)
{
// Ensure buffer is not a nullptr
FW_ASSERT(serBuffer.getData());

return read_data(addr, serBuffer);
}

Drv::I2cStatus I2cDriver ::
write_handler(
const NATIVE_INT_TYPE portNum,
U32 addr,
Fw::Buffer &serBuffer
)
{
// Ensure buffer is not a nullptr
FW_ASSERT(serBuffer.getData());

return write_data(addr, serBuffer);
}

} // end namespace Arduino
10 changes: 10 additions & 0 deletions Arduino/Drv/I2cDriver/I2cDriver.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Arduino {
@ I2C Driver for Arduino
passive component I2cDriver {

guarded input port write: Drv.I2c

guarded input port read: Drv.I2c

}
}
80 changes: 80 additions & 0 deletions Arduino/Drv/I2cDriver/I2cDriver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// ======================================================================
// \title I2cDriver.hpp
// \author ethanchee
// \brief hpp file for I2cDriver component implementation class
// ======================================================================

#ifndef I2cDriver_HPP
#define I2cDriver_HPP

#include "Arduino/Drv/I2cDriver/I2cDriverComponentAc.hpp"
#include <Wire.h>

namespace Arduino {

class I2cDriver :
public I2cDriverComponentBase
{

public:

// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

//! Construct object I2cDriver
//!
I2cDriver(
const char *const compName /*!< The component name*/
);

void open(TwoWire* wire);
void close();

//! Destroy object I2cDriver
//!
~I2cDriver();

PRIVATE:

//! Read the actual data
Drv::I2cStatus read_data(U32 addr, Fw::Buffer& fwBuffer);
//! Write the actual data
Drv::I2cStatus write_data(U32 addr, Fw::Buffer& fwBuffer);

// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------

//! Handler implementation for read
//!
Drv::I2cStatus read_handler(
const NATIVE_INT_TYPE portNum, /*!< The port number*/
U32 addr, /*!<
I2C slave device address
*/
Fw::Buffer &serBuffer /*!<
Buffer with data to read/write to/from
*/
);

//! Handler implementation for write
//!
Drv::I2cStatus write_handler(
const NATIVE_INT_TYPE portNum, /*!< The port number*/
U32 addr, /*!<
I2C slave device address
*/
Fw::Buffer &serBuffer /*!<
Buffer with data to read/write to/from
*/
);

//! Stores the open wire port, POINTER_CAST so Linux and Ardunio may use different types
void* m_port_pointer;

};

} // end namespace Arduino

#endif
56 changes: 56 additions & 0 deletions Arduino/Drv/I2cDriver/I2cDriverArduino.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ======================================================================
// \title I2cDriver.cpp
// \author ethanchee
// \brief cpp file for I2cDriver component implementation class
// ======================================================================


#include <Arduino/Drv/I2cDriver/I2cDriver.hpp>
#include <FpConfig.hpp>
#include "Fw/Types/Assert.hpp"

namespace Arduino {

void I2cDriver::open(TwoWire *wire) {
FW_ASSERT(wire != nullptr);
m_port_pointer = wire;
wire->begin();
}

void I2cDriver::close() {
FW_ASSERT(m_port_pointer != 0);
TwoWire* wire_ptr = reinterpret_cast<TwoWire*>(m_port_pointer);
wire_ptr->end();
}

Drv::I2cStatus I2cDriver::read_data(U32 addr, Fw::Buffer& fwBuffer)
{
TwoWire* wire_ptr = reinterpret_cast<TwoWire*>(m_port_pointer);

wire_ptr->requestFrom(static_cast<U8>(addr), fwBuffer.getSize());

int byte = 0;
NATIVE_UINT_TYPE count = 0;
U8* raw_data = reinterpret_cast<U8*>(fwBuffer.getData());
while ((wire_ptr->available() > 0) && (count < fwBuffer.getSize()) && ((byte = wire_ptr->read()) != -1)) {
*(raw_data + count) = static_cast<U8>(byte);
count++;
}
fwBuffer.setSize(count);

return Drv::I2cStatus::I2C_OK;
}

Drv::I2cStatus I2cDriver::write_data(U32 addr, Fw::Buffer& fwBuffer)
{
FW_ASSERT(m_port_pointer != 0);
TwoWire* wire_ptr = reinterpret_cast<TwoWire*>(m_port_pointer);

wire_ptr->beginTransmission(static_cast<U8>(addr));
wire_ptr->write(reinterpret_cast<U8*>(fwBuffer.getData()), fwBuffer.getSize());
wire_ptr->endTransmission();

return Drv::I2cStatus::I2C_OK;
}

} // end namespace Arduino
27 changes: 27 additions & 0 deletions Arduino/Drv/I2cDriver/I2cDriverLinux.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ======================================================================
// \title I2cDriver.cpp
// \author ethanchee
// \brief cpp file for I2cDriver component implementation class
// ======================================================================


#include <Arduino/Drv/I2cDriver/I2cDriver.hpp>
#include <FpConfig.hpp>

namespace Arduino {

void I2cDriver::close() {

}

Drv::I2cStatus I2cDriver::read_data(U32 addr, Fw::Buffer& fwBuffer)
{
return Drv::I2cStatus::I2C_OK;
}

Drv::I2cStatus I2cDriver::write_data(U32 addr, Fw::Buffer& fwBuffer)
{
return Drv::I2cStatus::I2C_OK;
}

} // end namespace Arduino
17 changes: 17 additions & 0 deletions Arduino/Drv/StreamDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
####
# F prime CMakeLists.txt:
#
# SOURCE_FILES: combined list of source and autocoding diles
# MOD_DEPS: (optional) module dependencies
#
####
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/StreamDriver.fpp"
"${CMAKE_CURRENT_LIST_DIR}/StreamDriver.cpp"
)
if(FPRIME_ARDUINO)
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/StreamDriverArduino.cpp")
else()
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/StreamDriverLinux.cpp")
endif()
register_fprime_module()
39 changes: 39 additions & 0 deletions Arduino/Drv/StreamDriver/StreamDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// ======================================================================
// \title StreamDriverImpl.cpp
// \author lestarch
// \brief cpp file for StreamDriver component implementation class
// ======================================================================

#include <Arduino/Drv/StreamDriver/StreamDriver.hpp>
#include "Fw/Types/BasicTypes.hpp"

namespace Arduino {

// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

StreamDriver ::StreamDriver(const char* compName)
: StreamDriverComponentBase(compName),
m_port_number(0),
m_port_pointer(static_cast<POINTER_CAST>(NULL)) {}

StreamDriver ::~StreamDriver(void) {}

// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------

Drv::SendStatus StreamDriver ::send_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer) {
write_data(fwBuffer);
deallocate_out(0, fwBuffer);
return Drv::SendStatus::SEND_OK;
}

void StreamDriver ::schedIn_handler(const NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) {
Fw::Buffer recv_buffer = this->allocate_out(0, SERIAL_BUFFER_SIZE);
read_data(recv_buffer);
recv_out(0, recv_buffer, Drv::RecvStatus::RECV_OK);
}

} // namespace Arduino
23 changes: 23 additions & 0 deletions Arduino/Drv/StreamDriver/StreamDriver.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Arduino {

passive component StreamDriver {

@ Polling for receiving data
sync input port schedIn: Svc.Sched

@ Indicates the driver has connected to the UART device
output port ready: Drv.ByteStreamReady

@Allocate new buffer
output port allocate: Fw.BufferGet

@return the allocated buffer
output port deallocate: Fw.BufferSend

@ Takes data to transmit out the UART device
guarded input port send: Drv.ByteStreamSend

@ Takes data to transmit out the UART device
output port $recv: Drv.ByteStreamRecv
}
}
Loading

0 comments on commit d2d3450

Please sign in to comment.