DISTORTEC / distortos

object-oriented C++ RTOS for microcontrollers
https://distortos.org/
Mozilla Public License 2.0
430 stars 66 forks source link

Configuration of SPIv1 for bit-banding and non bit-banding option #32

Closed CezaryGapinski closed 7 years ago

CezaryGapinski commented 7 years ago

SPIv1 driver is can be configured to work in bit-banding or non-bitbanding option based on arm cortex architecture

FreddieChopin commented 7 years ago

Merged with minor whitespace changes and added missing #include - next time please check whether the "alternate" version actually builds fine (; I've did that by just commenting out the macro that was added in bit-banding header.

CezaryGapinski commented 7 years ago

There is a problem with: CONFIG_ARCHITECTURE_ARMV7_M_KERNEL_BASEPRI in STM32-SPIv1-spiLowLevelInitialization.cpp - it is not always defined, for example to ARCHITECTURE_ARMV6_M architecture :(.

I've made some changes here: https://github.com/CezaryGapinski/distortos/commit/d058a343cb091455d28f26d1de6341adfc75b3e1

FreddieChopin commented 7 years ago

The idea is OK. I would prefer to do it like this:

namespace distortos
{

namespace chip
{

namespace
{

/*---------------------------------------------------------------------------------------------------------------------+
| local objects
+---------------------------------------------------------------------------------------------------------------------*/

/// priority of SPI interrupts
#if defined(CONFIG_ARCHITECTURE_ARMV7_M_KERNEL_BASEPRI)
constexpr uint8_t interruptPriority {CONFIG_ARCHITECTURE_ARMV7_M_KERNEL_BASEPRI};
#else   // !defined(CONFIG_ARCHITECTURE_ARMV7_M_KERNEL_BASEPRI)
constexpr uint8_t interruptPriority {};
#endif  // !defined(CONFIG_ARCHITECTURE_ARMV7_M_KERNEL_BASEPRI)

}   // namespace

/*---------------------------------------------------------------------------------------------------------------------+
| global functions
+---------------------------------------------------------------------------------------------------------------------*/
...
CezaryGapinski commented 7 years ago

Ok, new version is on my branch: https://github.com/CezaryGapinski/distortos/commit/02dbb6ede1b8871e975c491c0d6c953c7a9b0252

I also made a cherrypcik on my STM32L0 branch based on latest commit: https://github.com/CezaryGapinski/distortos/commit/2cc11e3b31f0214f610e91508e9c160005b264ca

for SPI1 and SPI2 enabled for STM32L071CB device. It's compiled with no problems, but It is not yet tested on eval board :(.

FreddieChopin commented 7 years ago

Ok, new version is on my branch:

Look OK, let's merge it (;

but It is not yet tested on eval board :(.

I hope you tested whether the system works at all for STM32L0? (;

CezaryGapinski commented 7 years ago

I hope you tested whether the system works at all for STM32L0? (;

SPI driver is not tested. But what I tested already was the base configuration for my NUCLEO-L073RZ with "Test Application". Test passed ok.

FreddieChopin commented 7 years ago

But what I tested already was the base configuration for my NUCLEO-L073RZ with "Test Application". Test passed ok.

Great! (;