Skip to content

Commit 3779e60

Browse files
authored
Merge pull request #407 from MikroElektronika/mikrosdk-2.14.6
mikrosdk-2.14.6
2 parents af66dc8 + 4646e82 commit 3779e60

File tree

34 files changed

+5844
-5040
lines changed

34 files changed

+5844
-5040
lines changed

changelog/v2.14.6/changelog.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<p align="center">
2+
<img src="http://www.mikroe.com/img/designs/beta/logo_small.png?raw=true" alt="MikroElektronika"/>
3+
</p>
4+
5+
---
6+
7+
**[BACK TO MAIN FILE](../../changelog.md)**
8+
9+
---
10+
11+
# `v2.14.6`
12+
13+
+ released: 2025-07-17
14+
15+
## Changes
16+
17+
- [`v2.14.6`](#v2146)
18+
- [Changes](#changes)
19+
- [New Features](#new-features)
20+
- [mikroSDK](#mikrosdk)
21+
- [Fixes](#fixes)
22+
- [FT800](#ft800)
23+
- [NEW HARDWARE](#new-hardware)
24+
25+
### New Features
26+
27+
#### mikroSDK
28+
29+
+ Introduced SPI transfer API
30+
+ Full-duplex SPI support available across all architectures in mikroSDK
31+
+ This addition enables simultaneous data transmission and reception via a single call
32+
33+
### Fixes
34+
35+
#### FT800
36+
37+
+ Refactored code to eliminate redundancy by encapsulating repeated logic into reusable functions
38+
+ Enhanced compatibility with compilers through conditional adjustments and code alignment:
39+
+ All MikroC compilers
40+
+ XC8 compiler
41+
+ Disabled FT800 support for AVR architectures due to insufficient performance for reliable display operation
42+
43+
### NEW HARDWARE
44+
45+
> NOTE:
46+
>> If any new hardware was added to current version, it will be listed here.
47+
48+
Support added for following hardware:
49+
50+
---
51+
52+
**[BACK TO MAIN FILE](../../changelog.md)**
53+
54+
---

drv/lib/include/drv_spi_master.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,38 @@ err_t spi_master_write_then_read( spi_master_t *obj, uint8_t *write_data_buffer,
515515
uint8_t *read_data_buffer,
516516
size_t length_read_data );
517517

518+
/**
519+
* @brief Full-duplex SPI transfer.
520+
* @details Simultaneously transmits and receives a buffer of data over SPI.
521+
* The data sent from the write buffer is echoed with received data into the read buffer.
522+
* @param[in] obj SPI master driver object.
523+
* @param[in] write_data_buffer Buffer containing bytes to transmit.
524+
* @param[out] read_data_buffer Buffer to store received bytes.
525+
* @param[in] data_length Number of bytes to transmit and receive.
526+
* @return One of the values defined by #spi_master_err_t.
527+
*
528+
* @pre Call #spi_master_open before this function.
529+
*
530+
* @b Example
531+
* @code
532+
* #define DATA_LENGTH 64
533+
*
534+
* uint8_t tx_buf[DATA_LENGTH] = { 0xA5, 0x5A, ... };
535+
* uint8_t rx_buf[DATA_LENGTH];
536+
*
537+
* spi_master_t spi;
538+
*
539+
* if ( SPI_MASTER_SUCCESS == spi_master_transfer( &spi, tx_buf, rx_buf, DATA_LENGTH ) ) {
540+
* // Successful transfer
541+
* } else {
542+
* // Handle the error
543+
* }
544+
* @endcode
545+
*/
546+
err_t spi_master_transfer( spi_master_t *obj, uint8_t *write_data_buffer,
547+
uint8_t *read_data_buffer,
548+
size_t data_length );
549+
518550
/**
519551
* @brief Close SPI Master Driver context object.
520552
* @details Closes SPI Master Driver context object,

drv/lib/src/lib_drv_spi_master/drv_spi_master.c

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ err_t spi_master_write_then_read( spi_master_t *obj, uint8_t *write_data_buffer,
374374
uint8_t *read_data_buffer,
375375
size_t length_read_data )
376376
{
377-
if ( _acquire( obj, false ) != ACQUIRE_FAIL )
378-
{
377+
if ( _acquire( obj, false ) != ACQUIRE_FAIL )
378+
{
379379
#if DRV_TO_HAL
380380
return hal_spi_master_write_then_read( &obj->handle, write_data_buffer,
381381
length_write_data,
@@ -424,7 +424,62 @@ err_t spi_master_write_then_read( spi_master_t *obj, uint8_t *write_data_buffer,
424424
return HAL_SPI_MASTER_SUCCESS;
425425
}
426426
#endif
427-
} else {
427+
} else {
428+
return SPI_MASTER_ERROR;
429+
}
430+
}
431+
432+
err_t spi_master_transfer( spi_master_t *obj, uint8_t *write_data_buffer,
433+
uint8_t *read_data_buffer,
434+
size_t data_length ) {
435+
if ( _acquire( obj, false ) != ACQUIRE_FAIL ) {
436+
#if DRV_TO_HAL
437+
return hal_spi_master_transfer( &obj->handle, write_data_buffer,
438+
read_data_buffer,
439+
data_length );
440+
#else
441+
hal_spi_master_handle_register_t *hal_handle = ( hal_spi_master_handle_register_t* )hal_is_handle_null( (handle_t *)&obj->handle );
442+
err_t hal_status = HAL_SPI_MASTER_SUCCESS;
443+
444+
if ( !hal_handle )
445+
{
446+
return HAL_SPI_MASTER_ERROR;
447+
}
448+
449+
if ( !write_data_buffer || !read_data_buffer )
450+
{
451+
return HAL_SPI_MASTER_ERROR;
452+
}
453+
454+
if ( data_length <= 0 )
455+
{
456+
return HAL_SPI_MASTER_ERROR;
457+
}
458+
459+
if ( hal_handle->init_state == false )
460+
{
461+
hal_status = hal_ll_module_configure_spi( (handle_t *)&hal_handle );
462+
}
463+
464+
if( hal_status != HAL_SPI_MASTER_SUCCESS )
465+
{
466+
return HAL_SPI_MASTER_ERROR;
467+
} else {
468+
hal_handle->init_state = true;
469+
}
470+
471+
hal_status = hal_spi_master_transfer( (handle_t *)&hal_handle, write_data_buffer,
472+
read_data_buffer,
473+
data_length );
474+
475+
if (hal_status == HAL_SPI_MASTER_MODULE_ERROR)
476+
{
477+
return HAL_SPI_MASTER_ERROR;
478+
} else {
479+
return HAL_SPI_MASTER_SUCCESS;
480+
}
481+
#endif
482+
} else {
428483
return SPI_MASTER_ERROR;
429484
}
430485
}

hal/lib/include/hal_spi_master.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,39 @@ err_t hal_spi_master_write_then_read( handle_t handle, uint8_t *write_data_buffe
486486
uint8_t *read_data_buffer,
487487
size_t length_read_data );
488488

489+
/**
490+
* @brief Perform full-duplex SPI transfer.
491+
* @details Simultaneously writes and reads a sequence of bytes on the
492+
* SPI bus in blocking mode. For each transmitted byte, a byte is received.
493+
*
494+
* @param[in] handle SPI master handle.
495+
* See #hal_spi_master_t structure definition for detailed explanation.
496+
* @param[in] write_data_buffer Buffer containing bytes to transmit.
497+
* @param[out] read_data_buffer Buffer to store received bytes.
498+
* @param[in] data_length Number of bytes to transmit and receive.
499+
*
500+
* @return The function can return one of the values defined by
501+
* #hal_spi_master_err_t, which is size dependant on the architecture.
502+
*
503+
* @pre Before calling this function,
504+
* the user is expected to call #hal_spi_master_open function.
505+
*
506+
* @note The transfer is performed in blocking mode.
507+
*
508+
* @b Example
509+
* @code
510+
* #define DATA_LENGTH 128
511+
*
512+
* uint8_t tx_data[ DATA_LENGTH ] = { 0xA5, 0x5A, ... };
513+
* uint8_t rx_data[ DATA_LENGTH ];
514+
*
515+
* hal_spi_master_transfer( handle, tx_data, rx_data, DATA_LENGTH );
516+
* @endcode
517+
*/
518+
err_t hal_spi_master_transfer( handle_t handle, uint8_t *write_data_buffer,
519+
uint8_t *read_data_buffer,
520+
size_t data_length );
521+
489522
/**
490523
* @brief Close SPI Master HAL context object.
491524
* @details Closes SPI Master HAL context object,

hal/lib/src/lib_hal_spi_master/hal_spi_master.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,52 @@ err_t hal_spi_master_write_then_read( handle_t handle, uint8_t *write_data_buffe
388388
}
389389
}
390390

391+
err_t hal_spi_master_transfer( handle_t handle, uint8_t *write_data_buffer,
392+
uint8_t *read_data_buffer,
393+
size_t data_length )
394+
{
395+
hal_spi_master_handle_register_t *hal_handle = ( hal_spi_master_handle_register_t* )hal_is_handle_null( handle );
396+
err_t hal_status = HAL_SPI_MASTER_SUCCESS;
397+
398+
if ( !hal_handle )
399+
{
400+
return HAL_SPI_MASTER_ERROR;
401+
}
402+
403+
if ( !write_data_buffer || !read_data_buffer )
404+
{
405+
return HAL_SPI_MASTER_ERROR;
406+
}
407+
408+
if ( data_length <= 0 )
409+
{
410+
return HAL_SPI_MASTER_ERROR;
411+
}
412+
413+
if ( hal_handle->init_state == false )
414+
{
415+
hal_status = hal_ll_module_configure_spi( &hal_handle );
416+
}
417+
418+
if( hal_status != HAL_SPI_MASTER_SUCCESS )
419+
{
420+
return HAL_SPI_MASTER_ERROR;
421+
} else {
422+
hal_handle->init_state = true;
423+
}
424+
425+
hal_status = hal_ll_spi_master_transfer( &hal_handle, write_data_buffer,
426+
read_data_buffer,
427+
data_length );
428+
429+
if (hal_status == HAL_SPI_MASTER_MODULE_ERROR)
430+
{
431+
return HAL_SPI_MASTER_ERROR;
432+
} else {
433+
return HAL_SPI_MASTER_SUCCESS;
434+
}
435+
}
436+
391437
err_t hal_spi_master_close( handle_t *handle )
392438
{
393439
hal_spi_master_handle_register_t *hal_handle = ( hal_spi_master_handle_register_t * )hal_is_handle_null( handle );

middleware/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ if(${MSDK_BUILD_TFT_MODULES})
3131
add_subdirectory(ft5xx6)
3232
add_subdirectory(stmpe811)
3333
add_subdirectory(tsc2003)
34-
add_subdirectory(ft800)
34+
if(NOT(${TOOLCHAIN_ID} STREQUAL "mikrocavr"))
35+
add_subdirectory(ft800)
36+
endif()
3537
endif()
3638
add_subdirectory(touch_controller)
3739
endif()

0 commit comments

Comments
 (0)