uf2-samdx1/inc/uart_driver.h
Scott Shawcroft aa9868d3f2 Re-org build in preparation for SAMD51 support.
SAMD51 builds

Enumerates ok but flash doesn't work.

Do manual flash writes and slow delay down when we have a much faster clock.

DM: fixed nvmctrl math in erase

DM: actually I think they want manual page writes

Re-enabled self-updater with SAMD51 support.

Get the version dynamically from git.

Correct flash offset now that we use a uint8_t pointer.

Turn on the neopixel.

Fix M0 compilation by avoiding USB macro.

Add board.mk files for every board.

Clean up ignores

Add grove zero board config file.

Don't use M0 name in the Zero bootloader

add board.mk for grove-zero

Add version info to all generated files.
Add .ino generation to scripts/gendata.py.
Clean up Makefile to handle new version number generation.

Note that Adafruit release tags will be v<a>.<b>.<c>-adafruit.<n>.
The first part of the tag is the upstream version. The <n> is the
Adafruit increment from that.

add pirkey and itsybitsy m0
change dotstar brightness to account for new 'dimmer' apa102's
update makefile to not use py3

consistancy and missing CRYSTALLESS

special metro m0 delay to avoid SWD contention while programming

Update to more recent Arduino

Add comment

Restore IRQs in neopixel functions

Remove -mlong-calls and add -nostartfiles; see #29
  Thanks @awatterott!

Avoid global writes in handover

Handle first read after handover correctly

V1.24; Add O marker for fixed MSC handover

Make the bootloader data go first in binary to avoid HardFault when erasing first page

Update samd pkg version

Fixes for WebUSB support

Fix Windows build

Remove WebUSB landing page support

add _binfo defn to linker scripts for doing usermode handover.

add proper serial number to USB descriptor; fix compile warning
2018-02-13 13:34:31 -05:00

107 lines
3.5 KiB
C

/* ----------------------------------------------------------------------------
* SAM Software Package License
* ----------------------------------------------------------------------------
* Copyright (c) 2011-2014, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following condition is met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef UART_DRIVER_H
#define UART_DRIVER_H
#include "sam.h"
#include <stdbool.h>
#include <stdio.h>
#define PINMUX_UNUSED 0xFFFFFFFF
#define GCLK_ID_SERCOM0_CORE 0x14
/* SERCOM UART available pad settings */
enum uart_pad_settings {
UART_RX_PAD0_TX_PAD2 = SERCOM_USART_CTRLA_RXPO(0) | SERCOM_USART_CTRLA_TXPO(1),
UART_RX_PAD1_TX_PAD2 = SERCOM_USART_CTRLA_RXPO(1) | SERCOM_USART_CTRLA_TXPO(1),
UART_RX_PAD2_TX_PAD0 = SERCOM_USART_CTRLA_RXPO(2),
UART_RX_PAD3_TX_PAD0 = SERCOM_USART_CTRLA_RXPO(3),
UART_RX_PAD1_TX_PAD0 = SERCOM_USART_CTRLA_RXPO(1),
UART_RX_PAD3_TX_PAD2 = SERCOM_USART_CTRLA_RXPO(3) | SERCOM_USART_CTRLA_TXPO(1),
};
/**
* \brief Gets the index of the provided SERCOM instance
*
* \param Pointer to SERCOM instance
* \return Index of the SERCOM module
*/
uint32_t uart_get_sercom_index(Sercom *sercom_instance);
/**
* \brief Initializes the UART
*
* \param Pointer to SERCOM instance
* \param Baud value corresponding to the desired baudrate
* \param SERCOM pad settings
*/
void uart_basic_init(Sercom *sercom, uint16_t baud_val, enum uart_pad_settings pad_conf);
/**
* \brief Disables UART interface
*
* \param Pointer to SERCOM instance
*/
void uart_disable(Sercom *sercom);
/**
* \brief Sends a single byte through UART interface
*
* \param Pointer to SERCOM instance
* \param Data to send
*/
void uart_write_byte(Sercom *sercom, uint8_t data);
/**
* \brief Reads a single character from UART interface
*
* \param Pointer to SERCOM instance
* \return Data byte read
*/
uint8_t uart_read_byte(Sercom *sercom);
/**
* \brief Sends buffer on UART interface
*
* \param Pointer to SERCOM instance
* \param Pointer to data to send
* \param Number of bytes to send
*/
void uart_write_buffer_polled(Sercom *sercom, uint8_t *ptr, uint16_t length);
/**
* \brief Reads data on UART interface
*
* \param Pointer to SERCOM instance
* \param Pointer to store read data
* \param Number of bytes to read
*/
void uart_read_buffer_polled(Sercom *sercom, uint8_t *ptr, uint16_t length);
#endif