Skip to content
This repository has been archived by the owner on Feb 25, 2021. It is now read-only.

Commit

Permalink
added dali.h and dali.c to project
Browse files Browse the repository at this point in the history
  • Loading branch information
timm authored and timm committed Mar 29, 2013
1 parent a5a6798 commit 7f1b929
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
36 changes: 36 additions & 0 deletions firmware/dali.c
@@ -0,0 +1,36 @@
#include "dali.h"
#include "euart.h"
#include <util/delay.h>

void dali_init()
{
euart_init();
}

int dali_send(word frame)
{
euart_put(frame);
return _ERR_OK_;
}

int dali_send_with_repeat(word frame)
{
euart_put(frame);
_delay_ms(100);
euart_put(frame);
return _ERR_OK_;
}


int dali_query(word frame, byte* result)
{
int i;
euart_put(frame);
_delay_ms(20);
for(i = 0; i < 50; i++)
{
_delay_ms(1);
if(euart_rx_ready())
*result = euart_get();
}
}
26 changes: 26 additions & 0 deletions firmware/dali.h
@@ -0,0 +1,26 @@
#ifndef _DALI_H_
#define _DALI_H_

#include "dali_codes.h"
#include "dali_encode.h"

#define _ERR_NO_ANSWER_ -100

#ifdef __cplusplus
extern "C"
{
#endif

void dali_init();

int dali_send(word frame);

int dali_send_with_repeat(word frame);

int dali_query(word frame, byte* result);

#ifdef __cplusplus
}
#endif

#endif

0 comments on commit 7f1b929

Please sign in to comment.