44 #include "lib/sensors.h" 47 #define DIMMER_SYNC_PORT_BASE GPIO_PORT_TO_BASE(DIMMER_SYNC_PORT) 48 #define DIMMER_SYNC_PIN_MASK GPIO_PIN_MASK(DIMMER_SYNC_PIN) 49 #define DIMMER_GATE_PORT_BASE GPIO_PORT_TO_BASE(DIMMER_GATE_PORT) 50 #define DIMMER_GATE_PIN_MASK GPIO_PIN_MASK(DIMMER_GATE_PIN) 52 static uint8_t enabled;
53 static uint8_t dimming;
55 PROCESS(ac_dimmer_int_process,
"AC Dimmer zero-cross interrupt process");
66 dimtime = (uint8_t)(100 - dimming);
71 GPIO_SET_PIN(DIMMER_GATE_PORT_BASE, DIMMER_GATE_PIN_MASK);
74 GPIO_CLR_PIN(DIMMER_GATE_PORT_BASE, DIMMER_GATE_PIN_MASK);
87 .handler = dimmer_zero_cross_int_handler,
110 dimming = (uint8_t)type;
111 return DIMMER_SUCCESS;
115 configure(
int type,
int value)
117 if(type != SENSORS_ACTIVE) {
126 GPIO_CLR_PIN(DIMMER_GATE_PORT_BASE, DIMMER_GATE_PIN_MASK);
147 dimming = DIMMER_DEFAULT_START_VALUE;
148 return DIMMER_SUCCESS;
160 return DIMMER_SUCCESS;
163 SENSORS_SENSOR(ac_dimmer, AC_DIMMER_ACTUATOR, value, configure, status);
Datatype for GPIO event handlers.
#define GPIO_ENABLE_INTERRUPT(PORT_BASE, PIN_MASK)
Enable interrupt triggering for pins with PIN_MASK of port with PORT_BASE.
#define PROCESS(name, strname)
Declare a process.
#define GPIO_SET_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE high.
Header file for an AC light dimmer with zero-crossing driver.
#define PROCESS_YIELD_UNTIL(c)
Yield the currently running process until a condition occurs.
#define PROCESS_BEGIN()
Define the beginning of a process.
Header file with register and macro declarations for the cc2538 GPIO module.
#define GPIO_DETECT_EDGE(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to detect edge.
#define PROCESS_END()
Define the end of a process.
#define GPIO_CLR_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE low.
Header file with declarations for the I/O Control module.
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
#define GPIO_DETECT_RISING(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to trigger an interrupt on rising edge.
void process_exit(struct process *p)
Cause a process to exit.
void gpio_hal_register_handler(gpio_hal_event_handler_t *handler)
Register a function to be called whenever a pin triggers an event.
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
Enable External Interrupt.
#define GPIO_DISABLE_INTERRUPT(PORT_BASE, PIN_MASK)
Disable interrupt triggering for pins with PIN_MASK of port with PORT_BASE.
#define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK)
Configure the pin to be software controlled with PIN_MASK of port with PORT_BASE. ...
#define PROCESS_EXITHANDLER(handler)
Specify an action when a process exits.
void process_poll(struct process *p)
Request a process to be polled.
void ioc_set_over(uint8_t port, uint8_t pin, uint8_t over)
Set Port:Pin override function.
#define GPIO_SET_INPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to input.
#define GPIO_SET_OUTPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to output.
uint32_t gpio_hal_pin_mask_t
GPIO pin mask representation.
#define IOC_OVERRIDE_OE
Output Enable.
#define GPIO_TRIGGER_SINGLE_EDGE(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to trigger an interrupt on single edge (controlled by G...
PROCESS_THREAD(cc2538_rf_process, ev, data)
Implementation of the cc2538 RF driver process.
#define gpio_hal_pin_to_mask(pin)
Convert a pin to a pin mask.
Header file for the GPIO HAL.
void process_start(struct process *p, process_data_t data)
Start a process.