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

Add Bangle.JS2 smart watch board support #18554

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

nica-f
Copy link

@nica-f nica-f commented Sep 4, 2022

boards: bangle-js2, remove no more needed module

boards: bangle/js2, remove sector count, will get auto detected

boards: bangle-js2, reformat comments for coding style

boards: bangle-js2, remove unnecessary definition of openocd

boards: Add Bangle-JS2 smart watch board support

Adds board support for the Bangle-JS2 smart watch.

Running on my watch for several days :-)

Resolves #18553

boards: bangle-js2, remove no more needed module

boards: bangle/js2, remove sector count, will get auto detected

boards: bangle-js2, reformat comments for coding style

boards: bangle-js2, remove unnecessary definition of openocd
@github-actions github-actions bot added Area: boards Area: Board ports Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration labels Sep 4, 2022
@benpicco benpicco requested a review from maribu September 4, 2022 23:32
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static tests have some complains and // C++ comments should be converted to /* C-style comments */

USEMODULE += mtd_spi_nor
endif

USEMODULE += cst816s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
USEMODULE += cst816s
ifneq (,$(filter touch_dev,$(USEMODULE)))
USEMODULE += cst816s
endif


void board_power_off(void)
{
ztimer_sleep(ZTIMER_MSEC, 5);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing happens before the sleep - what is is good for?

};

mtd_dev_t *mtd0 = (mtd_dev_t *)&banglejs2_nor_dev;
#endif /* MODULE_MTD */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to have a file system on the external flash you could add

#ifdef MODULE_VFS_DEFAULT
#include "vfs_default.h"
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(banglejs2_nor_dev), VFS_DEFAULT_NVM(0), 0);
#endif

here and

ifneq (,$(filter vfs_default,$(USEMODULE)))
  USEPKG += littlefs2
  USEMODULE += mtd
endif

to Makefile.dep

@@ -0,0 +1,102 @@
Bangle.js 2 - Pinout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go to doc.txt

.dev = NRF_SPIM2,
.sclk = LCD_SCK,
.mosi = LCD_MOSI,
//.miso = GPIO_UNDEF,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better set .miso = GPIO_UNDEF, since GPIO_UNDEF is not necessarily 0.

Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Some comments inline, mostly style nitpicks.

#include "timex.h"
#include "ztimer.h"


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

The CI dislikes more than one consecutive blank line

static const mtd_spi_nor_params_t _banglejs2_nor_params = {
.opcode = &mtd_spi_nor_opcode_default,
.wait_chip_erase = 9LU * US_PER_SEC,
.wait_32k_erase = 160LU *US_PER_MS,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.wait_32k_erase = 160LU *US_PER_MS,
.wait_32k_erase = 160LU * US_PER_MS,

mtd_dev_t *mtd0 = (mtd_dev_t *)&banglejs2_nor_dev;
#endif /* MODULE_MTD */


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

}

if (pwm_init(PWM_DEV(1), PWM_RIGHT, 1250, 100) > 0) {
pwm_set(PWM_DEV(1), 0, 50); /* 50% duty cylce @ 125kHz for EXTCOM ? */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will likely contribute to power consumption. I am not sure how PWM is implemented on the nRF5x, but mostly a high frequency timer peripheral is used. This in turn leads to the PLL generating the CPU clock remaining active.

/* power off peripherals as much as we can */
gpio_clear(LCD_DISP);
pwm_poweroff(PWM_DEV(0)); /* LCD ExtCOM */
pwm_poweroff(PWM_DEV(1)); /* LCD backlight */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments regarding LCD extcom / backlight are in reverse order compared to the init functions. I didn't check which one is correct.

// LCD backlight
{ NRF_PWM0, { LCD_BACKLIGHT, GPIO_UNDEF, GPIO_UNDEF, GPIO_UNDEF } },
// LCD EXTCOM
{ NRF_PWM1, { LCD_EXTCOMIN, GPIO_UNDEF, GPIO_UNDEF, GPIO_UNDEF } },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the LCD backlight and ghe LCD EXTCOM couldbe driven from the same PWM device, just as channel 0 and channel 1. This would of course only work if the same frequency would work with both. But it may make handling easier, if those need to be enabled simultaneously anyway.

* @{
*/
static const pwm_conf_t pwm_config[] = {
// LCD backlight
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// LCD backlight
/* LCD backlight */

static const pwm_conf_t pwm_config[] = {
// LCD backlight
{ NRF_PWM0, { LCD_BACKLIGHT, GPIO_UNDEF, GPIO_UNDEF, GPIO_UNDEF } },
// LCD EXTCOM
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// LCD EXTCOM
/* LCD EXTCOM */

{ NRF_PWM0, { LCD_BACKLIGHT, GPIO_UNDEF, GPIO_UNDEF, GPIO_UNDEF } },
// LCD EXTCOM
{ NRF_PWM1, { LCD_EXTCOMIN, GPIO_UNDEF, GPIO_UNDEF, GPIO_UNDEF } },
// vibration motor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// vibration motor
/* vibration motor */

#define PWM_NUMOF ARRAY_SIZE(pwm_config)

/** @} */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@benpicco
Copy link
Contributor

benpicco commented Oct 5, 2022

@nica-f ping 😉

@benpicco benpicco requested a review from OlegHahm October 25, 2022 21:35
@benpicco
Copy link
Contributor

Should we take over this PR?

@@ -0,0 +1,13 @@
# use JLink Segger RTT by default
RIOT_TERMINAL ?= jlink
Copy link
Member

@OlegHahm OlegHahm Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be openocd-rtt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants