MT2523 API Reference  LinkIt SDK v4
hal_spi_slave.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2017 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_SPI_SLAVE_H__
36 #define __HAL_SPI_SLAVE_H__
37 
38 #include "hal_platform.h"
39 
40 #ifdef HAL_SPI_SLAVE_MODULE_ENABLED
41 
42 #ifdef HAL_SPI_SLAVE_FEATURE_SW_CONTROL
43 
276 #else
277 
444 #endif
445 
446 #ifdef HAL_GPIO_FEATURE_SET_DRIVING
447 
472 #endif
473 
474 #ifdef __cplusplus
475 extern "C" {
476 #endif
477 
481 #ifdef HAL_SPI_SLAVE_FEATURE_SW_CONTROL
482 
484 typedef enum {
488 
489 
491 typedef enum {
495 
496 
497 /********************* SPI Slave FSM *******************************
498 **cmd\status PWROFF PWRON ConfigRead(CR) ConfigWrite(CW)
499 ** Poweroff N Y Abnormal Abnormal
500 ** Poweron Y N N N
501 **ConfigRead N Y Abnormal Abnormal
502 ** Read N N Y Abnormal
503 **ConfigWrite N Y Abnormal Abnormal
504 ** Write N N Abnormal Y
505 
506 Note: N: invalid operation.
507  Y: the operation completed successfully.
508  Abnormal: an error occurred during the operation.
509 *******************************************************************/
511 typedef enum {
523 
524 #endif
525 
526 
528 typedef enum {
535 
543 #ifdef HAL_SPI_SLAVE_FEATURE_SW_CONTROL
544 
545 typedef struct {
546  uint32_t timeout_threshold;
551 
552 
554 typedef struct {
558 #else
559 
560 typedef struct {
564 #endif
565 
573 #ifdef HAL_SPI_SLAVE_FEATURE_SW_CONTROL
574 
583 typedef void (* hal_spi_slave_callback_t)(hal_spi_slave_transaction_status_t status, void *user_data);
584 #else
585 
590 typedef void (* hal_spi_slave_callback_t)(void *user_data);
591 #endif
592 
596 #ifdef HAL_SPI_SLAVE_FEATURE_SW_CONTROL
597 
612 
613 
624 
625 
639 
640 
654 hal_spi_slave_status_t hal_spi_slave_send(hal_spi_slave_port_t spi_port, const uint8_t *data, uint32_t size);
655 
656 
701 hal_spi_slave_status_t hal_spi_slave_get_master_read_config(hal_spi_slave_port_t spi_port, uint32_t *address, uint32_t *length);
702 
703 
717 hal_spi_slave_status_t hal_spi_slave_receive(hal_spi_slave_port_t spi_port, uint8_t *buffer, uint32_t size);
718 
719 
764 hal_spi_slave_status_t hal_spi_slave_get_master_write_config(hal_spi_slave_port_t spi_port, uint32_t *address, uint32_t *length);
765 
766 
778 
779 
792 #else
793 
804 
805 
817 
818 #endif
819 
820 #ifdef __cplusplus
821 }
822 #endif
823 
828 #endif /*HAL_SPI_SLAVE_MODULE_ENABLED*/
829 #endif /* __HAL_SPI_SLAVE_H__ */
830 
831 
832 
SPI slave error, received continuous Configure Write command.
Definition: hal_spi_slave.h:518
SPI slave error, received POWER OFF command after Configure Write command.
Definition: hal_spi_slave.h:515
The SPI slave is busy.
Definition: hal_spi_slave.h:492
hal_spi_slave_command_type_t
This enum defines the SPI slave commands.
Definition: hal_platform.h:680
SPI slave error, received Write command after Configure Read command.
Definition: hal_spi_slave.h:520
The SPI slave API call was successful.
Definition: hal_spi_slave.h:533
hal_spi_slave_clock_polarity_t
SPI slave clock polarity definition.
Definition: hal_platform.h:654
hal_spi_slave_status_t hal_spi_slave_deinit(hal_spi_slave_port_t spi_port)
This function resets the SPI slave, gates its clock and disables interrupts.
hal_spi_slave_clock_phase_t phase
The SPI slave clock phase setting.
Definition: hal_spi_slave.h:549
SPI slave success operation.
Definition: hal_spi_slave.h:512
Disables send MISO data half SCLK cycle early.
Definition: hal_spi_slave.h:485
hal_spi_slave_callback_event_t
This enum defines the SPI slave event when an interrupt occurs.
Definition: hal_platform.h:667
SPI slave transaction status definition.
Definition: hal_spi_slave.h:554
hal_spi_slave_callback_event_t interrupt_status
The interrupt status of the SPI slave controller.
Definition: hal_spi_slave.h:556
hal_spi_slave_status_t hal_spi_slave_get_master_write_config(hal_spi_slave_port_t spi_port, uint32_t *address, uint32_t *length)
This function querys the address and the length from the config write command sent by the SPI master...
Invalid SPI slave port number.
Definition: hal_spi_slave.h:531
hal_spi_slave_status_t hal_spi_slave_send(hal_spi_slave_port_t spi_port, const uint8_t *data, uint32_t size)
This function sends data asynchronously with DMA mode, this function should be called from user's cal...
hal_spi_slave_status_t hal_spi_slave_receive(hal_spi_slave_port_t spi_port, uint8_t *buffer, uint32_t size)
This function receives data asynchronously with DMA mode.
An error occurred during the SPI slave API call.
Definition: hal_spi_slave.h:529
SPI slave invalid operation.
Definition: hal_spi_slave.h:513
SPI slave configure.
Definition: hal_spi_slave.h:545
hal_spi_slave_fsm_status_t fsm_status
An item from hal_spi_slave_fsm_status_t.
Definition: hal_spi_slave.h:555
hal_spi_slave_clock_phase_t
SPI slave clock format definition.
Definition: hal_platform.h:661
The SPI slave is idle.
Definition: hal_spi_slave.h:493
hal_spi_slave_status_t hal_spi_slave_set_early_miso(hal_spi_slave_port_t spi_port, hal_spi_slave_early_miso_t early_miso)
This function configures the SPI slave send MISO early half SCLK cycle parameter. ...
SPI slave error, received Configure Write command after Configure Read command.
Definition: hal_spi_slave.h:519
SPI slave error, received POWER OFF command after Configure Read command.
Definition: hal_spi_slave.h:514
Invalid parameter.
Definition: hal_spi_slave.h:532
hal_spi_slave_port_t
This enum defines the SPI slave port.
Definition: hal_platform.h:642
hal_spi_slave_early_miso_t
The SPI slave sends MISO data half SCLK cycle early.
Definition: hal_spi_slave.h:484
hal_spi_slave_bit_order_t bit_order
The SPI slave bit order setting.
Definition: hal_spi_slave.h:547
hal_spi_slave_status_t hal_spi_slave_register_callback(hal_spi_slave_port_t spi_port, hal_spi_slave_callback_t callback_function, void *user_data)
This function registers user's callback in the SPI slave driver.
hal_spi_slave_status_t hal_spi_slave_set_command(hal_spi_slave_port_t spi_port, hal_spi_slave_command_type_t command, uint8_t value)
This function configures the SPI slave command value.
hal_spi_slave_clock_polarity_t polarity
The SPI slave clock polarity setting.
Definition: hal_spi_slave.h:548
hal_spi_slave_fsm_status_t
SPI slave finite state machine status.
Definition: hal_spi_slave.h:511
hal_spi_slave_status_t hal_spi_slave_get_master_read_config(hal_spi_slave_port_t spi_port, uint32_t *address, uint32_t *length)
This function queries the address and length from the config read command sent by the SPI master...
The SPI slave was busy during the SPI slave API call.
Definition: hal_spi_slave.h:530
hal_spi_slave_running_status_t
SPI slave running status.
Definition: hal_spi_slave.h:491
SPI slave error, received continuous Configure Read command.
Definition: hal_spi_slave.h:516
SPI slave error, received Configure Read command after Configure Write command.
Definition: hal_spi_slave.h:517
hal_spi_slave_bit_order_t
SPI slave transaction bit order definition.
Definition: hal_platform.h:648
hal_spi_slave_status_t hal_spi_slave_init(hal_spi_slave_port_t spi_port, hal_spi_slave_config_t *spi_configure)
This function initializes the SPI slave and sets user defined common parameters such as timeout thres...
uint32_t timeout_threshold
The SPI slave timeout threshold setting.
Definition: hal_spi_slave.h:546
hal_spi_slave_status_t
SPI slave status.
Definition: hal_spi_slave.h:528
Enables send MISO data half SCLK cycle early.
Definition: hal_spi_slave.h:486
void(* hal_spi_slave_callback_t)(hal_spi_slave_transaction_status_t status, void *user_data)
This defines the callback function prototype.
Definition: hal_spi_slave.h:583
SPI slave error, received Read command after Configure Write command.
Definition: hal_spi_slave.h:521