Skip to content

Commit

Permalink
✨ stm32f1 adc peripheral manager
Browse files Browse the repository at this point in the history
- Updated to fix register pointer error.
- Verified and tested with modified demo using both adc1 and adc2,
as well as using adc1 with 2 separate channels.
  • Loading branch information
50xp50 committed Jan 24, 2025
1 parent 249dc3f commit 8df56a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/libhal-arm-mcu/stm32f1/adc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class adc_peripheral_manager final
hal::basic_lock* m_lock;
/// A pointer to track the location of the registers for the specified adc
/// peripheral.
void* adc_reg_location;
std::uintptr_t adc_reg_location;
};

/**
Expand Down
8 changes: 4 additions & 4 deletions src/stm32f1/adc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,21 +270,21 @@ adc_peripheral_manager::adc_peripheral_manager(adc_selection p_adc_selection,
hal::stm32f1::peripheral adc_peripheral;
switch (p_adc_selection) {
case adc_selection::adc1:
adc_offset = 12400;
adc_offset = 0x12400;
adc_peripheral = peripheral::adc1;
break;
case adc_selection::adc2:
adc_offset = 12800;
adc_offset = 0x12800;
adc_peripheral = peripheral::adc2;
break;
default:
adc_offset = 12400;
adc_offset = 0x12400;
adc_peripheral = peripheral::adc1;
break;
}
// Stores address of specified adc peripheral's config registers to the
// manager object. NOLINTNEXTLINE(performance-no-int-to-ptr)
adc_reg_location = reinterpret_cast<void*>(stm_apb2_base + adc_offset);
adc_reg_location = stm_apb2_base + adc_offset;

// NOLINTNEXTLINE(performance-no-int-to-ptr)
setup_adc(adc_peripheral, reinterpret_cast<adc_reg_t*>(adc_reg_location));
Expand Down

0 comments on commit 8df56a9

Please sign in to comment.