-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 🐛 Reading back from dma_spi does not work! - 🐛 Fix linker file path for conanfile, fixing where the default linker is used, segfaulting the lpc40 because the top of stack was in 0x2000'0000 and not 0x1000'0000. - ⚡ In the `lpc40::spi`, reduce time gap between transmitted bytes by 46% (from 1160ns to 630ns @ 3MHz) by using the "fifo not full" status vs the busy() status. This allows the software to keep the spi peripheral fed with data. - 🧪 Manually tested using saleae to confirm signals. Rx is tested by pulling the line to 3v3 and checking that 0xFF is returned for all bytes in the sequence and by removing the connection and confirming that 0x00 is in all bytes of the receive buffer.
- Loading branch information
Showing
9 changed files
with
470 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2024 Khalil Estell | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <span> | ||
|
||
#include <libhal/io_waiter.hpp> | ||
#include <libhal/spi.hpp> | ||
|
||
#include "constants.hpp" | ||
#include "pin.hpp" | ||
|
||
namespace hal::lpc40 { | ||
class dma_spi final : public hal::spi | ||
{ | ||
public: | ||
/// Information used to configure the spi bus | ||
struct bus_info | ||
{ | ||
/// peripheral id used to power on the spi peripheral at creation | ||
peripheral peripheral_id; | ||
/// spi data pin | ||
pin clock; | ||
/// spi clock pin | ||
pin data_out; | ||
/// spi clock pin | ||
pin data_in; | ||
/// clock function code | ||
std::uint8_t clock_function; | ||
/// scl pin function code | ||
std::uint8_t data_out_function; | ||
/// scl pin function code | ||
std::uint8_t data_in_function; | ||
}; | ||
|
||
/** | ||
* @brief Construct a new spi object | ||
* | ||
* @param p_bus - bus number to use | ||
* @param p_waiter - provides the implementation strategy for the time the CPU | ||
* waits until the transfer has completed. | ||
* @param p_settings - spi settings to achieve | ||
* @throws hal::operation_not_supported - if the p_bus is not 0, 1, or 2 or if | ||
* the spi settings could not be achieved. | ||
*/ | ||
dma_spi(std::uint8_t p_bus, | ||
hal::io_waiter& p_waiter = hal::polling_io_waiter(), | ||
spi::settings const& p_settings = {}); | ||
/** | ||
* @brief Construct a new spi object using bus info directly | ||
* | ||
* @param p_bus - Full bus information | ||
*/ | ||
dma_spi(bus_info p_bus); | ||
|
||
dma_spi(dma_spi const& p_other) = delete; | ||
dma_spi& operator=(dma_spi const& p_other) = delete; | ||
dma_spi(dma_spi&& p_other) noexcept = delete; | ||
dma_spi& operator=(dma_spi&& p_other) noexcept = delete; | ||
virtual ~dma_spi(); | ||
|
||
private: | ||
void driver_configure(settings const& p_settings) override; | ||
void driver_transfer(std::span<hal::byte const> p_data_out, | ||
std::span<hal::byte> p_data_in, | ||
hal::byte p_filler) override; | ||
|
||
hal::io_waiter* m_io_waiter; | ||
bus_info m_bus; | ||
}; | ||
} // namespace hal::lpc40 |
Oops, something went wrong.