|
20 | 20 | #include "esp_types.h" |
21 | 21 | #include "soc/spi_periph.h" |
22 | 22 | #include "soc/spi_struct.h" |
| 23 | +#include "soc/chip_revision.h" |
| 24 | +#include "soc/pcr_struct.h" |
23 | 25 | #include "soc/lldesc.h" |
24 | 26 | #include "hal/assert.h" |
25 | 27 | #include "hal/misc.h" |
| 28 | +#include "hal/efuse_hal.h" |
26 | 29 | #include "hal/spi_types.h" |
27 | | -#include "soc/pcr_struct.h" |
28 | 30 |
|
29 | 31 | #ifdef __cplusplus |
30 | 32 | extern "C" { |
@@ -688,6 +690,26 @@ static inline void spi_ll_master_keep_cs(spi_dev_t *hw, int keep_active) |
688 | 690 | /*------------------------------------------------------------------------------ |
689 | 691 | * Configs: parameters |
690 | 692 | *----------------------------------------------------------------------------*/ |
| 693 | +/** |
| 694 | + * Set the standard clock mode for master. |
| 695 | + * This config take effect only when SPI_CLK (pre-div before periph) div >=2 |
| 696 | + * |
| 697 | + * @param hw Beginning address of the peripheral registers. |
| 698 | + * @param enable_std True for std timing, False for half cycle delay sampling. |
| 699 | + */ |
| 700 | +static inline void spi_ll_master_set_rx_timing_mode(spi_dev_t *hw, spi_sampling_point_t sample_point) |
| 701 | +{ |
| 702 | + hw->clock.clk_edge_sel = (sample_point == SPI_SAMPLING_POINT_PHASE_1); |
| 703 | +} |
| 704 | + |
| 705 | +/** |
| 706 | + * Get if standard clock mode is supported. |
| 707 | + */ |
| 708 | +static inline bool spi_ll_master_is_rx_std_sample_supported(void) |
| 709 | +{ |
| 710 | + return ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 102); |
| 711 | +} |
| 712 | + |
691 | 713 | /** |
692 | 714 | * Set the clock for master by stored value. |
693 | 715 | * |
@@ -725,7 +747,7 @@ static inline int spi_ll_freq_for_pre_n(int fapb, int pre, int n) |
725 | 747 | */ |
726 | 748 | static inline int spi_ll_master_cal_clock(int fapb, int hz, int duty_cycle, spi_ll_clock_val_t *out_reg) |
727 | 749 | { |
728 | | - typeof(GPSPI2.clock) reg; |
| 750 | + typeof(GPSPI2.clock) reg = {.val = 0}; |
729 | 751 | int eff_clk; |
730 | 752 |
|
731 | 753 | //In hw, n, h and l are 1-64, pre is 1-8K. Value written to register is one lower than used value. |
|
0 commit comments