From: Nathael Pajani Date: Thu, 24 Sep 2020 04:13:22 +0000 (+0200) Subject: Fix coments and add macro for SPI X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=2e43b0dd488e8f174da51c1ea51a3c4d474457c0;p=soft%2Flpc122x%2Fcore Fix coments and add macro for SPI --- diff --git a/include/drivers/ssp.h b/include/drivers/ssp.h index 3f765ef..bbbfe7d 100644 --- a/include/drivers/ssp.h +++ b/include/drivers/ssp.h @@ -57,7 +57,7 @@ void spi_release_mutex(uint8_t ssp_num); /***************************************************************************** */ /* This function is used to transfer a word (4 to 16 bits) to AND from a device * As the SPI bus is full duplex, data can flow in both directions, but the clock is - * always provided by the master. The SPI clock cannont be activated without sending + * always provided by the master. The SPI clock cannot be activated without sending * data, which means we must send data to the device when we want to read data from * the device. * Note : the SSP device number is not checked, thus a value above the number of SSP @@ -82,6 +82,8 @@ uint16_t spi_transfer_single_frame(uint8_t ssp_num, uint16_t data); * pointed by "data_out" for each frame. If NULL, then the content of data_in * will be used. * data_in : buffer for read data. If NULL, read data will be discarded. + * width : used to differentiate between size up to 8 bits and above 8 bits. + * Use LPC_SSP_WORD_LEN(x) macro. * Returns the number of data words transfered or negative value on error. * As the SPI bus is full duplex, data can flow in both directions, but the clock is * always provided by the master. The SPI clock cannont be activated without sending @@ -93,6 +95,8 @@ uint16_t spi_transfer_single_frame(uint8_t ssp_num, uint16_t data); int spi_transfer_multiple_frames(uint8_t ssp_num, void* data_out, void* data_in, int size, int width); +#define LPC_SSP_WORD_LEN(x) (x) +#define LPC_SSP_MHz(x) ((x) * 1000 * 1000) /***************************************************************************** */ void ssp_clk_update(void); @@ -104,8 +108,8 @@ void ssp_clk_update(void); * Parameters : * frame_type is SPI, TI or MICROWIRE (use apropriate defines for this one). * LPC_SSP_FRAME_SPI - LPC_SSP_FRAME_TI - LPC_SSP_FRAME_MICROWIRE). - * data_width is a number between 4 and 16. - * rate : The bit rate, in Hz. + * data_width is a number between 4 and 16. Use LPC_SSP_WORD_LEN(x) macro for this one. + * rate : The bit rate, in Hz. Use LPC_SSP_MHz(x) macro to get Hz from MHz value. * The SPI Chip Select is not handled by the SPI driver in master SPI mode as it's * handling highly depends on the device on the other end of the wires. Use a GPIO * to activate the device's chip select (usually active low)