| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2011, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bspi.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/19 $ |
|---|
| 12 | * $brcm_Date: 5/5/11 2:14p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/spi/7038/bspi.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/19 5/5/11 2:14p agin |
|---|
| 21 | * SW7346-170: Update bpi.h to reflect 3 channels for 7346. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/18 5/13/10 3:32p jkim |
|---|
| 24 | * CR3548-909: change the prototyp to match the function definitions in .c |
|---|
| 25 | * file |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/17 5/7/10 6:41p jkim |
|---|
| 28 | * CR3548-909: implement get function for SetDTLConfig() and Set |
|---|
| 29 | * RDSCLKConfig() |
|---|
| 30 | * |
|---|
| 31 | * Hydra_Software_Devel/16 10/24/08 3:40p farshidf |
|---|
| 32 | * PR47943: update the SPI mac channel for 3549/3556 |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/15 10/22/08 2:28p farshidf |
|---|
| 35 | * PR47943: add the default settings for channel 2 |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/14 10/13/08 3:36p jkim |
|---|
| 38 | * PR46713: modify function prototype per magnum coding guideline |
|---|
| 39 | * |
|---|
| 40 | * Hydra_Software_Devel/13 5/21/07 4:14p jkim |
|---|
| 41 | * PR14344: add flag to use Dt and DSCK |
|---|
| 42 | * |
|---|
| 43 | * Hydra_Software_Devel/12 5/18/07 9:49a erickson |
|---|
| 44 | * PR14344: fix prototype |
|---|
| 45 | * |
|---|
| 46 | * Hydra_Software_Devel/11 5/17/07 10:29a jkim |
|---|
| 47 | * PR14344: modified to support slower devices. DTL and RDSCLK are now |
|---|
| 48 | * settable. |
|---|
| 49 | * |
|---|
| 50 | * Hydra_Software_Devel/10 3/18/05 6:50p agin |
|---|
| 51 | * PR14520: keypad for 97398 |
|---|
| 52 | * |
|---|
| 53 | * Hydra_Software_Devel/9 2/9/04 6:42p brianlee |
|---|
| 54 | * PR242: Added support for 16-bit transfer mode. |
|---|
| 55 | * |
|---|
| 56 | * Hydra_Software_Devel/8 1/28/04 10:22a brianlee |
|---|
| 57 | * PR9499: Fixed breg_spi.h file inclusion. |
|---|
| 58 | * |
|---|
| 59 | * Hydra_Software_Devel/7 11/6/03 9:51a brianlee |
|---|
| 60 | * Added the function BSPI_CloseSpiRegHandle(). |
|---|
| 61 | * |
|---|
| 62 | * Hydra_Software_Devel/6 10/15/03 2:42p brianlee |
|---|
| 63 | * Moved #define MAX_SPI_CHANNELS here so application can use it. |
|---|
| 64 | * |
|---|
| 65 | * Hydra_Software_Devel/5 9/25/03 12:17p brianlee |
|---|
| 66 | * Fixed tags for Midas service generator. |
|---|
| 67 | * |
|---|
| 68 | * Hydra_Software_Devel/4 9/17/03 4:48p lseverin |
|---|
| 69 | * fixed a few documentation warnings |
|---|
| 70 | * |
|---|
| 71 | * Hydra_Software_Devel/3 9/11/03 6:24p brianlee |
|---|
| 72 | * Modified default setting structure. Also fixed sample code. |
|---|
| 73 | * |
|---|
| 74 | * Hydra_Software_Devel/2 7/31/03 10:04a brianlee |
|---|
| 75 | * Removed read/write/setclk functions. These are now private. The |
|---|
| 76 | * application should use the register handle to access read/write |
|---|
| 77 | * functions. |
|---|
| 78 | * |
|---|
| 79 | * Hydra_Software_Devel/1 7/23/03 11:46a brianlee |
|---|
| 80 | * Initial version. |
|---|
| 81 | * |
|---|
| 82 | ***************************************************************************/ |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | /*= Module Overview ********************************************************* |
|---|
| 86 | <verbatim> |
|---|
| 87 | |
|---|
| 88 | Overview |
|---|
| 89 | The SPI PI module controls the SPI master core within the BCM7038. |
|---|
| 90 | The SPI master core supports several slave devices as selected by the |
|---|
| 91 | slave select signals. For the BCM7038, the SPI core supports 2 slave |
|---|
| 92 | selects. The SPI clock is configurable upon channel opening. It can |
|---|
| 93 | be set from 53 Khz to 1.6875 Mhz. By default, the SPI PI will set the |
|---|
| 94 | baud rate to the maximum value, 1.6875 Mhz. |
|---|
| 95 | |
|---|
| 96 | Design |
|---|
| 97 | The design for BSPI PI API is broken into two parts. |
|---|
| 98 | |
|---|
| 99 | o Part 1 (open/close/configuration): |
|---|
| 100 | |
|---|
| 101 | These APIs are used for opening and closing BSPI device/device channel. |
|---|
| 102 | When a device/device channel is opened, the device/device channel can be |
|---|
| 103 | configured for transfer speed. |
|---|
| 104 | |
|---|
| 105 | o Part 2 (command): |
|---|
| 106 | |
|---|
| 107 | These APIs are sending read and write commands using the SPI master controller. |
|---|
| 108 | |
|---|
| 109 | Usage |
|---|
| 110 | The usage of BSPI involves the following: |
|---|
| 111 | |
|---|
| 112 | * Configure/Open of BSPI |
|---|
| 113 | |
|---|
| 114 | * Configure BSPI device for the target system |
|---|
| 115 | * Open BSPI device |
|---|
| 116 | * Configure BSPI device channel for the target system |
|---|
| 117 | * Open BSPI device channel |
|---|
| 118 | * Create BSPI register handle |
|---|
| 119 | |
|---|
| 120 | * Sending commands |
|---|
| 121 | |
|---|
| 122 | * Send read/write commands using BSPI register handle. |
|---|
| 123 | |
|---|
| 124 | Sample Code |
|---|
| 125 | void main( void ) |
|---|
| 126 | { |
|---|
| 127 | BSPI_Handle hSpi; |
|---|
| 128 | BSPI_ChannelHandle hSpiChan; |
|---|
| 129 | BSPI_ChannelSettings defChnSettings; |
|---|
| 130 | BREG_Handle hReg; |
|---|
| 131 | BCHP_Handle hChip; |
|---|
| 132 | BINT_Handle hInt; |
|---|
| 133 | unsigned int chanNo; |
|---|
| 134 | uint8_t writeBuf[8]; |
|---|
| 135 | uint8_t readBuf[8]; |
|---|
| 136 | BREG_SPI_Handle hSpiReg; |
|---|
| 137 | |
|---|
| 138 | // Do other initialization, i.e. for BREG, BCHP, etc. |
|---|
| 139 | BSPI_Open( &hSpi, hChip, hReg, hInt, (BSPI_Settings *)NULL ); |
|---|
| 140 | |
|---|
| 141 | chanNo= 0; // example for channel 0 |
|---|
| 142 | BSPI_GetChannelDefaultSettings( hSpi, chanNo, &defChnSettings ); |
|---|
| 143 | |
|---|
| 144 | // Make any changes required from the default values |
|---|
| 145 | defChnSettings.baud = 1200000; // set clock to 1.2 Mhz |
|---|
| 146 | defChnSettings.clkConfig = (SPI_SPCR0_MSB_CPOL | SPI_SPCR0_MSB_CPHA); |
|---|
| 147 | defChnSettings.intMode = TRUE; // enable interrupt |
|---|
| 148 | |
|---|
| 149 | BSPI_OpenChannel( hSpi, &hSpiChan, chanNo, &defChnSettings ); |
|---|
| 150 | |
|---|
| 151 | BSPI_CreateSpiRegHandle (hSpiChan, &hSpiReg); |
|---|
| 152 | |
|---|
| 153 | // |
|---|
| 154 | // Do a read of 2 bytes from register 0x04 of SPI device whose |
|---|
| 155 | // chip address is 0x28. |
|---|
| 156 | // |
|---|
| 157 | writeBuf[0] = 0x28; // chip address |
|---|
| 158 | writeBuf[1] = 0x04; // register offset |
|---|
| 159 | BREG_SPI_Read (hSpiReg, writeBuf, readBuf, 4); // results in readBuf[2] and readBuf[3] |
|---|
| 160 | |
|---|
| 161 | printf("Data = %x %x \n", readBuf[2], readBuf[3]); |
|---|
| 162 | // |
|---|
| 163 | // Do a write of 1 byte from register 0x1C of SPI device whose |
|---|
| 164 | // chip ID is 0x28. |
|---|
| 165 | // |
|---|
| 166 | writeBuf[0] = 0x28; |
|---|
| 167 | writeBuf[1] = 0x1C; |
|---|
| 168 | writeBuf[2] = 0x30; // value to write |
|---|
| 169 | BREG_SPI_Write (hSpiReg, writeBuf, 3); |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | |
|---|
| 173 | </verbatim> |
|---|
| 174 | ***************************************************************************/ |
|---|
| 175 | |
|---|
| 176 | |
|---|
| 177 | #ifndef BSPI_H__ |
|---|
| 178 | #define BSPI_H__ |
|---|
| 179 | |
|---|
| 180 | #include "bchp.h" |
|---|
| 181 | #include "breg_mem.h" |
|---|
| 182 | #include "breg_spi.h" |
|---|
| 183 | #include "bint.h" |
|---|
| 184 | #include "bkni.h" |
|---|
| 185 | #include "berr_ids.h" |
|---|
| 186 | |
|---|
| 187 | #ifdef __cplusplus |
|---|
| 188 | extern "C" { |
|---|
| 189 | #endif |
|---|
| 190 | |
|---|
| 191 | /*************************************************************************** |
|---|
| 192 | Summary: |
|---|
| 193 | Number of SPI channels in BCM7038 |
|---|
| 194 | |
|---|
| 195 | Description: |
|---|
| 196 | |
|---|
| 197 | See Also: |
|---|
| 198 | |
|---|
| 199 | ****************************************************************************/ |
|---|
| 200 | #if (BCHP_CHIP==3548) || (BCHP_CHIP==3556) || (BCHP_CHIP==7346) |
|---|
| 201 | #define MAX_SPI_CHANNELS 3 |
|---|
| 202 | #else |
|---|
| 203 | #define MAX_SPI_CHANNELS 2 |
|---|
| 204 | #endif |
|---|
| 205 | |
|---|
| 206 | /*************************************************************************** |
|---|
| 207 | Summary: |
|---|
| 208 | Error Codes specific to BSPI |
|---|
| 209 | |
|---|
| 210 | Description: |
|---|
| 211 | |
|---|
| 212 | See Also: |
|---|
| 213 | |
|---|
| 214 | ****************************************************************************/ |
|---|
| 215 | #define BSPI_ERR_NOTAVAIL_CHN_NO BERR_MAKE_CODE(BERR_SPI_ID, 0) |
|---|
| 216 | |
|---|
| 217 | /*************************************************************************** |
|---|
| 218 | Summary: |
|---|
| 219 | The handles for spi module. |
|---|
| 220 | |
|---|
| 221 | Description: |
|---|
| 222 | Since BSPI is a device channel, it has main device handle as well |
|---|
| 223 | as a device channel handle. |
|---|
| 224 | |
|---|
| 225 | See Also: |
|---|
| 226 | BSPI_Open(), BSPI_OpenChannel() |
|---|
| 227 | |
|---|
| 228 | ****************************************************************************/ |
|---|
| 229 | typedef struct BSPI_P_Handle *BSPI_Handle; |
|---|
| 230 | |
|---|
| 231 | /*************************************************************************** |
|---|
| 232 | Summary: |
|---|
| 233 | The handles for spi module. |
|---|
| 234 | |
|---|
| 235 | Description: |
|---|
| 236 | Since BSPI is a device channel, it has main device handle as well |
|---|
| 237 | as a device channel handle. |
|---|
| 238 | |
|---|
| 239 | See Also: |
|---|
| 240 | BSPI_Open(), BSPI_OpenChannel() |
|---|
| 241 | |
|---|
| 242 | ****************************************************************************/ |
|---|
| 243 | typedef struct BSPI_P_ChannelHandle *BSPI_ChannelHandle; |
|---|
| 244 | |
|---|
| 245 | /*************************************************************************** |
|---|
| 246 | Summary: |
|---|
| 247 | Enumeration for slave selects |
|---|
| 248 | |
|---|
| 249 | Description: |
|---|
| 250 | This enumeration defines the slave select setting for a SPI channel |
|---|
| 251 | |
|---|
| 252 | See Also: |
|---|
| 253 | None. |
|---|
| 254 | |
|---|
| 255 | ****************************************************************************/ |
|---|
| 256 | typedef enum BSPI_Pcs |
|---|
| 257 | { |
|---|
| 258 | BSPI_Pcs_eUpgSpiPcs0 = 0, |
|---|
| 259 | BSPI_Pcs_eUpgSpiPcs1, |
|---|
| 260 | BSPI_Pcs_eUpgSpiPcs2 |
|---|
| 261 | } BSPI_Pcs; |
|---|
| 262 | |
|---|
| 263 | /*************************************************************************** |
|---|
| 264 | Summary: |
|---|
| 265 | Required default settings structure for SPI module. |
|---|
| 266 | |
|---|
| 267 | Description: |
|---|
| 268 | The default setting structure defines the default configure of |
|---|
| 269 | SPI when the device is opened. Since BSPI is a device |
|---|
| 270 | channel, it also has default settings for a device channel. |
|---|
| 271 | Currently there are no parameters for device setting. |
|---|
| 272 | |
|---|
| 273 | See Also: |
|---|
| 274 | BSPI_Open(), BSPI_OpenChannel() |
|---|
| 275 | |
|---|
| 276 | ****************************************************************************/ |
|---|
| 277 | typedef void *BSPI_Settings; |
|---|
| 278 | |
|---|
| 279 | /*************************************************************************** |
|---|
| 280 | Summary: |
|---|
| 281 | Required default settings structure for SPI module. |
|---|
| 282 | |
|---|
| 283 | Description: |
|---|
| 284 | The default setting structure defines the default configure of |
|---|
| 285 | SPI when the device is opened. Since BSPI is a device |
|---|
| 286 | channel, it also has default settings for a device channel. |
|---|
| 287 | Currently there are no parameters for device setting. |
|---|
| 288 | |
|---|
| 289 | See Also: |
|---|
| 290 | BSPI_Open(), BSPI_OpenChannel() |
|---|
| 291 | |
|---|
| 292 | ****************************************************************************/ |
|---|
| 293 | typedef struct BSPI_ChannelSettings |
|---|
| 294 | { |
|---|
| 295 | uint32_t baud; /* SPI baud rate */ |
|---|
| 296 | uint8_t clkConfig; /* SPI clock configuration */ |
|---|
| 297 | bool intMode; /* interrupt enable flag */ |
|---|
| 298 | uint8_t bitsPerTxfr; /* number of bits per transfer */ |
|---|
| 299 | bool lastByteContinueEnable; /* Last Byte Contiue Enable Flag */ |
|---|
| 300 | bool useUserDtlAndDsclk; /* Use User specified DTL and DSCLK */ |
|---|
| 301 | } BSPI_ChannelSettings; |
|---|
| 302 | |
|---|
| 303 | /*************************************************************************** |
|---|
| 304 | Summary: |
|---|
| 305 | This function opens SPI module. |
|---|
| 306 | |
|---|
| 307 | Description: |
|---|
| 308 | This function is responsible for opening BSPI module. When BSPI is |
|---|
| 309 | opened, it will create a module handle and configure the module based |
|---|
| 310 | on the default settings. Once the device is opened, it must be closed |
|---|
| 311 | before it can be opened again. |
|---|
| 312 | |
|---|
| 313 | Returns: |
|---|
| 314 | TODO: |
|---|
| 315 | |
|---|
| 316 | See Also: |
|---|
| 317 | BSPI_Close(), BSPI_OpenChannel(), BSPI_CloseChannel(), |
|---|
| 318 | BSPI_GetDefaultSettings() |
|---|
| 319 | |
|---|
| 320 | ****************************************************************************/ |
|---|
| 321 | BERR_Code BSPI_Open( |
|---|
| 322 | BSPI_Handle *pSPI, /* [out] Returns handle */ |
|---|
| 323 | BCHP_Handle hChip, /* [in] Chip handle */ |
|---|
| 324 | BREG_Handle hRegister, /* [in] Register handle */ |
|---|
| 325 | BINT_Handle hInterrupt, /* [in] Interrupt handle */ |
|---|
| 326 | const BSPI_Settings *pDefSettings /* [in] Default settings */ |
|---|
| 327 | ); |
|---|
| 328 | |
|---|
| 329 | /*************************************************************************** |
|---|
| 330 | Summary: |
|---|
| 331 | This function closes SPI module. |
|---|
| 332 | |
|---|
| 333 | Description: |
|---|
| 334 | This function is responsible for closing BSPI module. Closing BSPI |
|---|
| 335 | will free main BSPI handle. It is required that all opened |
|---|
| 336 | BSPI channels must be closed before calling this function. If this |
|---|
| 337 | is not done, the results will be unpredicable. |
|---|
| 338 | |
|---|
| 339 | Returns: |
|---|
| 340 | TODO: |
|---|
| 341 | |
|---|
| 342 | See Also: |
|---|
| 343 | BSPI_Open(), BSPI_CloseChannel() |
|---|
| 344 | |
|---|
| 345 | ****************************************************************************/ |
|---|
| 346 | BERR_Code BSPI_Close( |
|---|
| 347 | BSPI_Handle hDev /* [in] Device handle */ |
|---|
| 348 | ); |
|---|
| 349 | |
|---|
| 350 | /*************************************************************************** |
|---|
| 351 | Summary: |
|---|
| 352 | This function returns the default settings for SPI module. |
|---|
| 353 | |
|---|
| 354 | Description: |
|---|
| 355 | This function is responsible for returns the default setting for |
|---|
| 356 | BSPI module. The returning default setting should be when |
|---|
| 357 | opening the device. |
|---|
| 358 | |
|---|
| 359 | Returns: |
|---|
| 360 | TODO: |
|---|
| 361 | |
|---|
| 362 | See Also: |
|---|
| 363 | BSPI_Open() |
|---|
| 364 | |
|---|
| 365 | ****************************************************************************/ |
|---|
| 366 | BERR_Code BSPI_GetDefaultSettings( |
|---|
| 367 | BSPI_Settings *pDefSettings, /* [out] Returns default setting */ |
|---|
| 368 | BCHP_Handle hChip /* [in] Chip handle */ |
|---|
| 369 | ); |
|---|
| 370 | |
|---|
| 371 | /*************************************************************************** |
|---|
| 372 | Summary: |
|---|
| 373 | This function returns the total number of channels supported by |
|---|
| 374 | SPI module. |
|---|
| 375 | |
|---|
| 376 | Description: |
|---|
| 377 | This function is responsible for getting total number of channels |
|---|
| 378 | supported by BSPI module, since BSPI device is implemented as a |
|---|
| 379 | device channel. |
|---|
| 380 | |
|---|
| 381 | Returns: |
|---|
| 382 | TODO: |
|---|
| 383 | |
|---|
| 384 | See Also: |
|---|
| 385 | BSPI_OpenChannel(), BSPI_ChannelDefaultSettings() |
|---|
| 386 | |
|---|
| 387 | ****************************************************************************/ |
|---|
| 388 | BERR_Code BSPI_GetTotalChannels( |
|---|
| 389 | BSPI_Handle hDev, /* [in] Device handle */ |
|---|
| 390 | unsigned int *totalChannels /* [out] Returns total number downstream channels supported */ |
|---|
| 391 | ); |
|---|
| 392 | |
|---|
| 393 | /*************************************************************************** |
|---|
| 394 | Summary: |
|---|
| 395 | This function gets default setting for a SPI module channel. |
|---|
| 396 | |
|---|
| 397 | Description: |
|---|
| 398 | This function is responsible for returning the default setting for |
|---|
| 399 | channel of BSPI. The return default setting is used when opening |
|---|
| 400 | a channel. |
|---|
| 401 | |
|---|
| 402 | Returns: |
|---|
| 403 | TODO: |
|---|
| 404 | |
|---|
| 405 | See Also: |
|---|
| 406 | BSPI_OpenChannel() |
|---|
| 407 | |
|---|
| 408 | ****************************************************************************/ |
|---|
| 409 | BERR_Code BSPI_GetChannelDefaultSettings( |
|---|
| 410 | BSPI_Handle hDev, /* [in] Device handle */ |
|---|
| 411 | unsigned int channelNo, /* [in] Channel number to default setting for */ |
|---|
| 412 | BSPI_ChannelSettings *pChnDefSettings /* [out] Returns channel default setting */ |
|---|
| 413 | ); |
|---|
| 414 | |
|---|
| 415 | /*************************************************************************** |
|---|
| 416 | Summary: |
|---|
| 417 | This function opens SPI module channel. |
|---|
| 418 | |
|---|
| 419 | Description: |
|---|
| 420 | This function is responsible for opening BSPI module channel. When a |
|---|
| 421 | BSPI channel is opened, it will create a module channel handle and |
|---|
| 422 | configure the module based on the channel default settings. Once a |
|---|
| 423 | channel is opened, it must be closed before it can be opened again. |
|---|
| 424 | |
|---|
| 425 | Returns: |
|---|
| 426 | TODO: |
|---|
| 427 | |
|---|
| 428 | See Also: |
|---|
| 429 | BSPI_CloseChannel(), BSPI_GetChannelDefaultSettings() |
|---|
| 430 | |
|---|
| 431 | ****************************************************************************/ |
|---|
| 432 | BERR_Code BSPI_OpenChannel( |
|---|
| 433 | BSPI_Handle hDev, /* [in] Device handle */ |
|---|
| 434 | BSPI_ChannelHandle *phChn, /* [out] Returns channel handle */ |
|---|
| 435 | unsigned int channelNo, /* [in] Channel number to open */ |
|---|
| 436 | const BSPI_ChannelSettings *pChnDefSettings /* [in] Channel default setting */ |
|---|
| 437 | ); |
|---|
| 438 | |
|---|
| 439 | /*************************************************************************** |
|---|
| 440 | Summary: |
|---|
| 441 | This function closes SPI module channel. |
|---|
| 442 | |
|---|
| 443 | Description: |
|---|
| 444 | This function is responsible for closing BSPI module channel. Closing |
|---|
| 445 | BSPI channel it will free BSPI channel handle. It is required that all |
|---|
| 446 | opened BSPI channels must be closed before closing BSPI. |
|---|
| 447 | |
|---|
| 448 | Returns: |
|---|
| 449 | TODO: |
|---|
| 450 | |
|---|
| 451 | See Also: |
|---|
| 452 | BSPI_OpenChannel(), BSPI_CloseChannel() |
|---|
| 453 | |
|---|
| 454 | ****************************************************************************/ |
|---|
| 455 | BERR_Code BSPI_CloseChannel( |
|---|
| 456 | BSPI_ChannelHandle hChn /* [in] Device channel handle */ |
|---|
| 457 | ); |
|---|
| 458 | |
|---|
| 459 | /*************************************************************************** |
|---|
| 460 | Summary: |
|---|
| 461 | This function gets SPI module device handle based on |
|---|
| 462 | the device channel handle. |
|---|
| 463 | |
|---|
| 464 | Description: |
|---|
| 465 | This function is responsible returning BSPI module handle based on the |
|---|
| 466 | BSPI module channel. |
|---|
| 467 | |
|---|
| 468 | Returns: |
|---|
| 469 | TODO: |
|---|
| 470 | |
|---|
| 471 | See Also: |
|---|
| 472 | |
|---|
| 473 | ****************************************************************************/ |
|---|
| 474 | BERR_Code BSPI_GetDevice( |
|---|
| 475 | BSPI_ChannelHandle hChn, /* [in] Device channel handle */ |
|---|
| 476 | BSPI_Handle *pSPI /* [out] Returns Device handle */ |
|---|
| 477 | ); |
|---|
| 478 | |
|---|
| 479 | |
|---|
| 480 | /*************************************************************************** |
|---|
| 481 | Summary: |
|---|
| 482 | This function creates an SPI register handle. |
|---|
| 483 | |
|---|
| 484 | Description: |
|---|
| 485 | This function is responsible for creating an SPI register handle for |
|---|
| 486 | master SPI controller. It fills in the BREG_SPI_Handle structure with |
|---|
| 487 | pointers to the SPI PI functions. The application can then use this |
|---|
| 488 | SPI register interface to perform read and write operations. |
|---|
| 489 | |
|---|
| 490 | Returns: |
|---|
| 491 | TODO: |
|---|
| 492 | |
|---|
| 493 | See Also: |
|---|
| 494 | |
|---|
| 495 | ****************************************************************************/ |
|---|
| 496 | BERR_Code BSPI_CreateSpiRegHandle( |
|---|
| 497 | BSPI_ChannelHandle hChn, /* [in] Device channel handle */ |
|---|
| 498 | BREG_SPI_Handle *pSpiRegHandle /* [out] register handle */ |
|---|
| 499 | ); |
|---|
| 500 | |
|---|
| 501 | /*************************************************************************** |
|---|
| 502 | Summary: |
|---|
| 503 | This function closes SPI register handle |
|---|
| 504 | |
|---|
| 505 | Description: |
|---|
| 506 | This function is responsible for closing the SPI register handle. |
|---|
| 507 | This function frees BSPI register handle. |
|---|
| 508 | |
|---|
| 509 | Returns: |
|---|
| 510 | TODO: |
|---|
| 511 | |
|---|
| 512 | See Also: |
|---|
| 513 | BSPI_CreateSpiRegHandle() |
|---|
| 514 | |
|---|
| 515 | ****************************************************************************/ |
|---|
| 516 | BERR_Code BSPI_CloseSpiRegHandle( |
|---|
| 517 | BREG_SPI_Handle hSpiReg /* [in] SPI register handle */ |
|---|
| 518 | ); |
|---|
| 519 | |
|---|
| 520 | /*************************************************************************** |
|---|
| 521 | Summary: |
|---|
| 522 | This function aborts the current SPI transfer |
|---|
| 523 | |
|---|
| 524 | Description: |
|---|
| 525 | This function allows the user to abort an on-going SPI transfer. |
|---|
| 526 | |
|---|
| 527 | Returns: |
|---|
| 528 | TODO: |
|---|
| 529 | |
|---|
| 530 | See Also: |
|---|
| 531 | |
|---|
| 532 | ****************************************************************************/ |
|---|
| 533 | BERR_Code BSPI_AbortTxfr ( |
|---|
| 534 | BSPI_ChannelHandle channel /* [in] Device channel handle */ |
|---|
| 535 | ); |
|---|
| 536 | |
|---|
| 537 | /*************************************************************************** |
|---|
| 538 | Summary: |
|---|
| 539 | This function sets the SPI clock config |
|---|
| 540 | |
|---|
| 541 | Description: |
|---|
| 542 | |
|---|
| 543 | Returns: |
|---|
| 544 | TODO: |
|---|
| 545 | |
|---|
| 546 | See Also: |
|---|
| 547 | |
|---|
| 548 | ****************************************************************************/ |
|---|
| 549 | BERR_Code BSPI_GetClkConfig( |
|---|
| 550 | BSPI_ChannelHandle hChn, /* Device channel handle */ |
|---|
| 551 | uint8_t *pClkConfig /* pointer to clock config */ |
|---|
| 552 | ); |
|---|
| 553 | |
|---|
| 554 | /*************************************************************************** |
|---|
| 555 | Summary: |
|---|
| 556 | This function gets the SPI clock clock config |
|---|
| 557 | |
|---|
| 558 | Description: |
|---|
| 559 | |
|---|
| 560 | Returns: |
|---|
| 561 | TODO: |
|---|
| 562 | |
|---|
| 563 | See Also: |
|---|
| 564 | |
|---|
| 565 | ****************************************************************************/ |
|---|
| 566 | BERR_Code BSPI_SetClkConfig( |
|---|
| 567 | BSPI_ChannelHandle hChn, /* Device channel handle */ |
|---|
| 568 | uint8_t clkConfig /* clock config */ |
|---|
| 569 | ); |
|---|
| 570 | |
|---|
| 571 | /*************************************************************************** |
|---|
| 572 | Summary: |
|---|
| 573 | This function gets length of delay after transfer |
|---|
| 574 | |
|---|
| 575 | Description: |
|---|
| 576 | |
|---|
| 577 | Returns: |
|---|
| 578 | TODO: |
|---|
| 579 | |
|---|
| 580 | See Also: |
|---|
| 581 | |
|---|
| 582 | ****************************************************************************/ |
|---|
| 583 | BERR_Code BSPI_GetDTLConfig ( |
|---|
| 584 | BSPI_ChannelHandle hChn, /* Device channel handle */ |
|---|
| 585 | uint32_t *pDTLConfig /* pointer to DTLConfig */ |
|---|
| 586 | ); |
|---|
| 587 | |
|---|
| 588 | /*************************************************************************** |
|---|
| 589 | Summary: |
|---|
| 590 | This function sets length of delay after transfer |
|---|
| 591 | |
|---|
| 592 | Description: |
|---|
| 593 | |
|---|
| 594 | Returns: |
|---|
| 595 | TODO: |
|---|
| 596 | |
|---|
| 597 | See Also: |
|---|
| 598 | |
|---|
| 599 | ****************************************************************************/ |
|---|
| 600 | BERR_Code BSPI_SetDTLConfig ( |
|---|
| 601 | BSPI_ChannelHandle context, /* Device channel handle */ |
|---|
| 602 | const uint32_t data /* data to write */ |
|---|
| 603 | ); |
|---|
| 604 | |
|---|
| 605 | /*************************************************************************** |
|---|
| 606 | Summary: |
|---|
| 607 | This function gets the length of delay from PCS valid to SCK transition |
|---|
| 608 | |
|---|
| 609 | Description: |
|---|
| 610 | |
|---|
| 611 | Returns: |
|---|
| 612 | TODO: |
|---|
| 613 | |
|---|
| 614 | See Also: |
|---|
| 615 | |
|---|
| 616 | ****************************************************************************/ |
|---|
| 617 | BERR_Code BSPI_GetRDSCLKConfig( |
|---|
| 618 | BSPI_ChannelHandle hChn, /* Device channel handle */ |
|---|
| 619 | uint32_t *pRDSCLKConfig /* pointer to RDSCLKConfig */ |
|---|
| 620 | ); |
|---|
| 621 | |
|---|
| 622 | /*************************************************************************** |
|---|
| 623 | Summary: |
|---|
| 624 | This function sets the length of delay from PCS valid to SCK transition |
|---|
| 625 | |
|---|
| 626 | Description: |
|---|
| 627 | |
|---|
| 628 | Returns: |
|---|
| 629 | TODO: |
|---|
| 630 | |
|---|
| 631 | See Also: |
|---|
| 632 | |
|---|
| 633 | ****************************************************************************/ |
|---|
| 634 | BERR_Code BSPI_SetRDSCLKConfig( |
|---|
| 635 | BSPI_ChannelHandle context, /* Device channel handle */ |
|---|
| 636 | const uint32_t data /* data to write */ |
|---|
| 637 | ); |
|---|
| 638 | #ifdef __cplusplus |
|---|
| 639 | } |
|---|
| 640 | #endif |
|---|
| 641 | |
|---|
| 642 | #endif |
|---|
| 643 | |
|---|
| 644 | |
|---|
| 645 | |
|---|