Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FS-ELAB
pilc2server_old
Commits
ddd67b57
Commit
ddd67b57
authored
Feb 11, 2022
by
Joshua Supra
Browse files
added logic module to server(no ZMQ)
parent
ac2e739f
Changes
12
Hide whitespace changes
Inline
Side-by-side
main.c
View file @
ddd67b57
...
...
@@ -19,7 +19,8 @@
#include
"pilc2_functions/pilc2_adc.h"
#include
"pilc2_functions/pilc2_IO_mux.h"
#include
"pilc2_functions/pilc2_encoder.h"
//#include "pilc2_functions/pilc2_encoder.h"
#include
"pilc2_functions/pilc2_logic.h"
...
...
@@ -55,6 +56,8 @@ int main (int argc, char *argv[]){
* */
IOMuxAutoConfig
(
IOCards
);
/*setIOMuxCfg(PILC_IO_MUX_CFG_CH_0, IO_MUX_CFG_ENCODER);
setIOMuxCfg(PILC_IO_MUX_CFG_CH_1, IO_MUX_CFG_ENCODER);
setIOMuxCfg(PILC_IO_MUX_CFG_CH_2, IO_MUX_CFG_ENCODER);
...
...
@@ -72,8 +75,24 @@ int main (int argc, char *argv[]){
setIOMuxCfg(PILC_IO_MUX_CFG_CH_14, IO_MUX_CFG_ENCODER);
setIOMuxCfg(PILC_IO_MUX_CFG_CH_15, IO_MUX_CFG_ENCODER);*/
InitIOCards
(
IOCards
);
setIOConfig
(
0
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
1
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
2
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
3
,
1
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_OUT
);
setIOConfig
(
4
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
5
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
6
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
7
,
1
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_OUT
);
setIOConfig
(
8
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
9
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
10
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
11
,
1
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_OUT
);
setIOConfig
(
12
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
13
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
14
,
0
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_IN
);
setIOConfig
(
15
,
1
,
IO_MUX_CFG_LOGIC
,
IOCARD_NIMTTL_TTL_OUT
);
InitIOCards
(
IOCards
);
zmq_recive_data
[
1
]
=
malloc
(
sizeof
(
zmq_data
));
zmq_recive_data
[
1
]
->
data
=
(
unsigned
int
*
)
malloc
(
256
*
sizeof
(
char
));
...
...
@@ -85,7 +104,20 @@ int main (int argc, char *argv[]){
init_network
();
/**************************************************************************
* TEST Functions
**************************************************************************/
setLogicCfg
(
LOGIC_CFG_CH_0
,
0x000100
)
;
setLogicCfg
(
LOGIC_CFG_CH_3
,
0x010100
)
;
//setLogicCfg(unsigned int channel, unsigned int config)
/**************************************************************************
* TEST Functions
**************************************************************************/
while
(
1
)
{
...
...
pilc2_functions/Makefile
View file @
ddd67b57
...
...
@@ -20,7 +20,8 @@ DEPENDENCIES= \
pilc2_IO_mux.h
\
pilc2_pt100.h
\
pilc2_thermo.h
\
pilc2_encoder.h
pilc2_encoder.h
\
pilc2_logic.h
OBJ
=
\
pilc2_SPI_func.o
\
pilc2_register_func.o
\
...
...
@@ -40,7 +41,8 @@ OBJ= \
pilc2_IO_mux.o
\
pilc2_pt100.o
\
pilc2_thermo.o
\
pilc2_encoder.o
pilc2_encoder.o
\
pilc2_logic.o
all
:
$(OBJ)
ar vrcs
$(TARGETLIB)
$(OBJ)
...
...
pilc2_functions/libpilc2.a
View file @
ddd67b57
No preview for this file type
pilc2_functions/pilc2_IO_GPIOs.c
View file @
ddd67b57
...
...
@@ -24,6 +24,8 @@
#include
"pilc2_dadc.h"
#include
"pilc2_thermo.h"
#include
"pilc2_pt100.h"
#include
"pilc2_IO_mux.h"
#include
"pilc2_logic.h"
...
...
@@ -270,10 +272,15 @@ int GetIOCardRegister(IOCardStruct *IOCard) {
return
0
;
}
int
setIOConfig
(
unsigned
int
channel
,
unsigned
int
config
)
{
int
setIOConfig
(
unsigned
int
channel
,
unsigned
int
direction
,
unsigned
int
function
,
unsigned
int
level
)
{
setIOMuxCfg
(
channel
,
function
);
WriteFPGA
(
SPI_CS_MUX_OFFSET
,
channel
);
WriteIOCard
(
IOCARD_NIMTTL_WSTATUS
,
level
);
setIODDR
(
0x1
<<
channel
,
direction
);
return
0
;
}
...
...
@@ -301,6 +308,7 @@ void *updateIOLeds(void *vargp) {
}
unsigned
int
led_brightness
;
//unsigned int IO_status_mask_result;
for
(
int
i
=
0
;
i
<
16
;
i
++
){
/* if a card is present the card information will be printed */
...
...
@@ -315,8 +323,9 @@ void *updateIOLeds(void *vargp) {
led_color
.
Red
=
8
+
IOCard
[
i
].
IOStatus
*
42
;
led_color
.
Green
=
0
;
}
else
{
getNIMTTLcolour
(
i
,
&
led_color
);
led_color
.
Red
=
0
;
led_color
.
Green
=
8
+
IOCard
[
i
].
IOStatus
*
42
;
led_color
.
Green
=
led_color
.
Green
+
IOCard
[
i
].
IOStatus
*
42
;
}
led_color
.
Blue
=
0
;
break
;
...
...
@@ -424,6 +433,43 @@ void *updateIOLeds(void *vargp) {
}
void
getNIMTTLcolour
(
int
card_slot
,
led_color_struct
*
led_color
)
{
unsigned
int
muxcfg
;
unsigned
int
ABmask
=
0xFF00
;
unsigned
int
ABCmask
=
0xFF0000
;
unsigned
int
logicfg
;
muxcfg
=
getIOMuxCfg
(
card_slot
);
switch
(
muxcfg
)
{
case
IO_MUX_CFG_LOGIC
:
if
(
card_slot
<
16
)
logicfg
=
GetLogicCfg
(
LOGIC_CFG_CH_3
);
if
(
card_slot
<
12
)
logicfg
=
GetLogicCfg
(
LOGIC_CFG_CH_2
);
if
(
card_slot
<
8
)
logicfg
=
GetLogicCfg
(
LOGIC_CFG_CH_1
);
if
(
card_slot
<
4
)
logicfg
=
GetLogicCfg
(
LOGIC_CFG_CH_0
);
switch
(
card_slot
%
4
)
{
case
0
:
led_color
->
Green
=
8
;
break
;
case
1
:
if
((
logicfg
&
ABmask
)
!=
0
)
{
led_color
->
Green
=
8
;
}
else
{
led_color
->
Green
=
0
;
}
break
;
case
2
:
if
((
logicfg
&
ABCmask
)
!=
0
)
{
led_color
->
Green
=
8
;
}
else
{
led_color
->
Green
=
0
;
}
break
;
}
break
;
}
}
/****************************************************************************/
/**
...
...
pilc2_functions/pilc2_IO_GPIOs.h
View file @
ddd67b57
...
...
@@ -36,7 +36,8 @@
#define IO_CH_14 0x4000
#define IO_CH_15 0x8000
#define PILC_IODDR_CFG_REG 0xB
//#define PILC_IODDR_CFG_REG 0xB
#define PILC_IODDR_CFG_REG 0x1
#define PILC_IO_INPUT 0x0
#define PILC_IO_OUTPUT 0x1
...
...
@@ -68,6 +69,12 @@ typedef struct {
unsigned
int
SoftwareVersion
;
}
pilcIOGpioStruct
;
typedef
struct
{
unsigned
char
Red
;
unsigned
char
Green
;
unsigned
char
Blue
;
}
led_color_struct
;
void
initpilc2
(
IOCardStruct
*
IOCard
);
int
GetGpioConfig
(
pilcIOGpioStruct
*
pilcIOcfg
);
void
setIODDR
(
unsigned
int
channel
,
unsigned
int
config
);
...
...
@@ -78,8 +85,9 @@ int TestNIMTTLCard (IOCardStruct *IOCard);
int
GetIOCardStatus
(
IOCardStruct
*
IOCard
);
int
GetIOCardRegister
(
IOCardStruct
*
IOCard
);
void
*
updateIOLeds
(
void
*
vargp
);
int
setIOConfig
(
unsigned
int
channel
,
unsigned
int
config
);
int
setIOConfig
(
unsigned
int
channel
,
unsigned
int
direction
,
unsigned
int
function
,
unsigned
int
level
);
void
getNIMTTLcolour
(
int
card_slot
,
led_color_struct
*
led_color
);
IOCardStruct
IOCards
[
16
];
unsigned
int
WorkLEDcounter
;
...
...
pilc2_functions/pilc2_IO_Leds.c
View file @
ddd67b57
...
...
@@ -34,6 +34,9 @@ void InhibitFrontLED(unsigned int led_mask) {
}
void
*
FadeLEDsThreadRGB
(
void
*
vargp
){
while
(
1
){
for
(
int
k
=
0
;
k
<
MAX_BRIGHTNESS
;
k
++
){
...
...
pilc2_functions/pilc2_IO_Leds.h
View file @
ddd67b57
...
...
@@ -30,11 +30,7 @@
#define MAX_BRIGHTNESS 20
typedef
struct
{
unsigned
char
Red
;
unsigned
char
Green
;
unsigned
char
Blue
;
}
led_color_struct
;
void
WriteFrontLED
(
unsigned
char
LED
,
unsigned
char
Red
,
unsigned
char
Green
,
unsigned
char
Blue
);
void
RGBFadeLEDs
(
int
fadetime
,
char
status
);
...
...
@@ -42,3 +38,4 @@ void *FadeLEDsThreadMonoCol (void *vargp);
void
*
FadeLEDsThreadRGB
(
void
*
vargp
);
int
deinit_IOleds
(
void
);
void
InhibitFrontLED
(
unsigned
int
led_mask
);
pilc2_functions/pilc2_IO_mux.c
View file @
ddd67b57
...
...
@@ -22,20 +22,20 @@ void IOMuxAutoConfig(IOCardStruct *IOCard) {
for
(
int
i
=
0
;
i
<
16
;
i
++
){
switch
(
IOCard
[
i
].
TypeID
)
{
case
NIM_TTL
:
/*if (i == 15) {
setIODDR(0x1<<i, PILC_IO_OUTPUT);
WriteIOCard(IOCARD_NIMTTL_WSTATUS, IOCARD_NIMTTL_TTL_OUT);
}else {*/
setIODDR
(
0x1
<<
i
,
PILC_IO_INPUT
);
WriteIOCard
(
IOCARD_NIMTTL_WSTATUS
,
IOCARD_NIMTTL_TTL_IN
);
//}
case
NIM_TTL
:
setIODDR
(
0x1
<<
i
,
PILC_IO_INPUT
);
WriteFPGA
(
SPI_CS_MUX_OFFSET
,
i
);
WriteIOCard
(
IOCARD_NIMTTL_WSTATUS
,
IOCARD_NIMTTL_TTL_IN
);
setIOMuxCfg
(
i
,
IO_MUX_CFG_CTR
);
break
;
case
ADC
:
setIODDR
(
0x1
<<
i
,
PILC_IO_INPUT
);
setIOMuxCfg
(
i
,
IO_MUX_CFG_ADC
);
break
;
case
DAC
:
setIODDR
(
0x1
<<
i
,
PILC_IO_OUTPUT
);
setIOMuxCfg
(
i
,
IO_MUX_CFG_DAC
);
break
;
case
PT100
:
setIODDR
(
0x1
<<
i
,
PILC_IO_INPUT
);
setIOMuxCfg
(
i
,
IO_MUX_CFG_PT100
);
break
;
case
ADAPTER
:
if
(
IOCard
[
i
-
1
].
TypeID
==
DIFF_ADC
)
{
setIODDR
(
0x1
<<
i
,
PILC_IO_INPUT
);
setIOMuxCfg
(
i
,
IO_MUX_CFG_DADC
);
break
;
...
...
@@ -44,9 +44,11 @@ void IOMuxAutoConfig(IOCardStruct *IOCard) {
setIOMuxCfg
(
i
,
IO_MUX_CFG_ADAPTER_CARD
);
break
;
}
case
DIFF_ADC
:
setIODDR
(
0x1
<<
i
,
PILC_IO_INPUT
);
setIOMuxCfg
(
i
,
IO_MUX_CFG_DADC
);
break
;
setIOMuxCfg
(
i
,
IO_MUX_CFG_DADC
);
break
;
case
THERMO
:
setIODDR
(
0x1
<<
i
,
PILC_IO_INPUT
);
setIOMuxCfg
(
i
,
IO_MUX_CFG_THERMO
);
break
;
default:
setIODDR
(
0x1
<<
i
,
PILC_IO_INPUT
);
setIOMuxCfg
(
i
,
IO_MUX_CFG_CTR
);
break
;
}
...
...
pilc2_functions/pilc2_IO_mux.h
View file @
ddd67b57
...
...
@@ -28,6 +28,7 @@
#define IO_MUX_CFG_DADC 0x7
#define IO_MUX_CFG_THERMO 0x8
#define IO_MUX_CFG_ENCODER 0x9
#define IO_MUX_CFG_LOGIC 0xA
void
setIOMuxCfg
(
char
channel
,
unsigned
int
config
);
unsigned
int
getIOMuxCfg
(
char
channel
);
...
...
pilc2_functions/pilc2_network.c
View file @
ddd67b57
...
...
@@ -33,14 +33,9 @@ int init_network(void){
//create 0mq context and responder
context
=
zmq_ctx_new
();
/*int keep_alive = 1;
int keep_alive_idle = 300;
int keep_alive_intvl = 300;*/
/* create and bind socket for client connection */
client_responder
=
zmq_socket
(
context
,
ZMQ_REP
);
/*zmq_setsockopt (client_responder, ZMQ_TCP_KEEPALIVE, &keep_alive, sizeof(keep_alive));
zmq_setsockopt (client_responder, ZMQ_TCP_KEEPALIVE_IDLE, &keep_alive_idle, sizeof(keep_alive_idle));
zmq_setsockopt (client_responder, ZMQ_TCP_KEEPALIVE, &keep_alive_intvl, sizeof(keep_alive_intvl));*/
zmq_bind
(
client_responder
,
"tcp://eth1:4444"
);
/* create and bind socket for gui connection */
...
...
pilc2_functions/pilc2_network.h
View file @
ddd67b57
...
...
@@ -2,7 +2,7 @@
#define PILC2_NETWORK_H
#include
<stdbool.h>
//
#include <stdbool.h>
/**Communication Errors**/
#define ERR_OUT_OF_BONDS -1
...
...
pilc2_functions/pilc2_register_func.h
View file @
ddd67b57
...
...
@@ -3,7 +3,7 @@
#define PILC_REG_START_ADDR 0x80000000
#define PILC_REG_END_ADDR 0x8000
9
FFF
#define PILC_REG_END_ADDR 0x800
1
0FFF
#define PILC_REG_SIZE ( PILC_REG_END_ADDR - PILC_REG_START_ADDR )
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment