agileRTOS (zrtos)  Version 0.8.0 (ghostbuster)
sync.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 ykat UG (haftungsbeschraenkt) - All Rights Reserved
3  *
4  * Permission for non-commercial use is hereby granted,
5  * free of charge, without warranty of any kind.
6  */
7 #ifndef ZRTOS_VFS_MODULE_AVR_SPI_SYNC_H
8 #define ZRTOS_VFS_MODULE_AVR_SPI_SYNC_H
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #include <avr/io.h>
14 #include <avr/interrupt.h>
15 
16 #include <zrtos/cast.h>
17 #include <zrtos/types.h>
18 #include <zrtos/vfs/module/spi/sync.h>
19 
20 
24  ,void *buf
25  ,size_t len
26  ,size_t *l
27 ){
28  zrtos_error_t ret = ZRTOS_ERRROR__SUCCESS;
29  uint8_t *data_out = ZRTOS_CAST(uint8_t*,buf);
30  SPCR = file_data->control;
31  while(len--){
32  SPDR = *data_out;
33  while(!(SPSR & (1<<SPIF))){
34  continue;
35  }
36  *data_out++ = SPDR;
37  }
38  SPCR = 0;
39  *l = zrtos_types__ptr_get_byte_distance(data_out,buf);
40  return ret;
41 }
42 
44  zrtos_vfs_file_t *thiz
45  ,char *path
46  ,void *buf
47  ,size_t len
48  ,zrtos_vfs_offset_t offset
49  ,size_t *out
50 ){
52  thiz
53  ,path
54  ,buf
55  ,len
56  ,offset
57  ,out
59  );
60 }
61 
73 );
74 
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 #endif
#define ZRTOS_CAST(type, value)
Definition: cast.h:18
zrtos_error_t zrtos_vfs_module_avr_spi_sync__on_write(zrtos_vfs_file_t *thiz, char *path, void *buf, size_t len, zrtos_vfs_offset_t offset, size_t *out)
Definition: sync.h:43
#define ZRTOS_VFS_PLUGIN__4_ON_READ_DEFAULT()
Definition: vfs_plugin.h:216
size_t zrtos_vfs_offset_t
Definition: vfs_plugin.h:49
#define ZRTOS_VFS_PLUGIN__9_ON_IOCTL_DEFAULT()
Definition: vfs_plugin.h:319
#define ZRTOS_VFS_PLUGIN__7_ON_CAN_WRITE_DEFAULT()
Definition: vfs_plugin.h:277
#define ZRTOS_VFS_PLUGIN__8_ON_SEEK_DEFAULT()
Definition: vfs_plugin.h:294
#define ZRTOS_VFS_PLUGIN__3_ON_UMOUNT(callback)
Definition: vfs_plugin.h:198
#define ZRTOS_VFS_PLUGIN__6_ON_CAN_READ_DEFAULT()
Definition: vfs_plugin.h:260
zrtos_error_t zrtos_vfs_module_spi_sync__on_write_helper(zrtos_vfs_file_t *thiz, char *path, void *buf, size_t len, zrtos_vfs_offset_t offset, size_t *out, zrtos_error_t(*callback)(zrtos_vfs_module_spi_sync_inode_t *inode_data, zrtos_vfs_module_spi_sync_file_t *file_data, void *buf, size_t len, size_t *l))
Definition: spi_sync.h:151
#define ZRTOS_VFS_PLUGIN__2_ON_MOUNT(callback)
Definition: vfs_plugin.h:181
zrtos_error_t zrtos_vfs_module_spi_sync__on_open(zrtos_vfs_file_t *thiz)
Definition: spi_sync.h:97
#define ZRTOS_VFS_PLUGIN__5_ON_WRITE(callback)
Definition: vfs_plugin.h:237
zrtos_error_t zrtos_vfs_module_spi_sync__on_mount(zrtos_vfs_dentry_t *thiz)
Definition: spi_sync.h:130
size_t zrtos_types__ptr_get_byte_distance(void *bigger, void *smaller)
Definition: types.h:43
zrtos_error_t zrtos_vfs_module_avr_spi_sync__on_write_callback(zrtos_vfs_module_spi_sync_inode_t *inode_data, zrtos_vfs_module_spi_sync_file_t *file_data, void *buf, size_t len, size_t *l)
Definition: sync.h:21
#define ZRTOS_VFS_PLUGIN__1_ON_CLOSE(callback)
Definition: vfs_plugin.h:164
zrtos_vfs_module_spi_sync_control_t control
Definition: spi_sync.h:53
zrtos_error_t zrtos_vfs_module_spi_sync__on_umount(zrtos_vfs_dentry_t *thiz)
Definition: spi_sync.h:147
zrtos_error_t zrtos_vfs_module_spi_sync__on_close(zrtos_vfs_file_t *thiz)
Definition: spi_sync.h:123
ZRTOS_VFS_PLUGIN__INIT(spi, ZRTOS_VFS_PLUGIN__0_ON_OPEN(zrtos_vfs_module_spi_sync__on_open) ZRTOS_VFS_PLUGIN__1_ON_CLOSE(zrtos_vfs_module_spi_sync__on_close) ZRTOS_VFS_PLUGIN__2_ON_MOUNT(zrtos_vfs_module_spi_sync__on_mount) ZRTOS_VFS_PLUGIN__3_ON_UMOUNT(zrtos_vfs_module_spi_sync__on_umount) ZRTOS_VFS_PLUGIN__4_ON_READ_DEFAULT() ZRTOS_VFS_PLUGIN__5_ON_WRITE(zrtos_vfs_module_avr_spi_sync__on_write) ZRTOS_VFS_PLUGIN__6_ON_CAN_READ_DEFAULT() ZRTOS_VFS_PLUGIN__7_ON_CAN_WRITE_DEFAULT() ZRTOS_VFS_PLUGIN__8_ON_SEEK_DEFAULT() ZRTOS_VFS_PLUGIN__9_ON_IOCTL_DEFAULT())
static uint8_t
Definition: mcp2515.h:159
zrtos_error_t
Definition: error.h:20
#define ZRTOS_VFS_PLUGIN__0_ON_OPEN(callback)
Definition: vfs_plugin.h:147