git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3186 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
245dc734d7
commit
b077c0f2cc
|
@ -137,51 +137,8 @@ void _pal_lld_init(const PALConfig *config) {
|
|||
* @param[in] mode the mode
|
||||
*
|
||||
* @notapi
|
||||
*
|
||||
* n * 1 +
|
||||
* n * 4 +
|
||||
* n * 16 +
|
||||
* n * 64 +
|
||||
* n * 256 +
|
||||
* n * 1024 +
|
||||
* n * 4096 +
|
||||
* n * 16384
|
||||
*/
|
||||
#if 1
|
||||
void _pal_lld_setgroupmode(ioportid_t port,
|
||||
ioportmask_t mask,
|
||||
iomode_t mode) {
|
||||
|
||||
uint32_t m1 = (uint32_t)mask;
|
||||
uint32_t m2 = 0;
|
||||
uint32_t m4l = 0;
|
||||
uint32_t m4h = 0;
|
||||
uint32_t moder = (((mode & PAL_STM32_MODE_MASK) >> 0) & 3) * 0x5555;
|
||||
uint32_t otyper = (((mode & PAL_STM32_OTYPE_MASK) >> 2) & 1) * 0xffff;
|
||||
uint32_t ospeedr = (((mode & PAL_STM32_OSPEED_MASK) >> 3) & 3) * 0x5555;
|
||||
uint32_t pupdr = (((mode & PAL_STM32_PUDR_MASK) >> 5) & 3) * 0x5555;
|
||||
uint32_t afr = (((mode & PAL_STM32_ALTERNATE_MASK) >> 7) & 15) * 0x0f0f;
|
||||
uint32_t bit = 0;
|
||||
while (mask) {
|
||||
if ((mask & 1) != 0) {
|
||||
m2 |= 3 << (bit * 2);
|
||||
if (bit < 8)
|
||||
m4l |= 15 << ((bit & 7) * 4);
|
||||
else
|
||||
m4h |= 15 << ((bit & 7) * 4);
|
||||
}
|
||||
bit++;
|
||||
mask >>= 1;
|
||||
}
|
||||
port->AFRL = (port->AFRL & ~m4l) | afr;
|
||||
port->AFRH = (port->AFRH & ~m4h) | afr;
|
||||
port->OSPEEDR = (port->OSPEEDR & ~m2) | ospeedr;
|
||||
port->OTYPER = (port->OTYPER & ~m1) | otyper;
|
||||
port->PUPDR = (port->PUPDR & ~m2) | pupdr;
|
||||
port->MODER = (port->MODER & ~m2) | moder;
|
||||
}
|
||||
|
||||
#else
|
||||
void _pal_lld_setgroupmode(ioportid_t port,
|
||||
ioportmask_t mask,
|
||||
iomode_t mode) {
|
||||
|
@ -213,6 +170,39 @@ void _pal_lld_setgroupmode(ioportid_t port,
|
|||
mask >>= 1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void _pal_lld_setgroupmode(ioportid_t port,
|
||||
ioportmask_t mask,
|
||||
iomode_t mode) {
|
||||
|
||||
uint32_t m1 = (uint32_t)mask;
|
||||
uint32_t m2 = 0;
|
||||
uint32_t m4l = 0;
|
||||
uint32_t m4h = 0;
|
||||
uint32_t moder = (((mode & PAL_STM32_MODE_MASK) >> 0) & 3) * 0x5555;
|
||||
uint32_t otyper = (((mode & PAL_STM32_OTYPE_MASK) >> 2) & 1) * 0xffff;
|
||||
uint32_t ospeedr = (((mode & PAL_STM32_OSPEED_MASK) >> 3) & 3) * 0x5555;
|
||||
uint32_t pupdr = (((mode & PAL_STM32_PUDR_MASK) >> 5) & 3) * 0x5555;
|
||||
uint32_t afr = (((mode & PAL_STM32_ALTERNATE_MASK) >> 7) & 15) * 0x1111;
|
||||
uint32_t bit = 0;
|
||||
while (mask) {
|
||||
if ((mask & 1) != 0) {
|
||||
m2 |= 3 << bit;
|
||||
if (bit < 16)
|
||||
m4l |= 15 << ((bit & 14) * 2);
|
||||
else
|
||||
m4h |= 15 << ((bit & 14) * 2);
|
||||
}
|
||||
bit += 2;
|
||||
mask >>= 1;
|
||||
}
|
||||
port->AFRL = (port->AFRL & ~m4l) | (afr & m4l);
|
||||
port->AFRH = (port->AFRH & ~m4h) | (afr & m4h);
|
||||
port->OSPEEDR = (port->OSPEEDR & ~m2) | (ospeedr & m2);
|
||||
port->OTYPER = (port->OTYPER & ~m1) | (otyper & m1);
|
||||
port->PUPDR = (port->PUPDR & ~m2) | (pupdr & m2);
|
||||
port->MODER = (port->MODER & ~m2) | (moder & m2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HAL_USE_PAL */
|
||||
|
|
Loading…
Reference in New Issue