project init
This commit is contained in:
44
CMakeLists.txt
Normal file
44
CMakeLists.txt
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Generated Cmake Pico project file
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
# Enforce board type
|
||||||
|
set(PICO_BOARD "ADAFRUIT_FEATHER_RP2040")
|
||||||
|
|
||||||
|
# Initialise pico_sdk from installed location
|
||||||
|
# (note this can come from environment, CMake cache etc)
|
||||||
|
set(PICO_SDK_PATH "/Users/mchapman/source/pico/pico-sdk")
|
||||||
|
|
||||||
|
# Pull in Raspberry Pi Pico SDK (must be before project)
|
||||||
|
include(pico_sdk_import.cmake)
|
||||||
|
|
||||||
|
project(traegerController C CXX ASM)
|
||||||
|
|
||||||
|
# Initialise the Raspberry Pi Pico SDK
|
||||||
|
pico_sdk_init()
|
||||||
|
|
||||||
|
# Add executable. Default name is the project name, version 0.1
|
||||||
|
|
||||||
|
add_executable(traegerController traegerController.cpp )
|
||||||
|
|
||||||
|
pico_set_program_name(traegerController "traegerController")
|
||||||
|
pico_set_program_version(traegerController "0.1")
|
||||||
|
|
||||||
|
pico_enable_stdio_uart(traegerController 0)
|
||||||
|
pico_enable_stdio_usb(traegerController 1)
|
||||||
|
|
||||||
|
# Add the standard library to the build
|
||||||
|
target_link_libraries(traegerController pico_stdlib)
|
||||||
|
|
||||||
|
# Add any user requested libraries
|
||||||
|
target_link_libraries(traegerController
|
||||||
|
hardware_spi
|
||||||
|
hardware_i2c
|
||||||
|
hardware_timer
|
||||||
|
)
|
||||||
|
|
||||||
|
pico_add_extra_outputs(traegerController)
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# This is a generated file and its contents are an internal implementation detail.
|
||||||
|
# The download step will be re-executed if anything in this file changes.
|
||||||
|
# No other meaning or use of this file is supported.
|
||||||
|
|
||||||
|
method=source_dir
|
||||||
|
command=
|
||||||
|
source_dir=/Users/mchapman/source/pico/pico-sdk/tools/elf2uf2
|
||||||
|
work_dir=
|
||||||
|
|
||||||
1
build/elf2uf2/tmp/ELF2UF2Build-cfgcmd.txt
Normal file
1
build/elf2uf2/tmp/ELF2UF2Build-cfgcmd.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cmd='/opt/homebrew/Cellar/cmake/3.23.2/bin/cmake;-GUnix Makefiles;<SOURCE_DIR><SOURCE_SUBDIR>'
|
||||||
19
build/elf2uf2/tmp/ELF2UF2Build-mkdirs.cmake
Normal file
19
build/elf2uf2/tmp/ELF2UF2Build-mkdirs.cmake
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
file(MAKE_DIRECTORY
|
||||||
|
"/Users/mchapman/source/pico/pico-sdk/tools/elf2uf2"
|
||||||
|
"/Users/mchapman/source/traegerController/build/elf2uf2"
|
||||||
|
"/Users/mchapman/source/traegerController/build/elf2uf2"
|
||||||
|
"/Users/mchapman/source/traegerController/build/elf2uf2/tmp"
|
||||||
|
"/Users/mchapman/source/traegerController/build/elf2uf2/src/ELF2UF2Build-stamp"
|
||||||
|
"/Users/mchapman/source/traegerController/build/elf2uf2/src"
|
||||||
|
"/Users/mchapman/source/traegerController/build/elf2uf2/src/ELF2UF2Build-stamp"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(configSubDirs )
|
||||||
|
foreach(subDir IN LISTS configSubDirs)
|
||||||
|
file(MAKE_DIRECTORY "/Users/mchapman/source/traegerController/build/elf2uf2/src/ELF2UF2Build-stamp/${subDir}")
|
||||||
|
endforeach()
|
||||||
11
build/generated/pico_base/pico/config_autogen.h
Normal file
11
build/generated/pico_base/pico/config_autogen.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// AUTOGENERATED FROM PICO_CONFIG_HEADER_FILES and then PICO_<PLATFORM>_CONFIG_HEADER_FILES
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
|
||||||
|
// based on PICO_CONFIG_HEADER_FILES:
|
||||||
|
|
||||||
|
#include "/Users/mchapman/source/pico/pico-sdk/src/boards/include/boards/ADAFRUIT_FEATHER_RP2040.h"
|
||||||
|
|
||||||
|
// based on PICO_RP2040_CONFIG_HEADER_FILES:
|
||||||
|
|
||||||
|
#include "/Users/mchapman/source/pico/pico-sdk/src/rp2_common/cmsis/include/cmsis/rename_exceptions.h"
|
||||||
19
build/generated/pico_base/pico/version.h
Normal file
19
build/generated/pico_base/pico/version.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ---------------------------------------
|
||||||
|
// THIS FILE IS AUTOGENERATED; DO NOT EDIT
|
||||||
|
// ---------------------------------------
|
||||||
|
|
||||||
|
#ifndef _PICO_VERSION_H
|
||||||
|
#define _PICO_VERSION_H
|
||||||
|
|
||||||
|
#define PICO_SDK_VERSION_MAJOR 1
|
||||||
|
#define PICO_SDK_VERSION_MINOR 3
|
||||||
|
#define PICO_SDK_VERSION_REVISION 1
|
||||||
|
#define PICO_SDK_VERSION_STRING "1.3.1"
|
||||||
|
|
||||||
|
#endif
|
||||||
73
pico_sdk_import.cmake
Normal file
73
pico_sdk_import.cmake
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
# This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake
|
||||||
|
|
||||||
|
# This can be dropped into an external project to help locate this SDK
|
||||||
|
# It should be include()ed prior to project()
|
||||||
|
|
||||||
|
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
|
||||||
|
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
|
||||||
|
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT))
|
||||||
|
set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT})
|
||||||
|
message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH))
|
||||||
|
set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH})
|
||||||
|
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
|
||||||
|
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
|
||||||
|
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
|
||||||
|
|
||||||
|
if (NOT PICO_SDK_PATH)
|
||||||
|
if (PICO_SDK_FETCH_FROM_GIT)
|
||||||
|
include(FetchContent)
|
||||||
|
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
|
||||||
|
if (PICO_SDK_FETCH_FROM_GIT_PATH)
|
||||||
|
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
||||||
|
endif ()
|
||||||
|
# GIT_SUBMODULES_RECURSE was added in 3.17
|
||||||
|
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
|
||||||
|
FetchContent_Declare(
|
||||||
|
pico_sdk
|
||||||
|
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||||
|
GIT_TAG master
|
||||||
|
GIT_SUBMODULES_RECURSE FALSE
|
||||||
|
)
|
||||||
|
else ()
|
||||||
|
FetchContent_Declare(
|
||||||
|
pico_sdk
|
||||||
|
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||||
|
GIT_TAG master
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (NOT pico_sdk)
|
||||||
|
message("Downloading Raspberry Pi Pico SDK")
|
||||||
|
FetchContent_Populate(pico_sdk)
|
||||||
|
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
|
||||||
|
endif ()
|
||||||
|
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
|
||||||
|
else ()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
|
||||||
|
if (NOT EXISTS ${PICO_SDK_PATH})
|
||||||
|
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
|
||||||
|
if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
|
||||||
|
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
|
||||||
|
|
||||||
|
include(${PICO_SDK_INIT_CMAKE_FILE})
|
||||||
60
traegerController.cpp
Normal file
60
traegerController.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "pico/stdlib.h"
|
||||||
|
#include "hardware/spi.h"
|
||||||
|
#include "hardware/i2c.h"
|
||||||
|
#include "hardware/timer.h"
|
||||||
|
|
||||||
|
// SPI Defines
|
||||||
|
// We are going to use SPI 0, and allocate it to the following GPIO pins
|
||||||
|
// Pins can be changed, see the GPIO function select table in the datasheet for information on GPIO assignments
|
||||||
|
#define SPI_PORT spi0
|
||||||
|
#define PIN_MISO 16
|
||||||
|
#define PIN_CS 17
|
||||||
|
#define PIN_SCK 18
|
||||||
|
#define PIN_MOSI 19
|
||||||
|
|
||||||
|
// I2C defines
|
||||||
|
// This example will use I2C0 on GPIO8 (SDA) and GPIO9 (SCL) running at 400KHz.
|
||||||
|
// Pins can be changed, see the GPIO function select table in the datasheet for information on GPIO assignments
|
||||||
|
#define I2C_PORT i2c0
|
||||||
|
#define I2C_SDA 8
|
||||||
|
#define I2C_SCL 9
|
||||||
|
|
||||||
|
int64_t alarm_callback(alarm_id_t id, void *user_data) {
|
||||||
|
// Put your timeout handler code in here
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
stdio_init_all();
|
||||||
|
|
||||||
|
// SPI initialisation. This example will use SPI at 1MHz.
|
||||||
|
spi_init(SPI_PORT, 1000*1000);
|
||||||
|
gpio_set_function(PIN_MISO, GPIO_FUNC_SPI);
|
||||||
|
gpio_set_function(PIN_CS, GPIO_FUNC_SIO);
|
||||||
|
gpio_set_function(PIN_SCK, GPIO_FUNC_SPI);
|
||||||
|
gpio_set_function(PIN_MOSI, GPIO_FUNC_SPI);
|
||||||
|
|
||||||
|
// Chip select is active-low, so we'll initialise it to a driven-high state
|
||||||
|
gpio_set_dir(PIN_CS, GPIO_OUT);
|
||||||
|
gpio_put(PIN_CS, 1);
|
||||||
|
|
||||||
|
|
||||||
|
// I2C Initialisation. Using it at 400Khz.
|
||||||
|
i2c_init(I2C_PORT, 400*1000);
|
||||||
|
|
||||||
|
gpio_set_function(I2C_SDA, GPIO_FUNC_I2C);
|
||||||
|
gpio_set_function(I2C_SCL, GPIO_FUNC_I2C);
|
||||||
|
gpio_pull_up(I2C_SDA);
|
||||||
|
gpio_pull_up(I2C_SCL);
|
||||||
|
|
||||||
|
// Timer example code - This example fires off the callback after 2000ms
|
||||||
|
add_alarm_in_ms(2000, alarm_callback, NULL, false);
|
||||||
|
|
||||||
|
puts("Hello, world!");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user