1 /*""FILE COMMENT""******************************************************* 2 * System Name : Serial Peripheral Interface API for RX62Nxx 3 * File Name : r_pdl_spi_RX62Nxx.h 4 * Version : 1.02 5 * Contents : SPI API header 6 * Customer : 7 * Model : 8 * Order : 9 * CPU : RX 10 * Compiler : RXC 11 * OS : Nothing 12 * Programmer : 13 * Note : 14 ************************************************************************ 15 * Copyright, 2011. Renesas Electronics Corporation 16 * and Renesas Solutions Corporation 17 ************************************************************************ 18 * History : 2011.04.08 19 * : Ver 1.02 20 * : CS-5 release. 21 *""FILE COMMENT END""**************************************************/ 22 23 #ifndef R_PDL_SPI_RX62Nxx_H 24 #define R_PDL_SPI_RX62Nxx_H 25 26 #define SPI_CHANNELS 2 27 #define SPI_COMMANDS 8 28 29 /* Globals */ 30 extern volatile uint8_t rpdl_SPI_method[SPI_CHANNELS]; 31 extern volatile uint16_t rpdl_SPI_sequence_count[SPI_CHANNELS]; 32 extern volatile uint16_t rpdl_SPI_tx_sequence_counter[SPI_CHANNELS]; 33 extern volatile uint16_t rpdl_SPI_rx_sequence_counter[SPI_CHANNELS]; 34 extern volatile uint8_t rpdl_SPI_tx_frame_counter[SPI_CHANNELS]; 35 extern volatile uint8_t rpdl_SPI_frame_total[SPI_CHANNELS]; 36 extern volatile uint8_t rpdl_SPI_rx_frame_counter[SPI_CHANNELS]; 37 extern volatile const uint32_t * rpdl_SPI_tx_ptr[SPI_CHANNELS]; 38 extern volatile uint32_t * rpdl_SPI_rx_ptr[SPI_CHANNELS]; 39 40 /* Callback function prototypes */ 41 extern VoidCallBackFunc rpdl_SPI_callback_func[SPI_CHANNELS]; 42 43 /* Request trigger options */ 44 typedef enum { 45 SPI_USING_POLLING, 46 SPI_USING_IRQ, 47 SPI_USING_DMAC_DTC 48 } rpdl_spi_transfer_options; 49 50 bool R_SPI_CreateAll( 51 const uint8_t, 52 const uint32_t, 53 const uint32_t, 54 const uint32_t, 55 const uint32_t 56 ); 57 bool R_SPI_DestroyAll( 58 const uint8_t 59 ); 60 bool R_SPI_CommandAll( 61 const uint8_t, 62 const uint8_t, 63 const uint32_t, 64 const uint8_t 65 ); 66 bool R_SPI_TransferAll( 67 const uint8_t, 68 const uint8_t, 69 volatile const uint32_t * const, 70 volatile uint32_t * const, 71 const uint16_t, 72 VoidCallBackFunc const, 73 const uint8_t 74 ); 75 bool R_SPI_ControlAll( 76 const uint8_t, 77 const uint8_t, 78 const uint32_t 79 ); 80 bool R_SPI_GetStatusAll( 81 const uint8_t, 82 volatile uint16_t * const, 83 volatile uint16_t * const 84 ); 85 bool ReturnFalse(void); 86 87 /* Macro definitions */ 88 #define R_SPI_Create(a, b, c, d, e) \ 89 ( \ 90 ( (a) < SPI_CHANNELS) ? \ 91 R_SPI_CreateAll( (a), (b), (c), (d), (e) ): \ 92 ReturnFalse() \ 93 ) 94 95 #define R_SPI_Destroy(a) \ 96 ( \ 97 ( (a) < SPI_CHANNELS) ? \ 98 R_SPI_DestroyAll( (a) ): \ 99 ReturnFalse() \ 100 ) 101 102 #define R_SPI_Command(a, b, c, d) \ 103 ( \ 104 ( ( ((a) < SPI_CHANNELS) && ((b) < SPI_COMMANDS) ) ) ? \ 105 R_SPI_CommandAll( (a), (b), (c), (d) ): \ 106 ReturnFalse() \ 107 ) 108 109 #define R_SPI_Transfer(a, b, c, d, e, f, g) \ 110 ( \ 111 ( ( ((a) < SPI_CHANNELS) && ((g) <= IPL_MAX) ) ) ? \ 112 R_SPI_TransferAll( (a), (b), (c), (d), (e), (f), (g) ): \ 113 ReturnFalse() \ 114 ) 115 116 #define R_SPI_Control(a, b, c) \ 117 ( \ 118 ( (a) < SPI_CHANNELS) ? \ 119 R_SPI_ControlAll( (a), (b), (c) ): \ 120 ReturnFalse() \ 121 ) 122 123 #define R_SPI_GetStatus(a, b, c) \ 124 ( \ 125 ( (a) < SPI_CHANNELS) ? \ 126 R_SPI_GetStatusAll( (a), (b), (c) ): \ 127 ReturnFalse() \ 128 ) 129 130 #endif 131 /* End of file */ 132