From 4eef98aa9227d3442996463cafe016f4a3f3fba6 Mon Sep 17 00:00:00 2001 From: Kevin Sangalli Date: Wed, 27 Nov 2024 09:58:26 +0100 Subject: [PATCH] Fix of BSP of the board `amcfoc` to run EEPROM (#538) --- .../bsp/cm4/embot_hw_spi_bsp_amcfoc_2cm4.cpp | 2 +- .../examples/cm4-embot-os/src/main-basic.cpp | 52 ++++++++++++------- .../embot/hw/embot_hw_chip_M95512DF.h | 2 +- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/emBODY/eBcode/arch-arm/board/amcfoc/bsp/cm4/embot_hw_spi_bsp_amcfoc_2cm4.cpp b/emBODY/eBcode/arch-arm/board/amcfoc/bsp/cm4/embot_hw_spi_bsp_amcfoc_2cm4.cpp index db699db1c..d23ef9cad 100644 --- a/emBODY/eBcode/arch-arm/board/amcfoc/bsp/cm4/embot_hw_spi_bsp_amcfoc_2cm4.cpp +++ b/emBODY/eBcode/arch-arm/board/amcfoc/bsp/cm4/embot_hw_spi_bsp_amcfoc_2cm4.cpp @@ -114,7 +114,7 @@ namespace embot::hw::spi::bsp { SPI_HandleTypeDef hspi3 {}; constexpr std::array pinoutspi3 = { { {embot::hw::GPIO::PORT::C, embot::hw::GPIO::PIN::eleven}, // miso - {embot::hw::GPIO::PORT::D, embot::hw::GPIO::PIN::ten}, // mosi + {embot::hw::GPIO::PORT::D, embot::hw::GPIO::PIN::six}, // mosi {embot::hw::GPIO::PORT::C, embot::hw::GPIO::PIN::ten}, // sckl {embot::hw::GPIO::PORT::A, embot::hw::GPIO::PIN::four} // ssel } }; diff --git a/emBODY/eBcode/arch-arm/board/amcfoc/examples/cm4-embot-os/src/main-basic.cpp b/emBODY/eBcode/arch-arm/board/amcfoc/examples/cm4-embot-os/src/main-basic.cpp index a7c6f2e55..3031ef1ee 100644 --- a/emBODY/eBcode/arch-arm/board/amcfoc/examples/cm4-embot-os/src/main-basic.cpp +++ b/emBODY/eBcode/arch-arm/board/amcfoc/examples/cm4-embot-os/src/main-basic.cpp @@ -34,10 +34,11 @@ constexpr embot::os::Event evtTick = embot::core::binary::mask::pos2maskon(); // testduration(); // signal->off(); - -// test_eth_tick(); - -// test_eeprom_tick(); + +#if defined(TEST_ETH) + test_eth_tick(); +#endif + +#if defined(TEST_EEPROM) + test_eeprom_tick(); +#endif // embot::core::TimeFormatter tf(embot::core::now()); // embot::core::print("mainthread-onevent: evtTick received @ time = " + tf.to_string(embot::core::TimeFormatter::Mode::full)); - } -// test_can_tick(t, eventmask, param); +#if defined(TEST_CAN) + test_can_tick(t, eventmask, param); +#endif - + } } @@ -290,7 +304,7 @@ constexpr embot::hw::EEPROM eeprom2test {embot::hw::EEPROM::one}; void test_eeprom_init() { embot::hw::eeprom::init(eeprom2test, {}); - embot::hw::eeprom::erase(eeprom2test, 0, 8*1024, 100000); + //embot::hw::eeprom::erase(eeprom2test, 0, 8*1024, 100000); } constexpr size_t capacity {2048}; @@ -321,16 +335,18 @@ void test_eeprom_tick() std::memset(dd, 0, sizeof(dd)); embot::core::Data data {dd, numberofbytes}; - embot::hw::eeprom::read(eeprom2test, adr2use, data, 3*embot::core::time1millisec); + embot::hw::eeprom::read(eeprom2test, adr2use, data, 5*embot::core::time1millisec); + stophere++; std::memset(dd, cnt, sizeof(dd)); - embot::hw::eeprom::write(eeprom2test, adr2use, data, 3*embot::core::time1millisec); - + stophere++; + embot::hw::eeprom::write(eeprom2test, adr2use, data, 5*embot::core::time1millisec); + std::memset(dd, 0, sizeof(dd)); - embot::hw::eeprom::read(eeprom2test, adr2use, data, 3*embot::core::time1millisec); - + embot::hw::eeprom::read(eeprom2test, adr2use, data, 5*embot::core::time1millisec); + stophere++; } @@ -376,7 +392,7 @@ void test_can_init(embot::os::Thread *t, void *param) } -#define TEST_EMBOT_HW_CAN_BURST +//#define TEST_EMBOT_HW_CAN_BURST void test_can_tick(embot::os::Thread *t, embot::os::EventMask eventmask, void *param) { if(0 == eventmask) @@ -402,7 +418,7 @@ void test_can_tick(embot::os::Thread *t, embot::os::EventMask eventmask, void *p loop_put_transmit_eachtime, // as we do in ems when in cfg state loop_put_transmit_onlyfirsttime // a new mode i wnat to test }; - constexpr burstmode bm {burstmode::loop_put_transmit_eachtime}; + constexpr buprrstmode bm {burstmode::loop_put_transmit_eachtime}; constexpr bool getoutputsize {true}; // to verify if a irq tx disable / enable gives problems constexpr embot::core::relTime delay {0}; // 0 10 200 300 400 500 diff --git a/emBODY/eBcode/arch-arm/embot/hw/embot_hw_chip_M95512DF.h b/emBODY/eBcode/arch-arm/embot/hw/embot_hw_chip_M95512DF.h index fea0b3908..ad95c3288 100644 --- a/emBODY/eBcode/arch-arm/embot/hw/embot_hw_chip_M95512DF.h +++ b/emBODY/eBcode/arch-arm/embot/hw/embot_hw_chip_M95512DF.h @@ -145,7 +145,7 @@ namespace embot { namespace hw { namespace chip { }}} // namespace embot { namespace hw { namespace chip { -#define EMBOT_HW_CHIP_M95512DF_enable_test +#undef EMBOT_HW_CHIP_M95512DF_enable_test #if defined(EMBOT_HW_CHIP_M95512DF_enable_test) namespace embot { namespace hw { namespace chip { // it tests the chip and offers an example of use