This repository has been archived by the owner on Feb 25, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
timm
authored and
timm
committed
Mar 29, 2013
1 parent
a5a6798
commit 7f1b929
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |