+++ /dev/null
-# Generic directory or leaf node makefile for OCERA make framework
-
-ifndef MAKERULES_DIR
-MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
-endif
-
-ifeq ($(MAKERULES_DIR),)
-all : default
-.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
-else
-include $(MAKERULES_DIR)/Makefile.rules
-endif
-
+++ /dev/null
-# -*- makefile -*-
-
-SUBDIRS = sensor control
+++ /dev/null
-# Generic directory or leaf node makefile for OCERA make framework
-
-ifndef MAKERULES_DIR
-MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
-endif
-
-ifeq ($(MAKERULES_DIR),)
-all : default
-.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
-else
-include $(MAKERULES_DIR)/Makefile.rules
-endif
-
-# DO NOT DELETE
+++ /dev/null
-
-default_CONFIG = CONFIG_APP_CONTROL=n
-
-ifeq ($(CONFIG_APP_CONTROL),y)
-
-ULAN_ID=control
-
-default_CONFIG += CONFIG_ULOI_LT=x
-default_CONFIG += CONFIG_ULAN_DY=x
-default_CONFIG += MACH=$(MACH)
-default_CONFIG += ULAN_ID=$(ULAN_ID)
-
-LOCAL_CONFIG_H = ulan_config.h
-
-INCLUDES += -I.
-
-bin_PROGRAMS = control
-control_SOURCES = hydroponie.c ul_idstr.c hydroponieoi.c definitions.c board.c
-
-ifeq ($(BUILD_OS),linux)
-lib_LOADLIBES = uloi uldy ulan pthread rt
-DEFS += -DOS_POSIX
-else
-control_MOREOBJS = $(USER_LIB_DIR)/system_stub.o
-control_MOREOBJS += $(USER_LIB_DIR)/ivt.o
-lib_LOADLIBES = uloi uldy bspbase ulan ul_drv lpciap keyval lpciap lpciap_kvpb mach_hal
-endif
-
-# This selects linker script
-link_VARIANTS = app
-
-endif
\ No newline at end of file
+++ /dev/null
-
-#include <system_def.h>
-#include <cpu_def.h>
-#include <stdio.h>
-
-#include "board.h"
-
-// OBJECT INTERFACE VARIABLES
-uint16_t status_val;
-uint16_t oi_fan;
-uint16_t oi_cid_fan;
-uint16_t oi_humidifier;
-uint16_t oi_cid_humidifier;
-uint16_t oi_light;
-uint16_t oi_cid_light;
-uint16_t oi_period;
-
-// OBJECT INTERFACE FUNCTIONS
-int oi_cid_fan_wrfnc(ULOI_PARAM_coninfo void *context){
- uloi_uint_wrfnc(ULOI_ARG_coninfo context);
- return 1;
-}
-
-int oi_cid_humidifier_wrfnc(ULOI_PARAM_coninfo void *context){
- uloi_uint_wrfnc(ULOI_ARG_coninfo context);
- return 1;
-}
-
-int oi_cid_light_wrfnc(ULOI_PARAM_coninfo void *context){
- uloi_uint_wrfnc(ULOI_ARG_coninfo context);
- return 1;
-}
-
-int oi_period_wrfnc(ULOI_PARAM_coninfo void *context){
- uloi_uint_wrfnc(ULOI_ARG_coninfo context);
- return 1;
-}
-
-//*********************************************************
-int oi_fan_wrfnc(ULOI_PARAM_coninfo void *context){
- uloi_uint_wrfnc(ULOI_ARG_coninfo context);
- if (oi_fan == 1) {
- SET_OUT_PIN(OUT_PORT,P1_27_FAN);
- printf("FAN PIN UP\n");
- } else {
- CLR_OUT_PIN(OUT_PORT,P1_27_FAN);
- printf("FAN PIN DOWN\n");
- }
- return 1;
-}
-
-int oi_humidifier_wrfnc(ULOI_PARAM_coninfo void *context){
- uloi_uint_wrfnc(ULOI_ARG_coninfo context);
- if (oi_humidifier == 1) {
- SET_OUT_PIN(OUT_PORT,P1_28_HUMIDIFIER);
- printf("HUM PIN UP\n");
- } else {
- CLR_OUT_PIN(OUT_PORT,P1_28_HUMIDIFIER);
- printf("HUM PIN DOWN\n");
- }
- return 1;
-}
-
-int oi_light_wrfnc(ULOI_PARAM_coninfo void *context){
- uloi_uint_wrfnc(ULOI_ARG_coninfo context);
- if (oi_light == 1) {
- SET_OUT_PIN(OUT_PORT,P1_29_LIGHT);
- printf("LIGHT PIN UP\n");
- } else {
- CLR_OUT_PIN(OUT_PORT,P1_29_LIGHT);
- printf("LIGHT PIN DOWN\n");
- }
- return 1;
-}
-//*********************************************************
-
-void send_data() {
- int msgsend;
- uchar *buf;
- int i, len;
-
- len = DATA_BUF_LEN + 6;
-// if (oi_period == 1) len = len + 6;
-
- // preparing of msg
- buf = (uchar *) malloc(len*sizeof(uchar)); // NULL NULL NULL TEMPERATURE_CID len_data oi_temperature CID_HUM len_data oi_humidity
- for (i=0; i<=2; i++) buf[i] = 0;
-
- if (oi_period == 1){
- int2buf(&buf[3],HEART_CID);
- int2buf(&buf[5],2);
- int2buf(&buf[7],status_val);
- }
-
- msgsend = ul_send_query(ul_fd, ul_dyac->ul_dysa, UL_CMD_PDO, UL_BFL_NORE, (void*) buf, len);
- printf("[I] DATA\n");
- free(buf);
- ul_freemsg(ul_fd);
-}
-
-void accept_SDO(void) {
- // setting lan configuration
- if ((ul_inepoll(ul_fd)>0) && (ul_acceptmsg(ul_fd, &msginfo)>=0)) {
- if ((msginfo.cmd != UL_CMD_PDO) && (msginfo.sadr != 98)) {
- if (!(msginfo.flg&(UL_BFL_PROC | UL_BFL_FAIL))) {
- //waiting for msg from bus
- if (uloi_process_msg(ULOI_ARG_coninfo (uloi_objdes_array_t*)&uloi_objdes_main, &msginfo)<0) {
- //checking dynamic adresation
- if (uldy_process_msg(ULDY_ARG_ul_dyac &msginfo)>=0){
- printf("message recieved - UL_CMD_NCS, sadr: %i, dadr: %i, cmd: %i\n",msginfo.sadr, msginfo.dadr, msginfo.cmd);
- printf("server addr :%i\n",ul_dyac->ul_dysa);
- } else {
- ul_freemsg(ul_fd);
- printf("problem in uldy_process_msg\n");
- }
- } else {
- printf("ULOI message processed\n");
- }
- } else {
- ul_freemsg(ul_fd);
- }
- }
- }
-}
-
-void setmyaddr(void){
- ul_setmyadr(ul_fd,98);
-}
-
-void oiinit(void){
- oi_cid_fan=243;
- oi_cid_humidifier=244;
- oi_cid_light=245;
- oi_period=1;
- status_val = 5;
-}
-
-void work_with(void){
-
- PINSEL1 &= 0xFFFFB3FF;
-
- // u vetsi karbicky je SET z 0 do 3.3
- // u mensi je SET z -3.3 do 0
- // varpins yy
-
-// IO0SET = P0_21_BIT;
-// IO0SET = P0_22_BIT;
-
- SET_OUT_PIN(OUT_PORT, P1_27_FAN);
- CLR_OUT_PIN(OUT_PORT, P1_28_HUMIDIFIER);
- SET_OUT_PIN(OUT_PORT, P1_29_LIGHT);
-
- IO0SET = LED1_BIT; //vypinani LED
- IO0CLR = LED2_BIT; //zapinani LED
-
-// IO0CLR = LED1_BIT;
-// IO0SET = LED2_BIT;
-}
+++ /dev/null
-#ifndef _BOARD_H
-#define _BOARD_H
-
-#include <uloi_base.h>
-#include <types.h>
-
-#include "definitions.h"
-
-#define DATA_BUF_LEN 3
-#define SN 102
-
-extern const ULOI_CODE uloi_objdes_array_t uloi_objdes_main;
-extern uint16_t status_val;
-extern uint16_t oi_fan;
-extern uint16_t oi_cid_fan;
-extern uint16_t oi_humidifier;
-extern uint16_t oi_cid_humidifier;
-extern uint16_t oi_light;
-extern uint16_t oi_cid_light;
-extern uint16_t oi_period;
-
-int oi_cid_fan_wrfnc(ULOI_PARAM_coninfo void *context);
-int oi_cid_humidifier_wrfnc(ULOI_PARAM_coninfo void *context);
-int oi_cid_light_wrfnc(ULOI_PARAM_coninfo void *context);
-
-int oi_fan_wrfnc(ULOI_PARAM_coninfo void *context);
-int oi_humidifier_wrfnc(ULOI_PARAM_coninfo void *context);
-int oi_light_wrfnc(ULOI_PARAM_coninfo void *context);
-
-int oi_period_wrfnc(ULOI_PARAM_coninfo void *context);
-
-void accept_SDO(void);
-void setmyaddr(void);
-void send_data();
-void adc2oi(void);
-void oiinit(void);
-void work_with(void);
-
-#endif
+++ /dev/null
-/home/stefic/BAP/build_ulan/ulan/embedded/hydro/app/sensor/definitions.c
\ No newline at end of file
+++ /dev/null
-/home/stefic/BAP/build_ulan/ulan/embedded/hydro/app/sensor/definitions.h
\ No newline at end of file
+++ /dev/null
-/home/stefic/BAP/build_ulan/ulan/embedded/hydro/app/sensor/hydroponie.c
\ No newline at end of file
+++ /dev/null
-/home/stefic/BAP/build_ulan/ulan/embedded/hydro/app/sensor/hydroponie.h
\ No newline at end of file
+++ /dev/null
-/*
- OBJECT INTERFACE FOR CONTROL
-*/
-
-#include "board.h"
-
-#define I_FAN 400
-#define I_FAN_CID 410
-#define I_HUMIDIFIER 500
-#define I_HUMIDIFIER_CID 510
-#define I_LIGHT 600
-#define I_LIGHT_CID 610
-#define I_PERIOD 700
-
-
-uint16_t status_val;
-uint16_t oi_fan;
-uint16_t oi_cid_fan;
-uint16_t oi_humidifier;
-uint16_t oi_cid_humidifier;
-uint16_t oi_light;
-uint16_t oi_cid_light;
-uint16_t oi_period;
-
-int status_rdfnc(ULOI_PARAM_coninfo void *context)
-{
- return uloi_uint_rdfnc(ULOI_ARG_coninfo &status_val);
-}
-
-int errclr_wrfnc(ULOI_PARAM_coninfo void *context)
-{
- status_val=0;
- return 1;
-}
-
-/* description of input objects */
-const ULOI_CODE uloi_objdes_t uloid_objdes_DOII =
-ULOI_GENOBJDES_RAW(ULOI_DOII,NULL,NULL_CODE,NULL,uloi_doii_fnc,(void*)&uloi_objdes_main)
-/* description of output objects */
-const ULOI_CODE uloi_objdes_t uloid_objdes_DOIO =
-ULOI_GENOBJDES_RAW(ULOI_DOIO,NULL,NULL_CODE,NULL,uloi_doio_fnc,(void*)&uloi_objdes_main)
-/* ID numbers of recognized input objects */
-const ULOI_CODE uloi_objdes_t uloid_objdes_QOII =
-ULOI_GENOBJDES_RAW(ULOI_QOII,NULL,NULL_CODE,NULL,uloi_qoii_fnc,(void*)&uloi_objdes_main)
-/* ID numbers of recognized output objects */
-const ULOI_CODE uloi_objdes_t uloid_objdes_QOIO =
-ULOI_GENOBJDES_RAW(ULOI_QOIO,NULL,NULL_CODE,NULL,uloi_qoio_fnc,(void*)&uloi_objdes_main)
-/* object values read request */
-const ULOI_CODE uloi_objdes_t uloid_objdes_RDRQ =
-ULOI_GENOBJDES_RAW(ULOI_RDRQ,NULL,NULL_CODE,NULL,uloi_rdrq_fnc,(void*)&uloi_objdes_main)
-
-ULOI_GENOBJDES(STATUS,ULOI_STATUS,"u2",status_rdfnc,&status_val,NULL_CODE,NULL)
-ULOI_GENOBJDES(ERRCLR,ULOI_ERRCLR,"e",NULL_CODE,NULL,errclr_wrfnc,&status_val)
-
-ULOI_GENOBJDES(FAN,I_FAN,"u2",uloi_uint_rdfnc,&oi_fan,oi_fan_wrfnc,&oi_fan)
-ULOI_GENOBJDES(FAN_CID,I_FAN_CID,"u2",uloi_uint_rdfnc,&oi_cid_fan,oi_cid_fan_wrfnc,&oi_cid_fan)
-
-ULOI_GENOBJDES(HUMIDIFIER,I_HUMIDIFIER,"u2",uloi_uint_rdfnc,&oi_humidifier,oi_humidifier_wrfnc,&oi_humidifier)
-ULOI_GENOBJDES(HUMIDIFIER_CID,I_HUMIDIFIER_CID,"u2",uloi_uint_rdfnc,&oi_cid_humidifier,oi_cid_humidifier_wrfnc,&oi_cid_humidifier)
-
-ULOI_GENOBJDES(LIGHT,I_LIGHT,"u2",uloi_uint_rdfnc,&oi_light,oi_light_wrfnc,&oi_light)
-ULOI_GENOBJDES(LIGHT_CID,I_LIGHT_CID,"u2",uloi_uint_rdfnc,&oi_cid_light,oi_cid_light_wrfnc,&oi_cid_light)
-
-ULOI_GENOBJDES(PERIOD,I_PERIOD,"u2",uloi_uint_rdfnc,&oi_period,oi_period_wrfnc,&oi_period)
-
-const uloi_objdes_t * ULOI_CODE uloi_objdes_main_items[]={
- &uloid_objdes_DOII,
- &uloid_objdes_DOIO,
- &uloid_objdes_QOII,
- &uloid_objdes_QOIO,
- &uloid_objdes_RDRQ,
-
- &uloid_objdes_STATUS,
- &uloid_objdes_ERRCLR,
- &uloid_objdes_FAN,
- &uloid_objdes_FAN_CID,
- &uloid_objdes_HUMIDIFIER,
- &uloid_objdes_HUMIDIFIER_CID,
- &uloid_objdes_LIGHT,
- &uloid_objdes_LIGHT_CID,
- &uloid_objdes_PERIOD
-
-};
-
-const ULOI_CODE uloi_objdes_array_t uloi_objdes_main={
- {
- (uloi_objdes_t **)uloi_objdes_main_items,
- sizeof(uloi_objdes_main_items)/sizeof(uloi_objdes_main_items[0]),
- -1
- }
-};
+++ /dev/null
-#!/bin/bash
-
-usb_sendhex -d 0xdead -i 0x2263 -s 0x20000 -l 0x20000 -e;
-sleep 2 ;
-usb_sendhex -d 0xdead -i 0x2263 -s 0x20000 -f binary /home/stefic/BAP/build_ulan/ulan-build/arm-ul_usb1-ulad31/_compiled/bin/control-app.bin
-usb_sendhex -d 0xdead -i 0x2263 -r ;
+++ /dev/null
-/home/stefic/BAP/build_ulan/ulan/embedded/hydro/app/sensor/ul_idstr.c
\ No newline at end of file
+++ /dev/null
-/home/stefic/BAP/build_ulan/ulan/embedded/hydro/app/sensor/ul_idstr.h
\ No newline at end of file
+++ /dev/null
-# Generic directory or leaf node makefile for OCERA make framework
-
-ifndef MAKERULES_DIR
-MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
-endif
-
-ifeq ($(MAKERULES_DIR),)
-all : default
-.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
-else
-include $(MAKERULES_DIR)/Makefile.rules
-endif
-
-# DO NOT DELETE
+++ /dev/null
-
-default_CONFIG = CONFIG_APP_SENSOR=n
-
-ifeq ($(CONFIG_APP_SENSOR),y)
-
-ULAN_ID=sensor
-
-default_CONFIG += CONFIG_ULOI_LT=x
-default_CONFIG += CONFIG_ULAN_DY=x
-default_CONFIG += MACH=$(MACH)
-default_CONFIG += ULAN_ID=$(ULAN_ID)
-
-LOCAL_CONFIG_H = ulan_config.h
-
-INCLUDES += -I.
-
-
-bin_PROGRAMS = sensor
-sensor_SOURCES = hydroponie.c ul_idstr.c board.c hydroponieoi.c definitions.c
-
-ifeq ($(BUILD_OS),linux)
-lib_LOADLIBES = uloi uldy ulan pthread rt
-DEFS += -DOS_POSIX
-else
-sensor_MOREOBJS = $(USER_LIB_DIR)/system_stub.o
-sensor_MOREOBJS += $(USER_LIB_DIR)/ivt.o
-lib_LOADLIBES = uloi uldy bspbase ulan ul_drv lpciap keyval lpciap lpciap_kvpb mach_hal
-endif
-
-# This selects linker script
-link_VARIANTS = app
-
-endif
\ No newline at end of file
+++ /dev/null
-
-#include <stdio.h>
-#include <system_def.h>
-#include <cpu_def.h>
-
-#include "board.h"
-
-adc_stat_t adcst;
-
-// OBJECT INTERFACE VARIABLES
-uint16_t status_val;
-int16_t oi_temperature;
-uint16_t oi_cid_temp;
-int16_t oi_humidity;
-uint16_t oi_cid_hum;
-uint16_t oi_period;
-
-// OBJECT INTERFACE FUNCTIONS
-int oi_cid_temp_wrfnc(ULOI_PARAM_coninfo void *context){
- uloi_uint_wrfnc(ULOI_ARG_coninfo context);
- return 1;
-}
-
-int oi_cid_hum_wrfnc(ULOI_PARAM_coninfo void *context){
- uloi_uint_wrfnc(ULOI_ARG_coninfo context);
- return 1;
-}
-
-int oi_period_wrfnc(ULOI_PARAM_coninfo void *context){
- uloi_uint_wrfnc(ULOI_ARG_coninfo context);
- return 1;
-}
-
-void send_data() {
- int msgsend;
- uchar *buf;
- int i, len;
-
- len = DATA_BUF_LEN;
- if (oi_period == 1) len = len + 6;
-
- read_ADC(&adcst);
- adc2oi();
-
- //.preparing of msg
- buf = (uchar *) malloc(len*sizeof(uchar)); // NULL NULL NULL TEMPERATURE_CID len_data oi_temperature CID_HUM len_data oi_humidity
- for (i=0; i<=2; i++) buf[i] = 0;
-
- if (oi_period == 1){
- int2buf(&buf[3],HEART_CID);
- int2buf(&buf[5],2);
- int2buf(&buf[7],status_val);
- int2buf(&buf[9],oi_cid_temp);
- int2buf(&buf[11],2);
- int2buf(&buf[13],oi_temperature);
- int2buf(&buf[15],oi_cid_hum);
- int2buf(&buf[17],2);
- int2buf(&buf[19],oi_humidity);
- } else {
- int2buf(&buf[3],oi_cid_temp);
- int2buf(&buf[5],2);
- int2buf(&buf[7],oi_temperature);
- int2buf(&buf[9],oi_cid_hum);
- int2buf(&buf[11],2);
- int2buf(&buf[13],oi_humidity);
- }
-
- msgsend = ul_send_query(ul_fd, ul_dyac->ul_dysa, UL_CMD_PDO, UL_BFL_NORE, (void*) buf, len);
- printf("[I] DATA\n");
- free(buf);
- ul_freemsg(ul_fd);
-}
-
-void accept_SDO(void) {
- // setting lan configuration
- if ((ul_inepoll(ul_fd)>0) && (ul_acceptmsg(ul_fd, &msginfo)>=0)) {
- if ((msginfo.cmd != UL_CMD_PDO) && (msginfo.sadr != 99)) {
- if (!(msginfo.flg&(UL_BFL_PROC | UL_BFL_FAIL))) {
- //waiting for msg from bus
- if (uloi_process_msg(ULOI_ARG_coninfo (uloi_objdes_array_t*)&uloi_objdes_main, &msginfo)<0) {
- //checking dynamic adresation
- if (uldy_process_msg(ULDY_ARG_ul_dyac &msginfo)>=0){
- printf("message recieved - UL_CMD_NCS, sadr: %i, dadr: %i, cmd: %i\n",msginfo.sadr, msginfo.dadr, msginfo.cmd);
- printf("server addr :%i\n",ul_dyac->ul_dysa);
- } else {
- ul_freemsg(ul_fd);
- printf("problem in uldy_process_msg\n");
- }
- } else {
- printf("ULOI message processed\n");
- }
- } else {
- ul_freemsg(ul_fd);
- }
- }
- }
-}
-
-void setmyaddr(void){
- ul_setmyadr(ul_fd,99);
-}
-
-void adc2oi(void){
- oi_temperature = adcst.temp;
- oi_humidity = adcst.hum;
-}
-
-void oiinit(void){
- oi_cid_temp=233;
- oi_cid_hum=234;
- oi_period=2;
- status_val = 5;
-}
-
-void work_with(void){
- mstime_t time;
- led1_time = current_time();
- led2_time = current_time();
-// adcst.read = 0;
-// adcst.temp = 0;
-// adcst.temp_tmp = 0;
-// adcst.hum = 0;
-// adcst.hum_tmp = 0;
-// adcst.cnt = 0;
-
- time = current_time();
-
- while(1){
- blink();
- read_ADC(&adcst);
-
- if((current_time()-time) > 1000){
- printf("AD0.1 %i\n", adcst.temp);
- printf("AD0.2 %i\n", adcst.hum);
- time = current_time();
- }
- }
-}
-
-void init_ADC (int selected){
- PINSEL1|= 0x05000000; // P0.28 and P0.29 set for AD0.1 and AD0.2 inputs
- AD0CR &= 0x00000000; // Clear All Bit Control
- switch (selected){
- case 1: AD0CR |= 0x00000002; // Select ADC = AIN1, CLKDive => Pclk/(x+1)< 4.5Mhz
- break;
- case 2: AD0CR |= 0x00000004; // Select ADC = AIN2
- break;
- }
- AD0CR |= 0x0000FF00; // ADC Clock = VBP(PCLK) / 7 1.55us
- AD0CR &= 0xFFF1FFFF; // CLKS 11 ciclos de reloj Res Máx
- AD0CR |= 0x00200000; // PDN = 1 = Active ADC Module
-// AD0CR |= 0x00010000; // Burst = 1 = Continuing conversion
-// AD0CR &= 0xFF3FFFFF; // TEST[1:0] = 00 = Modo normal
-// AD0CR &= 0xF7FFFFFF; // EDGE = 0 = Flanco de bajada
-// AD0STAT = 0x00000110;
-}
-
-int read_ADC (adc_stat_t *adcst){
- init_ADC(1);
- AD0CR |= 0x01000000; // start conversion
- while (!(AD0GDR & (ADGDR_DONE))); // wait for DONE to go high
-
- adcst->read = AD0DR1; // get ADC data
- adcst->read = ((adcst->read >>6) & 0x03FF); // extraction of result
- adcst->temp_tmp += adcst->read;
-
- init_ADC(2);
- AD0CR |= 0x01000000; // start conversion
- while (!(AD0GDR & (ADGDR_DONE))); // wait for DONE to go high
-
- adcst->read = AD0DR2;
- adcst->read = ((adcst->read >>6) & 0x03FF); // extraction of result
- adcst->hum_tmp += adcst->read;
-
- adcst->cnt++;
- if (adcst->cnt == 30){
- adcst->cnt = 0;
- adcst->temp = adcst->temp_tmp/16;
- adcst->hum = adcst->hum_tmp/16;
- adcst->temp_tmp = 0;
- adcst->hum_tmp = 0;
- return 1;
- }
-
- return 0;
-}
+++ /dev/null
-#ifndef _BOARD_H
-#define _BOARD_H
-
-#include <uloi_base.h>
-#include <types.h>
-
-#include "definitions.h"
-
-#define DATA_BUF_LEN 15
-#define SN 101
-
-// OI
-extern const ULOI_CODE uloi_objdes_array_t uloi_objdes_main;
-extern uint16_t status_val;
-extern int16_t oi_temperature;
-extern uint16_t oi_cid_temp;
-extern int16_t oi_humidity;
-extern uint16_t oi_cid_hum;
-extern uint16_t oi_period;
-
-int oi_cid_temp_wrfnc(ULOI_PARAM_coninfo void *context);
-int oi_cid_hum_wrfnc(ULOI_PARAM_coninfo void *context);
-
-int oi_period_wrfnc(ULOI_PARAM_coninfo void *context);
-
-typedef struct
-{
- int16_t read;
- int16_t temp;
- int16_t hum;
- int16_t temp_tmp;
- int16_t hum_tmp;
- int cnt;
-} adc_stat_t;
-
-
-typedef struct
-{
-
-} adc_cal_t;
-
-void init_ADC (int);
-int read_ADC (adc_stat_t *);
-
-void accept_SDO(void);
-void setmyaddr(void);
-void send_data();
-void adc2oi(void);
-void oiinit(void);
-void work_with(void);
-
-#endif
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ul_lib/ulan.h>
-#include <system_def.h>
-#include <cpu_def.h>
-
-// #include <lpciap.h>
-// #include <keyval_id.h>
-// #include <keyval_loc.h>
-// #include <lpciap_kvpb.h>
-
-#include "definitions.h"
-
-//variables
-long sn = SN;
-
-#ifndef UL_WITHOUT_HANDLE
-uloi_coninfo_t *coninfo=&uloi_coninfo_global;
-ul_dyac_t *ul_dyac=&ul_dyac_global;
-// kvpb_block_t *kvpb_block=&kvpb_block_global;
-#endif
-
-// LED variables
-int led1 = 200;
-int led2 = 100;
-
-void long2buf(uchar *buf,unsigned long mod){
- buf[0]=mod>>0;
- buf[1]=mod>>8;
- buf[2]=mod>>16;
- buf[3]=mod>>24;
-}
-
-void int2buf(uchar *buf,int mod){
- buf[0]=mod>>0;
- buf[1]=mod>>8;
-}
-
-mstime_t current_time(){
- mstime_t ret = 0;
-
- #ifdef OS_POSIX
- struct timespec tp;
- if(clock_gettime(CLOCK_REALTIME, &tp) == 0){
- ret = tp.tv_sec*1000;
- ret += tp.tv_nsec/1000000;
- }
- #else
- lt_mstime_update();
- ret = actual_msec;
- #endif
-
- return ret;
-}
-
-void blink(void){
- #ifndef OS_POSIX
- if(led1 == 0) IO0SET=LED1_BIT;
- else if(led1 == 1) IO0CLR=LED1_BIT;
- else if((current_time()-led1_time) > led1){
- IO0PIN=IO0PIN^LED1_BIT;
- led1_time+=led1;
- }
-
- if(led2 == 0) IO0SET=LED2_BIT;
- else if(led2 == 1) IO0CLR=LED2_BIT;
- else if((current_time()-led2_time) > led2){
- IO0PIN=IO0PIN^LED2_BIT;
- led2_time+=led2;
- }
- #endif
-}
-
-int all_init(void){
- // kvpb init
-// kvpb_block->base=(uint8_t*)KEYVAL_START;
-// kvpb_block->size=KEYVAL_PAGE_LEN;
-// kvpb_block->flags=KVPB_DESC_DOUBLE|KVPB_DESC_CHUNKWO;
-// kvpb_block->chunk_size=KVPB_CHUNK_SIZE;
-// kvpb_block->erase=lpcisp_kvpb_erase;
-// kvpb_block->copy=lpcisp_kvpb_copy;
-// kvpb_block->flush=lpcisp_kvpb_flush;
-// printf("Keyval ready\n");
-
- /***********************************/
- // set configuration for device
-// kvpb_get_key(kvpb_block,KVPB_KEYID_ULAN_ADDR,1,&uaddr);
-// kvpb_get_key(kvpb_block,KVPB_KEYID_ULAN_SN,4,&usn);
-//
-// kvpb_get_key(kvpb_block,KVPB_KEYID_ADC_CFG,sizeof(adc_cal_t),&adccal);
-// kvpb_get_key(kvpb_block,KVPB_KEYID_CON_PARAM,sizeof(pid_con_param_t),&con_param);
-// kvpb_get_key(kvpb_block,KVPB_KEYID_APPL_PARAM,sizeof(appl_param_t),&appl_param);
-// printf("Keyval variables read\n");
-
- //opening file descriptor
- ul_fd = ul_open(NULL,NULL);
- ul_fd1 = ul_open(NULL,NULL);
- if ((ul_fd == UL_FD_INVALID) || (ul_fd1 == UL_FD_INVALID)){
- printf("error in creating ul_fd\n");
- return -1;
- }
-
- //memory set and filter set
- memset(&msginfo,0,sizeof(msginfo));
- addfilt=ul_addfilt(ul_fd,&msginfo);
- if(addfilt<0) {
- printf("spy_messages : add filter failed\n");
- return addfilt;
- }
-
- setmyaddr();
- ul_setidstr(ul_fd,ul_idstr);
-
- // uLan object interface init
- coninfo->cmd = UL_CMD_OISV;
- coninfo->sn = SN;
- coninfo->bsn = 0;
- coninfo->ul_fd = ul_fd;
- coninfo->ul_fd1 = ul_fd1;
-
- oiinit();
-
- // uLan dyac init
- uldy_init(ul_dyac,ul_fd,ul_save_sn,ul_save_adr,(char*)ul_idstr,sn);
-
- return 0;
-
-}
-
-void send_sn(void){
- int msgsend;
-
- //.preparing of msg
- uchar buf_out[ULDY_TMBUF_LEN];
- buf_out[0]=ULNCS_ADR_RQ;
- long2buf(&buf_out[1],sn);
-
- //address set and sign on the ulan
- msgsend = ul_send_command(ul_fd, msginfo.dadr, UL_CMD_NCS, UL_BFL_NORE, (void*) buf_out, ULDY_TMBUF_LEN);
- printf("[I] sn was send\n");
- ul_freemsg(ul_fd);
-}
-
-void heartbeat(void){
- //int period;
- int msgsend, i;
- int len = HEART_BUF_LEN;
- uchar *buf;
-
- //.preparing of msg
- buf = (uchar *) malloc(len*sizeof(uchar)); // NULL NULL NULL CID_HEART status_val
- for (i=0; i<=2; i++) buf[i] = 0;
- int2buf(&buf[3],HEART_CID);
- int2buf(&buf[5],2);
- int2buf(&buf[7],status_val);
-
- msgsend = ul_send_command(ul_fd, ul_dyac->ul_dysa, UL_CMD_PDO, UL_BFL_NORE, (void*) buf, HEART_BUF_LEN);
- printf("[I] BEAT\n");
- free(buf);
-}
-
-char ul_save_sn(uint32_t usn){
-// kvpb_set_key(kvpb_block,KVPB_KEYID_ULAN_SN,sizeof(unsigned long),&usn);
- return 0;
-}
-
-char ul_save_adr(uint8_t uaddr){
-// unsigned int v=uaddr;
-// kvpb_set_key(kvpb_block,KVPB_KEYID_ULAN_ADDR,sizeof(unsigned int),&v);
- return 0;
-}
+++ /dev/null
-#ifndef _DEFS_H
-#define _DEFS_H
-
-#include <time.h>
-#include <lt_timer.h>
-
-#include "hydroponie.h"
-#include "board.h"
-
-// CONSTANTS
-#define ULDY_TMBUF_LEN 5
-
-#define HEART_BUF_LEN 9
-#define HEART_CID 1023
-
-#define UL_DEV "/dev/ulan"
-
-// #define KVPB_KEYID_ADC_CFG 0x101
-// #define KVPB_KEYID_CON_PARAM 0x102
-// #define KVPB_KEYID_APPL_PARAM 0x103
-
-extern long sn;
-uchar server_adr;
-ul_msginfo msginfo;
-int addfilt;
-
-ul_fd_t ul_fd;
-ul_fd_t ul_fd1;
-
-uloi_coninfo_t uloi_coninfo_global;
-ul_dyac_t ul_dyac_global;
-// kvpb_block_t kvpb_block_global;
-
-#ifndef UL_WITHOUT_HANDLE
-extern uloi_coninfo_t *coninfo;
-extern ul_dyac_t *ul_dyac;
-//extern kvpb_block_t *kvpb_block;
-#endif
-
-#ifdef OS_POSIX
- typedef unsigned long mstime_t;
-#else
- typedef lt_mstime_t mstime_t;
-#endif
-
-mstime_t led1_time, led2_time;
-
-void long2buf(uchar *buf,unsigned long mod);
-void int2buf(uchar *buf,int mod);
-
-mstime_t current_time();
-void blink(void);
-
-int all_init(void);
-void send_sn(void);
-void heartbeat(void);
-
-char ul_save_sn(uint32_t usn);
-char ul_save_adr(uint8_t uaddr);
-
-
-#endif
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2008 by stefic *
- * stefaj1@fel.cvut.cz *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-//#define OS_POSIX
-
-#ifdef HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <system_def.h>
-#include <cpu_def.h>
-
-//INCLUDE IN CURRENT DIRECTORY
-#include "hydroponie.h"
-
-void loop(void){
- mstime_t ltime, l2time;
- mstime_t ctime;
-
- led1_time = current_time();
- led2_time = current_time();
-
- while(1){
- blink();
- send_sn();
- ltime = current_time();
- while(1){
- ctime = current_time();
- if((ctime-ltime) > 1000){
- break;
- }
- #ifdef OS_POSIX
- usleep(1);
- #endif
- accept_SDO();
- }
- if (ul_dyac->ul_dysa != 0) break;
- }
-
- ltime = current_time();
- l2time = current_time();
-
- while(1){
- blink();
- ctime = current_time();
-
- if (oi_period == 1){
- if((ctime-ltime) > 1000){
- send_data();
- ltime = current_time();
- }
- } else {
- if((ctime-ltime) > 1000){
- heartbeat();
- ltime = current_time();
- }
- if((ctime-l2time) > 1000*oi_period){
- send_data();
- l2time = current_time();
- }
- }
- accept_SDO();
- #ifdef OS_POSIX
- usleep(1);
- #endif
- }
-}
-
-int main(int argc, char *argv[]) {
-
- all_init();
-
- loop();
-
-// work_with();
-
- ul_close(ul_fd);
- ul_close(ul_fd1);
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#ifndef _HYDROPONIE_H
-#define _HYDROPONIE_H
-
-#include <ul_lib/ulan.h>
-#include <uldy_base.h>
-
-#include "definitions.h"
-#include "ul_idstr.h"
-
-#endif /* HYDRO */
+++ /dev/null
-/*
- OBJECT INTERFACE FOR SENSOR
-*/
-
-#include "board.h"
-
-#define I_TEMPERATURE 100
-#define I_TEMPERATURE_CID 110
-#define I_HUMIDITY 200
-#define I_HUMIDITY_CID 210
-#define I_PERIOD 300
-
-
-uint16_t status_val;
-int16_t oi_temperature;
-uint16_t oi_cid_temp;
-int16_t oi_humidity;
-uint16_t oi_cid_hum;
-uint16_t oi_period;
-
-int status_rdfnc(ULOI_PARAM_coninfo void *context)
-{
- return uloi_uint_rdfnc(ULOI_ARG_coninfo &status_val);
-}
-
-int errclr_wrfnc(ULOI_PARAM_coninfo void *context)
-{
- status_val=0;
- return 1;
-}
-
-/* description of input objects */
-const ULOI_CODE uloi_objdes_t uloid_objdes_DOII =
-ULOI_GENOBJDES_RAW(ULOI_DOII,NULL,NULL_CODE,NULL,uloi_doii_fnc,(void*)&uloi_objdes_main)
-/* description of output objects */
-const ULOI_CODE uloi_objdes_t uloid_objdes_DOIO =
-ULOI_GENOBJDES_RAW(ULOI_DOIO,NULL,NULL_CODE,NULL,uloi_doio_fnc,(void*)&uloi_objdes_main)
-/* ID numbers of recognized input objects */
-const ULOI_CODE uloi_objdes_t uloid_objdes_QOII =
-ULOI_GENOBJDES_RAW(ULOI_QOII,NULL,NULL_CODE,NULL,uloi_qoii_fnc,(void*)&uloi_objdes_main)
-/* ID numbers of recognized output objects */
-const ULOI_CODE uloi_objdes_t uloid_objdes_QOIO =
-ULOI_GENOBJDES_RAW(ULOI_QOIO,NULL,NULL_CODE,NULL,uloi_qoio_fnc,(void*)&uloi_objdes_main)
-/* object values read request */
-const ULOI_CODE uloi_objdes_t uloid_objdes_RDRQ =
-ULOI_GENOBJDES_RAW(ULOI_RDRQ,NULL,NULL_CODE,NULL,uloi_rdrq_fnc,(void*)&uloi_objdes_main)
-
-ULOI_GENOBJDES(STATUS,ULOI_STATUS,"u2",status_rdfnc,&status_val,NULL_CODE,NULL)
-ULOI_GENOBJDES(ERRCLR,ULOI_ERRCLR,"e",NULL_CODE,NULL,errclr_wrfnc,&status_val)
-
-ULOI_GENOBJDES(TEMPERATURE,I_TEMPERATURE,"s2",uloi_int_rdfnc,&oi_temperature,NULL_CODE,NULL)
-ULOI_GENOBJDES(TEMPERATURE_CID,I_TEMPERATURE_CID,"u2",uloi_uint_rdfnc,&oi_cid_temp,oi_cid_temp_wrfnc,&oi_cid_temp)
-
-ULOI_GENOBJDES(HUMIDITY,I_HUMIDITY,"s2",uloi_int_rdfnc,&oi_humidity,NULL_CODE,NULL)
-ULOI_GENOBJDES(HUMIDITY_CID,I_HUMIDITY_CID,"u2",uloi_uint_rdfnc,&oi_cid_hum,oi_cid_hum_wrfnc,&oi_cid_hum)
-
-ULOI_GENOBJDES(PERIOD,I_PERIOD,"u2",uloi_uint_rdfnc,&oi_period,oi_period_wrfnc,&oi_period)
-
-const uloi_objdes_t * ULOI_CODE uloi_objdes_main_items[]={
- &uloid_objdes_DOII,
- &uloid_objdes_DOIO,
- &uloid_objdes_QOII,
- &uloid_objdes_QOIO,
- &uloid_objdes_RDRQ,
-
- &uloid_objdes_STATUS,
- &uloid_objdes_ERRCLR,
- &uloid_objdes_TEMPERATURE,
- &uloid_objdes_TEMPERATURE_CID,
- &uloid_objdes_HUMIDITY,
- &uloid_objdes_HUMIDITY_CID,
- &uloid_objdes_PERIOD
-
-};
-
-const ULOI_CODE uloi_objdes_array_t uloi_objdes_main={
- {
- (uloi_objdes_t **)uloi_objdes_main_items,
- sizeof(uloi_objdes_main_items)/sizeof(uloi_objdes_main_items[0]),
- -1
- }
-};
+++ /dev/null
-#!/bin/bash
-
-usb_sendhex -d 0xdead -i 0x2263 -s 0x20000 -l 0x20000 -e;
-sleep 2 ;
-usb_sendhex -d 0xdead -i 0x2263 -s 0x20000 -f binary /home/stefic/BAP/build_ulan/ulan-build/arm-ul_usb1-ulad31/_compiled/bin/sensor-app.bin
-usb_sendhex -d 0xdead -i 0x2263 -r ;
+++ /dev/null
-#include <ulan_config.h>
-
-#define __STRINGIFY(x) #x /* stringify without expanding x */
-#define STRINGIFY(x) __STRINGIFY(x) /* expand x, then stringify */
-
-#ifdef CONFIG_ULAN_DY
- #define UL_DYC " .dy"
-#else
- #define UL_DYC
-#endif
-
-#ifdef CONFIG_ULOI_LT
- #define UL_OIC " .oi"
-#else
- #define UL_OIC
-#endif
-
-#define NAME ".mt " \
- STRINGIFY(ULAN_ID) \
- " .uP " \
- STRINGIFY(MACH) \
- UL_DYC \
- UL_OIC \
- " .co " \
- __DATE__ " " __TIME__
-
-const char *ul_idstr = NAME;
+++ /dev/null
-#ifndef _UL_IDSTR_H
-#define _UL_IDSTR_H
-
-#ifdef __cplusplus
-/*extern "C" {*/
-#endif
-
-extern const char *ul_idstr;
-
-#ifdef __cplusplus
-/*}*/ /* extern "C"*/
-#endif
-
-#endif /* _UL_IDSTR_H */