- decreased baudrate
- add PRINT git-svn-id: http://moon:8086/svn/projects/HendiControl@38 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -22,15 +22,16 @@
|
||||
#include "i2c.h"
|
||||
#include "mcp42x6.h"
|
||||
|
||||
#define PRINT(a,...) /*printf(a, ##__VA_ARGS__)*/
|
||||
#define ARDUINO_NANO 1
|
||||
|
||||
#define PRINT_PROMPT printf("\n:")
|
||||
#define PRINT_PROMPT putchar(0x0D);putchar(0x0A);putchar(':');
|
||||
#if ARDUINO_NANO
|
||||
#define F_CPU (16000000UL) // MHz
|
||||
#else
|
||||
#define F_CPU (18432000UL) // MHz
|
||||
#endif
|
||||
#define USART_BAUDRATE 38400UL
|
||||
#define USART_BAUDRATE 9600UL
|
||||
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
|
||||
#define TIMER_HW_CLOCK (F_CPU/8)
|
||||
#define TIMER_IRQ_CLOCK 1000UL
|
||||
@@ -54,7 +55,7 @@ typedef enum _eSwitch
|
||||
void setSwitch(int on)
|
||||
{
|
||||
const char *sw_str[2] = {"OFF", "ON"};
|
||||
printf("Set switch to %s\n", sw_str[on != 0]);
|
||||
PRINT("Set switch to %s\n", sw_str[on != 0]);
|
||||
portSet(PwrSwitch_out, on != 0);
|
||||
}
|
||||
|
||||
@@ -66,7 +67,7 @@ typedef enum _ePower
|
||||
|
||||
void setPower(uint16_t power)
|
||||
{
|
||||
printf("Set Power to %u\n", power);
|
||||
PRINT("Set Power to %u\n", power);
|
||||
uint8_t dac_cmd[] = {0x00, 0x00}; // 6.2 Write Volatile Memory (C2:C0 = ‘010’)
|
||||
size_t res = MCP47x6_write_volatile_dac(power, dac_cmd, sizeof(dac_cmd));
|
||||
i2c_send(0x60, I2C_WRITE, dac_cmd, res);
|
||||
@@ -132,9 +133,6 @@ int main(void)
|
||||
cmdStr[cmdStrSize] = 0;
|
||||
char c = msg.data;
|
||||
|
||||
putchar(c);
|
||||
break;
|
||||
|
||||
// Command finished with CR/LF
|
||||
if (c == 0x0A || c == 0x0D)
|
||||
{
|
||||
@@ -147,7 +145,7 @@ int main(void)
|
||||
if (state == StateNormal || state == StateRemote)
|
||||
{
|
||||
// Power Control
|
||||
if (toupper(cmdStr[0]) == 'Z')
|
||||
if (toupper(cmdStr[0]) == 'P')
|
||||
{
|
||||
uint16_t arg = (uint16_t)strtol(cmdStr+1, (char **)NULL, 10);
|
||||
setPower(arg);
|
||||
@@ -227,7 +225,7 @@ int main(void)
|
||||
|
||||
case TIMER_TIMEOUT:
|
||||
{
|
||||
printf("Timeout!\n");
|
||||
PRINT("Timeout!\n");
|
||||
setPower(PowerLow);
|
||||
// setSwitch(SwitchOff);
|
||||
state_next = StateError;
|
||||
@@ -240,7 +238,7 @@ int main(void)
|
||||
int sw_in = portGet(PwrSwitch_in);
|
||||
if (sw_in != sw_in_last)
|
||||
{
|
||||
printf ("PwrSwitch_in = %d\n", portGet(PwrSwitch_in));
|
||||
PRINT ("PwrSwitch_in = %d\n", portGet(PwrSwitch_in));
|
||||
if (sw_in == 0)
|
||||
{
|
||||
if (state == StateError)
|
||||
@@ -263,7 +261,7 @@ int main(void)
|
||||
}
|
||||
if (state != state_next)
|
||||
{
|
||||
printf("State change \"%s\" => \"%s\"\n", state_str[state], state_str[state_next]);
|
||||
PRINT("State change \"%s\" => \"%s\"\n", state_str[state], state_str[state_next]);
|
||||
}
|
||||
state = state_next;
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.compiler.warnings.Pedantic>True</avrgcc.compiler.warnings.Pedantic>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
|
||||
Reference in New Issue
Block a user