Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPC11uxx compile issue #378

Open
crashniels opened this issue Jul 26, 2023 · 4 comments
Open

LPC11uxx compile issue #378

crashniels opened this issue Jul 26, 2023 · 4 comments

Comments

@crashniels
Copy link

Currently when compiling for qmk it will not compile unless you uncomment this line.

Is this a bug or am I missing something? I have mentioned it in qmk/qmk_firmware#21621.

@dexter93
Copy link
Contributor

might be helpful to post the relevant build failure output log

@crashniels
Copy link
Author

Ψ Compiling keymap with make --jobs=1 corsair/k70_vengeance_rgb:default


QMK Firmware 0.21.6
Making corsair/k70_vengeance_rgb with keymap default

Generating: .build/obj_corsair_k70_vengeance_rgb_default/src/info_deps.d                            [OK]
arm-none-eabi-gcc (Arch Repository) 13.1.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Generating: .build/obj_corsair_k70_vengeance_rgb_default/src/config.h                               [OK]
Generating: .build/obj_corsair_k70_vengeance_rgb_default/src/keymap.c                               [OK]
Generating: .build/obj_corsair_k70_vengeance_rgb/src/info_config.h                                  [OK]
Generating: .build/obj_corsair_k70_vengeance_rgb/src/default_keyboard.c                             [OK]
Generating: .build/obj_corsair_k70_vengeance_rgb/src/default_keyboard.h                             [OK]
Compiling: keyboards/corsair/k70_vengeance_rgb/k70_vengeance_rgb.c                                  [OK]
Compiling: .build/obj_corsair_k70_vengeance_rgb/src/default_keyboard.c                              [OK]
Compiling: quantum/keymap_introspection.c                                                           [OK]
Compiling: quantum/quantum.c                                                                        [OK]
Compiling: quantum/bitwise.c                                                                        [OK]
Compiling: quantum/led.c                                                                            [OK]
Compiling: quantum/action.c                                                                         [OK]
Compiling: quantum/action_layer.c                                                                   [OK]
Compiling: quantum/action_tapping.c                                                                 [OK]
Compiling: quantum/action_util.c                                                                    [OK]
Compiling: quantum/eeconfig.c                                                                       [OK]
Compiling: quantum/keyboard.c                                                                       [OK]
Compiling: quantum/keymap_common.c                                                                  [OK]
Compiling: quantum/keycode_config.c                                                                 [OK]
Compiling: quantum/sync_timer.c                                                                     [OK]
Compiling: quantum/logging/debug.c                                                                  [OK]
Compiling: quantum/logging/sendchar.c                                                               [OK]
Compiling: quantum/logging/print.c                                                                  [OK]
Compiling: quantum/bootmagic/magic.c                                                                [OK]
Compiling: quantum/matrix_common.c                                                                  [OK]
Compiling: quantum/matrix.c                                                                        In file included from ./lib/chibios/os/hal/include/hal_pal.h:174,
                 from ./lib/chibios/os/hal/include/hal.h:306,
                 from platforms/chibios/gpio.h:18,
                 from platforms/gpio.h:21,
                 from quantum/matrix.h:22,
                 from quantum/matrix.c:21:
quantum/matrix.c: In function 'setPinOutput_writeLow':
platforms/chibios/gpio.h:28:57: error: 'PAL_MODE_OUTPUT_PUSHPULL' undeclared (first use in this function); did you mean 'PAL_MODE_OUTPUT_OPENDRAIN'?
   28 | #define setPinOutputPushPull(pin) palSetLineMode((pin), PAL_MODE_OUTPUT_PUSHPULL)
      |                                                         ^~~~~~~~~~~~~~~~~~~~~~~~
./lib/chibios-contrib/os/hal/ports/LPC/LLD/GPIO/hal_pal_lld.h:368:34: note: in definition of macro 'pal_lld_setpadmode'
  368 |   _pal_lld_setpadmode(port, pad, mode)
      |                                  ^~~~
./lib/chibios/os/hal/include/hal_pal.h:809:3: note: in expansion of macro 'palSetPadMode'
  809 |   palSetPadMode(PAL_PORT(line), PAL_PAD(line), mode)
      |   ^~~~~~~~~~~~~
platforms/chibios/gpio.h:28:35: note: in expansion of macro 'palSetLineMode'
   28 | #define setPinOutputPushPull(pin) palSetLineMode((pin), PAL_MODE_OUTPUT_PUSHPULL)
      |                                   ^~~~~~~~~~~~~~
platforms/chibios/gpio.h:30:27: note: in expansion of macro 'setPinOutputPushPull'
   30 | #define setPinOutput(pin) setPinOutputPushPull(pin)
      |                           ^~~~~~~~~~~~~~~~~~~~
quantum/matrix.c:80:9: note: in expansion of macro 'setPinOutput'
   80 |         setPinOutput(pin);
      |         ^~~~~~~~~~~~
platforms/chibios/gpio.h:28:57: note: each undeclared identifier is reported only once for each function it appears in
   28 | #define setPinOutputPushPull(pin) palSetLineMode((pin), PAL_MODE_OUTPUT_PUSHPULL)
      |                                                         ^~~~~~~~~~~~~~~~~~~~~~~~
