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

hamilton-combined-v9.0 basic app #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions apds-9007-app/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
APPLICATION = hamilton_apds9007_easyapp
RIOTBASE ?= /home/hskim/Desktop/rebase/RIOT-OS
BOARD = hamilton

# System functions
USEMODULE += random
USEMODULE += xtimer
USEMODULE += rtt_stdio
CFLAGS += -DRTT_STDIO_DISABLE_STDIN
CFLAGS += -DTHREAD_STACKSIZE_DEFAULT=2048

# CPU clock speed
CFLAGS += -DCLOCK_USE_OSCULP32_DFLL=1

# Sensors
USEMODULE += saul_reg # SAUL: sensor/actuator abstraction layer
USEMODULE += auto_init_saul
USEMODULE += tmp006 # ambient temperature
USEMODULE += hdc1000 # humidity and temperature
USEMODULE += fxos8700 # acceleration and magnetic field
USEMODULE += apds9007 # illumination
USEMODULE += ekmb1101111 # pir-based occupancy
USEMODULE += push_button # simple button

# Security
USEMODULE += crypto
USEMODULE += cipher_modes
CFLAGS += -DCRYPTO_AES

CFLAGS += -DAUTO_CSMA_EN=1

# Radio
USEMODULE += at86rf2xx
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=26

# Network
USEMODULE += gnrc_netdev_default
USEMODULE += auto_init_gnrc_netif
# Duty-cycling
USEMODULE += gnrc_lasmac
CFLAGS += -DDUTYCYCLE_SLEEP_INTERVAL=00000UL # If it is ZERO, no duty-cycling for packet reception
CFLAGS += -DLEAF_NODE=1 # Default is 1
# Specify the mandatory networking modules for IPv6 and UDP
USEMODULE += gnrc_ipv6
USEMODULE += gnrc_udp
CFLAGS += -DSOCK_HAS_IPV6
# Add also the shell, some shell commands
USEMODULE += netstats_l2
USEMODULE += netstats_ipv6


# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
# CFLAGS += -DDEVELHELP

QUIET ?= 1

FEATURES_REQUIRED += periph_timer

include $(RIOTBASE)/Makefile.include
61 changes: 61 additions & 0 deletions apds-9007-app/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <stdio.h>
#include <rtt_stdio.h>
#include "xtimer.h"
#include <string.h>
#include "net/gnrc/udp.h"
#include "phydat.h"
#include "saul_reg.h"
#include "periph/adc.h"
#include "periph/dmac.h"
#include "periph/timer.h"

#define ENABLE_DEBUG (1)
#include "debug.h"

#ifndef SAMPLE_INTERVAL
#define SAMPLE_INTERVAL ( 10000000UL)
#endif

saul_reg_t *sensor_light_t = NULL;

void critical_error(void) {
DEBUG("CRITICAL ERROR, REBOOT\n");
NVIC_SystemReset();
return;
}

void sensor_config(void) {
sensor_light_t = saul_reg_find_type(SAUL_SENSE_LIGHT);
if (sensor_light_t == NULL) {
DEBUG("[ERROR] Failed to init LIGHT sensor\n");
critical_error();
} else {
DEBUG("LIGHT sensor OK\n");
}
}

/* ToDo: Sampling sequence arrangement or thread/interrupt based sensing may be better */
void sample(void) {
phydat_t output; /* Sensor output data (maximum 3-dimension)*/
int dim; /* Demension of sensor output */

/* Illumination 1-dim */
dim = saul_reg_read(sensor_light_t, &output);
(void) dim;
}

int main(void) {
dmac_init();
adc_set_dma_channel(0);

sensor_config();
LED_OFF;

while (1) {
//Sample
sample();
xtimer_usleep(SAMPLE_INTERVAL);
}

return 0;
}
61 changes: 61 additions & 0 deletions hamilton-combined-v9.0-app/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
APPLICATION = hamilton_easyapp
RIOTBASE ?= /home/hskim/Desktop/rebase/RIOT-OS
BOARD = hamilton

# System functions
USEMODULE += random
USEMODULE += xtimer
USEMODULE += rtt_stdio
CFLAGS += -DRTT_STDIO_DISABLE_STDIN
CFLAGS += -DTHREAD_STACKSIZE_DEFAULT=2048

# CPU clock speed
CFLAGS += -DCLOCK_USE_OSCULP32_DFLL=1

# Sensors
USEMODULE += saul_reg # SAUL: sensor/actuator abstraction layer
USEMODULE += auto_init_saul
USEMODULE += tmp006 # ambient temperature
USEMODULE += hdc1000 # humidity and temperature
USEMODULE += fxos8700 # acceleration and magnetic field
USEMODULE += apds9007 # illumination
USEMODULE += ekmb1101111 # pir-based occupancy
USEMODULE += push_button # simple button

# Security
USEMODULE += crypto
USEMODULE += cipher_modes
CFLAGS += -DCRYPTO_AES

CFLAGS += -DAUTO_CSMA_EN=1

# Radio
USEMODULE += at86rf2xx
CFLAGS += -DIEEE802154_DEFAULT_CHANNEL=26

# Network
USEMODULE += gnrc_netdev_default
USEMODULE += auto_init_gnrc_netif
# Duty-cycling
USEMODULE += gnrc_lasmac
CFLAGS += -DDUTYCYCLE_SLEEP_INTERVAL=00000UL # If it is ZERO, no duty-cycling for packet reception
CFLAGS += -DLEAF_NODE=1 # Default is 1
# Specify the mandatory networking modules for IPv6 and UDP
USEMODULE += gnrc_ipv6
USEMODULE += gnrc_udp
CFLAGS += -DSOCK_HAS_IPV6
# Add also the shell, some shell commands
USEMODULE += netstats_l2
USEMODULE += netstats_ipv6


# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
# CFLAGS += -DDEVELHELP

QUIET ?= 1

FEATURES_REQUIRED += periph_timer

include $(RIOTBASE)/Makefile.include
Loading