Compare commits
	
		
			2 Commits
		
	
	
		
			v2.0.0
			...
			eddd461e96
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| eddd461e96 | |||
| 3312f5413f | 
@@ -8,6 +8,7 @@
 | 
			
		||||
## Dependencies
 | 
			
		||||
 | 
			
		||||
1. [zh_avr_free_rtos](http://git.zh.com.ru/avr_libraries/zh_avr_free_rtos)
 | 
			
		||||
2. [zh_avr_common](http://git.zh.com.ru/avr_libraries/zh_avr_common)
 | 
			
		||||
 | 
			
		||||
## Using
 | 
			
		||||
 | 
			
		||||
@@ -17,6 +18,7 @@ In an existing project, run the following command to install the component:
 | 
			
		||||
cd ../your_project/lib
 | 
			
		||||
git clone http://git.zh.com.ru/avr_libraries/zh_avr_free_rtos
 | 
			
		||||
git clone http://git.zh.com.ru/avr_libraries/zh_avr_vector
 | 
			
		||||
git clone http://git.zh.com.ru/avr_libraries/zh_avr_common
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
In the application, add the component:
 | 
			
		||||
@@ -65,20 +67,20 @@ void vector_example_task(void *pvParameters)
 | 
			
		||||
    strcpy(example, "Item 5");
 | 
			
		||||
    zh_avr_vector_push_back(&vector, &example);
 | 
			
		||||
    printf("Add 5 items. New vector size is: %d\n", zh_avr_vector_get_size(&vector));
 | 
			
		||||
    for (uint16_t i = 0; i < zh_avr_vector_get_size(&vector); ++i)
 | 
			
		||||
    for (uint8_t i = 0; i < zh_avr_vector_get_size(&vector); ++i)
 | 
			
		||||
    {
 | 
			
		||||
        printf("Item position %d is: %s\n", i, (char *)zh_avr_vector_get_item(&vector, i));
 | 
			
		||||
    }
 | 
			
		||||
    strcpy(example, "Item 6");
 | 
			
		||||
    zh_avr_vector_change_item(&vector, 3, &example);
 | 
			
		||||
    printf("Change item on 3 position.\n");
 | 
			
		||||
    for (uint16_t i = 0; i < zh_avr_vector_get_size(&vector); ++i)
 | 
			
		||||
    for (uint8_t i = 0; i < zh_avr_vector_get_size(&vector); ++i)
 | 
			
		||||
    {
 | 
			
		||||
        printf("Item position %d is: %s\n", i, (char *)zh_avr_vector_get_item(&vector, i));
 | 
			
		||||
    }
 | 
			
		||||
    zh_avr_vector_delete_item(&vector, 2);
 | 
			
		||||
    printf("Delete item on 2 position. New vector size is: %d\n", zh_avr_vector_get_size(&vector));
 | 
			
		||||
    for (uint16_t i = 0; i < zh_avr_vector_get_size(&vector); ++i)
 | 
			
		||||
    for (uint8_t i = 0; i < zh_avr_vector_get_size(&vector); ++i)
 | 
			
		||||
    {
 | 
			
		||||
        printf("Item position %d is: %s\n", i, (char *)zh_avr_vector_get_item(&vector, i));
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,30 +6,13 @@
 | 
			
		||||
#include "stdint.h"
 | 
			
		||||
#include "string.h"
 | 
			
		||||
#include "stdbool.h"
 | 
			
		||||
#include "avr_err.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C"
 | 
			
		||||
{
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    typedef enum
 | 
			
		||||
    {
 | 
			
		||||
        AVR_FAIL = -1,
 | 
			
		||||
        AVR_OK,
 | 
			
		||||
        AVR_ERR_NO_MEM,
 | 
			
		||||
        AVR_ERR_INVALID_ARG,
 | 
			
		||||
        AVR_ERR_INVALID_STATE,
 | 
			
		||||
        AVR_ERR_INVALID_SIZE,
 | 
			
		||||
        AVR_ERR_NOT_FOUND,
 | 
			
		||||
        AVR_ERR_NOT_SUPPORTED,
 | 
			
		||||
        AVR_ERR_TIMEOUT,
 | 
			
		||||
        AVR_ERR_INVALID_RESPONSE,
 | 
			
		||||
        AVR_ERR_INVALID_CRC,
 | 
			
		||||
        AVR_ERR_INVALID_VERSION,
 | 
			
		||||
        AVR_ERR_NOT_FINISHED,
 | 
			
		||||
        AVR_ERR_NOT_ALLOWED
 | 
			
		||||
    } avr_err_t;
 | 
			
		||||
 | 
			
		||||
    typedef struct // Main structure of vector data.
 | 
			
		||||
    {
 | 
			
		||||
        void **items;     // Array of pointers of vector items.
 | 
			
		||||
 
 | 
			
		||||
@@ -1 +1 @@
 | 
			
		||||
2.0.0
 | 
			
		||||
2.1.0
 | 
			
		||||
@@ -1,11 +1,5 @@
 | 
			
		||||
#include "zh_avr_vector.h"
 | 
			
		||||
 | 
			
		||||
#define ZH_ERROR_CHECK(cond, err, ...) \
 | 
			
		||||
    if (!(cond))                       \
 | 
			
		||||
    {                                  \
 | 
			
		||||
        return err;                    \
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
static avr_err_t _resize(zh_avr_vector_t *vector, uint8_t capacity);
 | 
			
		||||
 | 
			
		||||
avr_err_t zh_avr_vector_init(zh_avr_vector_t *vector, uint8_t unit)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user