Suggestions for SPI api
i noticed 1 working on spi api's. thought moment post remarks.
1. both spi begin() api's, reset data mode, bit order , divider defaults. invalidates previous calls setdatamode(), setbitorder() , setclockdivider(). doc not state should call these setters after begin(), , counter intuitive too. there avr code out there calls setters before begin(). better have begin() set data mode , friends values recorded in mode[], ... data fields. (and initialize these correctly).
2. find following bit counter intuitive:
i relate names miso, mosi , sck ss , therefore expect e.g. spi.setbitorder(ss, order) spi.setbitorder(order), not case.
i suggest this:
(i know break sketches, can still changed)
3. 2 macro's:
for sam:
for avr:
nothing world shocking sketch wants conservative use spi_clock_max ant compile sam , avr.
1. both spi begin() api's, reset data mode, bit order , divider defaults. invalidates previous calls setdatamode(), setbitorder() , setclockdivider(). doc not state should call these setters after begin(), , counter intuitive too. there avr code out there calls setters before begin(). better have begin() set data mode , friends values recorded in mode[], ... data fields. (and initialize these correctly).
2. find following bit counter intuitive:
code: [select]
static const uint8_t ss = board_spi_ss0;
i relate names miso, mosi , sck ss , therefore expect e.g. spi.setbitorder(ss, order) spi.setbitorder(order), not case.
i suggest this:
code: [select]
static const uint8_t ss0 = board_spi_ss0;
static const uint8_t ss = board_spi_default_ss ;
(i know break sketches, can still changed)
3. 2 macro's:
for sam:
code: [select]
#define spi_clock_min 1
#define spi_clock_max 255
for avr:
code: [select]
#define spi_clock_min spi_clock_div4
#define spi_clock_max spi_clock_div128
nothing world shocking sketch wants conservative use spi_clock_max ant compile sam , avr.
Arduino Forum > Products > Arduino Due (Moderator: fabioc84) > Suggestions for SPI api
arduino
Comments
Post a Comment