Jump to content

mios32_spi.c


Braintu
 Share

Recommended Posts

Hi,

I was trying to understand the configuration in mios32_spi.c and I am wondering if I don't understand it right or there is a small mistake...

From line 76 to 79 there is the initalization of the IO-Pins:

// Push-Pull Config

#define MIOS32_SPI0_PP_INIT { LPC_PINCON->PINMODE_OD1 &= ~((1 << 24) | (1 << 23) | (1 << 22) | (1 << 21) | (1 << 20)); }

// Open-Drain Config -- NOTE: unfortunately it has no effect on SCLK and MOSI pin! This isn't documented in the LPC17xx user manual

#define MIOS32_SPI0_OD_INIT { LPC_PINCON->PINMODE_OD1 |= ((1 << 24) | (1 << 23) | (1 << 22) | (1 << 21) | (1 << 20)); }

The macro MIOS32_SPI0_PP_INIT calls PINMODE_OD1 to set the resistor configuration but instead it clears the open drain mode and the next macro sets them again.

Or why is the headline Push-Pull Config?

Can somebody help?

Best,

braintu

EDIT:

Sorry for bothering. I understood the push/pull comment wrong. It refers to the output which push/pull-s not to the resistors...

Edited by Braintu
Link to comment
Share on other sites

PINMODE_OD1 isn't a function, but a configuration register of the LPC17 port peripheral.

MIOS32_SPI0_PP_INIT applies an AND mask over this register, which means that bits will be cleared (-> OD function for given pins disabled)

MIOS32_SPI0_OD_INIT applies an OR mask over this register, which means that bits will be set (-> OD function for given pins enabled)

Best Regards, Thorsten.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...