Skip to content

Commit

Permalink
mb9bf560l gpio driver bugfix not getting address and using wrong address
Browse files Browse the repository at this point in the history
  • Loading branch information
itzandroidtab committed Aug 5, 2024
1 parent 634c25b commit 3ee70a7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions targets/core/cypress/mb9bf560l/port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace klib::core::mb9bf560l::io::detail::pins {
static_assert(Periph::periph::id <= 20, "Invalid peripheral id");

// get the pointer to the pin select we need to write to
volatile uint32_t *const epfr = (reinterpret_cast<volatile uint32_t *const>(Pin::port::port->EPFR00));
volatile uint32_t *const epfr = (reinterpret_cast<volatile uint32_t *const>(&Pin::port::port->EPFR00));

// get the current value in the register
uint32_t reg = epfr[Periph::periph::id];
Expand Down Expand Up @@ -595,7 +595,7 @@ namespace klib::core::mb9bf560l::io::detail::pins {
}

// get the pointer to the pin select we need to write to
volatile uint32_t *const pfr = (reinterpret_cast<volatile uint32_t *const>(Pin::port::port->PFR0));
volatile uint32_t *const pfr = (reinterpret_cast<volatile uint32_t *const>(&Pin::port::port->PFR0));

// set the alternate function
if constexpr (std::is_same_v<Periph, io::detail::alternate::none>) {
Expand Down Expand Up @@ -628,15 +628,15 @@ namespace klib::core::mb9bf560l::io {
detail::pins::set_peripheral<Pin, io::detail::alternate::none>();

// get the pointer to the pin select we need to write to
volatile uint32_t *const ddr = (reinterpret_cast<volatile uint32_t *const>(Pin::port::port->DDR0));
volatile uint32_t *const ddr = (reinterpret_cast<volatile uint32_t *const>(&Pin::port::port->DDR0));

// disable the output on the pin
ddr[Pin::port::id] &= (~detail::pins::mask<Pin>);
}

constexpr static bool get() {
// get the pointer to the pin select we need to write to
volatile uint32_t *const pdir = (reinterpret_cast<volatile uint32_t *const>(Pin::port::port->PDIR0));
volatile uint32_t *const pdir = (reinterpret_cast<volatile uint32_t *const>(&Pin::port::port->PDIR0));

// get the status of the pin
return pdir[Pin::port::id] & detail::pins::mask<Pin>;
Expand All @@ -645,7 +645,7 @@ namespace klib::core::mb9bf560l::io {
template <bool Val>
constexpr static void pullup_enable() {
// get the pointer to the pin select we need to write to
volatile uint32_t *const pcr = (reinterpret_cast<volatile uint32_t *const>(Pin::port::port->PCR0));
volatile uint32_t *const pcr = (reinterpret_cast<volatile uint32_t *const>(&Pin::port::port->PCR0));

if constexpr (Val) {
pcr[Pin::port::id] |= detail::pins::mask<Pin>;
Expand All @@ -664,7 +664,7 @@ namespace klib::core::mb9bf560l::io {
detail::pins::set_peripheral<Pin, io::detail::alternate::none>();

// get the pointer to the pin select we need to write to
volatile uint32_t *const ddr = (reinterpret_cast<volatile uint32_t *const>(Pin::port::port->DDR0));
volatile uint32_t *const ddr = (reinterpret_cast<volatile uint32_t *const>(&Pin::port::port->DDR0));

// // enable the gpio output
ddr[Pin::port::id] |= detail::pins::mask<Pin>;
Expand All @@ -673,7 +673,7 @@ namespace klib::core::mb9bf560l::io {
template <bool Val>
constexpr static void set() {
// get the pointer to the pin select we need to write to
volatile uint32_t *const pdor = (reinterpret_cast<volatile uint32_t *const>(Pin::port::port->PDOR0));
volatile uint32_t *const pdor = (reinterpret_cast<volatile uint32_t *const>(&Pin::port::port->PDOR0));

if constexpr (Val) {
pdor[Pin::port::id] |= detail::pins::mask<Pin>;
Expand All @@ -685,7 +685,7 @@ namespace klib::core::mb9bf560l::io {

constexpr static void set(const bool val) {
// get the pointer to the pin select we need to write to
volatile uint32_t *const pdor = (reinterpret_cast<volatile uint32_t *const>(Pin::port::port->PDOR0));
volatile uint32_t *const pdor = (reinterpret_cast<volatile uint32_t *const>(&Pin::port::port->PDOR0));

if (val) {
pdor[Pin::port::id] |= detail::pins::mask<Pin>;
Expand Down

0 comments on commit 3ee70a7

Please sign in to comment.