Transfer spi into c++

This commit is contained in:
Thomas Klaehn
2020-03-29 20:43:56 +02:00
parent 7f1721a536
commit 53aa3ceda6
17 changed files with 131 additions and 4899 deletions

View File

@@ -1,5 +1,5 @@
#include "delay.h"
#include "platform/gpio.h"
#include "platform/hal.h"
using namespace hal;

View File

@@ -1,36 +0,0 @@
#include "app_util_platform.h"
#include "nrf_gpio.h"
#include "nrf_delay.h"
#include "boards.h"
#include "app_error.h"
#include <string.h>
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#include "board.h"
#include "driver.h"
const char buf[] = "Test";
int main(void)
{
unsigned int cnt = 0;
APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
NRF_LOG_DEFAULT_BACKENDS_INIT();
drv_open(&led_1);
drv_open(&spi_0);
NRF_LOG_INFO("SPI example started.");
while(1) {
char c = (cnt++ % 2) + 0x30;
drv_write(&led_1, &c, 1);
drv_write(&spi_0, buf, sizeof(buf));
NRF_LOG_FLUSH();
nrf_delay_ms(200);
}
}

View File

@@ -0,0 +1,19 @@
#include "delay.h"
#include "platform/hal.h"
using namespace hal;
const uint8_t buf[] = "Test";
int main(void)
{
Gpio led_1(17);
Spi spi_0(0, 2, 3, 4, 25);
while(1) {
delay_ms(200);
spi_0.send(buf, sizeof(buf));
led_1.toggle();
}
}