sipo.c
Go to the documentation of this file.00001
00045 #include "sipo.h"
00046
00047 #include "hw/hw_sipo.h"
00048
00049 #include <cfg/compiler.h>
00050
00051 #include <kern/kfile.h>
00052
00053 #include <string.h>
00054
00058 INLINE void sipo_putchar(uint8_t c)
00059 {
00060 for(int i = 0; i < 8; i++)
00061 {
00062 if((c & BV(i)) == 0)
00063 SIPO_SI_LOW();
00064 else
00065 SIPO_SI_HIGH();
00066
00067 SIPO_SI_CLOCK();
00068 }
00069 }
00070
00074 static size_t sipo_write(UNUSED_ARG(struct KFile *, fd), const void *_buf, size_t size)
00075 {
00076 const uint8_t *buf = (const uint8_t *)_buf;
00077 size_t write_len = size;
00078 ASSERT(buf);
00079
00080
00081 while(size--)
00082 sipo_putchar(*buf++);
00083
00084
00085 SIPO_LOAD();
00086
00087 return write_len;
00088 }
00089
00093 void sipo_init(Sipo *fd)
00094 {
00095 ASSERT(fd);
00096
00097 memset(fd, 0, sizeof(Sipo));
00098
00099
00100 DB(fd->fd._type = KFT_SIPO);
00101
00102
00103 fd->fd.write = sipo_write;
00104
00105 SIPO_INIT_PIN();
00106
00107 }