Commit 0417aba2 authored by Nicolas Pouillon's avatar Nicolas Pouillon

Add MutekH tests

parent 2b3c62a0
ifneq ($(CONFIG_BMAAA_BOARD),)
objs += $(CONFIG_BMAAA_BOARD).o
endif
%section bmaaa-pinky
%inherit nrf51-xxac
CONFIG_BMAAA
CONFIG_BMAAA_BOARD pinky
CONFIG_DRIVER_NRF5X_SPI
CONFIG_DRIVER_NRF5X_CLOCK
CONFIG_DRIVER_NRF5X_CLOCK_LFRC_CAL
CONFIG_DRIVER_NRF5X_TIMER
CONFIG_DRIVER_NRF5X_PRINTK_PIN 19
%common
%config CONFIG_BMAAA
desc BMAAA module
module bmaaa
%config end
%config CONFIG_BMAAA_BOARD
desc Board definition filename
flags value
parent CONFIG_BMAAA
%config end
/*
This file is part of MutekH.
MutekH is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; version 2.1 of the
License.
MutekH is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see
<http://www.gnu.org/licenses/>.
Copyright Nicolas Pouillon <nipo@ssji.net> (c) 2016
*/
#include <device/resources.h>
#include <device/class/iomux.h>
#include <device/class/i2c.h>
#include <device/class/uart.h>
#include <device/class/gpio.h>
#include <device/class/cmu.h>
#include <arch/nrf5x/ids.h>
DEV_DECLARE_STATIC(clock_dev, "clock", 0, nrf5x_clock_drv,
// Muxes
DEV_STATIC_RES_CMU_MUX(NRF_CLOCK_OSC_HFXO, NRF_CLOCK_SRC_HFCLK, 0b100, 1, 1),
DEV_STATIC_RES_CMU_MUX(NRF_CLOCK_OSC_HFRC, NRF_CLOCK_SRC_HFCLK, 0b011, 1, 1),
DEV_STATIC_RES_CMU_MUX(NRF_CLOCK_OSC_LFRC, NRF_CLOCK_SRC_LFCLK, 0b111, 1, 1),
// Oscillators
DEV_STATIC_RES_CMU_OSC_ACC(NRF_CLOCK_OSC_LFRC, 0b110, 32768, 1, 7, 18), // 246ppm
DEV_STATIC_RES_CMU_OSC_ACC(NRF_CLOCK_OSC_LFRC, 0b001, 32768, 1, 2, 25), // 2%
DEV_STATIC_RES_CMU_OSC_ACC(NRF_CLOCK_OSC_HFXO, 0b111, 32000000, 1, 7, 15), // 31ppm
DEV_STATIC_RES_CMU_OSC_ACC(NRF_CLOCK_OSC_HFRC, 0b111, 16000000, 1, 2, 25), // 2%
NRF_STATIC_RES_PERIPHERAL_MEM(NRF5X_CLOCK),
DEV_STATIC_RES_DEV_ICU("/cpu"),
DEV_STATIC_RES_IRQ(0, NRF5X_CLOCK, DEV_IRQ_SENSE_HIGH_LEVEL, 0, 1),
NRF_STATIC_RES_PERIPHERAL_MEM(NRF5X_TEMP),
DEV_STATIC_RES_IRQ(1, NRF5X_TEMP, DEV_IRQ_SENSE_HIGH_LEVEL, 0, 1),
);
#if defined(CONFIG_DRIVER_NRF5X_UART)
DEV_DECLARE_STATIC(uart_dev, "uart0", 0, nrf5x_uart_drv,
NRF_STATIC_RES_PERIPHERAL_MEM(NRF5X_UART0),
DEV_STATIC_RES_DEV_ICU("/cpu"),,
DEV_STATIC_RES_IRQ(0, NRF5X_UART0, DEV_IRQ_SENSE_HIGH_LEVEL, 0, 1)
DEV_STATIC_RES_DEV_IOMUX("/gpio"),
DEV_STATIC_RES_UART(1000000, 8, DEV_UART_PARITY_NONE, 1, 0, 0),
DEV_STATIC_RES_IOMUX("tx", 0, 19, 0, 0),
DEV_STATIC_RES_IOMUX("rx", 0, 20, 0, 0)
);
#endif
#if defined(CONFIG_DRIVER_NRF5X_SPI)
DEV_DECLARE_STATIC(spi_dev, "spi0", 0, nrf5x_spi_drv,
NRF_STATIC_RES_PERIPHERAL_MEM(NRF5X_SPI1),
DEV_STATIC_RES_DEV_ICU("/cpu"),
DEV_STATIC_RES_IRQ(0, NRF5X_SPI1, DEV_IRQ_SENSE_HIGH_LEVEL, 0, 1),
DEV_STATIC_RES_DEV_IOMUX("/gpio"),
DEV_STATIC_RES_IOMUX("clk", 0, 29, 0, 0),
DEV_STATIC_RES_IOMUX("mosi", 0, 28, 0, 0),
DEV_STATIC_RES_IOMUX("miso", 0, 27, 0, 0)
);
#endif
CONFIG_HEXO_CPU_STACK_SIZE 0x600
CONFIG_COMPILE_PIC undefined
CONFIG_COMPILE_FRAMEPTR undefined
CONFIG_COMPILE_MERGE
CONFIG_COMPILE_OPTIMIZE s
%include boards/bmaaa.build
%section nrf5?-*
CONFIG_DRIVER_NRF5X_CLOCK
CONFIG_DRIVER_NRF5X_RTC
CONFIG_DRIVER_NRF5X_PERSIST
CONFIG_DRIVER_NRF5X_AES
CONFIG_DRIVER_NRF5X_AES_RANDOM
CONFIG_DRIVER_NRF5X_RNG
CONFIG_DRIVER_NRF5X_NVMC
CONFIG_DRIVER_NRF5X_GPIO
CONFIG_MUTEK_PRINTK_ADDR 0x40002000
%subsection ble-*
CONFIG_DRIVER_NRF5X_AES_CCM
CONFIG_DRIVER_NRF5X_BLE
# CONFIG_DRIVER_BLE_RADIO
CONFIG_MUTEK_KROUTINE_IDLE
CONFIG_MUTEK_KROUTINE_SCHED
%end
%section nrf5x-ble-radio
CONFIG_DRIVER_NRF5X_BLE_RADIO
%section ble-peripheral
CONFIG_NET
CONFIG_BLE
CONFIG_BLE_PERIPHERAL
CONFIG_BLE_GATTDB_INCLUDE
%section ble-central
CONFIG_NET
CONFIG_BLE
CONFIG_BLE_CENTRAL
%section ble-security
CONFIG_BLE_SECURITY_DB
%inherit ble-crypto
%section ble-crypto
CONFIG_BLE_CRYPTO
CONFIG_DRIVER_NRF5X_PERSIST
CONFIG_DRIVER_NRF5X_AES
CONFIG_DRIVER_NRF5X_AES_RANDOM
CONFIG_DRIVER_NRF5X_AES_CCM
CONFIG_DRIVER_NRF5X_RNG
CONFIG_DRIVER_NRF5X_NVMC
%section ble-debug
CONFIG_DRIVER_NRF5X_BLE_DEBUG
%section printk
CONFIG_DRIVER_NRF5X_PRINTK
CONFIG_MUTEK_PRINTK_HEXDUMP
%section rtt
CONFIG_DRIVER_RTT
CONFIG_DRIVER_RTT_PRINTK
CONFIG_MUTEK_PRINTK_HEXDUMP
%section uart-shell
CONFIG_DRIVER_NRF5X_UART
CONFIG_DEVICE_UART
%inherit shell
%section rtt-shell
CONFIG_DRIVER_CHAR_RTT
CONFIG_DRIVER_CHAR_RTT_RX_BUFFER_SIZE 128
%inherit shell
%common
%include arch/arch.build
%include scripts/options.build
%set OUTPUT_NAME hello
%append MODULES $(OUTPUT_NAME):$(CONFIGPATH)
%include common.build
CONFIG_LICENSE_APP_BSD
CONFIG_APP_START
#include <mutek/startup.h>
#include <mutek/thread.h>
#include <mutek/printk.h>
#include <device/class/gpio.h>
#include <device/class/timer.h>
#define RS 18
#define D7 13
#define BACK 12
#define E 17
#define FIRST 12
#define LAST 18
static const uint64_t nibble_rev = 0xf7b3d591e6a2c480;
struct device_gpio_s gpio;
struct device_timer_s timer;
dev_timer_delay_t msec;
static void lcd_put(bool_t rs, uint8_t byte)
{
uint8_t val;
DEVICE_OP(&gpio, set_output, RS, RS,
rs ? dev_gpio_mask1 : dev_gpio_mask0,
rs ? dev_gpio_mask1 : dev_gpio_mask0);
val = nibble_rev >> ((byte >> 4) * 4);
DEVICE_OP(&gpio, set_output, D7, D7 + 3, &val, &val);
DEVICE_OP(&gpio, set_output, E, E, dev_gpio_mask0, dev_gpio_mask0);
dev_timer_wait_delay(&timer, msec, 0);
DEVICE_OP(&gpio, set_output, E, E, dev_gpio_mask1, dev_gpio_mask1);
dev_timer_wait_delay(&timer, msec, 0);
val = nibble_rev >> ((byte & 0xf) * 4);
DEVICE_OP(&gpio, set_output, D7, D7 + 3, &val, &val);
DEVICE_OP(&gpio, set_output, E, E, dev_gpio_mask0, dev_gpio_mask0);
dev_timer_wait_delay(&timer, msec, 0);
DEVICE_OP(&gpio, set_output, E, E, dev_gpio_mask1, dev_gpio_mask1);
dev_timer_wait_delay(&timer, msec, 0);
}
static void lcd_put_string(char *str)
{
while (*str)
lcd_put(1, *str++);
}
static CONTEXT_ENTRY(lcd_hello)
{
lcd_put(0, 0x33);
dev_timer_wait_delay(&timer, msec * 4, 0);
lcd_put(0, 0x33);
dev_timer_wait_delay(&timer, msec * 4, 0);
lcd_put(0, 0x32);
lcd_put(0, 0x28);
lcd_put(0, 0x08);
lcd_put(0, 0x01);
lcd_put(0, 0x06);
lcd_put(0, 0x0c);
lcd_put_string("Hello,");
lcd_put(0, 0xc0);
lcd_put_string("world !");
}
void app_start()
{
error_t err;
printk("Hello World!\n");
err = device_get_accessor_by_path(&gpio.base, NULL, "/gpio*", DRIVER_CLASS_GPIO);
assert(!err);
err = device_get_accessor_by_path(&timer.base, NULL, "/rtc*", DRIVER_CLASS_TIMER);
assert(!err);
DEVICE_OP(&gpio, set_output, FIRST, LAST, dev_gpio_mask1, dev_gpio_mask1);
DEVICE_OP(&gpio, set_output, BACK, BACK, dev_gpio_mask0, dev_gpio_mask0);
DEVICE_OP(&gpio, set_mode, FIRST, LAST, dev_gpio_mask1, DEV_PIN_PUSHPULL);
dev_timer_init_sec(&timer, &msec, 0, 1, 1000);
thread_create(lcd_hello, 0, NULL);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment