patacongo edited a comment on pull request #1832:
URL: https://github.com/apache/incubator-nuttx/pull/1832#issuecomment-694431378


   > 
   > 
   > @patacongo does this definition make sense for `STMPE811_GPIO_PIN(n)` I 
would expect to do something like this to define the pin config:
   > 
   > ```
   > #define KB_FW_BL (STMPE811_GPIO_OUTPUT | STMPE811_GPIO_PIN(3))
   > ```
   > 
   > But that sets the bit shift in the register not pin config. Instead I have 
to do something like this:
   > 
   > ```
   > #define KB_FW_BL (STMPE811_GPIO_OUTPUT | STMPE811_GPIO_PIN3)
   > ```
   > 
   > That seems inconsistent to me with how we normally set GPIO pincfg.
   
   What is there seems correct to me.  The encoding is  "Bits 0-2 is the pin 
number".  For:
   
       #define KB_FW_BL (STMPE811_GPIO_OUTPUT | STMPE811_GPIO_PIN3)
   
   That would be Bits 0-2 == 0b011.  For:
   
       #define KB_FW_BL (STMPE811_GPIO_OUTPUT | STMPE811_GPIO_PIN(3))
   
   STMPE811_GPIO_PIN(3) ix 0b1000 sowhich would not fit into Bits 0-2 and would 
clobber Bit 3:  "Bit 3 is the initial value for output pins"
   
   This is the full encoding:
   
       389 /* The STMPE811 GPIO interfaces take an 8-bit bit-encoded parameter 
to describe the GPIO pin.
       390  * The following definitions describe the bit-encoding of that 
parameter.
       391  *
       392  *  7654 3210
       393  *  ---- ----
       394  *  DIRF VPPP
       395  *
       396  * Input Pins:  1IRF .PPP
       397  *
       398  * Output Pins: 0... VPPP
       399  *
       400  * Bits 7 is the pin direction.
       401  */
       407 /* Bit 6 indicates that the pin will generate an interrupt (inputs 
only) */
       411 /* The bits 4-5 select the rising and/or the falling edge detection. 
*/
       416 /* Bit 3 is the initial value for output pins */
       422 /* Bits 0-2 is the pin number */


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to