Skip to content

Commit

Permalink
- Add skeleton for RV-8263-C8 RTC
Browse files Browse the repository at this point in the history
- Rename display driver to match it with the vendor_type scheme of the other drivers
- Remove Funkytown song from Buzzer driver
  • Loading branch information
Kampi committed May 27, 2024
1 parent 8152f4b commit 50b9d2b
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 20 deletions.
3 changes: 1 addition & 2 deletions app/boards/arm/zswatch_nrf5340/zswatch_nrf5340_cpuapp_5.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
CONFIG_ZSWATCH_PCB_REV=5
CONFIG_BT_DIS_HW_REV_STR="5"

#---------------
# FLASH
#-----------------
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_STREAM_FLASH=y
Expand Down Expand Up @@ -49,3 +47,4 @@ CONFIG_NVS=y

CONFIG_DEBUG_COREDUMP_BACKEND_OTHER=y

CONFIG_RTC=y
22 changes: 21 additions & 1 deletion app/boards/arm/zswatch_nrf5340/zswatch_nrf5340_cpuapp_5.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<NRF_PSEL(QSPI_IO3, 0, 16)>;
low-power-enable;
};

group2 {
psels = <NRF_PSEL(QSPI_CSN, 0, 18)>;
low-power-enable;
Expand Down Expand Up @@ -125,21 +126,25 @@

buttons: buttons {
compatible = "gpio-keys";

button1: button_1 {
label = "top-right";
gpios = <&gpio0 27 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
zephyr,code = <INPUT_KEY_1>;
};

button2: button_2 {
label = "bottom-left";
gpios = <&gpio1 10 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
zephyr,code = <INPUT_KEY_2>;
};

button3: button_3 {
label = "bottom-right";
gpios = <&gpio0 31 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
zephyr,code = <INPUT_KEY_KP0>;
};

button4: button_4 {
label = "top-left";
gpios = <&gpio0 26 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
Expand Down Expand Up @@ -167,12 +172,15 @@

pwmleds {
compatible = "pwm-leds";

display_blk: pwm_led_0 {
pwms = <&pwm0 0 PWM_USEC(15) PWM_POLARITY_INVERTED>;
};

vibrator_pwm: pwm_led_1 {
pwms = <&pwm1 0 PWM_MSEC(20) 0>;
};

buzzer_pwm: pwm_led_2 {
pwms = <&pwm2 0 PWM_HZ(880) PWM_POLARITY_NORMAL>;
};
Expand All @@ -181,6 +189,12 @@
};

&i2c1 {
rv_8263_c8: rv-8263-c8@A2 {
compatible = "microcrystal,rv-8263-c8";
reg = <0xA2>;
status = "okay";
};

bmi270: bmi270@68 {
compatible = "bosch,bmi270-plus";
reg = <0x68>;
Expand All @@ -200,6 +214,7 @@
resolution = <0>;
frequency = <0>;
};

npm1300_ek_pmic: pmic@6b {
compatible = "nordic,npm1300";
reg = <0x6b>;
Expand Down Expand Up @@ -253,6 +268,7 @@
thermistor-beta = <3380>;
charging-enable;
};

npm1300_ek_buttons: buttons {
compatible = "gpio-keys";
status = "disabled";
Expand Down Expand Up @@ -286,6 +302,7 @@
pinctrl-0 = <&qspi_default>;
pinctrl-1 = <&qspi_sleep>;
pinctrl-names = "default", "sleep";

gd25lq128d: gd25lq128d@0 {
compatible = "nordic,qspi-nor";
reg = <0>;
Expand All @@ -309,6 +326,7 @@
/ {
fstab {
compatible = "zephyr,fstab";

lvgl_lfs: lvgl_lfs {
compatible = "zephyr,fstab,littlefs";
mount-point = "/lvgl_lfs";
Expand Down Expand Up @@ -336,13 +354,15 @@
label = "littlefs_storage";
reg = <0x00000000 0x00200000>;
};

lvgl_raw_partition: partition@200000 {
label = "lvgl_raw_partition";
reg = <0x00200000 0x00200000>;
};

storage_partition: partition@400000 {
label = "storage_partition";
reg = <0x400000 0x100000 >;
};
};
};
};
1 change: 1 addition & 0 deletions app/drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_subdirectory(display)
add_subdirectory(input)
add_subdirectory(rtc)

add_subdirectory_ifdef(CONFIG_SENSOR sensor)
1 change: 1 addition & 0 deletions app/drivers/Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
rsource "display/Kconfig"
rsource "input/Kconfig"
rsource "rtc/Kconfig"

menu "Drivers"
rsource "sensor/Kconfig"
Expand Down
2 changes: 1 addition & 1 deletion app/drivers/display/gc9a01/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
zephyr_sources(gc9a01.c)
zephyr_sources(buydisplay_gc9a01.c)
File renamed without changes.
6 changes: 6 additions & 0 deletions app/drivers/rtc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2024, Daniel Kampert
#
# SPDX-License-Identifier: Apache-2.0
#

add_subdirectory_ifdef(CONFIG_RV_8263_C8 rv8263c8)
3 changes: 3 additions & 0 deletions app/drivers/rtc/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if RTC
rsource "rv8263c8/Kconfig"
endif
6 changes: 6 additions & 0 deletions app/drivers/rtc/rv8263c8/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2024, Daniel Kampert
#
# SPDX-License-Identifier: Apache-2.0
#

zephyr_sources(microcrystal_rv8263c8.c)
21 changes: 21 additions & 0 deletions app/drivers/rtc/rv8263c8/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# RV-8263-C8 RTC configuration options.

# Copyright (c) 240, Daniel Kampert
#
# SPDX-License-Identifier: Apache-2.0

menuconfig RV_8263_C8
bool "RV-8263-C8 RTC"
depends on DT_HAS_MICROCRYSTAL_RV_8263_C8_ENABLED
default y
select I2C
help
Enable the driver for the RV-8263-C8 RTC.

if RV_8263_C8

module = MICROCRYSTAL_RV_8263_C8
module-str = MICROCRYSTAL_RV_8263_C8
source "subsys/logging/Kconfig.template.log_config"

endif
79 changes: 79 additions & 0 deletions app/drivers/rtc/rv8263c8/microcrystal_rv8263c8.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* microcrystal_rv8263c8.c - Driver for Micro Crystal RV-8263-C8 RTC. */

/*
* Copyright (c) 2024, Daniel Kampert
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/rtc.h>
#include <zephyr/pm/device.h>
#include <zephyr/pm/device_runtime.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/byteorder.h>

#include "microcrystal_rv8263c8.h"

#define RV8263C8_REGISTER_CONTROL1 0x00
#define RV8263C8_REGISTER_CONTROL2 0x01
#define RV8263C8_REGISTER_OFFSET 0x02
#define RV8263C8_REGISTER_RAM 0x03
#define RV8263C8_REGISTER_SECONDS 0x04
#define RV8263C8_REGISTER_MINUTES 0x05
#define RV8263C8_REGISTER_HOURS 0x06
#define RV8263C8_REGISTER_DATE 0x07
#define RV8263C8_REGISTER_WEEKDAY 0x08
#define RV8263C8_REGISTER_MONTH 0x09
#define RV8263C8_REGISTER_YEAR 0x0A
#define RV8263C8_REGISTER_SECONDS_ALARM 0x0B
#define RV8263C8_REGISTER_MINUTES_ALARM 0x0C
#define RV8263C8_REGISTER_HOURS_ALARM 0x0D
#define RV8263C8_REGISTER_DATE_ALARM 0x0E
#define RV8263C8_REGISTER_WEEKDAY_ALARM 0x0F
#define RV8263C8_REGISTER_TIMER_VALUE 0x10
#define RV8263C8_REGISTER_TIMER_MODE 0x11

#define DT_DRV_COMPAT microcrystal_rv_8263_c8

LOG_MODULE_REGISTER(microcrystal_rv8263c8, CONFIG_MICROCRYSTAL_RV_8263_C8_LOG_LEVEL);

struct rv8263c8_config {
struct i2c_dt_spec i2c_bus;
};

struct rv8263c8_data {
struct k_spinlock lock;
};

static const struct rtc_driver_api rv8263c8_driver_api = {
.set_time = NULL,
.get_time = NULL,
};

static int rv8263c8_init(const struct device *dev)
{
int err;
const struct rv8263c8_config *config = dev->config;

if (!i2c_is_ready_dt(&config->i2c_bus)) {
LOG_ERR("I2C bus not ready");
return -ENODEV;
}

return 0;
}

#define RV8263C8_DEFINE(inst) \
static struct rv8263c8_data rv8263c8_data_##inst; \
static const struct rv8263c8_config rv8263c8_config_##inst = { \
.i2c_bus = I2C_DT_SPEC_INST_GET(inst), \
}; \
DEVICE_DT_INST_DEFINE(inst, &rv8263c8_init, NULL, &rv8263c8_data_##inst, \
&rv8263c8_config_##inst, POST_KERNEL, CONFIG_RTC_INIT_PRIORITY, \
&rv8263c8_driver_api);

DT_INST_FOREACH_STATUS_OKAY(RV8263C8_DEFINE)
9 changes: 9 additions & 0 deletions app/drivers/rtc/rv8263c8/microcrystal_rv8263c8.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* microcrystal_rv8263c8.h - Driver for Micro Crystal RV-8263-C8 RTC. */

/*
* Copyright (c 2024, Daniel Kampert
*
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once
9 changes: 9 additions & 0 deletions app/dts/bindings/rtc/microcrystal,rv-8263-c8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
description: |
The RV-8263-C8 is a CMOS real-time clock/calendar module optimized for low power consumption. An Offset
register makes it possible to compensate for the frequency deviation of the clock of 32.768 kHz
compatible: "microcrystal,rv-8263-c8"

include: [rtc-device.yaml, i2c-device.yaml]

#properties:
16 changes: 0 additions & 16 deletions app/src/drivers/zsw_buzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,6 @@ static void buzzer_off_work_handler(struct k_work *work);
static void run_next_tone_state(note_duration_t *state);
static void pattern_timer_timeout(struct k_timer *timer_id);

static struct note_duration_t funkytown_song[] = {
{.note = C5, .duration = quarter},
{.note = REST, .duration = eigth},
{.note = C5, .duration = quarter},
{.note = Bb4, .duration = quarter},
{.note = C5, .duration = quarter},
{.note = REST, .duration = quarter},
{.note = G4, .duration = quarter},
{.note = REST, .duration = quarter},
{.note = G4, .duration = quarter},
{.note = C5, .duration = quarter},
{.note = F5, .duration = quarter},
{.note = E5, .duration = quarter},
{.note = C5, .duration = quarter}
};

static struct note_duration_t mario_song[] = {
{.note = E6, .duration = quarter},
{.note = REST, .duration = eigth},
Expand Down

0 comments on commit 50b9d2b

Please sign in to comment.