Lines Matching refs:obj

185 static void _cyhal_qspi_set_pins_frozen(cyhal_qspi_t* obj, bool freeze)  in _cyhal_qspi_set_pins_frozen()  argument
192 gpio = obj->pin_io[i]; in _cyhal_qspi_set_pins_frozen()
199 obj->saved_io_hsiom[i] = Cy_GPIO_GetHSIOM(port, pin); in _cyhal_qspi_set_pins_frozen()
205 Cy_GPIO_SetHSIOM(port, pin, obj->saved_io_hsiom[i]); in _cyhal_qspi_set_pins_frozen()
210 gpio = obj->pin_sclk; in _cyhal_qspi_set_pins_frozen()
217 obj->saved_sclk_hsiom = Cy_GPIO_GetHSIOM(port, pin); in _cyhal_qspi_set_pins_frozen()
223 Cy_GPIO_SetHSIOM(port, pin, obj->saved_sclk_hsiom); in _cyhal_qspi_set_pins_frozen()
229 gpio = obj->pin_ssel[i]; in _cyhal_qspi_set_pins_frozen()
236 obj->saved_ssel_hsiom[i] = Cy_GPIO_GetHSIOM(port, pin); in _cyhal_qspi_set_pins_frozen()
242 Cy_GPIO_SetHSIOM(port, pin, obj->saved_ssel_hsiom[i]); in _cyhal_qspi_set_pins_frozen()
251 cyhal_qspi_t *obj = (cyhal_qspi_t *)callback_arg; in _cyhal_qspi_pm_callback() local
256 allow &= obj->context.txBufferCounter == 0; in _cyhal_qspi_pm_callback()
257 allow &= obj->context.rxBufferCounter == 0; in _cyhal_qspi_pm_callback()
258 allow &= Cy_SMIF_GetRxFifoStatus(obj->base) == 0; in _cyhal_qspi_pm_callback()
259 allow &= Cy_SMIF_GetTxFifoStatus(obj->base) == 0; in _cyhal_qspi_pm_callback()
262 obj->pm_transition_pending = true; in _cyhal_qspi_pm_callback()
266 _cyhal_qspi_set_pins_frozen(obj, true); in _cyhal_qspi_pm_callback()
269 _cyhal_qspi_set_pins_frozen(obj, false); in _cyhal_qspi_pm_callback()
270 obj->pm_transition_pending = false; in _cyhal_qspi_pm_callback()
273 obj->pm_transition_pending = false; in _cyhal_qspi_pm_callback()
301 cyhal_qspi_t *obj = (cyhal_qspi_t *)_cyhal_qspi_irq_obj; in _cyhal_qspi_cb_wrapper() local
303 …if ((obj->irq_cause & (uint32_t)hal_event) > 0) // Make sure a user requested event is set before … in _cyhal_qspi_cb_wrapper()
305 … cyhal_qspi_event_callback_t callback = (cyhal_qspi_event_callback_t) obj->callback_data.callback; in _cyhal_qspi_cb_wrapper()
306 callback(obj->callback_data.callback_arg, hal_event); in _cyhal_qspi_cb_wrapper()
322 cyhal_qspi_t* obj = (cyhal_qspi_t*)_cyhal_qspi_irq_obj; in _cyhal_qspi_irq_handler() local
324 Cy_SMIF_Interrupt(obj->base, &(obj->context)); in _cyhal_qspi_irq_handler()
422 static cy_rslt_t _cyhal_qspi_command_transfer(cyhal_qspi_t *obj, const cyhal_qspi_command_t *comman… in _cyhal_qspi_command_transfer() argument
489 …result = (cy_rslt_t)Cy_SMIF_TransmitCommand(obj->base, (uint8_t)(command->instruction.value & 0xFF… in _cyhal_qspi_command_transfer()
491 … (addr_size + mode_bits_size), bus_width, obj->slave_select, cmpltTxfr, &obj->context); in _cyhal_qspi_command_transfer()
493 result = (cy_rslt_t)Cy_SMIF_TransmitCommand_Ext(obj->base, command->instruction.value, in _cyhal_qspi_command_transfer()
496 bus_width, data_rate, obj->slave_select, cmpltTxfr, &obj->context); in _cyhal_qspi_command_transfer()
650 static cy_rslt_t _cyhal_qspi_slave_select_check_reserve(cyhal_qspi_t *obj, cyhal_gpio_t ssel, uint8… in _cyhal_qspi_slave_select_check_reserve() argument
653 CY_ASSERT(NULL != obj); in _cyhal_qspi_slave_select_check_reserve()
656 if ((NULL == ssel_map) || !_cyhal_utils_map_resource_equal(&obj->resource, ssel_map, true)) in _cyhal_qspi_slave_select_check_reserve()
661 if (NC != obj->pin_ssel[*found_idx]) in _cyhal_qspi_slave_select_check_reserve()
673 obj->pin_ssel[*found_idx] = ssel; in _cyhal_qspi_slave_select_check_reserve()
679 static cy_rslt_t _cyhal_qspi_process_pin_set(cyhal_qspi_t *obj, const cyhal_qspi_slave_pin_config_t… in _cyhal_qspi_process_pin_set() argument
682 CY_ASSERT(NULL != obj); in _cyhal_qspi_process_pin_set()
725 !_cyhal_utils_map_resource_equal(&obj->resource, io_maps[pin_offset],true)) in _cyhal_qspi_process_pin_set()
751 … if (NULL == io_maps[i] || !_cyhal_utils_map_resource_equal(&obj->resource, io_maps[i],true)) in _cyhal_qspi_process_pin_set()
761 …result = _cyhal_qspi_slave_select_check_reserve(obj, pin_set->ssel, found_ssel_idx, reserve_n_conn… in _cyhal_qspi_process_pin_set()
769 if ((NC != pin_set->io[i-pin_offset]) && (NC == obj->pin_io[i])) in _cyhal_qspi_process_pin_set()
777 obj->pin_io[i] = pin_set->io[i-pin_offset]; in _cyhal_qspi_process_pin_set()
787 static cy_rslt_t _cyhal_qspi_init_common(cyhal_qspi_t *obj, const cyhal_qspi_configurator_t *cfg, u… in _cyhal_qspi_init_common() argument
790 memset(obj, 0, sizeof(cyhal_qspi_t)); in _cyhal_qspi_init_common()
791 obj->resource.type = CYHAL_RSC_INVALID; in _cyhal_qspi_init_common()
792 obj->is_clock_owned = false; in _cyhal_qspi_init_common()
794 obj->dc_configured = (NULL != cfg->resource); in _cyhal_qspi_init_common()
795 if ((obj->dc_configured) && in _cyhal_qspi_init_common()
844 if ((CY_RSLT_SUCCESS == result) && (false == obj->dc_configured)) in _cyhal_qspi_init_common()
851 obj->pin_sclk = cfg->gpios.sclk; in _cyhal_qspi_init_common()
855 obj->pin_ssel[i] = NC; in _cyhal_qspi_init_common()
859 obj->pin_io[i] = NC; in _cyhal_qspi_init_common()
880 if (obj->dc_configured) in _cyhal_qspi_init_common()
882 obj->resource = *cfg->resource; in _cyhal_qspi_init_common()
894 obj->resource = rsc; in _cyhal_qspi_init_common()
901 …result = _cyhal_qspi_process_pin_set(obj, &pin_set, &data_select, &found_ssel_idx, !obj->dc_config… in _cyhal_qspi_init_common()
907 obj->base = _cyhal_qspi_base_addresses[obj->resource.block_num]; in _cyhal_qspi_init_common()
917 obj->clock = *cfg->clock; in _cyhal_qspi_init_common()
932 …result = _cyhal_utils_allocate_clock(&(obj->clock), &(obj->resource), CYHAL_CLOCK_BLOCK_PERIPHERAL… in _cyhal_qspi_init_common()
933 obj->is_clock_owned = (result == CY_RSLT_SUCCESS); in _cyhal_qspi_init_common()
937 if (obj->is_clock_owned) in _cyhal_qspi_init_common()
941 result = cyhal_qspi_set_frequency(obj, hz); in _cyhal_qspi_init_common()
946 result = cyhal_clock_set_enabled(&(obj->clock), true, true); in _cyhal_qspi_init_common()
952 …result = (cy_rslt_t) Cy_SMIF_Init(obj->base, cfg->config, _CYHAL_QSPI_TIMEOUT_10_MS, &obj->context… in _cyhal_qspi_init_common()
958 obj->slave_select = _cyhal_qspi_slave_idx_to_smif_ss(found_ssel_idx); in _cyhal_qspi_init_common()
959 Cy_SMIF_SetDataSelect(obj->base, obj->slave_select, data_select); in _cyhal_qspi_init_common()
970 …result = _cyhal_qspi_process_pin_set(obj, &pin_set, &data_select, &found_ssel_idx, !obj->dc_config… in _cyhal_qspi_init_common()
973 … Cy_SMIF_SetDataSelect(obj->base, _cyhal_qspi_slave_idx_to_smif_ss(found_ssel_idx), data_select); in _cyhal_qspi_init_common()
981 Cy_SMIF_Enable(obj->base, &obj->context); in _cyhal_qspi_init_common()
983 obj->callback_data.callback = NULL; in _cyhal_qspi_init_common()
984 obj->callback_data.callback_arg = NULL; in _cyhal_qspi_init_common()
985 obj->irq_cause = CYHAL_QSPI_EVENT_NONE; in _cyhal_qspi_init_common()
986 _cyhal_qspi_config_structs[obj->resource.block_num] = obj; in _cyhal_qspi_init_common()
988 obj->pm_transition_pending = false; in _cyhal_qspi_init_common()
989 obj->pm_callback.callback = &_cyhal_qspi_pm_callback; in _cyhal_qspi_init_common()
990obj->pm_callback.states = (cyhal_syspm_callback_state_t)(CYHAL_SYSPM_CB_CPU_DEEPSLEEP | CYHAL_SYSP… in _cyhal_qspi_init_common()
991 obj->pm_callback.args = obj; in _cyhal_qspi_init_common()
992 obj->pm_callback.next = NULL; in _cyhal_qspi_init_common()
993 obj->pm_callback.ignore_modes = CYHAL_SYSPM_AFTER_DS_WFI_TRANSITION; in _cyhal_qspi_init_common()
994 _cyhal_syspm_register_peripheral_callback(&(obj->pm_callback)); in _cyhal_qspi_init_common()
997 …_cyhal_irq_register(_cyhal_qspi_irq_n[obj->resource.block_num], CYHAL_ISR_PRIORITY_DEFAULT, _cyhal… in _cyhal_qspi_init_common()
998 _cyhal_irq_enable(_cyhal_qspi_irq_n[obj->resource.block_num]); in _cyhal_qspi_init_common()
1003 cyhal_qspi_free(obj); in _cyhal_qspi_init_common()
1010 …cyhal_qspi_t *obj, cyhal_gpio_t sclk, const cyhal_qspi_slave_pin_config_t *pin_set, uint32_t hz, u… in cyhal_qspi_init() argument
1013 CY_ASSERT(NULL != obj); in cyhal_qspi_init()
1056 return _cyhal_qspi_init_common(obj, &cfg, hz); in cyhal_qspi_init()
1059 cy_rslt_t cyhal_qspi_init_cfg(cyhal_qspi_t *obj, const cyhal_qspi_configurator_t *cfg) in cyhal_qspi_init_cfg() argument
1061 CY_ASSERT(NULL != obj); in cyhal_qspi_init_cfg()
1066 return _cyhal_qspi_init_common(obj, cfg, 0); in cyhal_qspi_init_cfg()
1069 void cyhal_qspi_free(cyhal_qspi_t *obj) in cyhal_qspi_free() argument
1071 if (CYHAL_RSC_SMIF == obj->resource.type) in cyhal_qspi_free()
1073 _cyhal_system_irq_t irqn = _cyhal_qspi_irq_n[obj->resource.block_num]; in cyhal_qspi_free()
1076 _cyhal_syspm_unregister_peripheral_callback(&(obj->pm_callback)); in cyhal_qspi_free()
1078 if (obj->base != NULL) in cyhal_qspi_free()
1080 Cy_SMIF_Disable(obj->base); in cyhal_qspi_free()
1081 Cy_SMIF_DeInit(obj->base); in cyhal_qspi_free()
1082 obj->base = NULL; in cyhal_qspi_free()
1084 if (!obj->dc_configured) in cyhal_qspi_free()
1086 cyhal_hwmgr_free(&(obj->resource)); in cyhal_qspi_free()
1088 obj->resource.type = CYHAL_RSC_INVALID; in cyhal_qspi_free()
1091 if (!obj->dc_configured) in cyhal_qspi_free()
1093 _cyhal_utils_release_if_used(&(obj->pin_sclk)); in cyhal_qspi_free()
1096 _cyhal_utils_release_if_used(&(obj->pin_ssel[i])); in cyhal_qspi_free()
1100 _cyhal_utils_release_if_used(&(obj->pin_io[i])); in cyhal_qspi_free()
1104 if (obj->is_clock_owned) in cyhal_qspi_free()
1106 cyhal_clock_free(&(obj->clock)); in cyhal_qspi_free()
1107 obj->is_clock_owned = false; in cyhal_qspi_free()
1111 cy_rslt_t cyhal_qspi_set_frequency(cyhal_qspi_t *obj, uint32_t hz) in cyhal_qspi_set_frequency() argument
1113 CY_ASSERT(NULL != obj); in cyhal_qspi_set_frequency()
1116 if (obj->is_clock_owned) in cyhal_qspi_set_frequency()
1125 return _cyhal_utils_set_clock_frequency2(&(obj->clock), hz, &tolerance); in cyhal_qspi_set_frequency()
1136 uint32_t cyhal_qspi_get_frequency(cyhal_qspi_t *obj) in cyhal_qspi_get_frequency() argument
1138 CY_ASSERT(NULL != obj); in cyhal_qspi_get_frequency()
1139 uint32_t freq = cyhal_clock_get_frequency(&(obj->clock)); in cyhal_qspi_get_frequency()
1148 cy_rslt_t cyhal_qspi_slave_configure(cyhal_qspi_t *obj, const cyhal_qspi_slave_pin_config_t *pin_se… in cyhal_qspi_slave_configure() argument
1150 CY_ASSERT(NULL != obj); in cyhal_qspi_slave_configure()
1153 cy_rslt_t result = _cyhal_qspi_process_pin_set(obj, pin_set, &data_select, &ssel_idx, true); in cyhal_qspi_slave_configure()
1156 Cy_SMIF_SetDataSelect(obj->base, _cyhal_qspi_slave_idx_to_smif_ss(ssel_idx), data_select); in cyhal_qspi_slave_configure()
1161 cy_rslt_t cyhal_qspi_select_active_ssel(cyhal_qspi_t *obj, cyhal_gpio_t ssel) in cyhal_qspi_select_active_ssel() argument
1163 CY_ASSERT(NULL != obj); in cyhal_qspi_select_active_ssel()
1166 if (ssel == obj->pin_ssel[ssel_idx]) in cyhal_qspi_select_active_ssel()
1168 obj->slave_select = _cyhal_qspi_slave_idx_to_smif_ss(ssel_idx); in cyhal_qspi_select_active_ssel()
1175 static cy_rslt_t _cyhal_qspi_wait_for_cmd_fifo(cyhal_qspi_t *obj) in _cyhal_qspi_wait_for_cmd_fifo() argument
1179 while ((Cy_SMIF_GetCmdFifoStatus(obj->base) == CY_SMIF_TX_CMD_FIFO_STATUS_RANGE) && in _cyhal_qspi_wait_for_cmd_fifo()
1191 cy_rslt_t cyhal_qspi_read(cyhal_qspi_t *obj, const cyhal_qspi_command_t *command, uint32_t address,… in cyhal_qspi_read() argument
1194 if (obj->pm_transition_pending) in cyhal_qspi_read()
1209 status = _cyhal_qspi_command_transfer(obj, command, address, false); in cyhal_qspi_read()
1215 status = _cyhal_qspi_wait_for_cmd_fifo(obj); in cyhal_qspi_read()
1219 … status = (cy_rslt_t)Cy_SMIF_SendDummyCycles(obj->base, command->dummy_cycles.dummy_count); in cyhal_qspi_read()
1221 status = (cy_rslt_t)Cy_SMIF_SendDummyCycles_Ext(obj->base, in cyhal_qspi_read()
1230 status = _cyhal_qspi_wait_for_cmd_fifo(obj); in cyhal_qspi_read()
1234 … status = (cy_rslt_t)Cy_SMIF_ReceiveDataBlocking(obj->base, (uint8_t *)data, chunk, in cyhal_qspi_read()
1235 _cyhal_qspi_convert_bus_width(command->data.bus_width), &obj->context); in cyhal_qspi_read()
1237 … status = (cy_rslt_t)Cy_SMIF_ReceiveDataBlocking_Ext(obj->base, (uint8_t *)data, chunk, in cyhal_qspi_read()
1239 (cy_en_smif_data_rate_t)command->data.data_rate, &obj->context); in cyhal_qspi_read()
1256 cy_rslt_t cyhal_qspi_read_async(cyhal_qspi_t *obj, const cyhal_qspi_command_t *command, uint32_t ad… in cyhal_qspi_read_async() argument
1259 if (obj->pm_transition_pending) in cyhal_qspi_read_async()
1265 cy_rslt_t status = _cyhal_qspi_command_transfer(obj, command, address, false); in cyhal_qspi_read_async()
1271 status = _cyhal_qspi_wait_for_cmd_fifo(obj); in cyhal_qspi_read_async()
1275 … status = (cy_rslt_t)Cy_SMIF_SendDummyCycles(obj->base, command->dummy_cycles.dummy_count); in cyhal_qspi_read_async()
1277 status = (cy_rslt_t)Cy_SMIF_SendDummyCycles_Ext(obj->base, in cyhal_qspi_read_async()
1286 status = _cyhal_qspi_wait_for_cmd_fifo(obj); in cyhal_qspi_read_async()
1290 … status = (cy_rslt_t)Cy_SMIF_ReceiveData(obj->base, (uint8_t *)data, (uint32_t)*length, in cyhal_qspi_read_async()
1291 … _cyhal_qspi_convert_bus_width(command->data.bus_width), _cyhal_qspi_cb_wrapper, &obj->context); in cyhal_qspi_read_async()
1293 … status = (cy_rslt_t)Cy_SMIF_ReceiveData_Ext(obj->base, (uint8_t *)data, (uint32_t)*length, in cyhal_qspi_read_async()
1295 … (cy_en_smif_data_rate_t)command->data.data_rate, _cyhal_qspi_cb_wrapper, &obj->context); in cyhal_qspi_read_async()
1304 cy_rslt_t cyhal_qspi_write(cyhal_qspi_t *obj, const cyhal_qspi_command_t *command, uint32_t address… in cyhal_qspi_write() argument
1308 if (obj->pm_transition_pending) in cyhal_qspi_write()
1313 cy_rslt_t status = _cyhal_qspi_command_transfer(obj, command, address, false); in cyhal_qspi_write()
1319 status = _cyhal_qspi_wait_for_cmd_fifo(obj); in cyhal_qspi_write()
1323 … status = (cy_rslt_t)Cy_SMIF_SendDummyCycles(obj->base, command->dummy_cycles.dummy_count); in cyhal_qspi_write()
1325 status = (cy_rslt_t)Cy_SMIF_SendDummyCycles_Ext(obj->base, in cyhal_qspi_write()
1334 status = _cyhal_qspi_wait_for_cmd_fifo(obj); in cyhal_qspi_write()
1338 … status = (cy_rslt_t)Cy_SMIF_TransmitDataBlocking(obj->base, (uint8_t *)data, *length, in cyhal_qspi_write()
1339 _cyhal_qspi_convert_bus_width(command->data.bus_width), &obj->context); in cyhal_qspi_write()
1341 … status = (cy_rslt_t)Cy_SMIF_TransmitDataBlocking_Ext(obj->base, (uint8_t *)data, *length, in cyhal_qspi_write()
1343 (cy_en_smif_data_rate_t)command->data.data_rate, &obj->context); in cyhal_qspi_write()
1353 cy_rslt_t cyhal_qspi_write_async(cyhal_qspi_t *obj, const cyhal_qspi_command_t *command, uint32_t a… in cyhal_qspi_write_async() argument
1356 if (obj->pm_transition_pending) in cyhal_qspi_write_async()
1362 cy_rslt_t status = _cyhal_qspi_command_transfer(obj, command, address, false); in cyhal_qspi_write_async()
1368 status = _cyhal_qspi_wait_for_cmd_fifo(obj); in cyhal_qspi_write_async()
1372 … status = (cy_rslt_t)Cy_SMIF_SendDummyCycles(obj->base, command->dummy_cycles.dummy_count); in cyhal_qspi_write_async()
1374 status = (cy_rslt_t)Cy_SMIF_SendDummyCycles_Ext(obj->base, in cyhal_qspi_write_async()
1383 status = _cyhal_qspi_wait_for_cmd_fifo(obj); in cyhal_qspi_write_async()
1387 status = (cy_rslt_t)Cy_SMIF_TransmitData(obj->base, (uint8_t *)data, *length, in cyhal_qspi_write_async()
1388 … _cyhal_qspi_convert_bus_width(command->data.bus_width), _cyhal_qspi_cb_wrapper, &obj->context); in cyhal_qspi_write_async()
1390 status = (cy_rslt_t)Cy_SMIF_TransmitData_Ext(obj->base, (uint8_t *)data, *length, in cyhal_qspi_write_async()
1392 … (cy_en_smif_data_rate_t)command->data.data_rate, _cyhal_qspi_cb_wrapper, &obj->context); in cyhal_qspi_write_async()
1401 …cyhal_qspi_t *obj, const cyhal_qspi_command_t *command, uint32_t address, const void *tx_data, siz… in cyhal_qspi_transfer() argument
1405 if (obj->pm_transition_pending) in cyhal_qspi_transfer()
1416 status = _cyhal_qspi_command_transfer(obj, command, address, true); in cyhal_qspi_transfer()
1422 status = cyhal_qspi_write(obj, command, address, tx_data, &tx_size); in cyhal_qspi_transfer()
1429 status = cyhal_qspi_read(obj, command, address, rx_data, &rx_size); in cyhal_qspi_transfer()
1436 void cyhal_qspi_register_callback(cyhal_qspi_t *obj, cyhal_qspi_event_callback_t callback, void *ca… in cyhal_qspi_register_callback() argument
1439 obj->callback_data.callback = (cy_israddress) callback; in cyhal_qspi_register_callback()
1440 obj->callback_data.callback_arg = callback_arg; in cyhal_qspi_register_callback()
1443 obj->irq_cause = CYHAL_QSPI_EVENT_NONE; in cyhal_qspi_register_callback()
1446 void cyhal_qspi_enable_event(cyhal_qspi_t *obj, cyhal_qspi_event_t event, uint8_t intr_priority, bo… in cyhal_qspi_enable_event() argument
1450 obj->irq_cause |= event; in cyhal_qspi_enable_event()
1454 obj->irq_cause &= ~event; in cyhal_qspi_enable_event()
1457 _cyhal_system_irq_t irqn = _cyhal_qspi_irq_n[obj->resource.block_num]; in cyhal_qspi_enable_event()