Copyright (C) 2016 Kuldeep Singh Dhaka Licence: GNU Free Documentation License Version 1.3 (with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts) name of the language: uc-def ________________________________________________________________________________ enclose the uc-def code inside #if defined(__UCD__) ... bla bla ... #endif anything that start with '%' (first character is a comment) in the uc-def language no line should contain any '#' ________________________________________________________________________________ access flags r = reading permitted w = writing permitted h = modified by hardware c = write 1 to clear, writing 0 has no affect s = write 1 to set, writing 0 has no affect t = write 1 to toggle, writing 0 has no affect ________________________________________________________________________________ ~~~~~~~~~~~~~~~~ family name instance
instance_by_id
register internal_only ~~~~~~~~~~~~~~~~ short hand: ~~~~~~~~~~~~~~~~ fam
~~~~~~~~~~~~~~~~ example: = SPI note: for [instance
], it will output. #define _ (....) note: for [instance
], it will output. #define _(...) _(
, ...) note: there can only be one "instance
" note: there can be multiple "instance
" is used note: instance is optional (so, that means for short hand,
is optional too) note: "register " tell the default register size (in bits) and register stride (in bits) note: "register " is optional. default: = 32 default: = [ is again optional inside the register] note: mean that the family has already been defined, (by default false) only generate register. useful when the registers are added ________________________________________________________________________________ ~~~~~~~~~~~~~~~~ register name offset offset_by_id size access bit_name bits_name variable internal_only ~~~~~~~~~~~~~~~~ short hand: ~~~~~~~~~~~~~~~~ reg ~~~~~~~~~~~~~~~~ example: = CFG note: can be multiple times, and the non-first will be considered alias of first note: is in bits and tell the number of bits in the register note: (optional) and is calculated from last register (size + offset). offset tell the number of bits away from the family if the register is first in the family, this value is assumed 0 note: " offset_by_id " can be used multiple times to specify several type of same register note: " offset_by_id " or " offset " . only one type can be used at a time note: is same as if not provided note: not given, then taken from family. note: is like global access note: if not provided, "r", "w" is assumed note: mean that the register has already been defined, (by default false) only generate bit and bits. useful when the register bits/bit are added note: = MMIO example: for = 8, = MMIO8 for = 16, = MMIO16 for = 32, = MMIO32 output: if multiple not given. #define _(...) (... + ) output: if multiple given FOR ALL i IN [0...) #define _(..., i) (... + + ( * i)) output: if variable given #define _(...., var1_name, var2_name, varN_name) (... + + (var1_equ) + (var2_equ) + (varN_equ)) variable thing usecase: #define DWC_OTG_HCxCHAR(base,x) (base + 0x500 + 0x20*(x)) #define DWC_OTG_HCCHAR_CHENA (1 << 31) by giving """ register name HCxCHAR offset 0x500 bit_name HCCHAR bits_name HCCHAR variable x 0x20*(x) bit CHENA 31 """ ________________________________________________________________________________ ~~~~~~~~~~~~~~~~ bit name offset access variable ~~~~~~~~~~~~~~~~ short hand ~~~~~~~~~~~~~~~~ bit ~~~~~~~~~~~~~~~~ example: = EN note: can be multiple times, and the non-first will be considered alias of first note: is the offset of the bit in number-of-bits note: (optional) is not provided, it calculated from using. - just after "register": = 0 - after another "bit": = + 1 - after another "bits": = + output: #define ___SHIFT () #define __(...) (1 << ___SHIFT) note: is like global access note: if not provided, "r", "w" is assumed if "variable" is provided, variable argument is taken and the equation is added to offset ________________________________________________________________________________ ~~~~~~~~~~~~~~~~ bits name offset offset access size variable value ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ bits ~~~~~~~~~~~~~~~~ note: , and are same in docs like "bit" note: is the value of the span of the bits. (in number-of-bits) note: "value " is used to define some kind of special value (multiple) example: for spi, MODE = 0, MODE1 = 1, MODE2 = 2, MODE3 = MODE3 using "value MODE0 0", "value MODE1 1" ... we can get the special values note: = MASK_BIT0 << 0 | MASK_BIT1 |... MASK_BITn where MASK_BITx = (1 << x) IF x IN [0, ) or MASK_BITx = (0 << x) IF x NOT IN [0, ) output: #define ___SHIFT () #define ___MASK (() << ___SHIFT) #define __(..., v) \ (((v) << ___SHIFT) & ___MASK) note: if missing, is infered from last value. and for the first one in the data-structure, 0 is asssumed (because it do not have any previous to refer) if "value" exists (for each "value") #define ___(...) \ __(..., ) if "variable" is provided, variable argument is taken and the equation is added to offset