2014-05-10 03:35 PM
Can the following code be made more efficient other than not having a function. Using a STMF405 and all I am trying to do is set bit 14 on Port C.
#define GPIOC 0x40020800
#define GPIOC_BSRR_OFFSET 0x18 #define BIT14_ON 0x00004000 #define GPIOC_BSRR_ADDRESS GPIOC + GPIOC_BSRR_OFFSETunsigned int volatile * GPIOC_BSRR = (unsigned int *)GPIOC_BSRR_ADDRESS;
void rx_tx_on(void) { *GPIOC_BSRR = BIT14_ON; }2014-05-10 07:23 PM
It all depends on what the compiler does with it, adept use of registers in assembler would allow you the ultimate flexibility.
In C GPIOC->BSRR = GPIO_Pin_14; Would probably be as efficient, and you could tell the compiler to inline it.