@@ -305,7 +305,10 @@ enum {
305305 SYNTIANT_NDP120_GET_NN_GRAPH = 0x67 ,
306306 SYNTIANT_NDP120_GET_DEBUG_INFO = 0x68 ,
307307 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
309312};
310313
311314enum {
@@ -1135,33 +1138,10 @@ syntiant_ndp120_tiny_poll(struct syntiant_ndp120_tiny_device_s *ndp,
11351138
11361139 * notifications = 0 ;
11371140
1138- retry :
1139-
11401141 s = syntiant_ndp120_tiny_read (
11411142 ndp , SYNTIANT_NDP120_SPI_OP , NDP120_SPI_INTSTS , & intsts );
11421143 if (s ) goto error ;
11431144
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-
11651145 if (clear ) {
11661146 s = syntiant_ndp120_tiny_write (
11671147 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
17941774 }
17951775 }
17961776
1797- /* write secure cmd */
1777+ /* write cmd */
17981778 s = syntiant_ndp120_tiny_write (ndp , SYNTIANT_NDP120_MCU_OP , addr , cmd );
17991779 addr += (uint32_t ) sizeof (cmd );
18001780 if (s ) goto error ;
@@ -1808,11 +1788,109 @@ int syntiant_ndp120_tiny_send_audio_extract(struct syntiant_ndp120_tiny_device_s
18081788 s = syntiant_ndp120_tiny_write_block (ndp , SYNTIANT_NDP120_MCU_OP , addr , & extract_from , sizeof (extract_from ));
18091789 if (s ) goto error ;
18101790
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+
18121876 s = syntiant_ndp120_tiny_do_mailbox_req_no_sync (ndp ,
18131877 SYNTIANT_NDP120_MB_MCU_CMD , NULL );
18141878 if (s ) goto error ;
18151879
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+
18161894error :
18171895 if (ndp -> iif -> unsync ) {
18181896 s0 = (ndp -> iif -> unsync )(ndp -> iif -> d );
@@ -1821,6 +1899,7 @@ int syntiant_ndp120_tiny_send_audio_extract(struct syntiant_ndp120_tiny_device_s
18211899 return s ;
18221900}
18231901
1902+
18241903int
18251904syntiant_ndp120_tiny_get_info (struct syntiant_ndp120_tiny_device_s * ndp ,
18261905 struct syntiant_ndp120_tiny_info * idata )
@@ -1834,7 +1913,7 @@ syntiant_ndp120_tiny_get_info(struct syntiant_ndp120_tiny_device_s *ndp,
18341913 if (ndp -> iif -> sync ) {
18351914 s = (ndp -> iif -> sync )(ndp -> iif -> d );
18361915 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" );
18381917 return s ;
18391918 }
18401919 }
@@ -1986,3 +2065,60 @@ int syntiant_ndp120_tiny_get_debug(struct syntiant_ndp120_tiny_device_s *ndp,
19862065 }
19872066 return s ;
19882067}
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