LoginSignup
0
0

More than 1 year has passed since last update.

MacでSeeed XIAO RP2040 C++,C開発

Last updated at Posted at 2022-08-14

環境

  • Intel Mac monterey Version.12.5
  • arm-none-eabi-gcc Version.10.3.1
  • cmake

参考文献

XIAOのBボタンを押しながら、USBケーブルを接続した後、USBドライブのindex.htmをオープンする。
The C/C++ SDKとExampleのリポジトリなどPICOに関するドキュメントへジャンプする。

手順

  • SDKクローン
git clone -b master https://github.com/raspberrypi/pico-sdk.git
cd pico-sdk
git submodule update --init
  • Exampleのクローン
git clone -b master https://github.com/raspberrypi/pico-examples.git
  • 環境変数設定
    • export PICO_SDK_PATH=[pico-sdkへのパス]
    • export PICO_TOOLCHAIN_PATH=[arm-none-eabi-gccへのパス]
  • サンプルコンパイル
    • buildディレクトリ作成
    • cd build
    • cmake Exampleへのパス
    • cd blink
    • make
  • uf2ファイルをXIAOへ書き込む
    • Bボタンを押しながら、USBケーブルを繋ぐ。
    • 現れたUSBドライブにuf2ファイルをドロップ

pico-exampleのコンパイル

cd pico-example
mkdir build
cd build

cmakeの実行とターゲットのリスト表示

cmake -D"PICO_BOARD=seeed_xiao_rp2040" -GNinja ..
ninja -t targets

コンパイル
ninja target名

pio_ws2812

PICO_DEFAULT_WS2812_POWER_PINを出力に設定し、1を出力する.

	#ifdef PICO_DEFAULT_WS2812_POWER_PIN
	gpio_init(PICO_DEFAULT_WS2812_POWER_PIN);
	gpio_set_dir(PICO_DEFAULT_WS2812_POWER_PIN, GPIO_OUT);
	gpio_put(PICO_DEFAULT_WS2812_POWER_PIN, 1);
   	#endif

USBにデバック出力する場合、CMakefileに追加

   # Debug output - Enable for USB CDC and disable for on-board UART
   # You can change these around (or even have both active) by changing the 1s and 0s
   pico_enable_stdio_usb(pio_ws2812 1)
   pico_enable_stdio_uart(pio_ws2812 0)

usbに出力する場合、MACがポートを利用できるまでにリセットから2秒以上かかるので、 
exampleのhello_timerを参照してwaitをかける。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0