µTasker Forum

µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: mark on February 19, 2015, 03:37:49 PM

Title: Kinetis Port Macros
Post by: mark on February 19, 2015, 03:37:49 PM
Hi All

Here is a complete list of Kinetis port macros which are compatible across all Kinetis (KE, KL, KV, K parts) apart from where an exception is noted.
The macros also contain simulator hooks and so when used the uTasker Kinetis simulator is ensured to remain synchronised to the present port states.
Note that many macros enable configuring/modifying multiple pins on a port at the same time.

Regards

Mark


// Configure pins as output, including enabling clock to specified port eg. _CONFIG_PORT_OUTPUT(A, (PORTA_BIT16 | PORTA_BIT8), (PORT_SRE_FAST | PORT_DSE_LOW));
//
_CONFIG_PORT_OUTPUT(ref, pins, chars)
_CONFIG_PORT_OUTPUT_FAST_LOW(ref, pins, chars) - version for faster configuring of lower 16 bits (not KE)
_CONFIG_PORT_OUTPUT_FAST_HIGH(ref, pins, chars) - version for faster configuring of upper 16 bits (not KE)

// Configure pins as Input, including enabling clock to specified port  eg. _CONFIG_PORT_INPUT(A, (PORTA_BIT4 |PORTA_BIT3 | PORTA_BIT2), PORT_PS_UP_ENABLE);
//
_CONFIG_PORT_INPUT(ref, pins, chars)
_CONFIG_PORT_INPUT_FAST_LOW(ref, pins, chars) - version for faster configuring of lower 16 bits (not KE)
_CONFIG_PORT_INPUT_FAST_HIGH(ref, pins, chars) - version for faster configuring of upper 16 bits (not KE)


// Configure a peripheral function eg. _CONFIG_PERIPHERAL(B, 2, (PB_2_FTM0_CH0 | PORT_SRE_FAST | PORT_DSE_HIGH));
//
_CONFIG_PERIPHERAL(port, pin, function)

// Write to a port with a mask eg. _WRITE_PORT_MASK(C, 0x1234,  0x0000ffff);
//
_WRITE_PORT_MASK(ref, value, mask)

// Write full port width _WRITE_PORT_MASK(C, 0x12345678);
//
_WRITE_PORT(ref, value)

// Toggle a port with a mask eg. _TOGGLE_PORT(D, PORTD_BIT3);
//
_TOGGLE_PORT(ref, mask)

// Read full port width eg. _READ_PORT(A);
//
_READ_PORT(ref)

// Read from a port with a mask eg. _READ_PORT(A, (PORTD_BIT3 | PORTD_BIT0));
//
_READ_PORT_MASK(ref, mask)

// Configure outputs, including enabling clock to specified port, and then set a value to them - this device sets the value and then drives
// eg. _CONFIG_DRIVE_PORT_OUTPUT_VALUE(C, (PORTC_BIT13 | PORTC_BIT0), (PORTC_BIT13), (PORT_SRE_SLOW | PORT_DSE_HIGH));
// - example configures two pins and synchronously sets these to '1' and '0' respectively
//
_CONFIG_DRIVE_PORT_OUTPUT_VALUE(ref, pins, value, chars)
_CONFIG_DRIVE_PORT_OUTPUT_VALUE_FAST_LOW(ref, pins, value, chars) - version for faster configuring of lower 16 bits (not KE)
_CONFIG_DRIVE_PORT_OUTPUT_VALUE_FAST_HIGH(ref, pins, value, chars) - version for faster configuring of upper 16 bits (not KE)


// Set from inputs to outputs and set a value to them - this is equivalent to _CONFIG_DRIVE_PORT_OUTPUT_VALUE on this device
//
_DRIVE_PORT_OUTPUT_VALUE(ref, mask, value)

// Set from outputs to inputs eg. _FLOAT_PORT(A, LCD_BUS_BITS);
//
#define _FLOAT_PORT(ref, pins)

// Set from inputs to outputs eg. _DRIVE_PORT_OUTPUT(A, LCD_BUS_BITS);
//
#define _DRIVE_PORT_OUTPUT(ref, pins)

// Set and clear individual bits of a port eg. _SETBITS(B, (PORTB_BIT5 | PORTB_BIT19)); / _CLEARBITS(B, (PORTB_BIT5 | PORTB_BIT19));
//
_SETBITS(ref, pins)
_CLEARBITS(ref, pins)