Modules | |
<eppl_internals> EPPL library internals macros | |
<eppl_target> Target wrapper | |
Macros | |
#define | EPPL_NP (-255L) |
Non-Pin value. More... | |
#define | EPPL_PINCNT ( EPPL_port_PORTSIZE * EPPL_port_PORTCNT ) |
Maximum number of pins. More... | |
#define | EPPL_DEFPP(port, pin) ( (port)*EPPL_port_PORTSIZE + (pin) ) |
Macro for port pin definition. More... | |
#define | EPPL_PORTNR(px) (((px) % EPPL_PINCNT) / EPPL_port_PORTSIZE) |
Get port number from pin identifier. More... | |
#define | EPPL_PINNR(px) ((px)%EPPL_port_PORTSIZE) |
Get pin number from pin identifier. More... | |
#define | EPPL_SC(px, conf) ( ((px) < 0) ? (px) : ( (px) + ( (conf) * EPPL_PINCNT ) ) ) |
Set Configuration macro. More... | |
#define | EPPL_GC(px) ( ( (px) / EPPL_PINCNT) % (EPPL_port_CONFSIZE) ) |
Get Configuration macro. More... | |
#define | EPPL_SR(px, from, to) ( ((px) < 0) ? (px) : ( ((from) << (EPPL_configBits)) | (to) ) * (EPPL_PINCNT) + (px)) |
Set Reinit macro. More... | |
#define | EPPL_GRfrom(px) ( (((px) / EPPL_PINCNT) >> EPPL_configBits) % EPPL_avr8_CONFSIZE ) |
Get Reinit from. | |
#define | EPPL_GRto(px) EPPL_GC(px) |
Get Reinit to. | |
#define | EPPL_COUNTARGS(args...) xEPPL_COUNTARGS(args, EPPL_COUNTARGS_RSEQ) |
Macro for counting number of parameters. More... | |
#define | EPPL_ActivePinCountInSet(pins...) EPPL_GETSUBSET(EPPL_checkPinDefined, 0, EPPL_extractOne, +, pins) |
Get active pins count in set given. More... | |
#define | EPPL_PinCountInSet(pins...) EPPL_COUNTARGS(pins) |
Get pins count in set given, including inactive ones. More... | |
#define | EPPL_PROCESSEVERYPIN(macro, op, pins...) EPPL_LC(EPPL_PROCESSEVERYPIN, EPPL_COUNTARGS(pins))(macro, op, pins) |
Macro for processing every single listed pin. More... | |
#define | EPPL_PROCESSEVERYARG(macro, op, args...) EPPL_PROCESSEVERYPIN(macro, op, args) |
Macro for processing every single argument. More... | |
#define | EPPL_REPEATONEVERYPIN(macro, pins...) |
Macro for repeating code on listed pins. More... | |
#define | EPPL_REPEATONEVERYARG(macro, args...) |
Macro for repeating code on listed arguments. More... | |
#define | eppl_init(default, pinconfigs...) |
Macro for port initialization. More... | |
#define | eppl_reinitFromISR(pinconfigs...) |
Macro that changes port configuration form interrupt procedure. More... | |
#define | eppl_reinit(pinconfigs...) |
Macro that changes port configuration. More... | |
#define | eppl_mapIn(pins...) ( EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_port_generateMapInFromOnePort, pins) (uint8_t)0 ) |
Map in function. More... | |
#define | eppl_mapOutFromISR(mode, value, pins...) do{ EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_port_generateMapOutToOnePort, mode, value, pins) }while(0) |
Value output mapping from ISR. More... | |
#define | eppl_mapOut(mode, value, pins...) |
Value output mapping. More... | |
Typedefs | |
typedef signed long | eppl_pin_t |
Definition of type that can store pin information. More... | |
There you can find all functions and constants that should be used in your programs to access processor pins.
#define EPPL_ActivePinCountInSet | ( | pins... | ) | EPPL_GETSUBSET(EPPL_checkPinDefined, 0, EPPL_extractOne, +, pins) |
Get active pins count in set given.
This macro counts all defined pins. Undefined pin is set to EPPL_NP value.
pins | Pin list to count |
#define EPPL_COUNTARGS | ( | args... | ) | xEPPL_COUNTARGS(args, EPPL_COUNTARGS_RSEQ) |
Macro for counting number of parameters.
Macro returns number of given parameters. Maximum number of processed parameters is 256. The best of all is it returns just one number. It does not return any value that has to be processed (I mean, for e.g. it returns 6 instead of something like: (1+2+3)). It means it could be used directly in macros like EPPL_REPEAT by connecting strings.
Macro is based on the post that could be found there: https://groups.google.com/forum/?fromgroups=#!topic/comp.std.c/d-6Mj5Lko_s
[in] | args | Arguments to be counted, at least 1, at most 256 |
#define EPPL_DEFPP | ( | port, | |
pin | |||
) | ( (port)*EPPL_port_PORTSIZE + (pin) ) |
Macro for port pin definition.
Use this macro for for port pin mnemonic definition.
Usage:
Or use it rather with a target specific definitions from the eppl_internals file.
[in] | port | Port number |
[in] | pin | Pin number in port |
#define EPPL_GC | ( | px | ) | ( ( (px) / EPPL_PINCNT) % (EPPL_port_CONFSIZE) ) |
Get Configuration macro.
Macro that extracts configuration information from connected Complex Pin Identifier and configuration.
#define eppl_init | ( | default, | |
pinconfigs... | |||
) |
Macro for port initialization.
Macro that initializes all pins in microcontroller. Put there all pin states that we require on microcontroller initialization. All pins can be given individually. The macro converts data to single value write to every register that requires initialization.
[in] | default | Default pin configuration. Use values directly (do not use EPPL_SC macro). |
[in] | pinconfigs | Pin configurations, separated by coma. Single pin configuration should be created using EPPL_SC macro. |
Usage example for AVR8 microcontroller:
#define eppl_mapIn | ( | pins... | ) | ( EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_port_generateMapInFromOnePort, pins) (uint8_t)0 ) |
Map in function.
Map in function maps data from processor pins to output value. Pins are mapped from MSB do LSB:
The code above would just simply copy data from PORTB to PORTC. An example generated code for the avr8 target:
[in] | pins | Pins list to map in. |
#define eppl_mapOut | ( | mode, | |
value, | |||
pins... | |||
) |
Value output mapping.
Macro that maps value from variable to output pins.
mode | Pin output mode. It is target dependent. |
value | Value to map out. |
pins | List of pins for map to. The LSB of value would be mapped to last listed pin. |
#define eppl_mapOutFromISR | ( | mode, | |
value, | |||
pins... | |||
) | do{ EPPL_REPEAT(EPPL_port_PORTCNT, EPPL_port_generateMapOutToOnePort, mode, value, pins) }while(0) |
Value output mapping from ISR.
Macro differs from eppl_mapOut in the way that it does not check if there are going to be any Hot Pins changed. It does not lock interrupts.
#define EPPL_NP (-255L) |
Non-Pin value.
Value that is used to mark non-pin in a Complex Pin Identifier value. It is used, for example, in EPPL_GETSUBSET where you have to put some value but you do not really want the macro to interpret it.
#define EPPL_PINCNT ( EPPL_port_PORTSIZE * EPPL_port_PORTCNT ) |
Maximum number of pins.
Maximum number of pins is just maximum number of ports multiplied by number of pins in port. It depends on porting files. It is rather maximum number of pins processed inside porting files than maximum number of real pins inside exact processor.
In correctly designed port files it is equal to maximum number of pins in target processor family.
#define EPPL_PinCountInSet | ( | pins... | ) | EPPL_COUNTARGS(pins) |
Get pins count in set given, including inactive ones.
Macro counts all pins in given set. Litteraly it equals number of arguments given after replacing in in preprocesor. It means if you write:
It would put in variable a value 3 no 1.
pins | Argument list to count |
#define EPPL_PINNR | ( | px | ) | ((px)%EPPL_port_PORTSIZE) |
Get pin number from pin identifier.
Macro extracts the pin in port number from the complex pin identifier
[in] | px | Complex pin identifier |
#define EPPL_PORTNR | ( | px | ) | (((px) % EPPL_PINCNT) / EPPL_port_PORTSIZE) |
Get port number from pin identifier.
Macro extracts the port number from the complex pin identifier
[in] | px | Complex pin identifier |
#define EPPL_PROCESSEVERYARG | ( | macro, | |
op, | |||
args... | |||
) | EPPL_PROCESSEVERYPIN(macro, op, args) |
Macro for processing every single argument.
Functionally it is exacly the same as EPPL_PROCESSEVERYPIN. But it is defined with different name to make code cleaner.
Use this function if you are to process arguments that is not a pin list.
#define EPPL_PROCESSEVERYPIN | ( | macro, | |
op, | |||
pins... | |||
) | EPPL_LC(EPPL_PROCESSEVERYPIN, EPPL_COUNTARGS(pins))(macro, op, pins) |
Macro for processing every single listed pin.
Macro that processes every listed pin using macro. Processed values are put back to the list, separated by commas.
Example usage:
Macro differs from EPPL_REPEATONEVERYPIN becouse it puts commas between processed values.
macro | Macro to be executed on every pin, it have to take 2 arguments: repeat count left and pin to process. Repeats left is pure number, so it can be used for macro names concat (operator ##). |
op | Operator to be used to connect listed pins. Use one of the fallowing:
|
pins | Pins list to process |
#define eppl_reinit | ( | pinconfigs... | ) |
Macro that changes port configuration.
Use this macro for changing port configuration using constant values. By changing port configuration we mean also changing pin state.
These macro works similarly to eppl_init with one difference - there is no default value, because all values that are not listed in pin configuration are left unchanged.
Macro also checks if there is going to be any unsafe port operation. If this is going to be the case, the interrupts would be blocked.
[in] | pinconfigs |
#define eppl_reinitFromISR | ( | pinconfigs... | ) |
Macro that changes port configuration form interrupt procedure.
Macro differs from eppl_reinit in the way that it does not check it there are going to be any Hot Pins changed. It does not lock interrupts.
[in] | pinconfigs | Pin configurations |
#define EPPL_REPEATONEVERYARG | ( | macro, | |
args... | |||
) |
Macro for repeating code on listed arguments.
Functionally it is exacly the same as EPPL_REPEATONEVERYPIN. But it is defined with different name to make code cleaner.
Use this function if you are to process arguments that is not a pin list.
#define EPPL_REPEATONEVERYPIN | ( | macro, | |
pins... | |||
) |
Macro for repeating code on listed pins.
Macro that repeats given macro execution on every pin on list. Example usage:
Macro differs from EPPL_PROCESSEVERYPIN becouse it does not put commas between processed values. Moreover REPEAT macro is taken inside do {} while(0) loop that makes it looks like one instruction from language tokens point of view. You can safetly use as a conditional or loop instruction.
macro | Macro to be processed, it have to take 2 arguments: repeat count left and pin to process. Repeats left is pure number, so it can be used for macro names concat (operator ##). |
pins | Pin list |
#define EPPL_SC | ( | px, | |
conf | |||
) | ( ((px) < 0) ? (px) : ( (px) + ( (conf) * EPPL_PINCNT ) ) ) |
Set Configuration macro.
Macro that returns a big constant number that keeps information about Complex Pin Identifier and its configuration.
#define EPPL_SR | ( | px, | |
from, | |||
to | |||
) | ( ((px) < 0) ? (px) : ( ((from) << (EPPL_configBits)) | (to) ) * (EPPL_PINCNT) + (px)) |
Set Reinit macro.
Macro to set reinit configuration. Use it to create reinit pins list in the eppl_reinit macro. You can use EPPL_SC as well but then all registers in port need to be reinitialized. If you would give any clue to the macro what mode or state you expected to be before changing, procedure would limit registry access only to the needed ones.
px | Complex pin identifier |
from | Configuration that you expect to be there now |
to | Configuration that you expect to be after eppl_reinit macro. |
typedef signed long eppl_pin_t |
Definition of type that can store pin information.
This data type is used for functions built into library. t has to be big enough to store all information about pins (port number, pin number, configuration).