MT7687 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 {
485  HAL_SPI_SLAVE_EARLY_MISO_DISABLE = 0,
486  HAL_SPI_SLAVE_EARLY_MISO_ENABLE = 1
487 } hal_spi_slave_early_miso_t;
488 
489 
491 typedef enum {
492  HAL_SPI_SLAVE_BUSY = 0,
493  HAL_SPI_SLAVE_IDLE = 1
494 } hal_spi_slave_running_status_t;
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 {
512  HAL_SPI_SLAVE_FSM_SUCCESS_OPERATION = 0x00,
513  HAL_SPI_SLAVE_FSM_INVALID_OPERATION = 0x01,
514  HAL_SPI_SLAVE_FSM_ERROR_PWROFF_AFTER_CR = 0x02,
515  HAL_SPI_SLAVE_FSM_ERROR_PWROFF_AFTER_CW = 0x03,
516  HAL_SPI_SLAVE_FSM_ERROR_CONTINOUS_CR = 0x04,
517  HAL_SPI_SLAVE_FSM_ERROR_CR_AFTER_CW = 0x05,
518  HAL_SPI_SLAVE_FSM_ERROR_CONTINOUS_CW = 0x06,
519  HAL_SPI_SLAVE_FSM_ERROR_CW_AFTER_CR = 0x07,
520  HAL_SPI_SLAVE_FSM_ERROR_WRITE_AFTER_CR = 0x08,
521  HAL_SPI_SLAVE_FSM_ERROR_READ_AFTER_CW = 0x09
522 } hal_spi_slave_fsm_status_t;
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;
547  hal_spi_slave_bit_order_t bit_order;
551 
552 
554 typedef struct {
555  hal_spi_slave_fsm_status_t fsm_status;
556  hal_spi_slave_callback_event_t interrupt_status;
557 } hal_spi_slave_transaction_status_t;
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 
623 hal_spi_slave_status_t hal_spi_slave_deinit(hal_spi_slave_port_t spi_port);
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 
777 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);
778 
779 
791 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);
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 
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:516
hal_spi_slave_clock_phase_t phase
The SPI slave clock phase setting.
Definition: hal_spi_slave.h:562
Invalid SPI slave port number.
Definition: hal_spi_slave.h:531
An error occurred during the SPI slave API call.
Definition: hal_spi_slave.h:529
SPI slave configure.
Definition: hal_spi_slave.h:560
hal_spi_slave_clock_phase_t
SPI slave clock format definition.
Definition: hal_platform.h:523
Invalid parameter.
Definition: hal_spi_slave.h:532
hal_spi_slave_port_t
This enum defines the SPI slave port.
Definition: hal_platform.h:510
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_clock_polarity_t polarity
The SPI slave clock polarity setting.
Definition: hal_spi_slave.h:561
The SPI slave was busy during the SPI slave API call.
Definition: hal_spi_slave.h:530
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 including clock polar...
void(* hal_spi_slave_callback_t)(void *user_data)
This defines the callback function prototype.
Definition: hal_spi_slave.h:590
hal_spi_slave_status_t
SPI slave status.
Definition: hal_spi_slave.h:528