[英]nrf51822 / YJ-14015 Blinky
我正在嘗試在blinky
china clone (YJ-14015)上構建一個簡單的第一個閃爍,作為構建氧化還原無線和調試 BLE 通信為何不起作用的一部分。
作為 SDK,我使用nrf5_SDK_11
作為鍵盤自定義固件基於它。
現在我用main.c
嘗試了一個非常小的示例閃爍
#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "nrf_gpio.h"
#define LED_PIN_1 1 // LED connected to pin 1
/* --> from nrf5_SDK_11/components/drivers_nrf/hal/nrf_gpio.h
__STATIC_INLINE void nrf_gpio_pin_set(uint32_t pin_number)
{
NRF_GPIO->OUTSET = (1UL << pin_number);
}
__STATIC_INLINE void nrf_gpio_pin_clear(uint32_t pin_number)
{
NRF_GPIO->OUTCLR = (1UL << pin_number);
}
*/
int main(void)
{
// Make LED pin an output pin
nrf_gpio_cfg_output(LED_PIN_1);
nrf_gpio_pin_set(LED_PIN_1);
// Toggle LEDs.
while (true)
{
// Down
NRF_GPIO->OUTCLR = (NRF_GPIO->OUT & (1UL << LED_PIN_1));
// nrf_gpio_pin_clear(LED_PIN_1);
nrf_delay_ms(1000);
// Up
NRF_GPIO->OUTSET= (NRF_GPIO->OUT | (1UL << LED_PIN_1));
// nrf_gpio_pin_set(LED_PIN_1);
nrf_delay_ms(1000);
}
}
我的期望是我可以在PIN 01
上看到電壓從高到低到高每秒翻轉一次……不幸的是,如果我將它連接到我的萬用表上,我只能得到1.55 V
對地電壓,但電壓只是保持不變不變,沒有任何改變。 我在這個循環中做錯了什么嗎?
對於閃爍,我使用ST-LinkV2 克隆+ docker 容器用於 openocd 和redox 無線項目的工具鏈,它基本上使用 telnet over openocd。 調整正確路徑后,閃爍似乎成功,如上所述, PIN 01
可以設置為1.55V
,所以我認為閃爍本身沒有問題。
如果其他人遇到同樣的困難:
過了一會兒,我想出了一種方法來修復yj-14015
的blinky
示例。 關鍵是根據氧化還原固件中的Makefile
調整我從北歐SDK拿來的Makefile。
相關行如下:
#flags common to all targets
CFLAGS = -DNRF51
CFLAGS += -DGAZELL_PRESENT
CFLAGS += -DBOARD_CUSTOM
CFLAGS += -DBSP_DEFINES_ONLY
CFLAGS += -mcpu=cortex-m0
CFLAGS += -mthumb -mabi=aapcs --std=gnu99
CFLAGS += -Wall -Werror -O3 -g3
CFLAGS += -Wno-unused-function
CFLAGS += -Wno-unused-variable
CFLAGS += -mfloat-abi=soft
# keep every function in separate section. This will allow linker to dump unused functions
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
CFLAGS += -fno-builtin --short-enums
# Assembler flags
ASMFLAGS += -x assembler-with-cpp
ASMFLAGS += -DNRF51
ASMFLAGS += -DGAZELL_PRESENT
ASMFLAGS += -DBOARD_CUSTOM
ASMFLAGS += -DBSP_DEFINES_ONLY
這將是完整的Makefile 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.