@@ -305,7 +305,10 @@ enum {
305
305
SYNTIANT_NDP120_GET_NN_GRAPH = 0x67 ,
306
306
SYNTIANT_NDP120_GET_DEBUG_INFO = 0x68 ,
307
307
SYNTIANT_NDP120_GET_NN_FLOW = 0x69 ,
308
- SYNTIANT_NDP120_GET_AUDIO_CHUNK_SIZE = 0x6a
308
+ SYNTIANT_NDP120_GET_AUDIO_CHUNK_SIZE = 0x6a ,
309
+ SYNTIANT_NDP120_INPUT_CONFIG = 0x6b ,
310
+ SYNTIANT_NDP120_SET_SPI_DIRECT = 0x6c ,
311
+ SYNTIANT_NDP120_SWITCH_FLOW_SET_ID = 0x6d
309
312
};
310
313
311
314
enum {
@@ -1135,33 +1138,10 @@ syntiant_ndp120_tiny_poll(struct syntiant_ndp120_tiny_device_s *ndp,
1135
1138
1136
1139
* notifications = 0 ;
1137
1140
1138
- retry :
1139
-
1140
1141
s = syntiant_ndp120_tiny_read (
1141
1142
ndp , SYNTIANT_NDP120_SPI_OP , NDP120_SPI_INTSTS , & intsts );
1142
1143
if (s ) goto error ;
1143
1144
1144
- /* this is unlikely, and is probably a result of a reset.
1145
- ignoring this causes false notifications that often
1146
- result in a host crash */
1147
-
1148
- if (intsts == 0xFF ) {
1149
- uint8_t id ;
1150
- uint32_t timeout = 0xffffffff ;
1151
- do {
1152
- s = syntiant_ndp120_tiny_read (
1153
- ndp , SYNTIANT_NDP120_SPI_OP , NDP120_SPI_ID0 , & id );
1154
- if (s ) goto error ;
1155
- if (id != 0xFF ) {
1156
- goto retry ;
1157
- }
1158
- timeout -- ;
1159
- } while (timeout );
1160
-
1161
- * notifications = SYNTIANT_NDP120_NOTIFICATION_ERROR ;
1162
- goto error ;
1163
- }
1164
-
1165
1145
if (clear ) {
1166
1146
s = syntiant_ndp120_tiny_write (
1167
1147
ndp , SYNTIANT_NDP120_SPI_OP , NDP120_SPI_INTSTS , intsts );
@@ -1794,7 +1774,7 @@ int syntiant_ndp120_tiny_send_audio_extract(struct syntiant_ndp120_tiny_device_s
1794
1774
}
1795
1775
}
1796
1776
1797
- /* write secure cmd */
1777
+ /* write cmd */
1798
1778
s = syntiant_ndp120_tiny_write (ndp , SYNTIANT_NDP120_MCU_OP , addr , cmd );
1799
1779
addr += (uint32_t ) sizeof (cmd );
1800
1780
if (s ) goto error ;
@@ -1808,11 +1788,109 @@ int syntiant_ndp120_tiny_send_audio_extract(struct syntiant_ndp120_tiny_device_s
1808
1788
s = syntiant_ndp120_tiny_write_block (ndp , SYNTIANT_NDP120_MCU_OP , addr , & extract_from , sizeof (extract_from ));
1809
1789
if (s ) goto error ;
1810
1790
1811
- /* send secure command */
1791
+ /* send command */
1792
+ s = syntiant_ndp120_tiny_do_mailbox_req_no_sync (ndp ,
1793
+ SYNTIANT_NDP120_MB_MCU_CMD , NULL );
1794
+ if (s ) goto error ;
1795
+
1796
+ error :
1797
+ if (ndp -> iif -> unsync ) {
1798
+ s0 = (ndp -> iif -> unsync )(ndp -> iif -> d );
1799
+ s = s ? s : s0 ;
1800
+ }
1801
+ return s ;
1802
+ }
1803
+
1804
+ int syntiant_ndp120_tiny_spi_direct_config (struct syntiant_ndp120_tiny_device_s * ndp ,
1805
+ uint32_t threshold_bytes )
1806
+ {
1807
+ uint8_t data_8 ;
1808
+ int s0 ;
1809
+ int s = SYNTIANT_NDP120_ERROR_NONE ;
1810
+ uint32_t addr = SYNTIANT_NDP120_DL_WINDOW_LOWER ;
1811
+ /*uint32_t address = SYNTIANT_NDP120_OPEN_RAM_RESULTS;*/
1812
+ uint32_t cmd = SYNTIANT_NDP120_SET_SPI_DIRECT ;
1813
+ uint32_t length = sizeof (threshold_bytes );
1814
+ if (ndp -> iif -> sync ) {
1815
+ s = (ndp -> iif -> sync )(ndp -> iif -> d );
1816
+ if (s ) {
1817
+ SYNTIANT_NDP120_PRINTF ("Error in syntiant_ndp120_tiny_spi_direct_config\n" );
1818
+ return s ;
1819
+ }
1820
+ }
1821
+
1822
+ /* write cmd */
1823
+ s = syntiant_ndp120_tiny_write (ndp , SYNTIANT_NDP120_MCU_OP , addr , cmd );
1824
+ addr += (uint32_t ) sizeof (cmd );
1825
+ if (s ) goto error ;
1826
+ /* write the length of payload */
1827
+ s = syntiant_ndp120_tiny_write (ndp , SYNTIANT_NDP120_MCU_OP , addr , length );
1828
+ if (s ) goto error ;
1829
+
1830
+ addr += (uint32_t ) sizeof (length );
1831
+ /* write payload */
1832
+ s = syntiant_ndp120_tiny_write_block (ndp , SYNTIANT_NDP120_MCU_OP , addr , & threshold_bytes , sizeof (threshold_bytes ));
1833
+ if (s ) goto error ;
1834
+ /* send command */
1835
+ s = syntiant_ndp120_tiny_do_mailbox_req_no_sync (ndp ,
1836
+ SYNTIANT_NDP120_MB_MCU_CMD , NULL );
1837
+ if (s ) goto error ;
1838
+ /*enabling watermark interrupt*/
1839
+ s = ndp_spi_read (NDP120_SPI_INTCTL , & data_8 );
1840
+ if (s ) goto error ;
1841
+ data_8 = NDP120_SPI_INTCTL_WM_INTEN_INSERT (data_8 , 1 );
1842
+ ndp_spi_write (NDP120_SPI_INTCTL , data_8 );
1843
+
1844
+ error :
1845
+ if (ndp -> iif -> unsync ) {
1846
+ s0 = (ndp -> iif -> unsync )(ndp -> iif -> d );
1847
+ s = s ? s : s0 ;
1848
+ }
1849
+ return s ;
1850
+ }
1851
+
1852
+ int
1853
+ syntiant_ndp120_tiny_switch_dnn_flow (struct syntiant_ndp120_tiny_device_s * ndp ,
1854
+ uint32_t flow_set_id , uint32_t * input_mode )
1855
+ {
1856
+ uint8_t data_8 ;
1857
+ int s0 ;
1858
+ int s = SYNTIANT_NDP120_ERROR_NONE ;
1859
+ uint32_t addr = SYNTIANT_NDP120_DL_WINDOW_LOWER ;
1860
+ uint32_t address = SYNTIANT_NDP120_OPEN_RAM_RESULTS ;
1861
+ uint32_t cmd [3 ] = {SYNTIANT_NDP120_SWITCH_FLOW_SET_ID , sizeof (flow_set_id ), 0 };
1862
+ if (ndp -> iif -> sync ) {
1863
+ s = (ndp -> iif -> sync )(ndp -> iif -> d );
1864
+ if (s ) {
1865
+ SYNTIANT_NDP120_PRINTF ("Error in syntiant_ndp120_tiny_switch_dnn_flow\n" );
1866
+ return s ;
1867
+ }
1868
+ }
1869
+ cmd [2 ] = flow_set_id ;
1870
+
1871
+ /* write cmd, length of the payload and payload */
1872
+ s = syntiant_ndp120_tiny_write_block (ndp , SYNTIANT_NDP120_MCU_OP , addr ,
1873
+ & cmd , sizeof (cmd ));
1874
+ if (s ) goto error ;
1875
+
1812
1876
s = syntiant_ndp120_tiny_do_mailbox_req_no_sync (ndp ,
1813
1877
SYNTIANT_NDP120_MB_MCU_CMD , NULL );
1814
1878
if (s ) goto error ;
1815
1879
1880
+ /* read input_mode */
1881
+ s = syntiant_ndp120_tiny_read_block (ndp ,SYNTIANT_NDP120_MCU_OP , address , input_mode ,
1882
+ sizeof (* input_mode ));
1883
+ if (s ) goto error ;
1884
+
1885
+ if (* input_mode == SYNTIANT_NDP120_TINY_INPUT_CONFIG_SPI ) {
1886
+ /*enabling watermark interrupt*/
1887
+ s = ndp_spi_read (NDP120_SPI_INTCTL , & data_8 );
1888
+ if (s ) goto error ;
1889
+ data_8 = NDP120_SPI_INTCTL_WM_INTEN_INSERT (data_8 , 1 );
1890
+ s = ndp_spi_write (NDP120_SPI_INTCTL , data_8 );
1891
+ if (s ) goto error ;
1892
+ }
1893
+
1816
1894
error :
1817
1895
if (ndp -> iif -> unsync ) {
1818
1896
s0 = (ndp -> iif -> unsync )(ndp -> iif -> d );
@@ -1821,6 +1899,7 @@ int syntiant_ndp120_tiny_send_audio_extract(struct syntiant_ndp120_tiny_device_s
1821
1899
return s ;
1822
1900
}
1823
1901
1902
+
1824
1903
int
1825
1904
syntiant_ndp120_tiny_get_info (struct syntiant_ndp120_tiny_device_s * ndp ,
1826
1905
struct syntiant_ndp120_tiny_info * idata )
@@ -1834,7 +1913,7 @@ syntiant_ndp120_tiny_get_info(struct syntiant_ndp120_tiny_device_s *ndp,
1834
1913
if (ndp -> iif -> sync ) {
1835
1914
s = (ndp -> iif -> sync )(ndp -> iif -> d );
1836
1915
if (s ) {
1837
- SYNTIANT_NDP120_PRINTF ("Error in syntiant_ndp120_secure_get_info \n" );
1916
+ SYNTIANT_NDP120_PRINTF ("Error in syntiant_ndp120_tiny_get_info \n" );
1838
1917
return s ;
1839
1918
}
1840
1919
}
@@ -1986,3 +2065,60 @@ int syntiant_ndp120_tiny_get_debug(struct syntiant_ndp120_tiny_device_s *ndp,
1986
2065
}
1987
2066
return s ;
1988
2067
}
2068
+
2069
+ int syntiant_ndp120_tiny_input_config (struct syntiant_ndp120_tiny_device_s * ndp , uint32_t input_mode )
2070
+ {
2071
+ int s0 ;
2072
+ uint8_t data_8 ;
2073
+ int s = SYNTIANT_NDP120_ERROR_NONE ;
2074
+ uint32_t addr = SYNTIANT_NDP120_DL_WINDOW_LOWER ;
2075
+ uint32_t address = SYNTIANT_NDP120_OPEN_RAM_RESULTS ;
2076
+ uint32_t configured_input = SYNTIANT_NDP120_TINY_GET_INPUT_CONFIG ;
2077
+ uint32_t data [3 ] = {SYNTIANT_NDP120_INPUT_CONFIG , sizeof (input_mode ), SYNTIANT_NDP120_TINY_GET_INPUT_CONFIG };
2078
+ if (ndp -> iif -> sync ) {
2079
+ s = (ndp -> iif -> sync )(ndp -> iif -> d );
2080
+ if (s ) {
2081
+ SYNTIANT_NDP120_PRINTF ("Error in syntiant_ndp120_tiny_input_config\n" );
2082
+ return s ;
2083
+ }
2084
+ }
2085
+ /* write cmd, length of payload, payload */
2086
+ s = syntiant_ndp120_tiny_write_block (ndp , SYNTIANT_NDP120_MCU_OP , addr , & data , sizeof (data ));
2087
+ if (s ) goto error ;
2088
+
2089
+ /* send command */
2090
+ s = syntiant_ndp120_tiny_do_mailbox_req_no_sync (ndp ,SYNTIANT_NDP120_MB_MCU_CMD , NULL );
2091
+ if (s ) goto error ;
2092
+
2093
+ s = syntiant_ndp120_tiny_read_block (ndp ,SYNTIANT_NDP120_MCU_OP , address , & configured_input ,sizeof (configured_input ));
2094
+ if (s ) goto error ;
2095
+
2096
+ if (configured_input != input_mode ) {
2097
+ data [2 ] = input_mode ;
2098
+ addr = SYNTIANT_NDP120_DL_WINDOW_LOWER ;
2099
+ /* write payload */
2100
+ s = syntiant_ndp120_tiny_write_block (ndp , SYNTIANT_NDP120_MCU_OP , addr , & data , sizeof (data ));
2101
+ if (s ) goto error ;
2102
+
2103
+ /* send command */
2104
+ s = syntiant_ndp120_tiny_do_mailbox_req_no_sync (ndp ,SYNTIANT_NDP120_MB_MCU_CMD , NULL );
2105
+ if (s ) goto error ;
2106
+ } else {
2107
+ s = SYNTIANT_NDP120_ERROR_CONFIG ;
2108
+ goto error ;
2109
+ }
2110
+ if (input_mode == SYNTIANT_NDP120_TINY_INPUT_CONFIG_SPI ) {
2111
+ /*enabling watermark interrupt*/
2112
+ s = ndp_spi_read (NDP120_SPI_INTCTL , & data_8 );
2113
+ if (s ) goto error ;
2114
+ data_8 = NDP120_SPI_INTCTL_WM_INTEN_INSERT (data_8 , 1 );
2115
+ s = ndp_spi_write (NDP120_SPI_INTCTL , data_8 );
2116
+ if (s ) goto error ;
2117
+ }
2118
+ error :
2119
+ if (ndp -> iif -> unsync ) {
2120
+ s0 = (ndp -> iif -> unsync )(ndp -> iif -> d );
2121
+ s = s ? s : s0 ;
2122
+ }
2123
+ return s ;
2124
+ }
0 commit comments