Compare commits

...

10 commits

Author SHA1 Message Date
Luke Wren
b73332122d Add gpio_get_out_level() accessor, and correct SIO GPIO_OUT struct type from WO to RW 2021-03-11 14:19:44 +00:00
Andrew Scheller
a2576202ff Add param-validation to spin_lock_instance 2021-03-10 11:06:34 +00:00
Andrew Scheller
26fd36f853 Fixup incorrect doxygen for multicore_fifo_wready 2021-03-10 11:01:51 +00:00
graham sanderson
3ad5e1570c missing group rubbish: 2021-03-10 11:00:42 +00:00
graham sanderson
a2c7d7507b build: fix mismatched config descriptions 2021-03-10 11:00:42 +00:00
graham sanderson
ea40696827 fix config type 2021-03-10 11:00:42 +00:00
graham sanderson
5867849b17 start development of 1.2.0 2021-03-10 11:00:42 +00:00
Christian Flach
6f7dc67791
pio: allow programs with 32 instructions (#236) 2021-03-08 12:48:28 -06:00
Christian Flach
090c5cd83b
pio: Add 'pragma once' to generated header files (#237)
We can't really use traditional include guards, because the header file may be piped to stdout (which means we might not have a file name).
2021-03-08 12:21:36 -06:00
Andrew Scheller
20b9823aca
Delete some redundant CMake parts (#240) 2021-03-08 12:02:22 -06:00
9 changed files with 43 additions and 69 deletions

View file

@ -1,12 +1,20 @@
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, pico_base # PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base
# PICO_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, pico_base # PICO_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base
set(PICO_SDK_VERSION_MAJOR 1) set(PICO_SDK_VERSION_MAJOR 1)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, pico_base # PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
# PICO_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, pico_base # PICO_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
set(PICO_SDK_VERSION_MINOR 1) set(PICO_SDK_VERSION_MINOR 2)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, pico_base # PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
# PICO_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, pico_base # PICO_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
set(PICO_SDK_VERSION_REVISION 0) set(PICO_SDK_VERSION_REVISION 0)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
# PICO_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
set(PICO_SDK_VERSION_PRE_RELEASE_ID develop)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base # PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base
# PICO_CONFIG: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base # PICO_CONFIG: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base
set(PICO_SDK_VERSION_STRING "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}") set(PICO_SDK_VERSION_STRING "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}")
if (PICO_SDK_VERSION_PRE_RELEASE_ID)
set(PICO_SDK_VERSION_STRING "${PICO_SDK_VERSION_STRING}-${PICO_SDK_VERSION_PRE_RELEASE_ID}")
endif()

View file

@ -17,7 +17,7 @@ typedef struct {
io_ro_32 gpio_hi_in; io_ro_32 gpio_hi_in;
uint32_t _pad; uint32_t _pad;
io_wo_32 gpio_out; io_rw_32 gpio_out;
io_wo_32 gpio_set; io_wo_32 gpio_set;
io_wo_32 gpio_clr; io_wo_32 gpio_clr;
io_wo_32 gpio_togl; io_wo_32 gpio_togl;
@ -27,7 +27,7 @@ typedef struct {
io_wo_32 gpio_oe_clr; io_wo_32 gpio_oe_clr;
io_wo_32 gpio_oe_togl; io_wo_32 gpio_oe_togl;
io_wo_32 gpio_hi_out; io_rw_32 gpio_hi_out;
io_wo_32 gpio_hi_set; io_wo_32 gpio_hi_set;
io_wo_32 gpio_hi_clr; io_wo_32 gpio_hi_clr;
io_wo_32 gpio_hi_togl; io_wo_32 gpio_hi_togl;

View file

@ -415,6 +415,26 @@ static inline void gpio_put(uint gpio, bool value) {
gpio_clr_mask(mask); gpio_clr_mask(mask);
} }
/*! \brief Determine whether a GPIO is currently driven high or low
* \ingroup hardware_gpio
*
* This function returns the high/low output level most recently assigned to a
* GPIO via gpio_put() or similar. This is the value that is presented outward
* to the IO muxing, *not* the input level back from the pad (which can be
* read using gpio_get()).
*
* To avoid races, this function must not be used for read-modify-write
* sequences when driving GPIOs -- instead functions like gpio_put() should be
* used to atomically update GPIOs. This accessor is intended for debug use
* only.
*
* \param gpio GPIO number
* \return true if the GPIO output level is high, false if low.
*/
static inline bool gpio_get_out_level(uint gpio) {
return !!(sio_hw->gpio_out & 1u << gpio);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Direction // Direction
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View file

@ -54,7 +54,7 @@ static_assert(PIO_INSTRUCTION_COUNT <= 32, "");
static uint32_t _used_instruction_space[2]; static uint32_t _used_instruction_space[2];
static int _pio_find_offset_for_program(PIO pio, const pio_program_t *program) { static int _pio_find_offset_for_program(PIO pio, const pio_program_t *program) {
assert(program->length < PIO_INSTRUCTION_COUNT); assert(program->length <= PIO_INSTRUCTION_COUNT);
uint32_t used_mask = _used_instruction_space[pio_get_index(pio)]; uint32_t used_mask = _used_instruction_space[pio_get_index(pio)];
uint32_t program_mask = (1u << program->length) - 1; uint32_t program_mask = (1u << program->length) - 1;
if (program->origin >= 0) { if (program->origin >= 0) {

View file

@ -194,6 +194,7 @@ inline static void restore_interrupts(uint32_t status) {
* \return The spinlock instance * \return The spinlock instance
*/ */
inline static spin_lock_t *spin_lock_instance(uint lock_num) { inline static spin_lock_t *spin_lock_instance(uint lock_num) {
invalid_params_if(SYNC, lock_num >= NUM_SPIN_LOCKS);
return (spin_lock_t *) (SIO_BASE + SIO_SPINLOCK0_OFFSET + lock_num * 4); return (spin_lock_t *) (SIO_BASE + SIO_SPINLOCK0_OFFSET + lock_num * 4);
} }

View file

@ -84,10 +84,10 @@ static inline bool multicore_fifo_rvalid(void) {
return !!(sio_hw->fifo_st & SIO_FIFO_ST_VLD_BITS); return !!(sio_hw->fifo_st & SIO_FIFO_ST_VLD_BITS);
} }
/*! \brief Check the FIFO to see if the write FIFO is full /*! \brief Check the write FIFO to see if it is ready for more data
* \ingroup multicore_fifo * \ingroup multicore_fifo
* *
* @return true if the FIFO is full, false otherwise * @return true if the FIFO has room for more data, false otherwise
*/ */
static inline bool multicore_fifo_wready(void) { static inline bool multicore_fifo_wready(void) {
return !!(sio_hw->fifo_st & SIO_FIFO_ST_RDY_BITS); return !!(sio_hw->fifo_st & SIO_FIFO_ST_RDY_BITS);

View file

@ -44,17 +44,3 @@ function(pico_add_uf2_output TARGET)
COMMAND ELF2UF2 ${TARGET}${CMAKE_EXECUTABLE_SUFFIX} ${TARGET}.uf2) COMMAND ELF2UF2 ${TARGET}${CMAKE_EXECUTABLE_SUFFIX} ${TARGET}.uf2)
endif() endif()
endfunction() endfunction()
if (NOT DEFINED PICO_BUILD_PICOFLASH)
if (DEFINED ENV{PICO_BUILD_PICOFLASH})
set(PICO_BUILD_PICOFLASH $ENV{PICO_BUILD_PICOFLASH})
else()
# for now
set(PICO_BUILD_PICOFLASH 1)
endif()
endif()
if (PICO_BUILD_PICOTOOL)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PICO_SDK_PATH}/tools)
find_package(Picotool REQUIRED)
endif()

View file

@ -1,43 +0,0 @@
# Finds (or builds) the PICOTOOL executable
#
# This will define the following variables
#
# PICOTOOL_FOUND
#
# and the following imported targets
#
# PICOTOOL
#
if (NOT PICOTOOL_FOUND)
# todo we would like to use pckgconfig to look for it first
# see https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
include(ExternalProject)
set(PICOTOOL_SOURCE_DIR ${PICO_SDK_PATH}/tools/picotool)
set(PICOTOOL_BINARY_DIR ${CMAKE_BINARY_DIR}/picotool)
set(PICOTOOL_BUILD_TARGET PicotoolBuild)
set(PICOTOOL_TARGET Picotool)
if (NOT TARGET ${PICOTOOL_BUILD_TARGET})
message("PICOTOOL will need to be built")
ExternalProject_Add(${PICOTOOL_BUILD_TARGET}
PREFIX picotool SOURCE_DIR ${PICOTOOL_SOURCE_DIR}
BINARY_DIR ${PICOTOOL_BINARY_DIR}
BUILD_ALWAYS 1 # force dependency checking
INSTALL_COMMAND ""
)
endif()
set(PICOTOOL_EXECUTABLE ${PICOTOOL_BINARY_DIR}/picotool)
if(NOT TARGET ${PICOTOOL_TARGET})
add_executable(${PICOTOOL_TARGET} IMPORTED)
endif()
set_property(TARGET ${PICOTOOL_TARGET} PROPERTY IMPORTED_LOCATION
${PICOTOOL_EXECUTABLE})
add_dependencies(${PICOTOOL_TARGET} ${PICOTOOL_BUILD_TARGET})
set(PICOTOOL_FOUND 1)
endif()

View file

@ -68,6 +68,8 @@ struct c_sdk_output : public output_format {
header(out, "This file is autogenerated by pioasm; do not edit!"); header(out, "This file is autogenerated by pioasm; do not edit!");
fprintf(out, "#pragma once\n");
fprintf(out, "\n");
fprintf(out, "#if !PICO_NO_HARDWARE\n"); fprintf(out, "#if !PICO_NO_HARDWARE\n");
fprintf(out, "#include \"hardware/pio.h\"\n"); fprintf(out, "#include \"hardware/pio.h\"\n");
fprintf(out, "#endif\n"); fprintf(out, "#endif\n");