Просмотр исходного кода

remove: spi,device模式已经自带spi锁,不需要额外加锁

Wendal Chen 4 месяцев назад
Родитель
Сommit
52b6fc7e95
2 измененных файлов с 0 добавлено и 12 удалено
  1. 0 2
      components/little_flash/port/little_flash_port.c
  2. 0 10
      luat/modules/luat_lib_spi.c

+ 0 - 2
components/little_flash/port/little_flash_port.c

@@ -8,7 +8,6 @@
 static lf_err_t little_flash_spi_transfer(const little_flash_t *lf,uint8_t *tx_buf, uint32_t tx_len, uint8_t *rx_buf, uint32_t rx_len){
     lf_err_t result = LF_ERR_OK;
     luat_spi_device_t *spi_dev = (luat_spi_device_t*)lf->spi.user_data;
-    luat_spi_lock(spi_dev->spi_config.id);
     if (tx_len && rx_len) {
         if (luat_spi_device_transfer(spi_dev , (const char*)tx_buf, tx_len, (char*)rx_buf, rx_len) <= 0) {
             result = LF_ERR_TRANSFER;
@@ -22,7 +21,6 @@ static lf_err_t little_flash_spi_transfer(const little_flash_t *lf,uint8_t *tx_b
             result = LF_ERR_READ;
         }
     }
-    luat_spi_unlock(spi_dev->spi_config.id);
     return result;
 }
 

+ 0 - 10
luat/modules/luat_lib_spi.c

@@ -458,9 +458,7 @@ static int l_spi_recv(lua_State *L) {
     {
         luat_spi_device_t *spi_device = (luat_spi_device_t *)luaL_testudata(L, 1, META_SPI);
         if (spi_device){
-            luat_spi_lock(spi_device->bus_id);
             luat_spi_device_recv(spi_device, recv_buff, len);
-            luat_spi_unlock(spi_device->bus_id);
             ret = len;
         }
         else {
@@ -653,9 +651,7 @@ static int l_spi_device_transfer(lua_State *L) {
         if(recv_buff == NULL)
             return 0;
     }
-    luat_spi_lock(spi_device->bus_id);
     int ret = luat_spi_device_transfer(spi_device, send_buff, send_length, recv_buff, recv_length);
-    luat_spi_unlock(spi_device->bus_id);
     if (send_mode == LUA_TTABLE){
         luat_heap_free(send_buff);
     }
@@ -692,9 +688,7 @@ static int l_spi_device_send(lua_State *L) {
         luat_zbuff_t *buff = (luat_zbuff_t *)luaL_checkudata(L, 2, LUAT_ZBUFF_TYPE);
         send_buff = (char*)(buff->addr+buff->cursor);
         len = buff->len - buff->cursor;
-        luat_spi_lock(spi_device->bus_id);
         ret = luat_spi_device_send(spi_device, send_buff, len);
-        luat_spi_unlock(spi_device->bus_id);
         lua_pushinteger(L, ret);
     }else if (lua_istable(L, 2)){
         len = lua_rawlen(L, 2); //返回数组的长度
@@ -704,9 +698,7 @@ static int l_spi_device_send(lua_State *L) {
             send_buff[i] = (char)lua_tointeger(L, -1);
             lua_pop(L, 1); //将刚刚获取的元素值从栈中弹出
         }
-        luat_spi_lock(spi_device->bus_id);
         ret = luat_spi_device_send(spi_device, send_buff, len);
-        luat_spi_unlock(spi_device->bus_id);
         lua_pushinteger(L, ret);
         luat_heap_free(send_buff);
     }else if(lua_isstring(L, 2)){
@@ -735,9 +727,7 @@ static int l_spi_device_recv(lua_State *L) {
     int len = luaL_optinteger(L, 2,1);
     char* recv_buff = luat_heap_malloc(len);
     if(recv_buff == NULL) return 0;
-    luat_spi_lock(spi_device->bus_id);
     int ret = luat_spi_device_recv(spi_device, recv_buff, len);
-    luat_spi_unlock(spi_device->bus_id);
     if (ret > 0) {
         lua_pushlstring(L, recv_buff, ret);
         luat_heap_free(recv_buff);