./lib/chibios-contrib/os/hal/ports/LPC/LLD/GPIO/hal_pal_lld.h:368:34: note: in definition of macro 'pal_lld_setpadmode'
  368 |   _pal_lld_setpadmode(port, pad, mode)
      |                                  ^~~~
./lib/chibios/os/hal/include/hal_pal.h:809:3: note: in expansion of macro 'palSetPadMode'
  809 |   palSetPadMode(PAL_PORT(line), PAL_PAD(line), mode)
      |   ^~~~~~~~~~~~~
platforms/chibios/gpio.h:28:35: note: in expansion of macro 'palSetLineMode'
   28 | #define setPinOutputPushPull(pin) palSetLineMode((pin), PAL_MODE_OUTPUT_PUSHPULL)
      |                                   ^~~~~~~~~~~~~~
platforms/chibios/gpio.h:30:27: note: in expansion of macro 'setPinOutputPushPull'
   30 | #define setPinOutput(pin) setPinOutputPushPull(pin)
      |                           ^~~~~~~~~~~~~~~~~~~~
quantum/matrix.c:80:9: note: in expansion of macro 'setPinOutput'
   80 |         setPinOutput(pin);
      |         ^~~~~~~~~~~~
quantum/matrix.c: In function 'setPinOutput_writeHigh':
platforms/chibios/gpio.h:28:57: error: 'PAL_MODE_OUTPUT_PUSHPULL' undeclared (first use in this function); did you mean 'PAL_MODE_OUTPUT_OPENDRAIN'?
   28 | #define setPinOutputPushPull(pin) palSetLineMode((pin), PAL_MODE_OUTPUT_PUSHPULL)
      |                                                         ^~~~~~~~~~~~~~~~~~~~~~~~
./lib/chibios-contrib/os/hal/ports/LPC/LLD/GPIO/hal_pal_lld.h:368:34: note: in definition of macro 'pal_lld_setpadmode'
  368 |   _pal_lld_setpadmode(port, pad, mode)
      |                                  ^~~~
./lib/chibios/os/hal/include/hal_pal.h:809:3: note: in expansion of macro 'palSetPadMode'
  809 |   palSetPadMode(PAL_PORT(line), PAL_PAD(line), mode)
      |   ^~~~~~~~~~~~~
platforms/chibios/gpio.h:28:35: note: in expansion of macro 'palSetLineMode'
   28 | #define setPinOutputPushPull(pin) palSetLineMode((pin), PAL_MODE_OUTPUT_PUSHPULL)
      |                                   ^~~~~~~~~~~~~~
platforms/chibios/gpio.h:30:27: note: in expansion of macro 'setPinOutputPushPull'
   30 | #define setPinOutput(pin) setPinOutputPushPull(pin)
      |                           ^~~~~~~~~~~~~~~~~~~~
quantum/matrix.c:87:9: note: in expansion of macro 'setPinOutput'
   87 |         setPinOutput(pin);
      |         ^~~~~~~~~~~~
 [ERRORS]
 | 
 | 
 | 
make[1]: *** [builddefs/common_rules.mk:361: .build/obj_corsair_k70_vengeance_rgb_default/quantum/matrix.o] Error 1
Make finished with errors
make: *** [Makefile:392: corsair/k70_vengeance_rgb:default] Error 1

If I uncomment the line it compiles fine.

@dexter93
Copy link
Contributor

per the chip docs, LPC11uxx doesn't have PAL_MODE_OUTPUT_PUSHPULL support ( at least, specified in the docs), hence the undef there. However, you are able to compile a working(-ish?) qmk build.
image

Digging a bit deeper,

commenting out the undef inherits the default value

 /**
   * @brief   Push-pull output pad.
   */
  #define PAL_MODE_OUTPUT_PUSHPULL        6U

which through qmk's abstraction

#define setPinOutputPushPull(pin) palSetLineMode((pin), PAL_MODE_OUTPUT_PUSHPULL)

goes all the way down to the LPC GPIO LLD, forwarding the value to

void _pal_lld_setpadmode(ioportid_t port, iopadid_t pad, iomode_t mode) {

The following condition gets calculated as false

  if (mode & MODE_DIR_MASK) {
    LPC_GPIO->DIR[LPC_IOPORT_NUM(port)] |= (uint32_t) 1U << pad;
  } else {
    LPC_GPIO->DIR[LPC_IOPORT_NUM(port)] &= ~(((uint32_t)1U) << pad);
  }

Which in turn sets the pin direction to input
image

The User Manual for the chip family has some directions on selecting GPIO output

image

while not specified by name, it might be possible to enable pushpull output by doing

#define PAL_MODE_OUTPUT_PUSHPULL   (MODE_DIR_OUT | MODE_AD_DIGITAL)

no clue if it will actually work however.

Re-writing the matrix scan routines in QMK to be open-drain compatible might be the more appropriate approach for your use-case

@Rayyanbaig1243
Copy link

I updated this file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants