[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#define [/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]PORT_MASK 0xFFF [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//12 bit port on LPC1114[/COLOR][/SIZE][/COLOR][/SIZE] [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void [/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]GPIOSetMultiValue[/B]( [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] portNum, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MultiBitMask, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Value )[/SIZE][/LEFT] [SIZE=2]{[/SIZE] [SIZE=2] LPC_GPIO[portNum]->MASKED_ACCESS[(PORT_MASK) & MultiBitMask] = Value;[/SIZE] [SIZE=2]}[/SIZE] [LEFT][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t [/COLOR][/SIZE][/COLOR][/SIZE] [SIZE=2][B]GPIOGetMultiValue[/B]( [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] portNum, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MultiBitMask )[/SIZE] [SIZE=2]{[/SIZE][/LEFT] [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])((PORT_MASK)&( LPC_GPIO[portNum]->MASKED_ACCESS[(PORT_MASK)&MultiBitMask]));[/SIZE] [SIZE=2]}[/SIZE] [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void [/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]GPIOSetDaftValue[/B]( [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] portNum, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] bitPosi, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] bitVal )[/SIZE][/LEFT] [SIZE=2]{[/SIZE] [SIZE=2]LPC_GPIO[portNum]->MASKED_ACCESS[(1<<bitPosi)] = (bitVal<<bitPosi)+7 ; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//7 is ignored![/COLOR][/SIZE][/COLOR][/SIZE] [SIZE=2]}[/SIZE] [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]_Bool [/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B]getbit[/B]([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] portNum, [/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] bit) //@gbm[/SIZE] [SIZE=2]{[/SIZE] [SIZE=2][B][COLOR=#7f0055][COLOR=#7f0055]return[/COLOR][/COLOR][/B] !! LPC_GPIO[portNum]->MASKED_ACCESS[1 << bit];[/SIZE] [LEFT][SIZE=2]}[/SIZE][/LEFT] |
[LEFT][SIZE=2]GPIOSetValue(2,6,0);[/SIZE][/LEFT] [LEFT][SIZE=2]bitVal = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])getbit(2,6);[/SIZE][/LEFT] [LEFT][SIZE=2]GPIOSetValue(2,6,1);[/SIZE][/LEFT] [LEFT][SIZE=2]bitVal = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])getbit(2,6);[/SIZE][/LEFT] [LEFT][SIZE=2]GPIOSetDaftValue(2,6,0);[/SIZE][/LEFT] [LEFT][SIZE=2]bitVal = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])getbit(2,6);[/SIZE][/LEFT] [LEFT][SIZE=2]GPIOSetDaftValue(2,6,1);[/SIZE][/LEFT] [LEFT][SIZE=2]bitVal = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])getbit(2,6);[/SIZE][/LEFT] [LEFT][SIZE=2]bitVal = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])getbit(2,2);[/SIZE][/LEFT] [LEFT][SIZE=2]GPIOSetValue(2,6,0);[/SIZE][/LEFT] [LEFT][SIZE=2]bitVal = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])getbit(2,6);[/SIZE][/LEFT] [LEFT][SIZE=2]GPIOSetDaftValue(2,6,1);[/SIZE][/LEFT] [LEFT][SIZE=2] [/SIZE] [SIZE=2]bitVal = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])getbit(2,2);[/SIZE][/LEFT] [LEFT][SIZE=2]bitVal = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])getbit(2,6);[/SIZE][/LEFT] [LEFT][SIZE=2] [/SIZE] [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/*[/COLOR][/SIZE] [SIZE=2][COLOR=#3f7f5f]void GPIOSetMultiValue( uint32_t portNum, uint32_t bitMask, uint32_t Value );[/COLOR][/SIZE] [SIZE=2][COLOR=#3f7f5f]uint32_t GPIOGetMultiValue( uint32_t portNum, uint32_t bitMask );[/COLOR][/SIZE] [SIZE=2][COLOR=#3f7f5f]*/[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]GPIOSetMultiValue( 2, 0xA4, 0x1A4 );[/SIZE][/LEFT] [LEFT][SIZE=2]bitVal = GPIOGetMultiValue( 2, 0x84 );[/SIZE][/LEFT] [LEFT][SIZE=2]bitVal = ([/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]uint32_t[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])getbit( 2, 5); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//note:0x20 is the mask not the [U]bitno[/U] which is 5[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f] [/COLOR][/SIZE][SIZE=2]bitVal = GPIOGetMultiValue( 2, 0x04 );[/SIZE] [SIZE=2]bitVal = GPIOGetMultiValue( 2, 0xA0 );[/SIZE] [SIZE=2]bitVal = GPIOGetMultiValue( 2, 0xA4 );[/SIZE][/LEFT] |
inline static _Bool getbit(uint32_t port, uint32_t bit) { [SIZE=2] return !! LPC_GPIO[portNum]->MASKED_ACCESS[1 << bit];[/SIZE] } |