blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
357
content_id
stringlengths
40
40
detected_licenses
listlengths
0
58
license_type
stringclasses
2 values
repo_name
stringlengths
4
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-14 21:31:45
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-01 00:00:00
2023-09-05 23:26:37
committer_date
timestamp[ns]date
1970-01-01 00:00:00
2023-09-05 23:26:37
github_id
int64
966
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
24 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-02-03 21:17:16
2023-08-24 19:49:39
gha_language
stringclasses
180 values
src_encoding
stringclasses
35 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
6
10.4M
extension
stringclasses
121 values
filename
stringlengths
1
148
content
stringlengths
6
10.4M
6bee4ba3c2d9374ce5e74e913bfdbbf60ccfc695
a364f5e25e4ec3563c2a6e366069488786927948
/sys/arch/arm32/vidc/console/vt220.h
793b440bfbc820abb4a18db4f8242884283195ab
[]
no_license
noud/mouse-bsd
b044db5ba4085794b94ea729eb4148e1c86d73b5
a16ee9b253dbd25c931216ef9be36611fb847411
refs/heads/main
2023-02-24T06:22:20.517329
2020-08-25T20:21:40
2020-08-25T20:21:40
334,500,331
1
0
null
null
null
null
UTF-8
C
false
false
3,558
h
vt220.h
/* $NetBSD: vt220.h,v 1.2 1996/03/18 19:33:12 mark Exp $ */ /* * Copyright (c) 1994-1995 Melvyn Tang-Richardson * Copyright (c) 1994-1995 RiscBSD kernel team * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the RiscBSD kernel team * 4. The name of the company nor the name of the author may be used to * endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE RISCBSD TEAM ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * RiscBSD kernel project * * vt220.h * * VT220 emulation header file * * Created : 17/09/94 */ #define MAXTABSTOPS 132 #define STATE_INIT 0 #define STATE_HASH 1 #define STATE_BROPN 2 #define STATE_BRCLO 3 #define STATE_STAR 4 #define STATE_PLUS 5 #define STATE_MINUS 6 #define STATE_DOT 7 #define STATE_SLASH 8 #define STATE_AMPSND 9 #define SHP_INIT 10 #define STATE_ESC 11 #define STATE_CSIQM 14 #define STATE_CSI 15 #define STATE_DCS 16 #define STATE_SCA 17 #define STATE_STR 18 /* sub-states for Device Control String processing */ #define DCS_INIT 0 /* got ESC P ... */ #define DCS_AND_UDK 1 /* got ESC P ... | */ #define DCS_UDK_DEF 2 /* got ESC P ... | fnckey / */ #define DCS_UDK_ESC 3 /* got ESC P ... | fnckey / ... ESC */ #define DCS_DLD_DSCS 4 /* got ESC P ... { */ #define DCS_DLD_DEF 5 /* got ESC P ... { dscs */ #define DCS_DLD_ESC 6 /* got ESC P ... { dscs ... / ... ESC */ #define F_AWM (1) #define F_LASTCHAR (2) #define F_IRM (3) #define MAXPARMS 10 struct vt220_info { int tab_stops[MAXTABSTOPS]; int state; int hp_state; int disable_function; int lastchar; int beepoff; int param[MAXPARMS]; int parami; u_char m_om, sc_om; /* flag, vt100 mode, origin mode */ u_char scrr_beg; u_char scrr_len; u_char scrr_end; int simple_cursor_store; int simple_cursor_on; int dcs_state; int G0, G1, G2, G3, GL, GR, sc_G0, sc_G1, sc_G2, sc_G3, sc_GL, sc_GR; int Gs, ss; int xcur, ycur, sc_xcur, sc_ycur; int sc_flag; char *report_chars; int report_count; int cursor_on; int fgcol, bgcol; int nfgcol, nbgcol; int attribs; int flags; int sflags; int lastpos; int irm; };
f98a396539e5cb317b465f810b210507c970aa0e
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
/source/linux/drivers/nvme/host/extr_pci.c_nvme_init_request.c
7c4bce9d2149eff2435a4e75f5acdeade2c25c3b
[]
no_license
isabella232/AnghaBench
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
9a5f60cdc907a0475090eef45e5be43392c25132
refs/heads/master
2023-04-20T09:05:33.024569
2021-05-07T18:36:26
2021-05-07T18:36:26
null
0
0
null
null
null
null
UTF-8
C
false
false
1,323
c
extr_pci.c_nvme_init_request.c
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward declarations */ typedef struct TYPE_2__ TYPE_1__ ; /* Type definitions */ struct request {int dummy; } ; struct nvme_queue {int dummy; } ; struct nvme_iod {struct nvme_queue* nvmeq; } ; struct blk_mq_tag_set {struct nvme_dev* driver_data; } ; struct nvme_dev {int /*<<< orphan*/ ctrl; struct nvme_queue* queues; struct blk_mq_tag_set tagset; } ; struct TYPE_2__ {int /*<<< orphan*/ * ctrl; } ; /* Variables and functions */ int /*<<< orphan*/ BUG_ON (int) ; struct nvme_iod* blk_mq_rq_to_pdu (struct request*) ; TYPE_1__* nvme_req (struct request*) ; __attribute__((used)) static int nvme_init_request(struct blk_mq_tag_set *set, struct request *req, unsigned int hctx_idx, unsigned int numa_node) { struct nvme_dev *dev = set->driver_data; struct nvme_iod *iod = blk_mq_rq_to_pdu(req); int queue_idx = (set == &dev->tagset) ? hctx_idx + 1 : 0; struct nvme_queue *nvmeq = &dev->queues[queue_idx]; BUG_ON(!nvmeq); iod->nvmeq = nvmeq; nvme_req(req)->ctrl = &dev->ctrl; return 0; }
cff3ec1404141095586ab2f4201461a0394115e7
9325b1dd91d251f6f13e748bf19dff3a54515ad9
/tools/jmi-lifter/main.c
871e7a495824108b768cee63f714b522564aa226
[ "BSD-3-Clause" ]
permissive
mietek/icfp-contest-2012
d47e3a0f2daf13536c2b591d2e1c06ac75ed6c72
3f974bff9e1588e879ab55d7cfbc112c35e5f745
refs/heads/master
2021-01-16T19:35:21.372344
2019-02-14T15:16:52
2019-02-14T15:16:52
4,973,304
1
0
null
null
null
null
UTF-8
C
false
false
5,296
c
main.c
#include <limits.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "libvm.h" //reverse string (str, 0, strlen-1) void reverse(char *x, int beg, int end){ char c; if ( beg >= end ) return; c = *(x+beg); *(x+beg) = *(x+end); *(x+end) = c; reverse(x, ++beg, --end); } int bounded(struct state *s, int w, int h){ return (w>=1 && h>=1 && w<= s->world_w && h<= s->world_h); } void anyMove(struct state *s, char **a, int stage){ int k,is,js; char *answer = malloc( (2)*sizeof( char )); struct state *t=copy(s); answer[1]='\0'; for(k=0; k<=5 ; k++){ if((k+stage)%5==0){answer[0]='R';is=-1; js= 0;} if((k+stage)%5==1){answer[0]='L';is= 1; js= 0;} if((k+stage)%5==2){answer[0]='U';is= 0; js=-1;} if((k+stage)%5==3){answer[0]='D';is= 0; js= 1;} if(k==4) {answer[0]='W';is= 0; js= 0;} if(k==5) answer[0]='A'; t = make_moves(s, answer); if(t->condition == C_NONE) break; } free(t); *a=answer; return; } int goSomewhere(struct state *s, char **a, int penalty){ int i,j, is, js, k, wx=0, wy=0, stage=-1; unsigned int change = 0, end = 0; struct state *ns; char * answer; char move='U'; unsigned int *c = malloc( ((s-> world_w+1) * s->world_h+1) * sizeof( unsigned int )); if (c == NULL ){} for(i=0; i<((s-> world_w+1) * s->world_h+1); i++){ c[i]=UINT_MAX; } c[point_to_index(s, s->robot_x, s->robot_y)]=0; put(s, 1, 1, O_EMPTY); move_robot(s, 1, 1); ns = copy(s); do{ free(s); s = copy(ns); update_world(ns, s); change++; stage++; end = 0; for(i=1; i <= s->world_w; i++){ for(j=1; j <= s->world_h; j++){ if(c[point_to_index(s,i,j)]==stage){ if(get(s, i, j) == O_LIFT_OPEN || get(s, i, j) == O_LAMBDA){ wx=i; wy=j; end=stage; break; } //consider four cells - (-1, 0), (1, 0), (0, -1), (0, 1) for(k = 1; k<=4; k++){ if(k==1) {is= 0 ; js=-1;} if(k==2) {is= 0 ; js= 1;} if(k==3) {is=-1 ; js= 0;} if(k==4) {is= 1 ; js= 0;} if(bounded(s,i+is,j+js) && c[point_to_index(s, i+is, j+js)]==UINT_MAX){ //can we go there? if( !bounded(s, i+is, j+js+1) || (get(s, i+is, j+js+1) != O_EMPTY || get(ns, i+is, j+js+1) != O_ROCK)){ if(get(s, i+is, j+js)==O_LIFT_OPEN || get(s, i+is, j+js)==O_LAMBDA || get(s, i+is, j+js)==O_EARTH || get(s, i+is, j+js)==O_EMPTY){ if((bounded(s, i+is, j+js+1) && get(s, i+is, j+js+1)==O_ROCK) || (bounded(s, i+is+1, j+js+1) && get(s, i+is+1, j+js)==O_ROCK && get(s, i+is+1, j+js+1)==O_ROCK) || (bounded(s, i+is-1, j+js+1) && get(s, i+is-1, j+js)==O_ROCK && get(s, i+is-1, j+js+1)==O_ROCK)){ c[point_to_index(s, i+is, j+js)]=stage+penalty; }else{ c[point_to_index(s, i+is, j+js)]=stage+1; } change = 0; } } } } } } } }while(change <= penalty && end == 0); //debug //dump(s); if(0){ for(j=s->world_h; j>0; j--){ for(i=1; i<=s->world_w; i++){ if(c[point_to_index(s, i, j)]==UINT_MAX){ printf("X"); }else{ printf("%u", c[point_to_index(s, i, j)]); } } printf("\n"); } printf("\n"); } i=0; if(end>0){ answer = malloc( (end+2)*sizeof( char )); if (answer == NULL ){} while(end>0){ for(k=1; k<=4;k++){ if(k==1) {is=-1; js= 0;move='R';} if(k==2) {is= 1; js= 0;move='L';} if(k==3) {is= 0; js=-1;move='U';} if(k==4) {is= 0; js= 1;move='D';} if( bounded(s, wx+is, wy+js) && c[point_to_index(s, wx+is, wy+js)] < end) { end = c[point_to_index(s, wx+is, wy+js)]; answer[i++]=move; wx = wx+is; wy = wy+js; break; } } } answer[i]='\0'; reverse(answer,0,strlen(answer)-1); }else{ answer = malloc(1*sizeof( char )); if (answer == NULL ){} answer[0]='\0'; *a=answer; free(c); return 1; } *a=answer; free(c); return 0; } int main(int argc, char *argv[]){ struct state *s = new_from_file(argv[1]); struct state *t, *s0; char *answer; int status, stage, i, j, bestv=0; char *result = malloc (((s-> world_w+1) * s->world_h * sizeof(char))); char *best = malloc (((s-> world_w+1) * s->world_h * sizeof(char))); s0 = copy(s); srand(time(NULL)); for(j=1; j<150; j++){ stage=0; strcpy(result, ""); free(s); s = copy(s0); i= j%80+1; do{ t = copy(s); status=goSomewhere(t, &answer, i); // free(t); t = copy(s); if(status==0) s = make_moves(s, answer); if(status==1 || s->condition == C_LOSE || (j>30 && rand()*100>180-j)){ free(s); s=copy(t); anyMove(t, &answer, rand()*5); stage++; s = make_moves(s, answer); } strcat(result, answer); free(t); }while(s->condition == C_NONE && stage < s->world_h*8 && s->score>-1000 ); s = make_moves(s0, result); printf("%d: %ld\n", j, s->score); if(s->score > bestv){ strcpy(best, result); bestv = s->score; } } s = make_moves(s0, best); dump(s); printf("%s\n", best); fflush(stdout); return 0; }
f6cfa50c9ec7ffafc1c29776788bde571625c2fd
8067a79042bbb508a25541cdd0729c79396de7e6
/Estructuras-de-control-iterativas/legendre.c
0a736cc48a4902ec62b3dc5d7beb1bd6fe9897e1
[]
no_license
hugocerna/Programacion
d2196dcce3ec13898cdfe46c97875d459ad1ade1
7e1fcd117f1be69cc873a6228b213edc5c7a12cb
refs/heads/master
2020-06-12T23:33:52.424177
2016-12-03T14:03:52
2016-12-03T14:03:52
75,477,479
1
0
null
2016-12-03T14:09:23
2016-12-03T14:09:23
null
UTF-8
C
false
false
392
c
legendre.c
#include <stdio.h> int main () { int n, i, d, primos, propios; for (n = 1; n <= 50; n = n +1) { i = n*n; primos = 0; while (primos == 0) { i = i + 1; propios = 0; for (d = 2; d < i; d = d + 1) { if (i%d == 0) propios = propios + 1; } if (propios == 0) primos = primos + 1; } printf ("Entre (%d)^2 y (%d)^2 esta el primo: %d\n",n,n+1,i); } }
046f63846ec68eb156eba5f1daa2b3f393f4a91a
bd86163afca468c412d990460102ac559e6882e9
/range_tree.h
12c521dc58b217c22cbced1934be52c5e265e691
[]
no_license
michaelx812/CS537_p4
ccd2e11c305e1666cf73b8431332ec2850a32a34
c124911b3653556f0c9bef1636447398ae2668d8
refs/heads/master
2020-04-16T09:21:23.989290
2019-01-13T09:55:31
2019-01-13T09:55:31
165,461,103
0
0
null
null
null
null
UTF-8
C
false
false
3,242
h
range_tree.h
/*Authors: Ge Xu, Patrick Lown */ #ifndef RANGE_TREE_H #define RANGE_TREE_H #include <stdlib.h> #include <stdio.h> #include <stdbool.h> typedef struct interval interval; typedef struct tree_node tree_node; /* This structure will hold intervals of address ranges. The low will represent the lower addr and high will represent higher addr This will be used with as a data field for interval tree structure nodes. */ struct interval { void* low; int len; }; /* This will be used as the main data structure for implementing ranged queuries Each tree_node will store an interval, a max value for the highest addr in its right subtree, and pointers to its left and right subtree. The struct and idea for this structure and its properties were inspired by this implementation of an interval tree: https://www.geeksforgeeks.org/interval-tree/ */ struct tree_node { interval *i; tree_node *left,*parent,*right; char color; bool freed; }; /* This function will construct a new interval for use in a tree_node for the interval tree. */ interval* new_interval(void* ptr, size_t size); /* This function will construct a new tree node and return the addr of it, the required parameter will be the interval of addresses that this tree node will store. Its max will be the value of its high addr. Both children will be set to NULL */ tree_node* new_tree_node(interval* i); /* This function initializes the root node of the tree */ //tree_node** init_root(tree_node** root); tree_node** init_root(); /* This function will insert a node in the tree based on the lower value of interval passed in. The implementation of this tree is currently that of a Red Black Tree. This guarentees insertions in O(logn) time as the RBT always remains "balanced" The algorithm for this function is drawn heavily from "Introduction to Algorithms, Third Edition 3rd" by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein Chapter 13: Red Black Trees Additionally, https://stackoverflow.com/questions/42800462/trying-to-implement-a-red-black-tree-in-c and https://www.geeksforgeeks.org/c-program-red-black-tree-insertion/ were used as resources for implementation */ void insert_node(tree_node **root, interval* i); /* This function will delete a tree node in the current interval tree. Has potential to change the max for interval nodes. https://stackoverflow.com/questions/28012126/trouble-deleting-a-node-in-red-black-tree-c-code */ void delete_node(tree_node** root, tree_node *node); /* Simple function that checks if two intervals overlap with each other. Used in functions throughout this header file. Returns 1 if intervals overlap, 0 if they do not */ int does_overlap(interval i, interval j); /* This function will check the interval tree to see if the interval passed in overlaps with any of the intervals currently in the tree. It will return 1 if an overlapping interval is found and 0 if no overlapping intervals are found. Complexity: O(logn) time for check */ tree_node* search_range(tree_node **root, void* ptr, size_t size); /* This function will search for the node that contains this ptr address, if not found return NULL */ tree_node* search_ptr(tree_node **root, void* ptr); #endif
7d9f1e8f7f44e132390a10b8c1bc6bafb536cb06
86a6aa269de0b787b8e6952e570c0f1d66cc45e3
/src/material.c
99a6b832c09bc5f0f67e2e155a3f7df06969f665
[]
no_license
irene-fdez/parque_OpenGL
df9adc4e9e739e49b0016db8af6849dc48387c73
e6f398c01c77e27c9e486984b2dd120608b0f3b4
refs/heads/master
2023-04-22T12:25:12.595829
2021-04-27T15:11:19
2021-04-27T15:11:19
362,155,161
0
0
null
null
null
null
UTF-8
C
false
false
15,321
c
material.c
/*************************************************************************/ /* */ /* material.c */ /* Rev. 2.0 01/01/2002 AUTORES: O. Belmonte, M. Chover, J. Ribelles */ /* */ /*************************************************************************/ /***************** INCLUDES DE LAS LIBRERIAS NECESARIAS ******************/ #include "glut.h" #include "material.h" #include <stdio.h> /********************** RUTINA DE INICIO **************************************************/ /******************************************************************************************/ /* Inicia OpenGL para poder definir las propiedades de los materiales */ /* Parametros: Ninguno */ /* Salida: Ninguna */ /******************************************************************************************/ void IniciaMaterial(void) { /* Se modificara las propiedades de color de material ambiente y difusa */ glColorMaterial(GL_FRONT, GL_DIFFUSE); /* Se permite el cambio de la propiedad de material con glColor */ glEnable(GL_COLOR_MATERIAL); } /*********************** DEFINICION DE MATERIALES *****************************************/ /******************************************************************************************/ /* Define las propiedades del material cobre */ /* Parametros: Ninguno */ /* Salida: Ninguna */ /******************************************************************************************/ void Cobre(void) { glColor3f(1, 1, 1); } /*********************** ESPECIFICACI�N DE TEXTURAS****************************************/ /******************************************************************************************/ /* Lee una imagen de textura en formato tga */ /* Parametros --> char *fichero : Cadena de caracteres con el nombre del fichero */ /* int num: Numero que identifica la textura */ /* Salido --> Ninguna */ /******************************************************************************************/ void leerTextura(char* fichero, int num) { int i, j; char r, g, b, c; FILE* tga; /* Apertura del fichero TGA */ if ((tga = fopen(fichero, "rb")) == NULL) printf("Error abriendo el fichero: %s\n", fichero); else { /* Lee los 18 primeros caracteres de la cabecera */ for (j = 1; j <= 18; j++) fscanf(tga, "%c", &c); /* Lee la imagen */ for (j = altoTextura - 1; j >= 0; j--) { for (i = anchoTextura - 1; i >= 0; i--) { fscanf(tga, "%c%c%c", &b, &g, &r); textura[num][j][i][0] = (GLubyte)r; textura[num][j][i][1] = (GLubyte)g; textura[num][j][i][2] = (GLubyte)b; } } fclose(tga); /* Cierre del fichero TGA */ } } /*********************** RUTINA DE CARGA Y ACTIVACION DE TEXTURAS *************************/ /******************************************************************************************/ /* TEXTURA CIELO */ /******************************************************************************************/ void initTexturaCielo() { leerTextura("./resources/cielo.tga", 0); } void texturaCielo(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[0]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA BOSQUE */ /******************************************************************************************/ void initTexturaBosque() { leerTextura("./resources/bosque.tga", 1); } void texturaBosque(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[1]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA HIERBA */ /******************************************************************************************/ void initTexturaHierba() { leerTextura("./resources/hierba.tga", 2); } void texturaHierba(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[2]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA AGUA */ /******************************************************************************************/ void initTexturaAgua() { leerTextura("./resources/agua2.tga", 3); } void texturaAgua(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[3]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA CAMINO */ /******************************************************************************************/ void initTexturaCamino() { leerTextura("./resources/camino.tga", 4); } void texturaCamino(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[4]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA CESPED */ /******************************************************************************************/ void initTexturaCesped() { leerTextura("./resources/cesped.tga", 5); } void texturaCesped(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[5]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } ///======================================================================================== ///======================================================================================== ///======================================================================================== ///======================================================================================== /******************************************************************************************/ /* TEXTURA BALDOSA */ /******************************************************************************************/ void initTexturaBaldosa() { leerTextura("./resources/baldosamini.tga", 6); } void texturaBaldosa(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[6]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA TRONCO */ /******************************************************************************************/ void initTexturaTronco() { leerTextura("./resources/tronco.tga", 7); } void texturaTronco(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[7]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA HOJAS */ /******************************************************************************************/ void initTexturaHojas() { leerTextura("./resources/hojas.tga", 8); } void texturaHojas(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[8]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA COLUMNA */ /******************************************************************************************/ void initTexturaColumna() { leerTextura("./resources/piedrecillas.tga", 9); } void texturaColumna(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[9]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA MADERA */ /******************************************************************************************/ void initTexturaMadera(void) { leerTextura("./resources/madera.tga", 10); } void texturaMadera(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[10]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA BALDOSA FRONTAL */ /******************************************************************************************/ void initTexturaBaldosaF(void) { leerTextura("./resources/baldosa_frontal.tga", 11); } void texturaBaldosaF(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[11]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA TEJADO */ /******************************************************************************************/ void initTexturaTejado(void) { leerTextura("./resources/tejado.tga", 12); } void texturaTejado(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[12]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA MORTERO */ /******************************************************************************************/ void initTexturaMortero(void) { leerTextura("./resources/mortero.tga", 13); } void texturaMortero(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[13]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA CEMENTO */ /******************************************************************************************/ void initTexturaCemento(void) { leerTextura("./resources/cemento.tga", 14); } void texturaCemento(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[14]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); } /******************************************************************************************/ /* TEXTURA ACERO */ /******************************************************************************************/ void initTexturaAcero(void){ leerTextura("./resources/acero.tga", 15); } void texturaAcero(void) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, 0, 3, anchoTextura, altoTextura, 0, GL_RGB, GL_UNSIGNED_BYTE, textura[15]); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); }
f75c0fea03023f935a6da1365519078239b6e112
cffb6a47916cf07da288fc76fb4ff35a3a0adca2
/01_C语言提高/00_资料/day03_C提高(多级指针)/4_源代码/02_代码/day03/ConsoleApplication1/ConsoleApplication1/02_const的使用.c
ab16a2cb16b87564d998cdd59ed572d82bfa4017
[]
no_license
hongchanaigai/CoderLife
c32d1c7fcf186c6d9f59f8c584a21bec7ddacf01
42ea20f3ffbfec9fc801e68614199585180ed10d
refs/heads/master
2022-12-28T01:05:13.185369
2020-10-12T08:33:32
2020-10-12T08:33:32
283,144,131
0
1
null
null
null
null
GB18030
C
false
false
1,504
c
02_const的使用.c
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct MyStruct { int a; int b; }MyStruct; void fun(MyStruct *p) { //指针能变 //p = NULL; //指针指向的内存也可以变 //p->a = 10; //ok } void fun1(MyStruct const *p) { //p = NULL; //ok //p->a = 10; //err } void fun2(MyStruct * const p) { //p = NULL; //err p->a = 10;//ok } //p只读 void fun3(MyStruct const * const p) { MyStruct tmp; tmp.a = p->a; } int main(void) { //const修饰一个变量为只读 const int a = 10; //a = 100; //err //指针变量, 指针指向的内存, 2个不同概念 char buf[] = "aklgjdlsgjlkds"; //从左往右看,跳过类型,看修饰哪个字符 //如果是*, 说明指针指向的内存不能改变 //如果是指针变量,说明指针的指向不能改变,指针的值不能修改 const char *p = buf; // 等价于上面 char const *p1 = buf; //p[1] = '2'; //err p = "agdlsjaglkdsajgl"; //ok char * const p2 = buf; p2[1] = '3'; //p2 = "salkjgldsjaglk"; //err //p3为只读,指向不能变,指向的内存也不能变 const char * const p3 = buf; //如何引用另外.c中const变量,了解 extern const int aa; //不能再赋值,只能声明 printf("aa = %d\n", aa); //const修饰的变量,定义时初始化 //在c语言中, const是一个冒牌货 const int b = 10; //b = 100; //err int *q = &b; *q = 22; printf("%d, %d\n", b, *q); printf("\n"); system("pause"); return 0; }
a76f6b9c3f6a8ad2da2e6e7f5e045e1adc1f3ce6
23e393f8c385a4e0f8f3d4b9e2d80f98657f4e1f
/Win32 Programming/Win32API/KeyExplorer/RESOURCE.H
6aa7a3b9d60623fff8f33db1ae2e8afba0db578f
[]
no_license
IgorYunusov/Mega-collection-cpp-1
c7c09e3c76395bcbf95a304db6462a315db921ba
42d07f16a379a8093b6ddc15675bf777eb10d480
refs/heads/master
2020-03-24T10:20:15.783034
2018-06-12T13:19:05
2018-06-12T13:19:05
142,653,486
3
1
null
2018-07-28T06:36:35
2018-07-28T06:36:35
null
UTF-8
C
false
false
12,377
h
RESOURCE.H
//{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by KeyExplorer.rc // #define IDS_APP_TITLE 1 #define IDI_SKELETON 101 #define IDR_MAINFRAME 102 #define IDD_ABOUTBOX 103 #define IDI_BRLOGO 106 #define IDI_JMNCO 108 #define IDS_PLATFORM_WIN32_NT 110 #define IDS_PLATFORM_WIN32_NTAS 111 #define IDS_PLATFORM_WIN32_NTW 112 #define IDS_PLATFORM_WIN32_NTS 113 #define IDS_PLATFORM_WIN32s 114 #define IDS_PLATFORM_WIN32_WINDOWS 115 #define IDS_PLATFORM_UNKNOWN 116 #define IDS_PROCESSOR_ARCHITECTURE_UNKNOWN 120 #define IDS_PROCESSOR_ARCHITECTURE_INTEL_386_486 121 #define IDS_PROCESSOR_ARCHITECTURE_INTEL_PENTIUM 122 #define IDS_PROCESSOR_ARCHITECTURE_ALPHA 123 #define IDS_PROCESSOR_ARCHITECTURE_MIPS 124 #define IDS_PROCESSOR_ARCHITECTURE_PPC 125 #define IDS_PROCESSOR_LEVEL_INTEL_UNKNOWN 126 #define IDS_PROCESSOR_LEVEL_ALPHA_UNKNOWN 127 #define IDS_PROCESSOR_LEVEL_MIPS_UNKNOWN 128 #define IDS_PROCESSOR_LEVEL_PPC_UNKNOWN 129 #define IDS_PROCESSOR_NOREV_INTEL_386 130 #define IDS_PROCESSOR_NOREV_INTEL_486 131 #define IDS_PROCESSOR_NOREV_INTEL_PENTIUM 132 #define IDS_PROCESSOR_NOREV_MIPS_R4000 133 #define IDS_PROCESSOR_NOREV_ALPHA_21064 134 #define IDS_NO_UNICODE 135 #define IDC_TOOLBAR 140 #define IDC_HEADER 141 #define IDS_VK_LBUTTON 201 #define IDS_VK_RBUTTON 202 #define IDS_VK_CANCEL 203 #define IDS_VK_MBUTTON 204 #define IDS_VK_BACK 205 #define IDS_VK_TAB 206 #define IDS_VK_CLEAR 207 #define IDS_VK_RETURN 208 #define IDS_VK_SHIFT 209 #define IDS_VK_CONTROL 210 #define IDS_VK_MENU 211 #define IDS_VK_PAUSE 212 #define IDS_VK_CAPITAL 213 #define IDS_VK_ESCAPE 214 #define IDS_VK_SPACE 215 #define IDS_VK_PRIOR 216 #define IDS_VK_NEXT 217 #define IDS_VK_END 218 #define IDS_VK_HOME 219 #define IDS_VK_LEFT 220 #define IDS_VK_UP 221 #define IDS_VK_RIGHT 222 #define IDS_VK_DOWN 223 #define IDS_VK_SELECT 224 #define IDS_VK_PRINT 225 #define IDS_VK_EXECUTE 226 #define IDS_VK_SNAPSHOT 227 #define IDS_VK_INSERT 228 #define IDS_VK_DELETE 229 #define IDS_VK_HELP 230 #define IDS_VK_0 231 #define IDS_VK_1 232 #define IDS_VK_2 233 #define IDS_VK_3 234 #define IDS_VK_4 235 #define IDS_VK_5 236 #define IDS_VK_6 237 #define IDS_VK_7 238 #define IDS_VK_8 239 #define IDS_VK_9 240 #define IDS_VK_A 241 #define IDS_VK_B 242 #define IDS_VK_C 243 #define IDS_VK_D 244 #define IDS_VK_E 245 #define IDS_VK_F 246 #define IDS_VK_G 247 #define IDS_VK_H 248 #define IDS_VK_I 249 #define IDS_VK_J 250 #define IDS_VK_K 251 #define IDS_VK_L 252 #define IDS_VK_M 253 #define IDS_VK_N 254 #define IDS_VK_O 255 #define MAX_RESOURCESTRING 255 #define IDS_VK_P 256 #define IDS_VK_Q 257 #define IDS_VK_R 258 #define IDS_VK_S 259 #define IDS_VK_T 260 #define IDS_VK_U 261 #define IDS_VK_V 262 #define IDS_VK_W 263 #define IDS_VK_X 264 #define IDS_VK_Y 265 #define IDS_VK_Z 266 #define IDS_VK_NUMPAD0 267 #define IDS_VK_NUMPAD1 268 #define IDS_VK_NUMPAD2 269 #define IDS_VK_NUMPAD3 270 #define IDS_VK_NUMPAD4 271 #define IDS_VK_NUMPAD5 272 #define IDS_VK_NUMPAD6 273 #define IDS_VK_NUMPAD7 274 #define IDS_VK_NUMPAD8 275 #define IDS_VK_NUMPAD9 276 #define IDS_VK_MULTIPLY 277 #define IDS_VK_ADD 278 #define IDS_VK_SEPARATOR 279 #define IDS_VK_SUBTRACT 280 #define IDS_VK_DECIMAL 281 #define IDS_VK_DIVIDE 282 #define IDS_VK_F1 283 #define IDS_VK_F2 284 #define IDS_VK_F3 285 #define IDS_VK_F4 286 #define IDS_VK_F5 287 #define IDS_VK_F6 288 #define IDS_VK_F7 289 #define IDS_VK_F8 290 #define IDS_VK_F9 291 #define IDS_VK_F10 292 #define IDS_VK_F11 293 #define IDS_VK_F12 294 #define IDS_VK_F13 295 #define IDS_VK_F14 296 #define IDS_VK_F15 297 #define IDS_VK_F16 298 #define IDS_VK_NUMLOCK 299 #define IDS_VK_OEM_SCROLL 300 #define IDS_VK_OEM_1 301 #define IDS_VK_OEM_PLUS 302 #define IDS_VK_OEM_COMMA 303 #define IDS_VK_OEM_MINUS 304 #define IDS_VK_OEM_PERIOD 305 #define IDS_VK_OEM_2 306 #define IDS_VK_OEM_3 307 #define IDS_VK_OEM_4 308 #define IDS_VK_OEM_5 309 #define IDS_VK_OEM_6 310 #define IDS_VK_OEM_7 311 #define IDS_VK_OEM_8 312 #define IDS_VK_OEM_102 313 #define IDS_VK_UNDEFINED 314 #define IDS_WM_KEYUP 315 #define IDS_WM_KEYDOWN 316 #define IDS_WM_SYSKEYUP 317 #define IDS_WM_SYSKEYDOWN 318 #define IDS_WM_CHAR 319 #define IDS_WM_SYSCHAR 320 #define IDS_WM_DEADCHAR 321 #define IDS_WM_SYSDEADCHAR 322 #define IDS_DOWN 323 #define IDS_UP 324 #define IDS_EXT 325 #define IDS_NOTEXT 326 #define IDS_ALT 327 #define IDS_NOALT 328 #define IDS_PRESS 329 #define IDS_RELEASE 330 #define IDS_MESSAGE 331 #define IDS_CODECHAR 332 #define IDS_REPEAT 333 #define IDS_SCAN 334 #define IDS_EXTENDED 335 #define IDS_CONTEXT 336 #define IDS_PREVKEY 337 #define IDS_TRANSITION 338 #define IDS_MESSAGETITLE 339 #define IDS_KEYCODETITLE 340 #define IDS_REPEATCOUNTTITLE 341 #define IDS_SCANCODETITLE 342 #define IDS_EXTFLAGTITLE 343 #define IDS_CONTEXTTITLE 344 #define IDS_UPDOWNTITLE 345 #define IDS_TRANSITIONTITLE 346 #define IDS_VK_F17 347 #define IDS_VK_F18 348 #define IDS_VK_F19 349 #define IDS_VK_F20 350 #define IDS_VK_F21 351 #define IDS_VK_F22 352 #define IDS_VK_F23 353 #define IDS_VK_F24 354 #define IDS_VK_LSHIFT 355 #define IDS_VK_RSHIFT 356 #define IDS_VK_LCONTROL 357 #define IDS_VK_RCONTROL 358 #define IDS_VK_LMENU 359 #define IDS_VK_RMENU 360 #define IDS_VK_PROCESSKEY 361 #define IDS_VK_ATTN 362 #define IDS_VK_CRSEL 363 #define IDS_VK_EXSEL 364 #define IDS_VK_EREOF 365 #define IDS_VK_PLAY 366 #define IDS_VK_ZOOM 367 #define IDS_VK_NONAME 368 #define IDS_VK_PA1 369 #define IDS_VK_OEM_CLEAR 370 #define IDS_DIGITS 371 #define IDC_ABOUT_COMPANY 1000 #define IDC_ABOUT_FILEDESC 1001 #define IDC_ABOUT_COPYRIGHT 1002 #define IDC_ABOUT_PRODVER 1003 #define IDC_ABOUT_OSVERSION 1004 #define IDC_ABOUT_TRADEMARK 1005 #define IDC_ABOUT_PROCESSORVERSION 1006 #define IDC_ABOUT_LABEL 1007 #define IDC_ABOUT_FILEDESCRIPTION 1008 #define IDC_ABOUT_VERSION 1009 #define IDC_ABOUT_LEGALCOPYRIGHT 1010 #define IDC_ABOUT_LEGALTRADEMARKS 1011 #define IDC_ABOUT_COMMENTS 1012 #define ID_FILE_NEW 40001 #define ID_FILE_OPEN 40002 #define ID_FILE_CLOSE 40003 #define ID_FILE_SAVE 40004 #define ID_FILE_SAVE_AS 40005 #define ID_FILE_SAVE_ALL 40006 #define ID_FILE_PAGE_SETUP 40007 #define ID_FILE_PRINT_SETUP 40008 #define ID_FILE_PRINT 40009 #define ID_FILE_PRINT_PREVIEW 40010 #define ID_EDIT_UNDO 40021 #define ID_EDIT_REDO 40022 #define ID_EDIT_CUT 40023 #define ID_EDIT_COPY 40024 #define ID_EDIT_PASTE 40025 #define ID_EDIT_CLEAR 40027 #define ID_EDIT_CLEAR_ALL 40028 #define ID_EDIT_FIND 40029 #define ID_EDIT_REPEAT 40030 #define ID_EDIT_REPLACE 40031 #define ID_EDIT_SELECT_ALL 40032 #define ID_EDIT_PROPERTIES 40033 #define ID_VIEW_TOOLBAR 40041 #define ID_VIEW_STATUS_BAR 40042 #define ID_PREV_PANE 40051 #define ID_NEXT_PANE 40059 #define ID_WINDOW_NEW 40061 #define ID_WINDOW_ARRANGE 40062 #define ID_WINDOW_CASCADE 40063 #define ID_WINDOW_TILE_HORZ 40064 #define ID_WINDOW_TILE_VERT 40065 #define ID_WINDOW_SPLIT 40066 #define ID_HELP_HELP_TOPICS 40071 #define ID_FILE_MRU_FILE1 40091 #define ID_FILE_MRU_FILE2 40092 #define ID_FILE_MRU_FILE3 40093 #define ID_FILE_MRU_FILE4 40094 #define ID_APP_ABOUT 40098 #define ID_APP_EXIT 40099 #define ID_INDICATOR_EXT 41001 #define ID_INDICATOR_CAPS 41002 #define ID_INDICATOR_NUM 41003 #define ID_INDICATOR_SCRL 41004 #define ID_INDICATOR_OVR 41005 #define ID_INDICATOR_REC 41006 #define IDC_STATIC -1 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 109 #define _APS_NEXT_COMMAND_VALUE 40031 #define _APS_NEXT_CONTROL_VALUE 1013 #define _APS_NEXT_SYMED_VALUE 141 #endif #endif
880d24906f42131cd95fb0732b088be8f43c857d
6613a88fdc05d05b4b99d0227a31c3da13fb4276
/arduino.c
b68a7335de529fb0750f305fcbd9a90ab2fab718
[ "MIT" ]
permissive
MXProgrammingClub/Ranger-Karel
d36445f51fb3b2b3ef59653fe6637fdefed0c3d6
c4f9d0315e3fbe8b5f561c427782274b2e5dd1d2
refs/heads/master
2020-09-11T08:44:48.880495
2019-11-19T04:05:03
2019-11-19T04:05:03
222,009,960
0
0
null
null
null
null
UTF-8
C
false
false
6,087
c
arduino.c
// generated by mBlock5 for mBot Ranger // codes make you happy #include <ESP8266HTTPClient.h> #include <ArduinoJson.h> #include "ESP8266WiFi.h" // your network SSID (name) & network password char myssid[] = "Your wifi/hotspot name"; char mypass[] = "Your password"; // unwiredlabs Hostname & Geolocation Endpoint url const char* Host = "www.unwiredlabs.com"; String endpoint = "/v2/process.php"; // UnwiredLabs API_Token. Signup here to get a free token https://unwiredlabs.com/trial String token = "d99cccda52ec0b"; String jsonString = "{\n"; // Variables to store unwiredlabs response double latitude = 0.0; double longitude = 0.0; double accuracy = 0.0; void loop() { char bssid[6]; DynamicJsonBuffer jsonBuffer; // WiFi.scanNetworks will return the number of networks found int n = WiFi.scanNetworks(); Serial.println("scan done"); if (n == 0 ) { Serial.println("No networks available"); } else { Serial.print(n); Serial.println(" networks found"); } // now build the jsonString... jsonString = "{\n"; jsonString += "\"token\" : \""; jsonString += token; jsonString += "\",\n"; jsonString += "\"id\" : \"saikirandevice01\",\n"; jsonString += "\"wifi\": [\n"; for (int j = 0; j < n; ++j) { jsonString += "{\n"; jsonString += "\"bssid\" : \""; jsonString += (WiFi.BSSIDstr(j)); jsonString += "\",\n"; jsonString += "\"signal\": "; jsonString += WiFi.RSSI(j); jsonString += "\n"; if (j < n - 1) { jsonString += "},\n"; } else { jsonString += "}\n"; } } jsonString += ("]\n"); jsonString += ("}\n"); Serial.println(jsonString); WiFiClientSecure client; //Connect to the client and make the api call Serial.println("Requesting URL: https://" + (String)Host + endpoint); if (client.connect(Host, 443)) { Serial.println("Connected"); client.println("POST " + endpoint + " HTTP/1.1"); client.println("Host: " + (String)Host); client.println("Connection: close"); client.println("Content-Type: application/json"); client.println("User-Agent: Arduino/1.0"); client.print("Content-Length: "); client.println(jsonString.length()); client.println(); client.print(jsonString); delay(500); } //Read and parse all the lines of the reply from server while (client.available()) { String line = client.readStringUntil('\r'); JsonObject& root = jsonBuffer.parseObject(line); if (root.success()) { latitude = root["lat"]; longitude = root["lon"]; accuracy = root["accuracy"]; Serial.println(); Serial.print("Latitude = "); Serial.println(latitude, 6); Serial.print("Longitude = "); Serial.println(longitude, 6); Serial.print("Accuracy = "); Serial.println(accuracy); } } Serial.println("closing connection"); Serial.println(); client.stop(); delay(5000); } Add TipAsk Que #include <Arduino.h> #include <Wire.h> #include <SoftwareSerial.h> #include <MeAuriga.h> MeGyro gyro_0(0, 0x69); MeUltrasonicSensor ultrasonic_7(7); MeRGBLed rgbled_0(0, 12); MeEncoderOnBoard Encoder_1(SLOT1); MeEncoderOnBoard Encoder_2(SLOT2); MeLightSensor lightsensor_12(12); float distance = 0; float x = 0; float y = 0; void isr_process_encoder1(void) { if(digitalRead(Encoder_1.getPortB()) == 0){ Encoder_1.pulsePosMinus(); }else{ Encoder_1.pulsePosPlus(); } } void isr_process_encoder2(void) { if(digitalRead(Encoder_2.getPortB()) == 0){ Encoder_2.pulsePosMinus(); }else{ Encoder_2.pulsePosPlus(); } } void move(int direction, int speed) { int leftSpeed = 0; int rightSpeed = 0; if(direction == 1){ leftSpeed = -speed; rightSpeed = speed; }else if(direction == 2){ leftSpeed = speed; rightSpeed = -speed; }else if(direction == 3){ leftSpeed = -speed; rightSpeed = -speed; }else if(direction == 4){ leftSpeed = speed; rightSpeed = speed; } Encoder_1.setTarPWM(leftSpeed); Encoder_2.setTarPWM(rightSpeed); } void _delay(float seconds) { if(seconds < 0.0){ seconds = 0.0; } long endTime = millis() + seconds * 1000; while(millis() < endTime) _loop(); } void setup() { gyro_0.begin(); rgbled_0.setpin(44); rgbled_0.fillPixelsBak(0, 2, 1); TCCR1A = _BV(WGM10); TCCR1B = _BV(CS11) | _BV(WGM12); TCCR2A = _BV(WGM21) | _BV(WGM20); TCCR2B = _BV(CS21); attachInterrupt(Encoder_1.getIntNum(), isr_process_encoder1, RISING); attachInterrupt(Encoder_2.getIntNum(), isr_process_encoder2, RISING); randomSeed((unsigned long)(lightsensor_12.read() * 123456)); while(1) { x = gyro_0.getAngle(1); y = gyro_0.getAngle(2); while(!(25 > distance)) { _loop(); distance = ultrasonic_7.distanceCm(); rgbled_0.setColor(0,0,255,33); rgbled_0.show(); move(1, 75 / 100.0 * 255); rgbled_0.setColor(5, 0, 255, 0); rgbled_0.show(); } rgbled_0.setColor(0,255,0,0); rgbled_0.show(); move(3, 50 / 100.0 * 255); _delay(1); move(3, 0); distance = ultrasonic_7.distanceCm(); _loop(); Serial.begin(115200); // Set WiFi to station mode and disconnect from an AP if it was previously connected WiFi.mode(WIFI_STA); WiFi.disconnect(); Serial.println("Setup done"); // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(myssid); WiFi.begin(myssid, mypass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("."); } } void _loop() { gyro_0.update(); Encoder_1.loop(); Encoder_2.loop(); } void loop() { _loop(); }
68c818a3f71aa1d815b26c223b564bc270902d5e
d8c885f94bcfb5e4fa575d53552e4c0e762feca6
/main.c
8a9e9413c75a6c4bf0fb87ce6e174c5b797b852d
[]
no_license
narokwq/Red-Black
a6806baf7227b2afb4d93883ad5dc5496255a9be
b3c468edff99c4d69ad6b04c97609f0a414ba656
refs/heads/master
2016-09-06T02:29:56.888870
2015-10-21T03:55:02
2015-10-21T03:55:02
42,652,476
0
0
null
null
null
null
UTF-8
C
false
false
960
c
main.c
#include <stdio.h> #include "RedBlack.h" int main(){ t_elemento no = {10}; t_elemento no2 = {5}; t_elemento no3 = {15}; t_elemento no4 = {2}; t_elemento no5 = {12}; t_elemento no6 = {8}; t_elemento no7 = {18}; //Teste inserir sem verificar regras arvore t = criar_arvore(); inserir(t,no); inserir(t,no2); inserir(t,no3); inserir(t,no4); inserir(t,no5); inserir(t,no6); inserir(t,no7); if(buscar(t, (t_elemento){8})) printf("Achou chave 8\n"); else printf("Nao Achou chave 8\n"); printf("Removeu chave 8\n"); remover(t, no6); //Fim de teste printf("\nPre-ordem\n"); pre_ordem(t, t->raiz); printf("\nIn-ordem\n"); in_ordem(t, t->raiz); printf("\nPos-ordem\n"); pos_ordem(t, t->raiz); printf("\n"); printf("\nGraficamente\n"); exibirGraficamente(t, 30, 15); printf("\n\n"); liberarTree(t); getchar(); }
edb0b99e16e5602c5945a78f9edc004e779a4f74
f19263a84d4fb65001e86a61d0abc19aac2cad36
/src/riverdb.h
8f150e32285ade75a25484253f02b9c9b180a159
[ "MIT" ]
permissive
liminglives/riverdb
292d68ca942d5b16ab7bd3dda78d31b4c885a116
3582cc924fdd48c30e5d5fe1ed95cced5be0d521
refs/heads/master
2021-09-06T10:04:58.515618
2018-01-30T08:21:40
2018-01-30T08:21:40
114,465,770
0
1
MIT
2018-01-31T08:40:53
2017-12-16T14:13:06
C++
UTF-8
C
false
false
121
h
riverdb.h
#pragma once #include "time_riverdb.h" #include "kv_riverdb.h" #include "riverdb_writer.h" #include "riverdb_reader.h"
66203b167b1259d5b6eabbb182feb98b6753ae40
1a288ec88327a07d41c9ecfa356804a88ab014fc
/Linked Lists/MergeTwoSortedLists.c
7ddd5785303592549be4df91c7ea3d74d909fa8e
[]
no_license
subhamsahoo/Algotithms-and-data-structures
ef974de77c3330780df722cbf0c06d79699416eb
df6b7686da7b78d8eb0ca80aa8cd7f6c43522923
refs/heads/master
2020-03-27T08:38:40.690371
2018-08-27T09:22:32
2018-08-27T09:22:32
146,272,691
0
0
null
null
null
null
UTF-8
C
false
false
1,776
c
MergeTwoSortedLists.c
/* Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists, and should also be sorted. For example, given following linked lists : 5 -> 8 -> 20 4 -> 11 -> 15 The merged list should be : 4 -> 5 -> 8 -> 11 -> 15 -> 20 */ /** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; * * typedef struct ListNode listnode; * * listnode* listnode_new(int val) { * listnode* node = (listnode *) malloc(sizeof(listnode)); * node->val = val; * node->next = NULL; * return node; * } */ /** * @input A : Head pointer of linked list * @input B : Head pointer of linked list * * @Output head pointer of list. */ listnode* mergeTwoLists(listnode* A, listnode* B) { listnode *result=NULL,*temp1=A,*temp2=B; while(temp1!=NULL&&temp2!=NULL) { if(temp1->val<temp2->val) { if(result==NULL) { A=temp1; result=temp1; } else { result->next=temp1; result=result->next; } temp1=temp1->next; } else { if(result==NULL) { A=temp2; result=temp2; } else { result->next=temp2; result=result->next; } temp2=temp2->next; } } if(temp1==NULL&&temp2!=NULL){ if(result==NULL) A=temp2; else result->next=temp2; } if(temp1!=NULL&&temp2==NULL) { if(result==NULL) A=temp1; else result->next=temp1; } return A; }
fd95f64440e13bf1b1be54df4dc54ef113f8b8f0
7e4a18e8fcb935c6095cb2d3c71f773d02f45f4e
/factorial.c
1261e9238c882ca044191f1e27085031164156fe
[]
no_license
Akshada-Shitole/C-Codes-Basics
8480a3921a74f73520212ba6b484317d23da7c22
25e7bdcf99dd0696fddf0e85fda80250af08308e
refs/heads/master
2020-09-30T02:01:23.121869
2019-12-11T07:19:34
2019-12-11T07:19:34
227,172,867
1
0
null
null
null
null
UTF-8
C
false
false
543
c
factorial.c
//14. Find factorial using function #include<stdio.h> int fact(int n); int main() { int no,factorial=0; printf("\nEnter number to calculate factorial : "); scanf("%d",&no); factorial = fact(no); printf("\n\nFactorial of %d is %d",no,factorial); getche(); return 0; } int fact(int n) { int i,result=n; for(i=n-1;i>0;i--) { result=result*i; } return result; } /* Output: Enter number to calculate factorial : 5 Factorial of 5 is 120 */
27687d206c63411167d980de55c8ae55d878a391
a36fbfb9e4036b6105fd204d47fe79ee40ce26fd
/Src/Panel/IdVgsPanel.c
b6e725ce0377861c15ef5b069c099fa32784a744
[]
no_license
sinoagg/SA6101_Software
5ac9221e860bd1df23ba2d55ad8f97babc4f2cbd
2e48fd622c2d525b54f4441ee6f00b5fedf3b862
refs/heads/master
2020-03-22T08:54:33.814108
2018-08-31T11:01:08
2018-08-31T11:01:08
139,799,748
0
0
null
null
null
null
GB18030
C
false
false
6,738
c
IdVgsPanel.c
#include "Id-Vds Configuration.h" #include <userint.h> //============================================================================== // // Title: IdVgsPanel.c // Purpose: A short description of the implementation. // // Created on: 18/7/11 at 13:36:34 by . // Copyright: . All Rights Reserved. // //============================================================================== //============================================================================== // Include files #include "IdVgsPanel.h" #include "Id-Vgs Configuration.h" #define COLOR_BLUE 0xA0B4DCL // 点击激活蓝色 #define COLOR_GREY 0xA9A9A9L //未点击灰色 #define FOCUS 0 #define UNFOCUS 1 #define BIAS 0 #define STEP 2 //============================================================================== // Constants //============================================================================== // Types //============================================================================== // Static global variables //============================================================================== // Static functions //============================================================================== // Global variables ExpPanelTypeDef IdVgPanel={ 0, IDVGS_CFG_VG_START, IDVGS_CFG_VG_STOP, IDVGS_CFG_VG_STEP, IDVGS_CFG_VD_START, IDVGS_CFG_VD_STOP, IDVGS_CFG_VD_STEP, IDVGS_CFG_DRAINMODE, IDVGS_CFG_GATEMODE, }; //============================================================================== // Global functions static void SetDrainDisp(int panel, char focus) { if(focus==FOCUS) { DisplayImageFile (panel, IDVGS_CFG_PIC_DRAIN, "Resource\\bg_pressed.ico");// change picture SetCtrlAttribute (panel, IDVGS_CFG_TXT_DRAIN, ATTR_TEXT_BGCOLOR, COLOR_BLUE);// change text bgcolor } else { DisplayImageFile (panel, IDVGS_CFG_PIC_DRAIN, "Resource\\bg.ico");// change picture SetCtrlAttribute (panel, IDVGS_CFG_TXT_DRAIN, ATTR_TEXT_BGCOLOR, COLOR_GREY);// change text bgcolor } } static void SetGateDisp(int panel, char focus) { if(focus==FOCUS) { DisplayImageFile (panel, IDVGS_CFG_PIC_GATE, "Resource\\bg_pressed.ico");// change picture SetCtrlAttribute (panel, IDVGS_CFG_TXT_GATE, ATTR_TEXT_BGCOLOR, COLOR_BLUE);// change text bgcolor } else { DisplayImageFile (panel, IDVGS_CFG_PIC_GATE, "Resource\\bg.ico");// change picture SetCtrlAttribute (panel, IDVGS_CFG_TXT_GATE, ATTR_TEXT_BGCOLOR, COLOR_GREY);// change text bgcolor } } int CVICALLBACK IdVgGateDecoCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch(event) { case EVENT_LEFT_CLICK_UP: SetGateDisp(panel,FOCUS); SetDrainDisp(panel,UNFOCUS); break; } return 0; } int CVICALLBACK IdVgDrainDecoCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch(event) { case EVENT_LEFT_CLICK_UP: SetGateDisp(panel,UNFOCUS); SetDrainDisp(panel,FOCUS); break; } return 0; } int CVICALLBACK IdVgGateModeCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if(event==EVENT_LEFT_CLICK_UP) { SetDrainDisp(panel, UNFOCUS); SetGateDisp(panel, FOCUS); } return 0; } int CVICALLBACK IdVgDrainModeCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch(event) { case EVENT_LEFT_CLICK_UP: SetDrainDisp(panel, FOCUS); SetGateDisp(panel, UNFOCUS); break; case EVENT_VAL_CHANGED: int val; GetCtrlVal(panel,IDVGS_CFG_DRAINMODE,&val); if(val==STEP) { DisplayImageFile (panel, IDVGS_CFG_PIC_IDVD_DRAIN, "Resource\\V_Step.ico"); SetCtrlAttribute(panel, IDVGS_CFG_VD_STOP,ATTR_VISIBLE,1); SetCtrlAttribute(panel, IDVGS_CFG_TXT_STOP,ATTR_VISIBLE,1); SetCtrlAttribute(panel, IDVGS_CFG_MV_STOP,ATTR_VISIBLE,1); SetCtrlAttribute(panel, IDVGS_CFG_VD_STEP,ATTR_VISIBLE,1); SetCtrlAttribute(panel, IDVGS_CFG_TXT_STEP,ATTR_VISIBLE,1); SetCtrlAttribute(panel, IDVGS_CFG_MV_STEP,ATTR_VISIBLE,1); } else if(val==BIAS) { DisplayImageFile (panel, IDVGS_CFG_PIC_IDVD_DRAIN, "Resource\\V_Bias.ico"); SetCtrlAttribute(panel, IDVGS_CFG_VD_STOP,ATTR_VISIBLE,0); SetCtrlAttribute(panel, IDVGS_CFG_TXT_STOP,ATTR_VISIBLE,0); SetCtrlAttribute(panel, IDVGS_CFG_MV_STOP,ATTR_VISIBLE,0); SetCtrlAttribute(panel, IDVGS_CFG_VD_STEP,ATTR_VISIBLE,0); SetCtrlAttribute(panel, IDVGS_CFG_TXT_STEP,ATTR_VISIBLE,0); SetCtrlAttribute(panel, IDVGS_CFG_MV_STEP,ATTR_VISIBLE,0); } break; } return 0; } int CVICALLBACK IdVgDrainStartCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if(event==EVENT_LEFT_CLICK_UP) { SetDrainDisp(panel, FOCUS); SetGateDisp(panel, UNFOCUS); } return 0; } int CVICALLBACK IdVgDrainStopCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if(event==EVENT_LEFT_CLICK_UP) { SetDrainDisp(panel, FOCUS); SetGateDisp(panel, UNFOCUS); } return 0; } int CVICALLBACK IdVgDrainStepCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if(event==EVENT_LEFT_CLICK_UP) { SetDrainDisp(panel, FOCUS); SetGateDisp(panel, UNFOCUS); } return 0; } int CVICALLBACK IdVgGateStartCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if(event==EVENT_LEFT_CLICK_UP) { SetDrainDisp(panel, UNFOCUS); SetGateDisp(panel, FOCUS); } return 0; } int CVICALLBACK IdVgGateStopCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if(event==EVENT_LEFT_CLICK_UP) { SetDrainDisp(panel, UNFOCUS); SetGateDisp(panel, FOCUS); } return 0; } int CVICALLBACK IdVgGateStepCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if(event==EVENT_LEFT_CLICK_UP) { SetDrainDisp(panel, UNFOCUS); SetGateDisp(panel, FOCUS); } return 0; } int CVICALLBACK IdVgGatePicCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if(event==EVENT_LEFT_CLICK_UP) { SetDrainDisp(panel, UNFOCUS); SetGateDisp(panel, FOCUS); } return 0; } int CVICALLBACK IdVgDrainPicCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { if(event==EVENT_LEFT_CLICK_UP) { SetGateDisp(panel,UNFOCUS); SetDrainDisp(panel,FOCUS); } return 0; }
5d16f8d8cd30ba5383ea519dc9beb48deb4ce43f
5bed411d97bd00ed745465880e9cf8420f8ffd99
/pset4/helpers_more.c
aebf7499def37834e2f2c03475889eb646ed35ac
[]
no_license
ignacioF1/CS50
7f482ab3492f211e9afb20e44c0f4a3f3d6649b3
e6fe4fdc2e19ec607693957ff82c0580ef638d71
refs/heads/master
2022-12-07T02:43:20.260970
2020-08-27T14:10:28
2020-08-27T14:10:28
290,620,074
0
0
null
null
null
null
UTF-8
C
false
false
24,239
c
helpers_more.c
#include "helpers.h" #include <math.h> // Convert image to grayscale void grayscale(int height, int width, RGBTRIPLE image[height][width]) { float prom; for (int i = 0 ; i < height ; i ++) // For every row { for (int j = 0 ; j < width ; j ++) // For every pixel { prom = roundf((image[i][j].rgbtRed + image[i][j].rgbtGreen + image[i][j].rgbtBlue) / 3.0f); image[i][j].rgbtRed = prom; image[i][j].rgbtGreen = prom; image[i][j].rgbtBlue = prom; } } return; } // Convert image to sepia void sepia(int height, int width, RGBTRIPLE image[height][width]) { for (int i = 0 ; i < height ; i ++) // For every row { for (int j = 0 ; j < width ; j ++) // For every pixel { // Apply sepia formula float sepiaRed = roundf(0.393 * image[i][j].rgbtRed + 0.769 * image[i][j].rgbtGreen + 0.189 * image[i][j].rgbtBlue); float sepiaGreen = roundf(0.349 * image[i][j].rgbtRed + 0.686 * image[i][j].rgbtGreen + 0.168 * image[i][j].rgbtBlue); float sepiaBlue = roundf(0.272 * image[i][j].rgbtRed + 0.534 * image[i][j].rgbtGreen + 0.131 * image[i][j].rgbtBlue); // For each amount of color, set to 255 if it is greater than 255 if (sepiaRed > 255) { sepiaRed = 255; } if (sepiaGreen > 255) { sepiaGreen = 255; } if (sepiaBlue > 255) { sepiaBlue = 255; } image[i][j].rgbtRed = sepiaRed; image[i][j].rgbtGreen = sepiaGreen; image[i][j].rgbtBlue = sepiaBlue; } } return; } // Reflect image horizontally void reflect(int height, int width, RGBTRIPLE image[height][width]) { int mid = width / 2; int temp; for (int i = 0 ; i < height ; i ++) // For every row { for (int j = 0 ; j < mid ; j ++) // For every pixel { temp = image[i][j].rgbtRed; image[i][j].rgbtRed = image[i][(width - 1) - j].rgbtRed; image[i][(width - 1) - j].rgbtRed = temp; temp = image[i][j].rgbtGreen; image[i][j].rgbtGreen = image[i][(width - 1) - j].rgbtGreen; image[i][(width - 1) - j].rgbtGreen = temp; temp = image[i][j].rgbtBlue; image[i][j].rgbtBlue = image[i][(width - 1) - j].rgbtBlue; image[i][(width - 1) - j].rgbtBlue = temp; } } return; } // Blur image void blur(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE imagetemp[height][width]; // I'll divide the problem into solving these parts separately // The corners, the border lines and the center part // + + + + + // // + + + + + // + + + + + // + + + + + // // + + + + + // Center part for (int i = 1 ; i < (height - 1) ; i ++) // For every row, except for the borders { for (int j = 1 ; j < (width - 1) ; j ++) // For every pixel, exept from the borders { float promR = roundf((image[i - 1][j - 1].rgbtRed + image[i][j - 1].rgbtRed + image[i + 1][j - 1].rgbtRed + image[i - 1][j].rgbtRed + image[i][j].rgbtRed + image[i + 1][j].rgbtRed + image[i - 1][j + 1].rgbtRed + image[i][j + 1].rgbtRed + image[i + 1][j + 1].rgbtRed) / 9.0f); float promG = roundf((image[i - 1][j - 1].rgbtGreen + image[i][j - 1].rgbtGreen + image[i + 1][j - 1].rgbtGreen + image[i - 1][j].rgbtGreen + image[i][j].rgbtGreen + image[i + 1][j].rgbtGreen + image[i - 1][j + 1].rgbtGreen + image[i][j + 1].rgbtGreen + image[i + 1][j + 1].rgbtGreen) / 9.0f); float promB = roundf((image[i - 1][j - 1].rgbtBlue + image[i][j - 1].rgbtBlue + image[i + 1][j - 1].rgbtBlue + image[i - 1][j].rgbtBlue + image[i][j].rgbtBlue + image[i + 1][j].rgbtBlue + image[i - 1][j + 1].rgbtBlue + image[i][j + 1].rgbtBlue + image[i + 1][j + 1].rgbtBlue) / 9.0f); imagetemp[i][j].rgbtRed = promR; imagetemp[i][j].rgbtGreen = promG; imagetemp[i][j].rgbtBlue = promB; } } // Upper horizontal border line int i = 0; for (int j = 1 ; j < (width - 1) ; j ++) // For every pixel, exept from the corners { float promR = roundf((image[i][j - 1].rgbtRed + image[i][j].rgbtRed + image[i][j + 1].rgbtRed + image[i + 1][j - 1].rgbtRed + image[i + 1][j].rgbtRed + image[i + 1][j + 1].rgbtRed) / 6.0f); float promG = roundf((image[i][j - 1].rgbtGreen + image[i][j].rgbtGreen + image[i][j + 1].rgbtGreen + image[i + 1][j - 1].rgbtGreen + image[i + 1][j].rgbtGreen + image[i + 1][j + 1].rgbtGreen) / 6.0f); float promB = roundf((image[i][j - 1].rgbtBlue + image[i][j].rgbtBlue + image[i][j + 1].rgbtBlue + image[i + 1][j - 1].rgbtBlue + image[i + 1][j].rgbtBlue + image[i + 1][j + 1].rgbtBlue) / 6.0f); imagetemp[i][j].rgbtRed = promR; imagetemp[i][j].rgbtGreen = promG; imagetemp[i][j].rgbtBlue = promB; } // Lower horizontal border line i = height - 1; for (int j = 1 ; j < (width - 1) ; j ++) // For every pixel, exept from the corners { float promR = roundf((image[i][j - 1].rgbtRed + image[i][j].rgbtRed + image[i][j + 1].rgbtRed + image[i - 1][j - 1].rgbtRed + image[i - 1][j].rgbtRed + image[i - 1][j + 1].rgbtRed) / 6.0f); float promG = roundf((image[i][j - 1].rgbtGreen + image[i][j].rgbtGreen + image[i][j + 1].rgbtGreen + image[i - 1][j - 1].rgbtGreen + image[i - 1][j].rgbtGreen + image[i - 1][j + 1].rgbtGreen) / 6.0f); float promB = roundf((image[i][j - 1].rgbtBlue + image[i][j].rgbtBlue + image[i][j + 1].rgbtBlue + image[i - 1][j - 1].rgbtBlue + image[i - 1][j].rgbtBlue + image[i - 1][j + 1].rgbtBlue) / 6.0f); imagetemp[i][j].rgbtRed = promR; imagetemp[i][j].rgbtGreen = promG; imagetemp[i][j].rgbtBlue = promB; } // Left vertical border line int j = 0; for (i = 1 ; i < (height - 1) ; i ++) // For every pixel, exept from the corners { float promR = roundf((image[i - 1][j].rgbtRed + image[i][j].rgbtRed + image[i + 1][j].rgbtRed + image[i - 1][j + 1].rgbtRed + image[i][j + 1].rgbtRed + image[i + 1][j + 1].rgbtRed) / 6.0f); float promG = roundf((image[i - 1][j].rgbtGreen + image[i][j].rgbtGreen + image[i + 1][j].rgbtGreen + image[i - 1][j + 1].rgbtGreen + image[i][j + 1].rgbtGreen + image[i + 1][j + 1].rgbtGreen) / 6.0f); float promB = roundf((image[i - 1][j].rgbtBlue + image[i][j].rgbtBlue + image[i + 1][j].rgbtBlue + image[i - 1][j + 1].rgbtBlue + image[i][j + 1].rgbtBlue + image[i + 1][j + 1].rgbtBlue) / 6.0f); imagetemp[i][j].rgbtRed = promR; imagetemp[i][j].rgbtGreen = promG; imagetemp[i][j].rgbtBlue = promB; } // Right vertical border line j = width - 1; for (i = 1 ; i < (height - 1) ; i ++) // For every pixel, exept from the corners { float promR = roundf((image[i - 1][j].rgbtRed + image[i][j].rgbtRed + image[i + 1][j].rgbtRed + image[i - 1][j - 1].rgbtRed + image[i][j - 1].rgbtRed + image[i + 1][j - 1].rgbtRed) / 6.0f); float promG = roundf((image[i - 1][j].rgbtGreen + image[i][j].rgbtGreen + image[i + 1][j].rgbtGreen + image[i - 1][j - 1].rgbtGreen + image[i][j - 1].rgbtGreen + image[i + 1][j - 1].rgbtGreen) / 6.0f); float promB = roundf((image[i - 1][j].rgbtBlue + image[i][j].rgbtBlue + image[i + 1][j].rgbtBlue + image[i - 1][j - 1].rgbtBlue + image[i][j - 1].rgbtBlue + image[i + 1][j - 1].rgbtBlue) / 6.0f); imagetemp[i][j].rgbtRed = promR; imagetemp[i][j].rgbtGreen = promG; imagetemp[i][j].rgbtBlue = promB; } // Top left corner i = 0; j = 0; float promR = roundf((image[i][j].rgbtRed + image[i + 1][j].rgbtRed + image[i][j + 1].rgbtRed + image[i + 1][j + 1].rgbtRed) / 4.0f); float promG = roundf((image[i][j].rgbtGreen + image[i + 1][j].rgbtGreen + image[i][j + 1].rgbtGreen + image[i + 1][j + 1].rgbtGreen) / 4.0f); float promB = roundf((image[i][j].rgbtBlue + image[i + 1][j].rgbtBlue + image[i][j + 1].rgbtBlue + image[i + 1][j + 1].rgbtBlue) / 4.0f); imagetemp[i][j].rgbtRed = promR; imagetemp[i][j].rgbtGreen = promG; imagetemp[i][j].rgbtBlue = promB; // Bottom left corner i = height - 1; j = 0; promR = roundf((image[i][j].rgbtRed + image[i - 1][j].rgbtRed + image[i - 1][j + 1].rgbtRed + image[i][j + 1].rgbtRed) / 4.0f); promG = roundf((image[i][j].rgbtGreen + image[i - 1][j].rgbtGreen + image[i - 1][j + 1].rgbtGreen + image[i][j + 1].rgbtGreen) / 4.0f); promB = roundf((image[i][j].rgbtBlue + image[i - 1][j].rgbtBlue + image[i - 1][j + 1].rgbtBlue + image[i][j + 1].rgbtBlue) / 4.0f); imagetemp[i][j].rgbtRed = promR; imagetemp[i][j].rgbtGreen = promG; imagetemp[i][j].rgbtBlue = promB; // Top right corner i = 0; j = width - 1; promR = roundf((image[i][j].rgbtRed + image[i + 1][j].rgbtRed + image[i][j - 1].rgbtRed + image[i + 1][j - 1].rgbtRed) / 4.0f); promG = roundf((image[i][j].rgbtGreen + image[i + 1][j].rgbtGreen + image[i][j - 1].rgbtGreen + image[i + 1][j - 1].rgbtGreen) / 4.0f); promB = roundf((image[i][j].rgbtBlue + image[i + 1][j].rgbtBlue + image[i][j - 1].rgbtBlue + image[i + 1][j - 1].rgbtBlue) / 4.0f); imagetemp[i][j].rgbtRed = promR; imagetemp[i][j].rgbtGreen = promG; imagetemp[i][j].rgbtBlue = promB; // Bottom right corner i = height - 1; j = width - 1; promR = roundf((image[i][j].rgbtRed + image[i - 1][j].rgbtRed + image[i][j - 1].rgbtRed + image[i - 1][j - 1].rgbtRed) / 4.0f); promG = roundf((image[i][j].rgbtGreen + image[i - 1][j].rgbtGreen + image[i][j - 1].rgbtGreen + image[i - 1][j - 1].rgbtGreen) / 4.0f); promB = roundf((image[i][j].rgbtBlue + image[i - 1][j].rgbtBlue + image[i][j - 1].rgbtBlue + image[i - 1][j - 1].rgbtBlue) / 4.0f); imagetemp[i][j].rgbtRed = promR; imagetemp[i][j].rgbtGreen = promG; imagetemp[i][j].rgbtBlue = promB; // Transfer the temporal image to the image for (i = 0 ; i < height ; i ++) // For every row { for (j = 0 ; j < width ; j ++) // For every pixel { image[i][j].rgbtRed = imagetemp[i][j].rgbtRed; image[i][j].rgbtGreen = imagetemp[i][j].rgbtGreen; image[i][j].rgbtBlue = imagetemp[i][j].rgbtBlue; } } return; } // Detect edges void edges(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE imagetemp[height][width]; int GxR; int GxG; int GxB; int GyR; int GyG; int GyB; float GxyR; float GxyG; float GxyB; int i; int j; // I'll divide the problem into solving these parts separately // The corners, the border lines and the center part // + + + + + // // + + + + + // + + + + + // + + + + + // // + + + + + // Center part for (i = 1 ; i < (height - 1) ; i ++) // For every row, except for the borders { for (j = 1 ; j < (width - 1) ; j ++) // For every pixel, exept from the borders { GxR = ((-1 * (image[i - 1][j - 1].rgbtRed)) - (2 * (image[i][j - 1].rgbtRed)) - (image[i + 1][j - 1].rgbtRed) + image[i - 1][j + 1].rgbtRed + (2 * (image[i][j + 1].rgbtRed)) + image[i + 1][j + 1].rgbtRed); GxG = ((-1 * (image[i - 1][j - 1].rgbtGreen)) - (2 * (image[i][j - 1].rgbtGreen)) - (image[i + 1][j - 1].rgbtGreen) + image[i - 1][j + 1].rgbtGreen + (2 * (image[i][j + 1].rgbtGreen)) + image[i + 1][j + 1].rgbtGreen); GxB = ((-1 * (image[i - 1][j - 1].rgbtBlue)) - (2 * (image[i][j - 1].rgbtBlue)) - (image[i + 1][j - 1].rgbtBlue) + image[i - 1][j + 1].rgbtBlue + (2 * (image[i][j + 1].rgbtBlue)) + image[i + 1][j + 1].rgbtBlue); GyR = ((-1 * (image[i - 1][j - 1].rgbtRed)) - (2 * (image[i - 1][j].rgbtRed)) - (image[i - 1][j + 1].rgbtRed) + image[i + 1][j - 1].rgbtRed + (2 * (image[i + 1][j].rgbtRed)) + image[i + 1][j + 1].rgbtRed); GyG = ((-1 * (image[i - 1][j - 1].rgbtGreen)) - (2 * (image[i - 1][j].rgbtGreen)) - (image[i - 1][j + 1].rgbtGreen) + image[i + 1][j - 1].rgbtGreen + (2 * (image[i + 1][j].rgbtGreen)) + image[i + 1][j + 1].rgbtGreen); GyB = ((-1 * (image[i - 1][j - 1].rgbtBlue)) - (2 * (image[i - 1][j].rgbtBlue)) - (image[i - 1][j + 1].rgbtBlue) + image[i + 1][j - 1].rgbtBlue + (2 * (image[i + 1][j].rgbtBlue)) + image[i + 1][j + 1].rgbtBlue); GxyR = roundf(sqrt(pow(GxR, 2) + pow(GyR, 2))); GxyG = roundf(sqrt(pow(GxG, 2) + pow(GyG, 2))); GxyB = roundf(sqrt(pow(GxB, 2) + pow(GyB, 2))); if (GxyR > 255) { GxyR = 255; } if (GxyG > 255) { GxyG = 255; } if (GxyB > 255) { GxyB = 255; } imagetemp[i][j].rgbtRed = GxyR; imagetemp[i][j].rgbtGreen = GxyG; imagetemp[i][j].rgbtBlue = GxyB; } } // Upper horizontal border line i = 0; for (j = 1 ; j < (width - 1) ; j ++) // For every pixel, exept from the corners { GxR = (- 2 * (image[i][j - 1].rgbtRed) - 1 * (image[i + 1][j - 1].rgbtRed) + 2 * (image[i][j + 1].rgbtRed) + image[i + 1][j + 1].rgbtRed); GxG = (- 2 * (image[i][j - 1].rgbtGreen) - 1 * (image[i + 1][j - 1].rgbtGreen) + 2 * (image[i][j + 1].rgbtGreen) + image[i + 1][j + 1].rgbtGreen); GxB = (- 2 * (image[i][j - 1].rgbtBlue) - 1 * (image[i + 1][j - 1].rgbtBlue) + 2 * (image[i][j + 1].rgbtBlue) + image[i + 1][j + 1].rgbtBlue); GyR = (image[i + 1][j - 1].rgbtRed + 2 * (image[i + 1][j].rgbtRed) + image[i + 1][j + 1].rgbtRed); GyG = (image[i + 1][j - 1].rgbtGreen + 2 * (image[i + 1][j].rgbtGreen) + image[i + 1][j + 1].rgbtGreen); GyB = (image[i + 1][j - 1].rgbtBlue + 2 * (image[i + 1][j].rgbtBlue) + image[i + 1][j + 1].rgbtBlue); GxyR = roundf(sqrt(pow(GxR, 2) + pow(GyR, 2))); GxyG = roundf(sqrt(pow(GxG, 2) + pow(GyG, 2))); GxyB = roundf(sqrt(pow(GxB, 2) + pow(GyB, 2))); if (GxyR > 255) { GxyR = 255; } if (GxyG > 255) { GxyG = 255; } if (GxyB > 255) { GxyB = 255; } imagetemp[i][j].rgbtRed = GxyR; imagetemp[i][j].rgbtGreen = GxyG; imagetemp[i][j].rgbtBlue = GxyB; } // Lower horizontal border line i = height - 1; for (j = 1 ; j < (width - 1) ; j ++) // For every pixel, exept from the corners { GxR = (- 2 * (image[i][j - 1].rgbtRed) - 1 * (image[i - 1][j - 1].rgbtRed) + 2 * (image[i][j + 1].rgbtRed) + image[i - 1][j + 1].rgbtRed); GxG = (- 2 * (image[i][j - 1].rgbtGreen) - 1 * (image[i - 1][j - 1].rgbtGreen) + 2 * (image[i][j + 1].rgbtGreen) + image[i - 1][j + 1].rgbtGreen); GxB = (- 2 * (image[i][j - 1].rgbtBlue) - 1 * (image[i - 1][j - 1].rgbtBlue) + 2 * (image[i][j + 1].rgbtBlue) + image[i - 1][j + 1].rgbtBlue); GyR = (- 1 * image[i - 1][j - 1].rgbtRed - 2 * (image[i - 1][j].rgbtRed) - 1 * image[i - 1][j + 1].rgbtRed); GyG = (- 1 * image[i - 1][j - 1].rgbtGreen - 2 * (image[i - 1][j].rgbtGreen) - 1 * image[i - 1][j + 1].rgbtGreen); GyB = (- 1 * image[i - 1][j - 1].rgbtBlue - 2 * (image[i - 1][j].rgbtBlue) - 1 * image[i - 1][j + 1].rgbtBlue); GxyR = roundf(sqrt(pow(GxR, 2) + pow(GyR, 2))); GxyG = roundf(sqrt(pow(GxG, 2) + pow(GyG, 2))); GxyB = roundf(sqrt(pow(GxB, 2) + pow(GyB, 2))); if (GxyR > 255) { GxyR = 255; } if (GxyG > 255) { GxyG = 255; } if (GxyB > 255) { GxyB = 255; } imagetemp[i][j].rgbtRed = GxyR; imagetemp[i][j].rgbtGreen = GxyG; imagetemp[i][j].rgbtBlue = GxyB; } // Left vertical border line j = 0; for (i = 1 ; i < (height - 1) ; i ++) // For every pixel, exept from the corners { GxR = ((image[i - 1][j + 1].rgbtRed) + 2 * (image[i][j + 1].rgbtRed) + image[i + 1][j + 1].rgbtRed); GxG = ((image[i - 1][j + 1].rgbtGreen) + 2 * (image[i][j + 1].rgbtGreen) + image[i + 1][j + 1].rgbtGreen); GxB = ((image[i - 1][j + 1].rgbtBlue) + 2 * (image[i][j + 1].rgbtBlue) + image[i + 1][j + 1].rgbtBlue); GyR = (- 1 * image[i - 1][j + 1].rgbtRed - 2 * (image[i - 1][j].rgbtRed) + image[i + 1][j + 1].rgbtRed + 2 * (image[i + 1][j].rgbtRed)); GyG = (- 1 * image[i - 1][j + 1].rgbtGreen - 2 * (image[i - 1][j].rgbtGreen) + image[i + 1][j + 1].rgbtGreen + 2 * (image[i + 1][j].rgbtGreen)); GyB = (- 1 * image[i - 1][j + 1].rgbtBlue - 2 * (image[i - 1][j].rgbtBlue) + image[i + 1][j + 1].rgbtBlue + 2 * (image[i + 1][j].rgbtBlue)); GxyR = roundf(sqrt(pow(GxR, 2) + pow(GyR, 2))); GxyG = roundf(sqrt(pow(GxG, 2) + pow(GyG, 2))); GxyB = roundf(sqrt(pow(GxB, 2) + pow(GyB, 2))); if (GxyR > 255) { GxyR = 255; } if (GxyG > 255) { GxyG = 255; } if (GxyB > 255) { GxyB = 255; } imagetemp[i][j].rgbtRed = GxyR; imagetemp[i][j].rgbtGreen = GxyG; imagetemp[i][j].rgbtBlue = GxyB; } // Right vertical border line j = width - 1; for (i = 1 ; i < (height - 1) ; i ++) // For every pixel, exept from the corners { GxR = (- 1 * (image[i - 1][j - 1].rgbtRed) - 2 * (image[i][j - 1].rgbtRed) - 1 * (image[i + 1][j - 1].rgbtRed)); GxG = (- 1 * (image[i - 1][j - 1].rgbtGreen) - 2 * (image[i][j - 1].rgbtGreen) - 1 * (image[i + 1][j - 1].rgbtGreen)); GxB = (- 1 * (image[i - 1][j - 1].rgbtBlue) - 2 * (image[i][j - 1].rgbtBlue) - 1 * (image[i + 1][j - 1].rgbtBlue)); GyR = (- 1 * image[i - 1][j - 1].rgbtRed - 2 * (image[i - 1][j].rgbtRed) + image[i + 1][j - 1].rgbtRed + 2 * (image[i + 1][j].rgbtRed)); GyG = (- 1 * image[i - 1][j - 1].rgbtGreen - 2 * (image[i - 1][j].rgbtGreen) + image[i + 1][j - 1].rgbtGreen + 2 * (image[i + 1][j].rgbtGreen)); GyB = (- 1 * image[i - 1][j - 1].rgbtBlue - 2 * (image[i - 1][j].rgbtBlue) + image[i + 1][j - 1].rgbtBlue + 2 * (image[i + 1][j].rgbtBlue)); GxyR = roundf(sqrt(pow(GxR, 2) + pow(GyR, 2))); GxyG = roundf(sqrt(pow(GxG, 2) + pow(GyG, 2))); GxyB = roundf(sqrt(pow(GxB, 2) + pow(GyB, 2))); if (GxyR > 255) { GxyR = 255; } if (GxyG > 255) { GxyG = 255; } if (GxyB > 255) { GxyB = 255; } imagetemp[i][j].rgbtRed = GxyR; imagetemp[i][j].rgbtGreen = GxyG; imagetemp[i][j].rgbtBlue = GxyB; } // Top left corner i = 0; j = 0; GxR = (2 * (image[i][j + 1].rgbtRed) + image[i + 1][j + 1].rgbtRed); GxG = (2 * (image[i][j + 1].rgbtGreen) + image[i + 1][j + 1].rgbtGreen); GxB = (2 * (image[i][j + 1].rgbtBlue) + image[i + 1][j + 1].rgbtBlue); GyR = (image[i + 1][j + 1].rgbtRed + 2 * (image[i + 1][j].rgbtRed)); GyG = (image[i + 1][j + 1].rgbtGreen + 2 * (image[i + 1][j].rgbtGreen)); GyB = (image[i + 1][j + 1].rgbtBlue + 2 * (image[i + 1][j].rgbtBlue)); GxyR = roundf(sqrt(pow(GxR, 2) + pow(GyR, 2))); GxyG = roundf(sqrt(pow(GxG, 2) + pow(GyG, 2))); GxyB = roundf(sqrt(pow(GxB, 2) + pow(GyB, 2))); if (GxyR > 255) { GxyR = 255; } if (GxyG > 255) { GxyG = 255; } if (GxyB > 255) { GxyB = 255; } imagetemp[i][j].rgbtRed = GxyR; imagetemp[i][j].rgbtGreen = GxyG; imagetemp[i][j].rgbtBlue = GxyB; // Bottom left corner i = height - 1; j = 0; GxR = (2 * (image[i][j + 1].rgbtRed) + image[i - 1][j + 1].rgbtRed); GxG = (2 * (image[i][j + 1].rgbtGreen) + image[i - 1][j + 1].rgbtGreen); GxB = (2 * (image[i][j + 1].rgbtBlue) + image[i - 1][j + 1].rgbtBlue); GyR = (- 1 * (image[i - 1][j + 1].rgbtRed) - 2 * (image[i - 1][j].rgbtRed)); GyG = (- 1 * (image[i - 1][j + 1].rgbtGreen) - 2 * (image[i - 1][j].rgbtGreen)); GyB = (- 1 * (image[i - 1][j + 1].rgbtBlue) - 2 * (image[i - 1][j].rgbtBlue)); GxyR = roundf(sqrt(pow(GxR, 2) + pow(GyR, 2))); GxyG = roundf(sqrt(pow(GxG, 2) + pow(GyG, 2))); GxyB = roundf(sqrt(pow(GxB, 2) + pow(GyB, 2))); if (GxyR > 255) { GxyR = 255; } if (GxyG > 255) { GxyG = 255; } if (GxyB > 255) { GxyB = 255; } imagetemp[i][j].rgbtRed = GxyR; imagetemp[i][j].rgbtGreen = GxyG; imagetemp[i][j].rgbtBlue = GxyB; // Top right corner i = 0; j = width - 1; GxR = (- 2 * (image[i][j - 1].rgbtRed) - 1 * (image[i + 1][j - 1].rgbtRed)); GxG = (- 2 * (image[i][j - 1].rgbtGreen) - 1 * (image[i + 1][j - 1].rgbtGreen)); GxB = (- 2 * (image[i][j - 1].rgbtBlue) - 1 * (image[i + 1][j - 1].rgbtBlue)); GyR = ((image[i + 1][j - 1].rgbtRed) + 2 * (image[i + 1][j].rgbtRed)); GyG = ((image[i + 1][j - 1].rgbtGreen) + 2 * (image[i + 1][j].rgbtGreen)); GyB = ((image[i + 1][j - 1].rgbtBlue) + 2 * (image[i + 1][j].rgbtBlue)); GxyR = roundf(sqrt(pow(GxR, 2) + pow(GyR, 2))); GxyG = roundf(sqrt(pow(GxG, 2) + pow(GyG, 2))); GxyB = roundf(sqrt(pow(GxB, 2) + pow(GyB, 2))); if (GxyR > 255) { GxyR = 255; } if (GxyG > 255) { GxyG = 255; } if (GxyB > 255) { GxyB = 255; } imagetemp[i][j].rgbtRed = GxyR; imagetemp[i][j].rgbtGreen = GxyG; imagetemp[i][j].rgbtBlue = GxyB; // Bottom right corner i = height - 1; j = width - 1; GxR = (- 2 * (image[i][j - 1].rgbtRed) - 1 * (image[i - 1][j - 1].rgbtRed)); GxG = (- 2 * (image[i][j - 1].rgbtGreen) - 1 * (image[i - 1][j - 1].rgbtGreen)); GxB = (- 2 * (image[i][j - 1].rgbtBlue) - 1 * (image[i - 1][j - 1].rgbtBlue)); GyR = (-(image[i - 1][j - 1].rgbtRed) - 2 * (image[i - 1][j].rgbtRed)); GyG = (-(image[i - 1][j - 1].rgbtGreen) - 2 * (image[i - 1][j].rgbtGreen)); GyB = (-(image[i - 1][j - 1].rgbtBlue) - 2 * (image[i - 1][j].rgbtBlue)); GxyR = roundf(sqrt(pow(GxR, 2) + pow(GyR, 2))); GxyG = roundf(sqrt(pow(GxG, 2) + pow(GyG, 2))); GxyB = roundf(sqrt(pow(GxB, 2) + pow(GyB, 2))); if (GxyR > 255) { GxyR = 255; } if (GxyG > 255) { GxyG = 255; } if (GxyB > 255) { GxyB = 255; } imagetemp[i][j].rgbtRed = GxyR; imagetemp[i][j].rgbtGreen = GxyG; imagetemp[i][j].rgbtBlue = GxyB; // Transfer the temporal image to the image for (i = 0 ; i < height ; i ++) // For every row { for (j = 0 ; j < width ; j ++) // For every pixel { image[i][j].rgbtRed = imagetemp[i][j].rgbtRed; image[i][j].rgbtGreen = imagetemp[i][j].rgbtGreen; image[i][j].rgbtBlue = imagetemp[i][j].rgbtBlue; } } return; }
70b16ebf2b655702b219957753e712c517d698a4
6592e0486e940f655617b72766febb61883eadc8
/shanaeh-project/lcd_2004.c
30f9bfad7e99bd93e56cef150ca80110545c72c1
[]
no_license
Shanaeh/plant-protection-program
32091d2075dc6484717a2efb0ae217f024900ca2
bbf4ef5a49bb8b65a33d5cd5f3e173896c97d76e
refs/heads/master
2022-12-16T16:40:11.188868
2020-09-14T03:05:34
2020-09-14T03:05:34
214,719,452
0
0
null
null
null
null
UTF-8
C
false
false
3,478
c
lcd_2004.c
#include "printf.h" #include "uart.h" #include "gpio.h" #include "timer.h" #include "ftoa.h" #include "strings.h" #include "lcd_2004.h" void toggle_enable() { timer_delay_us(E_DELAY); gpio_write(LCD_E, 1); timer_delay_us(E_DELAY); gpio_write(LCD_E, 0); timer_delay_us(E_DELAY); } void lcd_write_byte(unsigned int bits, unsigned int mode) { //bits = a hex code //mode = either char display or instruction register gpio_write(LCD_RS, mode); //Higher bits (endian) -- check chars on pg 17 of manual if char mode //D7 - D4 //If there was a bit on this slot, then it'll be the same after &-ing it if((bits&0x80) == 0x80) gpio_write(LCD_D7, 1); else gpio_write(LCD_D7, 0); //0x80 = 1000 0000 if((bits&0x40) == 0x40) gpio_write(LCD_D6, 1); else gpio_write(LCD_D6, 0); //0x40 = 0100 0000 if((bits&0x20) == 0x20) gpio_write(LCD_D5, 1); else gpio_write(LCD_D5, 0); //0x20 = 0010 0000 if((bits&0x10) == 0x10) gpio_write(LCD_D4, 1); else gpio_write(LCD_D4, 0); //0x10 = 0001 0000 and so on! //Lower bits (endian) //D3 - D0 if((bits&0x08) == 0x08) gpio_write(LCD_D3, 1); else gpio_write(LCD_D3, 0); //0x08 = 0000 1000 if((bits&0x04) == 0x04) gpio_write(LCD_D2, 1); else gpio_write(LCD_D2, 0); //0x04 = 0000 0100 if((bits&0x02) == 0x02) gpio_write(LCD_D1, 1); else gpio_write(LCD_D1, 0); //0x02 = 0000 0010 if((bits&0x01) == 0x01) gpio_write(LCD_D0, 1); else gpio_write(LCD_D0, 0); //0x01 = 0000 0001 toggle_enable(); } //User's responsibility not to overload line length (the display will keep outputting and overwriting former memory) void lcd_write_line(char* line) { int line_len = strlen(line); for(int i=0; i<line_len; i++) { lcd_write_byte(*line, CHAR_MODE); line++; } } //Taking in the constant lcd_line_# (address) and OR-ing with 0x80. Layer of abstraction (for my sanity). void lcd_set_display_address(unsigned int line_address) { //0x80 = 1000 0000, or 1 for D7 (which is a command to set the line address for the char display). line_address = 0x80 | line_address; lcd_write_byte(line_address, INSTRUCT_MODE); } void lcd_clear_screen() { lcd_write_byte(1, INSTRUCT_MODE); } //Initializes the gpio pins, mappings in the .h enum. void lcd_gpio_init() { gpio_set_output(LCD_E); gpio_set_output(LCD_RS); gpio_set_output(LCD_RW); gpio_set_output(LCD_D0); gpio_set_output(LCD_D1); gpio_set_output(LCD_D2); gpio_set_output(LCD_D3); gpio_set_output(LCD_D4); gpio_set_output(LCD_D5); gpio_set_output(LCD_D6); gpio_set_output(LCD_D7); gpio_set_output(LED_ON); } //page 45 of the manual for specific instructions (many, many hours of drawing diagrams and coding in binary). void lcd_display_init() { timer_delay_ms(45); //more than 40 ms //Function set: 8 bit, 2 lines, 5x7 char display //RS=0; D7-D0 = 0011 1000 (0x38) lcd_write_byte(0x38, INSTRUCT_MODE); //Function set: display on, cursor on, cursor blinking //RS=0; D7-D0 = 0000 1111 (0x0F) lcd_write_byte(0x0F, INSTRUCT_MODE); //Function set: entry mode, increment cursor position, no display shift (chars stay on same screen coordinates) //RS=0; D7-D0 = 0000 0110 (0x06) lcd_write_byte(0x06, INSTRUCT_MODE); } void lcd_2004_init(void) { lcd_gpio_init(); lcd_display_init(); }
f71af811edb65db3be71b1f93b4e966374fca96e
d3e265a487ca0d756f3a277d3305e2b3ed8bdd67
/source/utils/verify_help.c
61ede7cea2860e1c75b79bfbd7275f13b683adfe
[]
no_license
LucasALLOIN/my_runner
cd5b93d0b77c9804b3cacf73fca699d78c9d66bd
93e1feb3b9a3c0bfb210801ac20a4409c43b9bb7
refs/heads/master
2021-01-25T17:10:34.768552
2018-02-25T00:39:41
2018-02-25T00:39:41
122,792,300
0
0
null
null
null
null
UTF-8
C
false
false
568
c
verify_help.c
/* ** EPITECH PROJECT, 2018 ** verify_help ** File description: ** verify_help */ #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <SFML/Audio.h> #include <SFML/Graphics.h> #include <sys/types.h> #include <fcntl.h> #include "my.h" #include "main.h" int verify_help(char **argv) { if (my_strcmp(argv[1], "-h") == 0) { my_putstr("USAGE\n\tmy_runner map.txt\n\n"); my_putstr("OPTION\n -h\tLaunch help mode\n\n"); my_putstr("USER INTERACTION\n"); my_putstr("\tSpace to jump\n"); my_putstr("\tS to shoot\n"); return (1); } return (0); }
e61f080265a7b1bc25532e02e1103b31a1a33275
0bc88a2199b99a74a41c02866cfd3272baedd3ca
/parser/parse_dollar.c
75d4d930ff29a52c96ec5d652fea7c8a6c00fd5f
[]
no_license
cgriceld/42-own-bash
d17112bfc6c6a8d305cdd3c62bd8467bf6667071
02c1deeb5685e1b624b4d091aa2b18c444bd668c
refs/heads/main
2023-06-17T01:34:53.456673
2021-06-20T16:31:53
2021-06-20T16:31:53
null
0
0
null
null
null
null
UTF-8
C
false
false
2,119
c
parse_dollar.c
#include "../minibash.h" static int exp_dollar2(char *value, char **str) { char *tmp; tmp = *str; *str = ft_strjoin(*str, value); free(tmp); if (!*str) return (1); return (0); } static int exp_dollar(char *value, t_quo *quo, t_quo_split *tmp_split) { if (quo->after_space && tmp_split->arg) { if (init_quo_split(&tmp_split->next)) return (1); tmp_split->next->arg = ft_strdup(value); if (!tmp_split->next->arg) return (1); quo->split_len++; quo->after_space = 0; } else if (!tmp_split->arg) { tmp_split->arg = ft_strdup(value); if (!tmp_split->arg) return (1); quo->split_len++; } else return (exp_dollar2(value, &tmp_split->arg)); return (0); } static int prepare_dollar(t_seq *tmp_seq, t_shell *shell, t_quo *quo, \ t_quo_split *tmp_split) { quo->start++; quo->end++; if (!*quo->end || ft_strchr(" <>\\$=", *quo->end)) { quo->start--; join_routine(tmp_seq, shell, quo, tmp_split); return (1); } if (*quo->end == '?') { quo->slashes = -1; join_routine(tmp_seq, shell, quo, tmp_split); quo->slashes = 0; quo->end++; return (1); } else if (ft_isdigit(*quo->end)) { quo->end++; return (1); } while (*quo->end && !ft_strchr(" $<>\"\\'=", *quo->end)) quo->end++; return (0); } static int exp_dollar_utils(char *value, t_seq *tmp_seq) { if (!tmp_seq->tmp_redir->path) { tmp_seq->tmp_redir->path = ft_strdup(""); if (!tmp_seq->tmp_redir->path) return (1); } if (exp_dollar2(value, &tmp_seq->tmp_redir->path)) return (1); return (0); } void parse_dollar(t_seq *tmp_seq, t_shell *shell, t_quo *quo, \ t_quo_split *tmp_split) { char *exp; char *value; if (prepare_dollar(tmp_seq, shell, quo, tmp_split)) return ; exp = ft_substr(tmp_seq->run, quo->start - tmp_seq->run, \ quo->end - quo->start); if (!exp) error_quotes(&quo, &shell); value = envp_get_value(shell, exp); if (!value) { free(exp); return ; } if (tmp_split) { if (exp_dollar(value, quo, tmp_split)) error_dollar(&exp, quo, shell); } else if (exp_dollar_utils(value, tmp_seq)) error_dollar(&exp, quo, shell); free(exp); }
8e02b0ce74cfe31dd8e418cf088fbd0ab5848eef
58f31cdd97904dcca22d0c662e7102ac7cdaa780
/20181108_min_heap.c
4d74dc5b296ba9014d0bbe66e487d9c2d4b379d1
[]
no_license
melodyjerry/daily_algorithms
90b15b386ce008eeadb05512fb39b7e01bfdcbeb
aefcaa324bdda5eb1e9692c1fabbf92559da97e2
refs/heads/master
2022-04-26T14:41:34.109574
2020-04-29T07:28:44
2020-04-29T07:28:44
null
0
0
null
null
null
null
UTF-8
C
false
false
1,832
c
20181108_min_heap.c
#include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <assert.h> #include <limits.h> void fatal_error(char *msg) { printf("fatal_error: %s\n", msg); exit(1); } void error(char *msg) { printf("error: %s\n", msg); exit(1); } void swap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; } typedef struct HeapStruct { int capacity; int size; int *arr; } HeapStruct, *Heap; Heap create_heap(int size) { Heap h = malloc(sizeof(HeapStruct)); if (h == NULL) fatal_error("out of space"); // one more space for sentinel h->arr = malloc(sizeof(int) * (size + 1)); if (h->arr == NULL) fatal_error("out of space"); h->arr[0] = INT_MIN; h->capacity = size; h->size = 0; return h; } void free_heap(Heap h) { if (h == NULL) return; free(h->arr); free(h); } bool is_empty(Heap h) { return h->size == 0; } bool is_full(Heap h) { return h->size == h->capacity; } void insert(int value, Heap h) { if (is_full(h)) error("Heap is full, cant insert"); int i; for (i=++h->size; h->arr[i / 2] > value; i /= 2) h->arr[i] = h->arr[i / 2]; h->arr[i] = value; } void percolate_down(int *arr, int i, int size) { int child; int tmp = arr[i]; while (2 * i <= size) { child = 2 * i; if (child != size && arr[child + 1] < arr[child]) child++; if (arr[child] > tmp) break; arr[i] = arr[child]; i = child; } arr[i] = tmp; } int delete_min(Heap h) { if (is_empty(h)) error("Heap is empty, cant delete min"); // delete min swap(&h->arr[1], &h->arr[h->size]); h->size--; // balance percolate_down(h->arr, 1, h->size); return h->arr[h->size + 1]; } int main() { }
42fb64e238a2776f2a4b1390ff8c61f6540f3b3c
cbc72cfe1e5697defd2fc0b88155e576ea02a61c
/FreeRTOS10/usart.c
cbff4e67966e45d237c7ec76d626d3968c637614
[]
no_license
LE0NIDAS1/robotAspiradora
08fbac059766e84538aecb34198ffcece840883d
179a352e09e2359220ce81819d03eece6e8828e3
refs/heads/master
2020-08-22T02:56:20.621743
2019-11-05T20:06:39
2019-11-05T20:06:39
216,303,331
0
0
null
null
null
null
UTF-8
C
false
false
1,441
c
usart.c
/* * usart.c * * Created: 18/10/2019 0:19:28 * Author: leoeg */ #include "usart.h" #include <avr/io.h> #define RX_BUFF 10 volatile char Rec_Buffer[16]; void USART_init(void){ UBRR0H = (uint8_t)(BAUD_PRESCALLER>>8); UBRR0L = (uint8_t)(BAUD_PRESCALLER); UCSR0B = (1<<RXEN0)|(1<<TXEN0); TX_START(); RX_START(); UCSR0C = (3<<UCSZ00); } unsigned char USART_Receive (void) { while((!(UCSR0A)) & (1<<RXC0)); // wait while data is being received return UDR0; // return 8-bit data } void USART_send( unsigned char data){ while(!(UCSR0A & (1<<UDRE0))) ; UDR0 = data; } unsigned char recibe_caracter_usart(){ if(UCSR0A&(1<<7)){ //si el bit7 del registro UCSR0A se ha puesto a 1 return UDR0; //devuelve el dato almacenado en el registro UDR0 } else//sino return 0 ;//retorna 0 } void putByte(unsigned char data) { // Stay here until data buffer is empty while (!(UCSR0A & _BV(UDRE0))); UDR0 = (unsigned char) data; } void USART_putstring(char* StringPtr){ while(*StringPtr != 0x00){ USART_send(*StringPtr); StringPtr++; } } uint8_t getByte(void) { // Check to see if something was received while (!(UCSR0A & _BV(RXC0))); return (uint8_t) UDR0; } char* readString(void) { static char rxstr[RX_BUFF]; static char* temp; temp = rxstr; while((*temp = getByte()) != '\n') { ++temp; } return rxstr; }
ed94bb989330330e9936d6a24464f79751ea6fbd
c83313a99c38000b4baf85ad2f7b79014df99e8b
/vm_repo/srcs/ft_get_para.c
5036ac47015ca084ece31c2604664cac3dc25091
[]
no_license
snk11/corewar
eb32aa75c5d1f257ea5243d19c5ea3b3480e320d
b582abe3d572991c13d68725c26883f1d539bab1
refs/heads/master
2021-01-18T03:25:28.646674
2018-05-19T09:09:17
2018-05-19T09:09:17
85,822,126
0
0
null
null
null
null
UTF-8
C
false
false
2,508
c
ft_get_para.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_get_para.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: syusof <syusof@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/05/22 15:01:26 by syusof #+# #+# */ /* Updated: 2017/06/21 11:53:32 by syusof ### ########.fr */ /* */ /* ************************************************************************** */ #include "tyassine.h" unsigned char *ft_get_para_p1(unsigned char *s, t_proc *proc1, int x) { unsigned char *s1; unsigned char *si; unsigned int position; unsigned int index; s1 = NULL; position = get_position(proc1, x); si = ft_new_s_on_sizeint(proc1->params.size_params[x], s, position); index = ft_get_index_t(si, sizeof(unsigned int), proc1->pc); s1 = ft_memalloc(sizeof(unsigned char) * REG_SIZE); ft_int_to_reg(s1, index); return (s1); } unsigned char *ft_get_para_p2(unsigned char *s, t_proc *proc1, int x) { unsigned char *s1; unsigned char *si; unsigned int position; unsigned int index; s1 = NULL; position = get_position(proc1, x); si = ft_new_s_on_sizeint(proc1->params.size_params[x], s, position); index = ft_get_index_t(si, sizeof(unsigned int), proc1->pc); s1 = ft_new_s_on_sizeint(REG_SIZE, s, index); return (s1); } unsigned char *ft_get_para(unsigned char *s, t_proc *proc1, int x) { unsigned char *s1; unsigned int position; unsigned int conv1; s1 = NULL; position = get_position(proc1, x); if (proc1->params.type[x] == T_REG) { conv1 = ft_conv_to_int_nomod(proc1->params.arg[x], proc1->params.size_params[x]); if (conv1 <= REG_NUMBER && conv1 > 0) s1 = proc1->reg[conv1 - 1]; else return (NULL); } else if (proc1->params.type[x] == T_DIR) s1 = ft_new_s_on_sizeint(proc1->params.size_params[x], s, position); else if (proc1->params.type[x] == T_IND && (proc1->op.num == 10 || proc1->op.num == 11)) s1 = ft_get_para_p2(s, proc1, x); else if (proc1->params.type[x] == T_IND) s1 = ft_get_para_p1(s, proc1, x); return (s1); }
d640f98dbde9d75ea0b308b4ba18b4adcdb1e165
c9b1d9481663f35a745533e215e512c31f00f945
/vendors/realtek/sdk/amebaZ2/component/common/bluetooth/realtek/sdk/example/bt_mesh/lib/model/realtek/datatrans_model.c
26d00da7392038986c7348e34219511234a7b7a2
[ "Apache-2.0", "MIT" ]
permissive
ambiot/amazon-freertos
199d8c8cfebf7d4ce41cdf0377a6622c56ea3f7c
ef61d5f521de921cc931d9262e3d5af9b75fbd2e
refs/heads/master
2023-08-24T08:06:28.437220
2021-07-08T13:33:49
2021-07-08T13:33:49
191,755,880
14
16
MIT
2022-09-20T23:47:06
2019-06-13T12:09:22
C
UTF-8
C
false
false
7,909
c
datatrans_model.c
/** ***************************************************************************************** * Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved. ***************************************************************************************** * @file datatrans_model_client.c * @brief Source file for data transmission client model. * @details Data types and external functions declaration. * @author hector_huang * @date 2018-10-29 * @version v1.0 * ************************************************************************************* */ /* Add Includes here */ #include "datatrans_model.h" static mesh_msg_send_cause_t datatrans_server_send(const mesh_model_info_p pmodel_info, uint16_t dst, uint16_t app_key_index, uint8_t *pmsg, uint16_t msg_len) { mesh_msg_t mesh_msg; mesh_msg.pmodel_info = pmodel_info; access_cfg(&mesh_msg); mesh_msg.pbuffer = pmsg; mesh_msg.msg_len = msg_len; if (0 != dst) { mesh_msg.dst = dst; mesh_msg.app_key_index = app_key_index; } return access_send(&mesh_msg); } static mesh_msg_send_cause_t datatrans_send_data(const mesh_model_info_p pmodel_info, uint16_t dst, uint16_t app_key_index, uint16_t data_len, uint8_t *data) { mesh_msg_send_cause_t ret; datatrans_data_t *pmsg; uint16_t msg_len = sizeof(datatrans_data_t); msg_len += data_len; pmsg = plt_malloc(msg_len, RAM_TYPE_DATA_ON); if (NULL == pmsg) { return MESH_MSG_SEND_CAUSE_NO_MEMORY; } ACCESS_OPCODE_BYTE(pmsg->opcode, MESH_MSG_DATATRANS_DATA); memcpy(pmsg->data, data, data_len); ret = datatrans_server_send(pmodel_info, dst, app_key_index, (uint8_t *)pmsg, msg_len); plt_free(pmsg, RAM_TYPE_DATA_ON); return ret; } mesh_msg_send_cause_t datatrans_publish(const mesh_model_info_p pmodel_info, uint16_t data_len, uint8_t *data) { mesh_msg_send_cause_t ret = MESH_MSG_SEND_CAUSE_INVALID_DST; if (mesh_model_pub_check(pmodel_info)) { ret = datatrans_send_data(pmodel_info, 0, 0, data_len, data); } return ret; } static mesh_msg_send_cause_t datatrans_client_send(const mesh_model_info_p pmodel_info, uint16_t dst, uint16_t app_key_index, uint8_t *pmsg, uint16_t msg_len) { mesh_msg_t mesh_msg; mesh_msg.pmodel_info = pmodel_info; access_cfg(&mesh_msg); mesh_msg.pbuffer = pmsg; mesh_msg.msg_len = msg_len; mesh_msg.dst = dst; mesh_msg.app_key_index = app_key_index; return access_send(&mesh_msg); } mesh_msg_send_cause_t datatrans_write(const mesh_model_info_p pmodel_info, uint16_t dst, uint16_t app_key_index, uint16_t data_len, uint8_t *data, bool ack) { datatrans_write_t *pmsg; mesh_msg_send_cause_t ret; uint16_t msg_len = sizeof(datatrans_write_t); msg_len += data_len; pmsg = plt_malloc(msg_len, RAM_TYPE_DATA_ON); if (NULL == pmsg) { return MESH_MSG_SEND_CAUSE_NO_MEMORY; } if (ack) { ACCESS_OPCODE_BYTE(pmsg->opcode, MESH_MSG_DATATRANS_WRITE); } else { ACCESS_OPCODE_BYTE(pmsg->opcode, MESH_MSG_DATATRANS_WRITE_UNACK); } memcpy(pmsg->data, data, data_len); ret = datatrans_client_send(pmodel_info, dst, app_key_index, (uint8_t *)pmsg, msg_len); plt_free(pmsg, RAM_TYPE_DATA_ON); return ret; } mesh_msg_send_cause_t datatrans_read(const mesh_model_info_p pmodel_info, uint16_t dst, uint16_t app_key_index, uint16_t read_len) { datatrans_read_t msg; ACCESS_OPCODE_BYTE(msg.opcode, MESH_MSG_DATATRANS_READ); msg.read_len = read_len; return datatrans_client_send(pmodel_info, dst, app_key_index, (uint8_t *)&msg, sizeof(datatrans_read_t)); } static bool datatrans_receive(mesh_msg_p pmesh_msg) { bool ret = TRUE; uint8_t *pbuffer = pmesh_msg->pbuffer + pmesh_msg->msg_offset; mesh_model_info_p pmodel_info = pmesh_msg->pmodel_info; switch (pmesh_msg->access_opcode) { case MESH_MSG_DATATRANS_STATUS: if (pmesh_msg->msg_len == sizeof(datatrans_status_t)) { datatrans_status_t *pmsg = (datatrans_status_t *)pbuffer; if (NULL != pmesh_msg->pmodel_info->model_data_cb) { datatrans_client_status_t status_data; status_data.status = pmsg->status; status_data.written_len = pmsg->written_len; pmesh_msg->pmodel_info->model_data_cb(pmesh_msg->pmodel_info, DATATRANS_CLIENT_STATUS, &status_data); } } break; case MESH_MSG_DATATRANS_DATA: { datatrans_data_t *pmsg = (datatrans_data_t *)pbuffer; if (NULL != pmesh_msg->pmodel_info->model_data_cb) { datatrans_client_data_t read_data; read_data.data_len = pmesh_msg->msg_len - sizeof(datatrans_data_t); read_data.data = pmsg->data; pmesh_msg->pmodel_info->model_data_cb(pmesh_msg->pmodel_info, DATATRANS_CLIENT_DATA, &read_data); } } break; case MESH_MSG_DATATRANS_READ: if (pmesh_msg->msg_len == sizeof(datatrans_read_t)) { datatrans_read_t *pmsg = (datatrans_read_t *)pbuffer; datatrans_server_read_t read_data = {0, NULL}; if (NULL != pmodel_info->model_data_cb) { read_data.data_len = pmsg->read_len; pmodel_info->model_data_cb(pmodel_info, DATATRANS_SERVER_READ, &read_data); } datatrans_send_data(pmodel_info, pmesh_msg->src, pmesh_msg->app_key_index, read_data.data_len, read_data.data); } break; case MESH_MSG_DATATRANS_WRITE: case MESH_MSG_DATATRANS_WRITE_UNACK: { datatrans_write_t *pmsg = (datatrans_write_t *)pbuffer; uint16_t data_len = pmesh_msg->msg_len - sizeof(datatrans_write_t); datatrans_server_write_t write_data = {data_len, NULL, DATATRANS_SUCCESS, data_len}; if (NULL != pmodel_info->model_data_cb) { write_data.data = pmsg->data; pmodel_info->model_data_cb(pmodel_info, DATATRANS_SERVER_WRITE, &write_data); } if (pmesh_msg->access_opcode == MESH_MSG_DATATRANS_WRITE) { datatrans_status_t msg; ACCESS_OPCODE_BYTE(msg.opcode, MESH_MSG_DATATRANS_STATUS); msg.status = write_data.status; msg.written_len = write_data.written_len; datatrans_server_send(pmodel_info, pmesh_msg->src, pmesh_msg->app_key_index, (uint8_t *)&msg, sizeof(datatrans_status_t)); } } break; default: ret = FALSE; break; } return ret; } bool datatrans_reg(uint8_t element_index, mesh_model_info_p pmodel_info) { if (NULL == pmodel_info) { return FALSE; } pmodel_info->model_id = MESH_MODEL_DATATRANS; if (NULL == pmodel_info->model_receive) { pmodel_info->model_receive = datatrans_receive; if (NULL == pmodel_info->model_data_cb) { printw("datatrans client reg: missing data process callback!"); } } return mesh_model_reg(element_index, pmodel_info); }
79096df2e1f908b43f92373acc9e2ce6ccabd375
b395515dba0a0ea060a37e212239d544e612dab9
/Lab tasks/Lab 4/temperature conversion.c
5690d776581e8d98c33f930f4649639be83e8dc6
[]
no_license
AbdulRehmanTariqCh/C
99be0da68aa4f42d8673914188f604a761cdf703
c7116e7cecdae46caa1ff30f68425ea30771ff1f
refs/heads/master
2022-05-19T16:43:16.667000
2019-08-06T16:15:08
2019-08-06T16:15:08
null
0
0
null
null
null
null
UTF-8
C
false
false
1,274
c
temperature conversion.c
/* Implement the following functions. The functions return a real number: (a) Function Celsius returns the Celsius equivalent of a Fahrenheit temperature (Hint: 0 Celsius is equal to 32 Fahrenheit and 100 Celsius is equal to 212 Fahrenheit). (b) Function Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature. Use these functions to write a program that prints charts showing the Fahrenheit equivalent of all Celsius temperatures between 0 and 100 degrees and the Celsius equivalent of all Fahrenheit temperatures between 32 and 212 degrees. */ #include <stdio.h> float celsius(float temp); float fahrenheit(float temp); int main() { printf("CELSIUS\t\t\tFAHRENHEIT\t\t\t FAHRENHEIT\t\t\tCELSIUS\n"); int i; for (i = 0; i <= 212; i++) { if (i >= 0 && i<32) { printf("%d C\t\t\t %6.1f F\n", i, fahrenheit(i)); } if (i >= 32 && i <= 100) { printf("%d C\t\t\t %6.1f F\t\t\t\t%d F\t\t\t%6.1f C\n", i, fahrenheit(i), i, celsius(i)); } if (i>100 && i <= 212) { printf(" \t\t\t \t\t\t\t\t%d F\t\t\t%6.1f C\n", i, celsius(i)); } } system("pause"); return 0; } float celsius(float temp) { return (temp - 32) / 1.8; } float fahrenheit(float temp) { return (temp*1.8) + 32; }
842d298651e3afb44b024a91f5dc54a84ff96674
abaf2780739fc61a0754276305954e5346195794
/src/lab_2/szyfr.c
db9b5ff00a956ab7c05209f0786ee78f6ae2aa6b
[]
no_license
Qams/system-programming-unix
e64922c899b75df93150b090f8404e1af5353e3d
ba6c73cc26bfd3bdf617e62dfcbb58a321ebc08a
refs/heads/master
2021-01-10T16:08:16.931289
2016-05-11T11:46:22
2016-05-11T11:46:22
53,332,013
0
0
null
null
null
null
UTF-8
C
false
false
1,440
c
szyfr.c
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> #include <fcntl.h> #define BUFSIZE 512 void generujZnaki(int fd2, int ile) { int i=0, l; char z; for(i;i<ile;i++) { l = rand()%26; z = l + 'a'; write(fd2, &z, sizeof(z)); } } void pomin(int fd, int ile) { int i = 0; char tmp; for(i;i<ile;i++) { read(fd, &tmp, 1); } } void szyfruj(char* from, char* to) { int fd, fd2, liczba; char c, tmp; ssize_t nread, n; fd = open(from, O_RDONLY); fd2 = open(to, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); while((nread = read(fd, &c, 1)) > 0) { if((n = write(fd2, &c, nread)) == -1) { perror("Blad zapisu 1"); exit(EXIT_FAILURE); } liczba = rand()%9 + 1; tmp = liczba + '0'; if((n = write(fd2, &tmp, 1)) == -1) { perror("Blad zapisu 2"); exit(EXIT_FAILURE); } generujZnaki(fd2, liczba); } printf("\n"); close(fd); close(fd2); } void deszyfruj(char* from, char* to) { int fd, fd2, liczba, toInt; char c, tmp; ssize_t nread, n; fd = open(from, O_RDONLY); fd2 = open(to, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); while((nread = read(fd, &c, 1)) > 0) { if((n = write(fd2, &c, 1)) == -1) { perror("Blad zapisu przy deszyfracji"); exit(EXIT_FAILURE); } read(fd, &c, 1); toInt = c - '0'; pomin(fd, toInt); } } int main(int argc, char** argv) { szyfruj(argv[1], argv[2]); srand(time(NULL)); return 0; }
39dfad5539f580594ce7abd308ad67fe5b91a56b
c7f397f2a3caa45bd93f394b991bc8c3209c3e7b
/Langage_C/Matchstick/include/matchstick.h
8c18dae3b9163bdd060da7805c7fdc5eeaf849ed
[]
no_license
RodolpheDedant/Projets-realises
3ba7045b3359c47949dc30506ad86ab963a2cb3c
a21012358fcc64c5d511235f5906c717142869be
refs/heads/master
2023-06-01T21:36:09.368330
2021-06-14T16:57:40
2021-06-14T16:57:40
376,879,070
0
0
null
null
null
null
UTF-8
C
false
false
941
h
matchstick.h
/* ** EPITECH PROJECT, 2020 ** delivery ** File description: ** matchstick.h */ #ifndef MATCHSTICK_H #define MATCHSTICK_H #include <stdlib.h> #include <time.h> typedef struct map { int line; int col; int max_stick; int ret_val; }map_t; typedef struct game { int line; int match; int stick; int inc; }game_t; int matchstick(char **av); char **tab_create(map_t *map); char **print_fence(char **tab, map_t *map); char **print_game_board(char **tab, map_t *map); int count_max_line(int x); int game(char **tab, map_t *map); int line(char **tab, map_t *map, game_t *game); int change_map(game_t *game, char **tab, map_t *map); int getmatch(char **tab, map_t *map, game_t *game); int ia(char **tab, map_t *map, game_t *game); void print_map(char **map); int check_buffer(char *buffer); int check_victory(char **tab); int check_bis(game_t *game, map_t *map, char **tab); int count_stick_line(char *map); #endif
853bee8d7b73678aed7407c19a5cb198fbc048b8
cf3401b4551d09b211d255c9614daaa05ce4d2e3
/unit_test/k_stl/string.h
0c59b0b3e968386a0f9913f67a73fb8d9aca07f7
[]
no_license
wspeirs/Mooose
0e6767dc27195ce3d6b9a6a789e70a80f0e0a489
c621d55a716033f24e6d4d81d55823685c6a7465
refs/heads/master
2020-05-13T07:41:08.620646
2010-07-27T02:44:59
2010-07-27T02:44:59
767,633
3
0
null
null
null
null
UTF-8
C
false
false
32
h
string.h
../../src/include/k_std/string.h
8c2ee35d05e5bbf3048fa01770d67fb1b62f5784
6601ed1b6c24e8b7e78312aeaadf816262c4bee3
/c/libelf/rawdata.c
5d9a9f30476eaf5d48bf44df2054fba0740653e3
[ "BSD-2-Clause" ]
permissive
t-crest/patmos
bb9764c5897ee8bbac2a336cb09d7bb77d54916a
c63dadffa3db2ad241c31ae6e952d6fe2298986a
refs/heads/master
2023-04-11T12:18:37.795018
2023-03-25T17:57:33
2023-03-25T17:57:33
1,500,522
108
90
BSD-2-Clause
2023-03-25T17:57:35
2011-03-19T17:01:39
VHDL
UTF-8
C
false
false
2,543
c
rawdata.c
/* rawdata.c - implementation of the elf_rawdata(3) function. Copyright (C) 1995 - 2000 Michael Riepe This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include <private.h> #ifndef lint static const char rcsid[] = "@(#) $Id: rawdata.c,v 1.10 2008/05/23 08:15:35 michael Exp $"; #endif /* lint */ Elf_Data* elf_rawdata(Elf_Scn *scn, Elf_Data *data) { Scn_Data *sd; Elf *elf; if (!scn) { return NULL; } elf_assert(scn->s_magic == SCN_MAGIC); elf = scn->s_elf; elf_assert(elf); elf_assert(elf->e_magic == ELF_MAGIC); if (!elf->e_readable) { return NULL; } else if (scn->s_index == SHN_UNDEF || scn->s_type == SHT_NULL) { seterr(ERROR_NULLSCN); } else if (data) { return NULL; } else if ((sd = scn->s_rawdata)) { elf_assert(sd->sd_magic == DATA_MAGIC); elf_assert(sd->sd_scn == scn); return &sd->sd_data; } else if (scn->s_offset < 0 || scn->s_offset > elf->e_size) { seterr(ERROR_OUTSIDE); } else if (scn->s_type != SHT_NOBITS && scn->s_offset + scn->s_size > elf->e_size) { seterr(ERROR_TRUNC_SCN); } else if (!(sd = (Scn_Data*)malloc(sizeof(*sd)))) { seterr(ERROR_MEM_SCNDATA); } else { *sd = _elf_data_init; sd->sd_scn = scn; sd->sd_freeme = 1; sd->sd_data.d_size = scn->s_size; sd->sd_data.d_version = _elf_version; if (scn->s_type != SHT_NOBITS && scn->s_size) { if (!(sd->sd_memdata = (char*)malloc(scn->s_size))) { seterr(ERROR_IO_2BIG); free(sd); return NULL; } else if (elf->e_rawdata) { memcpy(sd->sd_memdata, elf->e_rawdata + scn->s_offset, scn->s_size); } else if (!_elf_read(elf, sd->sd_memdata, scn->s_offset, scn->s_size)) { free(sd->sd_memdata); free(sd); return NULL; } sd->sd_data.d_buf = sd->sd_memdata; sd->sd_free_data = 1; } scn->s_rawdata = sd; return &sd->sd_data; } return NULL; }
ad151cd039615cca9e1d7c65671551a39923b339
0892034e4842f2e468232373ca676ce9a9dfaa7e
/CHAMELEON_H01_S02_RC4_20140303/sink_wired.h
0557886aa843e39fe108be4cd8ffbe8cbbc5dacb
[]
no_license
layerfsd/BC
99847cafd96f7803ec4db9641cbdf5e06def03da
9f5a2fa4c89bf2291ab5e30dedcc5a5054ebd53d
refs/heads/master
2020-12-26T03:55:02.999336
2015-08-03T02:52:33
2015-08-03T02:52:33
57,318,459
0
1
null
2016-04-28T16:41:49
2016-04-28T16:41:48
null
UTF-8
C
false
false
2,697
h
sink_wired.h
/**************************************************************************** Copyright (C) Cambridge Silicon Radio Ltd. 2004-2013 FILE NAME sink_wired.h DESCRIPTION */ #ifndef _SINK_WIRED_H_ #define _SINK_WIRED_H_ #include <stdlib.h> #if defined(ENABLE_WIRED) /* Wired */ typedef struct { unsigned reserved:8; unsigned unused:4; unsigned volume:4; }wired_info; #endif /**************************************************************************** NAME wiredAudioInit DESCRIPTION Set up wired audio PIOs and configuration RETURNS void */ #ifdef ENABLE_WIRED void wiredAudioInit(void); #else #define wiredAudioInit() ((void)(0)) #endif /**************************************************************************** NAME wiredAudioRoute DESCRIPTION Route wired audio stream through DSP RETURNS void */ #ifdef ENABLE_WIRED void wiredAudioRoute(void); #else #define wiredAudioRoute() ((void)(0)) #endif /**************************************************************************** NAME wiredAudioDisconnect DESCRIPTION Force disconnect of wired audio RETURNS void */ #ifdef ENABLE_WIRED void wiredAudioDisconnect(void); #else #define wiredAudioDisconnect() ((void)(0)) #endif /**************************************************************************** NAME wiredAudioSinkMatch DESCRIPTION Compare sink to wired audio sink. RETURNS TRUE if Sink matches, FALSE otherwise */ #ifdef ENABLE_WIRED bool wiredAudioSinkMatch(Sink sink); #else #define wiredAudioSinkMatch(x) (FALSE) #endif /**************************************************************************** NAME wiredAudioUpdateVolume DESCRIPTION Adjust wired audio volume if currently being routed RETURNS TRUE if wired audio being routed, FALSE otherwise */ #ifdef ENABLE_WIRED bool wiredAudioUpdateVolume(volume_direction dir); #else #define wiredAudioUpdateVolume(x) (FALSE) #endif /**************************************************************************** NAME wiredAudioConnected DESCRIPTION Determine if wired audio input is connected RETURNS TRUE if connected, otherwise FALSE */ #ifdef ENABLE_WIRED bool wiredAudioConnected(void); #else #define wiredAudioConnected() (FALSE) #endif /**************************************************************************** NAME wiredAudioCanPowerOff DESCRIPTION Determine if wired audio blocks power off RETURNS TRUE if device can power off, otherwise FALSE */ #define wiredAudioCanPowerOff() ((!wiredAudioConnected()) || powerManagerIsVbatCritical()) #endif /* _SINK_WIRED_H_ */
b7222bf3d42982b8ee2073b8f980f63c3e6a948a
1425b748166b2dcd5494ff4f832946c1231c080d
/calc.c
3c4bbb6f1f96b251da1bfe5db2d2d3c44760f8a5
[]
no_license
kumarvickysingh/Calculator-2-Digit
d3ce4c9fd901ea9a199465a3f3c4c0365f7d9234
c50df090b0e882029719a6018ab3c34d18a3e36d
refs/heads/master
2021-03-30T10:32:47.446341
2020-03-17T18:33:38
2020-03-17T18:33:38
248,045,135
1
0
null
null
null
null
UTF-8
C
false
false
297
c
calc.c
#include<stdio.h> int main() { int a,b,c,d,e; float f; printf(" \n\n\n\n\t\t\tEnter two numbers : "); scanf("%d%d",&a,&b); c=a+b; printf("\n\n\t Sum = %d",c); d=a*b; printf("\n\n\t Mul = %d",d); e=a-b; printf("\n\n\t Sub = %d",e); f=a/b; printf("\n\n\t Div = %f",f); return(0); }
9693db7f4bf199937d4fbef9d628b8af093f5fc0
699670793200ffd65e961638830552aeaba752ef
/Semester-5/OS_LAB/lab 5/p2.c
1f8a592ae12d9847b97cbec06732075472935021
[]
no_license
RajvardhanReddyN/MIT_Manipal_CSE_Labs_2018-2022
a345f7785d60a6c143e564e34b66c0de4e44d37b
26e51cca32c5aab8109f4516bd01e05ffe202c77
refs/heads/main
2023-07-02T04:43:23.291152
2021-08-16T08:54:39
2021-08-16T08:54:39
396,651,954
10
0
null
null
null
null
UTF-8
C
false
false
443
c
p2.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <string.h> int main(int argc, char *argv[]) { int n; int fd[2]; char buf[1025]; char *data = "Mid Term Lab Exams from tomorrrow!"; pipe(fd); write(fd[1], data, strlen(data)); if (n = read(fd[0], buf, 1024) >= 0) { buf[n] = 0; printf("Read %d bytes from pipe\"%s\"\n", n, buf); } else perror("Read"); exit(0); }
cee419f623958be86106e090bf88bd93e52ac7cd
4c1fc3797d329d38ad8164c5b9104a4fe177ce1b
/libft/srcs/hash_map/hm_insert.c
f9d50387503fc7e7424e1bb8c502db7955be913e
[]
no_license
thk2b/42sh
11a9c0f8cc84850f850c3455c961af96601d5b84
7f07f6dc56e4e1793afe06b392d8fff528918db0
refs/heads/master
2020-04-06T13:03:17.673051
2019-08-12T07:28:55
2019-08-12T07:28:55
157,481,698
0
1
null
null
null
null
UTF-8
C
false
false
1,197
c
hm_insert.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* hm_insert.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tkobb <tkobb@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/10/21 21:20:40 by tkobb #+# #+# */ /* Updated: 2018/10/25 14:19:22 by tkobb ### ########.fr */ /* */ /* ************************************************************************** */ #include "hash_map.h" #include "libft.h" int hm_insert(t_hm *hm, const char *key, void *value) { int index; t_hm_item *item; VALIDATE_HASH(index = hm->hash_fn(key) % hm->arr_size, 1); MCK(item = hm_new_item(key, value), 1); llist_push(&hm->keys[index], (void*)item); hm->size++; return (0); }
e153731af9828b5a0782754d1ee927be18cd1efc
8adab1e7c9a3db7906bb9f83b0e37d4abafdb50a
/keyboards/handwired/dactyl_manuform/4x5/4x5.h
a70f52f3e14b2cb9c4ce335bc6f2831e7409eb7a
[ "GPL-2.0-only", "LicenseRef-scancode-other-copyleft", "BSD-3-Clause", "GPL-3.0-or-later", "LGPL-2.0-or-later", "LGPL-2.1-or-later", "LicenseRef-scancode-warranty-disclaimer", "GPL-1.0-or-later", "GPL-3.0-only" ]
permissive
fzf/qmk_toolbox
d7975c0d6af28c19957b57c6f5976ad9b8173c4d
10d6b425bd24b45002555022baf16fb11254118b
refs/heads/master
2022-09-05T11:51:53.952007
2020-06-03T09:31:26
2020-06-03T09:32:27
269,046,233
0
0
MIT
2020-06-03T09:30:37
2020-06-03T09:30:36
null
UTF-8
C
false
false
2,044
h
4x5.h
#pragma once #include "dactyl_manuform.h" #include "quantum.h" #ifdef USE_I2C #include <stddef.h> #ifdef __AVR__ #include <avr/io.h> #include <avr/interrupt.h> #endif #endif #ifndef FLIP_HALF #define LAYOUT( \ L00, L01, L02, L03, L04, R00, R01, R02, R03, R04, \ L10, L11, L12, L13, L14, R10, R11, R12, R13, R14, \ L20, L21, L22, L23, L24, R20, R21, R22, R23, R24, \ L31, L32, R32, R33, \ L33, L34, R30, R31, \ L44, L43, R41, R40, \ L42, L41, R43, R42 \ ) \ { \ { L00, L01, L02, L03, L04 }, \ { L10, L11, L12, L13, L14 }, \ { L20, L21, L22, L23, L24 }, \ { KC_NO, L31, L32, L33, L34 }, \ { KC_NO, L41, L42, L43, L44 }, \ \ { R04, R03, R02, R01, R00 }, \ { R14, R13, R12, R11, R10 }, \ { R24, R23, R22, R21, R20 }, \ { KC_NO, R33, R32, R31, R30 }, \ { KC_NO, R43, R42, R41, R40 } \ } #else #define LAYOUT( \ L00, L01, L02, L03, L04, R00, R01, R02, R03, R04, \ L10, L11, L12, L13, L14, R10, R11, R12, R13, R14, \ L20, L21, L22, L23, L24, R20, R21, R22, R23, R24, \ L31, L32, R32, R33, \ L33, L34, R30, R31, \ L44, L43, R41, R40, \ L42, L41, R43, R42 \ ) \ { \ { R04, R03, R02, R01, R00 }, \ { R14, R13, R12, R11, R10 }, \ { R24, R23, R22, R21, R20 }, \ { KC_NO, R33, R32, R31, R30 }, \ { KC_NO, R43, R42, R41, R40 }, \ \ { L00, L01, L02, L03, L04 }, \ { L10, L11, L12, L13, L14 }, \ { L20, L21, L22, L23, L24 }, \ { KC_NO, L31, L32, L33, L34 }, \ { KC_NO, L41, L42, L43, L44 } \ \ } #endif
e5066e3dee46d67b35f799487183a16679cdd0f2
7e1f97967b73f6e5ef028d910ee798925b788a67
/clang-ex/ccan/ccan/crypto/shachain/test/run-badhash.c
bc9785120b3cacc794b3ae0445e16de1c919b866
[ "BSD-3-Clause" ]
permissive
fjrti/snippets
e7744e2624506ce984cc9aec5aba4d7a3511dbdc
defc0b3ca3bb214eae963f75c0d1ccb066fccc1b
refs/heads/master
2022-04-29T21:54:16.188735
2022-04-15T09:08:35
2022-04-15T09:08:35
89,904,548
3
1
null
null
null
null
UTF-8
C
false
false
855
c
run-badhash.c
#include <ccan/crypto/shachain/shachain.h> /* Include the C files directly. */ #include <ccan/crypto/shachain/shachain.c> #include <ccan/tap/tap.h> #define NUM_TESTS 1000 int main(void) { struct sha256 seed; struct shachain chain; size_t i; plan_tests(NUM_TESTS); memset(&seed, 0xFF, sizeof(seed)); shachain_init(&chain); for (i = 0; i < NUM_TESTS; i++) { struct sha256 expect; unsigned int num_known = chain.num_valid; shachain_from_seed(&seed, i, &expect); /* Screw it up. */ expect.u.u8[0]++; /* Either it should fail, or it couldn't derive any others. */ if (shachain_add_hash(&chain, i, &expect)) { ok1(chain.num_valid == num_known + 1); /* Fix it up in-place */ chain.known[num_known].hash.u.u8[0]--; } else { expect.u.u8[0]--; ok1(shachain_add_hash(&chain, i, &expect)); } } return exit_status(); }
e6f0ad9f8a12fb995bf1d8e9dbd3aa89fdccac26
9d4d1246d7a6ea037d47de317a23bad36117bd0f
/MLN-Android/mlncore/src/main/jni/japi/stack.c
0a30fedb1836d6124e330a38e30675d5b0650d68
[ "MIT" ]
permissive
dingpuyu/MLN
122ba786ef876feff65c2b8fc8f48116678635d1
32124e5f261ef360f8c97688a4391fda9605389b
refs/heads/master
2020-08-30T19:32:12.119442
2019-12-05T08:27:51
2019-12-05T08:27:51
218,469,439
1
0
MIT
2019-10-30T07:38:52
2019-10-30T07:38:52
null
UTF-8
C
false
false
1,751
c
stack.c
/** * Created by MomoLuaNative. * Copyright (c) 2019, Momo Group. All rights reserved. * * This source code is licensed under the MIT. * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. */ // // Created by Xiong.Fangyu 2019/06/06. // #if defined(MEM_INFO) #include "stack.h" #include <dlfcn.h> #include <stdlib.h> #include <string.h> typedef struct _stack { uintptr_t * pcs; char ** method_name; int size; int max; int ignore; int _gmn; } _stack_info; static char * new_str(const char * src) { char * r = (char *) malloc(sizeof(char *) * (strlen(src) + 1)); return strcpy(r, src); } static _Unwind_Reason_Code unwind_backtrace_callback(struct _Unwind_Context* context, void* arg) { uintptr_t pc = _Unwind_GetIP(context); _stack_info * t = (_stack_info *) arg; if (t->size ++ < t->ignore) return _URC_NO_REASON; int i = t->size - 1 - t->ignore; if (i >= t->max) return _URC_END_OF_STACK; Dl_info info; if (pc && dladdr((void *)pc, &info)) { t->pcs[i] = (uintptr_t)info.dli_saddr - (uintptr_t)info.dli_fbase; if (t->_gmn && info.dli_sname) t->method_name[i] = new_str(info.dli_sname); else t->method_name[i] = NULL; } else { t->pcs[i] = 0; t->method_name[i] = NULL; } return _URC_NO_REASON; } int get_call_stack(stack_symbol * out, int ignore, int get_method_name) { _stack_info si; si.pcs = out->pc; si.method_name = out->method_name; si.size = 0; si.max = MAX_STACK_LENGTH; si.ignore = ignore; si._gmn = get_method_name; return _Unwind_Backtrace(unwind_backtrace_callback, &si) == _URC_END_OF_STACK; } #endif //MEM_INFO
9d9a273e5bfa2c818463c3d2af7a75a7c14a12e2
a92eca8084a4100267555c9f0c11e0bb702675f9
/thread_process/pthread/create.c
cb66a6770daa37341856f23787abfa9412da86b2
[]
no_license
victorygogogo/LearnAndTry
ceabddd02b9feb751c6c3f0e0713b1c9683b4869
8d2f651ca8b14986f920c5c6fbbc42e1be8eb7fb
refs/heads/main
2023-06-28T22:03:20.295098
2021-07-21T08:58:11
2021-07-21T08:58:11
null
0
0
null
null
null
null
UTF-8
C
false
false
962
c
create.c
#include <stdio.h> #include <unistd.h>//getpid() #include <pthread.h> void *print_hello(void *arg) { pid_t pid = getpid(); pthread_t tid = pthread_self(); printf("I am thread: %d, pid: %u, tid: 0x%x\r\n", *((int *)arg), (unsigned int)pid, (unsigned int)tid);//先强制类型转换泛型指针,然后取指针指向的值 return 0; // 执行到线程函数的末尾会自动结束线程 } int main() { int num_thread = 5; int index[num_thread]; pthread_t thread_tid[num_thread]; for (int i = 0; i < num_thread; i++) { index[i] = i; printf("main() : 创建线程, %d\n", i); int ret = pthread_create(&thread_tid[i], 0, print_hello, (void *)&(index[i])); if (ret != 0) printf("Thread creation failed"); } pthread_exit(NULL);// 退出运行main函数的主线程,该操作不影响其他5个线程 return 0;// 有了上面那句pthread_exit就不会执行到这句 }
72640ad48dcf2f988646b4752d06cfc1cdbb4c8e
cfa63643ff581b7275d0f455099ea95a04cf679f
/src_c_onesided/timing_milc.c
b4a26e20ed4d8912a27cba1cef1dbe8c7f04a5b8
[ "BSD-3-Clause-Open-MPI" ]
permissive
truls/dbrew-ddtbench
d1e3ac1f3ab0b4e67c079432c1fcb7ce97c81be8
7d2b387e9360e0de26be14b265a5b7faeaad30dc
refs/heads/master
2021-01-11T23:20:22.725875
2017-05-23T04:02:38
2017-05-23T04:02:38
78,567,028
0
0
null
null
null
null
UTF-8
C
false
false
9,953
c
timing_milc.c
// Copyright (c) 2012 The Trustees of University of Illinois. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <stdio.h> #include <stdlib.h> #include "mpi.h" #include "../src_c/ddtbench.h" #define itag 0 static inline int idx5D(int x, int y, int z, int t, int u, int DIM1, int DIM2, int DIM3, int DIM4) { return x+DIM1*(y+DIM2*(z+DIM3*(t+DIM4*u))); } void timing_milc_su3_zdown_ddt( int DIM2, int DIM3, int DIM4, int DIM5, int outer_loop, int inner_loop, int* correct_flag, int* ptypesize, char* testname, MPI_File filehandle_debug, MPI_Comm local_communicator ) { float* array; int myrank; int i, j, base, bytes; MPI_Datatype dtype_su3_vector_t, dtype_temp_t, dtype_su3_zdown_t; int typesize; MPI_Aint stride; char method[50]; MPI_Win win; //! just some statements to prevent compiler warnings of unused variables //! those parameter are included for future features *correct_flag = 0; *ptypesize = 0; // typesize = filehandle_debug MPI_Comm_rank( local_communicator, &myrank ); array = malloc( 2 * 3 * DIM2 * DIM3 * DIM4 * DIM5 * sizeof(float) ); MPI_Win_create( array, 2 * 3 * DIM2 * DIM3 * DIM4 * DIM5 * sizeof(float), sizeof(float), MPI_INFO_NULL, local_communicator, &win ); MPI_Win_fence( 0 /* assert */, win ); /* initial fence to open epoch */ base = myrank * 3 * DIM2 * DIM3 * DIM4 * DIM5 * 2 + 1; utilities_fill_unique_array_5D_float( &array[0], 6, DIM2, DIM3, DIM4, DIM5, base ); if ( myrank == 0 ) { snprintf( &method[0], 50, "mpi_ddt" ); MPI_Type_size( MPI_FLOAT, &typesize ); bytes = 2 * DIM5 * DIM2*DIM3/2 * 3 * 2 * typesize; timing_init( testname, method, bytes ); } for( i=0 ; i<outer_loop ; i++ ) { //! modelling the zdown direction MPI_Type_contiguous( 6, MPI_FLOAT, &dtype_su3_vector_t ); MPI_Type_vector( DIM5, DIM2*DIM3/2, DIM2*DIM3*DIM4/2, dtype_su3_vector_t, &dtype_temp_t ); MPI_Type_size( dtype_su3_vector_t, &typesize ); stride = typesize * DIM2 * DIM3 * DIM4 * DIM5/2; MPI_Type_create_hvector( 2, 1, stride, dtype_temp_t, &dtype_su3_zdown_t ); MPI_Type_commit( &dtype_su3_zdown_t ); MPI_Type_free( &dtype_su3_vector_t ); MPI_Type_free( &dtype_temp_t ); if ( myrank == 0 ) { timing_record(1); } for( j=0 ; j<inner_loop ; j++ ) { if ( myrank == 0 ) { MPI_Put( &array[0], 1, dtype_su3_zdown_t, 1 /* target */, 0 /* offset */, 1 /* count */, dtype_su3_zdown_t, win ); MPI_Win_fence( 0 /* assert */, win ); MPI_Win_fence( 0 /* assert */, win ); timing_record(3); } else { MPI_Win_fence( 0 /* assert */, win ); MPI_Put( &array[0], 1, dtype_su3_zdown_t, 0 /* target */, 0 /* offset */, 1 /* count */, dtype_su3_zdown_t, win ); MPI_Win_fence( 0 /* assert */, win ); } } //! inner loop MPI_Type_free( &dtype_su3_zdown_t ); if ( myrank == 0 ) { timing_record(5); } } //! outer loop if ( myrank == 0 ) { timing_print( 1 ); } MPI_Win_free( &win ); free( array ); } void timing_milc_su3_zdown_manual( int DIM2, int DIM3, int DIM4, int DIM5, int outer_loop, int inner_loop, int* correct_flag, int* ptypesize, char* testname, MPI_File filehandle_debug, MPI_Comm local_communicator ) { float* array; float* buffer; int myrank; int i, j, k, l, m, n, o; int base, bytes, pos, dsize; int typesize; char method[50]; MPI_Win win; //! just some statements to prevent compiler warnings of unused variables //! those parameter are included for future features *correct_flag = 0; *ptypesize = 0; // typesize = filehandle_debug; array = malloc( 2 * 3 * DIM2 * DIM3 * DIM4 * DIM5 * sizeof(float) ); MPI_Comm_rank( local_communicator, &myrank ); dsize = 2 * DIM5 * DIM2*DIM3/2 * 3 * 2; buffer = malloc( dsize * sizeof(float) ); MPI_Win_create( buffer, dsize * sizeof(float), sizeof(float), MPI_INFO_NULL, local_communicator, &win ); MPI_Win_fence( 0 /* assert */, win ); /* initial fence to open epoch */ base = myrank * 3 * DIM2 * DIM3 * DIM4 * DIM5 * 2 + 1; utilities_fill_unique_array_5D_float( &array[0], 6, DIM2, DIM3, DIM4, DIM5, base ); if ( myrank == 0 ) { snprintf( &method[0], 50, "manual" ); MPI_Type_size( MPI_FLOAT, &typesize ); bytes = 2 * DIM5 * DIM2*DIM3/2 * 3 * 2 * typesize; timing_init( testname, &method[0], bytes ); } for( i=0 ; i<outer_loop ; i++ ) { //! modelling the zdown direction for( j=0 ; j<inner_loop ; j++) { if ( myrank == 0 ) { pos = 0; for( k=0 ; k<DIM5 ; k++ ) { for( l=0 ; l<DIM4 ; l+=DIM4/2 ) { for( m=0 ; m<DIM3/2 ; m++ ) { for( n=0; n<DIM2 ; n++ ) { for( o=0 ; o<6 ; o++ ) { buffer[pos++] = array[idx5D(o,n,m,l,k,6,DIM2,DIM3,DIM4)]; } } } } } timing_record(2); MPI_Put( &buffer[0], dsize, MPI_FLOAT, 1 /* target */, 0 /* offset */, dsize /* count */, MPI_FLOAT, win ); MPI_Win_fence( 0 /* assert */, win ); MPI_Win_fence( 0 /* assert */, win ); timing_record(3); pos = 0; for( k=0 ; k<DIM5 ; k++ ) { for( l=0 ; l<DIM4 ; l+=DIM4/2 ) { for( m=0 ; m<DIM3/2 ; m++ ) { for( n=0; n<DIM2 ; n++ ) { for( o=0 ; o<6 ; o++ ) { array[idx5D(o,n,m,l,k,6,DIM2,DIM3,DIM4)] = buffer[pos++]; } } } } } timing_record(4); } else { MPI_Win_fence( 0 /* assert */, win ); pos = 0; for( k=0 ; k<DIM5 ; k++ ) { for( l=0 ; l<DIM4 ; l+=DIM4/2 ) { for( m=0 ; m<DIM3/2 ; m++ ) { for( n=0; n<DIM2 ; n++ ) { for( o=0 ; o<6 ; o++ ) { array[idx5D(o,n,m,l,k,6,DIM2,DIM3,DIM4)] = buffer[pos++]; } } } } } pos = 0; for( k=0 ; k<DIM5 ; k++ ) { for( l=0 ; l<DIM4 ; l+=DIM4/2 ) { for( m=0 ; m<DIM3/2 ; m++ ) { for( n=0; n<DIM2 ; n++ ) { for( o=0 ; o<6 ; o++ ) { buffer[pos++] = array[idx5D(o,n,m,l,k,6,DIM2,DIM3,DIM4)]; } } } } } MPI_Put( &buffer[0], dsize, MPI_FLOAT, 0 /* target */, 0 /* offset */, dsize /* count */, MPI_FLOAT, win ); MPI_Win_fence( 0 /* assert */, win ); } } //! inner loop } //! outer loop if ( myrank == 0 ) { timing_print( 1 ); } MPI_Win_free( &win ); free( buffer ); free( array ); } void timing_milc_su3_zdown_mpi_pack_ddt( int DIM2, int DIM3, int DIM4, int DIM5, int outer_loop, int inner_loop, int* correct_flag, int* ptypesize, char* testname, MPI_File filehandle_debug, MPI_Comm local_communicator ){ float* array; float* buffer; int myrank; int i, j; int base, bytes, pos, dsize; MPI_Datatype dtype_su3_vector_t, dtype_temp_t, dtype_su3_zdown_t; int typesize; MPI_Aint stride; char method[50]; MPI_Win win; //! just some statements to prevent compiler warnings of unused variables //! those parameter are included for future features *correct_flag = 0; *ptypesize = 0; // typesize = filehandle_debug array = malloc( 2 * 3 * DIM2 * DIM3 * DIM4 * DIM5 * sizeof(float) ); MPI_Comm_rank( local_communicator, &myrank ); dsize = 2 * DIM5 * DIM2*DIM3/2 * 3 * 2; MPI_Type_size( MPI_FLOAT, &typesize ); bytes = dsize * typesize; buffer = malloc( bytes ); MPI_Win_create( buffer, bytes, sizeof(char), MPI_INFO_NULL, local_communicator, &win ); MPI_Win_fence( 0 /* assert */, win ); /* initial fence to open epoch */ base = myrank * 3 * DIM2 * DIM3 * DIM4 * DIM5 * 2 + 1; utilities_fill_unique_array_5D_float( &array[0], 6, DIM2, DIM3, DIM4, DIM5, base ); if ( myrank == 0 ) { snprintf( &method[0], 50, "mpi_pack_ddt" ); timing_init( testname, &method[0], bytes ); } for( i=0 ; i<outer_loop ; i++ ) { //! modelling the zdown direction MPI_Type_contiguous( 6, MPI_FLOAT, &dtype_su3_vector_t ); MPI_Type_vector( DIM5, DIM2*DIM3/2, DIM2*DIM3*DIM4/2, dtype_su3_vector_t, &dtype_temp_t ); MPI_Type_size( dtype_su3_vector_t, &typesize ); stride = typesize*DIM2*DIM3*DIM4*DIM5/2; MPI_Type_create_hvector( 2, 1, stride, dtype_temp_t, &dtype_su3_zdown_t ); MPI_Type_commit( &dtype_su3_zdown_t ); MPI_Type_free( &dtype_su3_vector_t ); MPI_Type_free( &dtype_temp_t ); if ( myrank == 0 ) { timing_record(1); } for( j=0 ; j<inner_loop ; j++ ) { if ( myrank == 0 ) { pos = 0; MPI_Pack( &array[0], 1, dtype_su3_zdown_t, &buffer[0], bytes, &pos, local_communicator ); timing_record(2); MPI_Put( &buffer[0], pos, MPI_PACKED, 1 /* target */, 0 /* offset */, pos /* count */, MPI_PACKED, win ); MPI_Win_fence( 0 /* assert */, win ); MPI_Win_fence( 0 /* assert */, win ); timing_record(3); pos = 0; MPI_Unpack( &buffer[0], bytes, &pos, &array[0], 1, dtype_su3_zdown_t, local_communicator ); timing_record(4); } else { MPI_Win_fence( 0 /* assert */, win ); pos = 0; MPI_Unpack( &buffer[0], bytes, &pos, &array[0], 1, dtype_su3_zdown_t, local_communicator ); pos = 0; MPI_Pack( &array[0], 1, dtype_su3_zdown_t, &buffer[0], bytes, &pos, local_communicator ); MPI_Put( &buffer[0], pos, MPI_PACKED, 0 /* target */, 0 /* offset */, pos /* count */, MPI_PACKED, win ); MPI_Win_fence( 0 /* assert */, win ); } } //! inner loop MPI_Type_free( &dtype_su3_zdown_t ); if ( myrank == 0 ) { timing_record(5); } } //! outer loop if ( myrank == 0 ) { timing_print( 1 ); } MPI_Win_free( &win ); free( array ); free( buffer ); }
d182a08c7687a8c2e681a34c9ba5b62a47730bc2
0fadd66d8dba96897e984c22a92cba9136ac36bb
/src/run_Manly.c
725ae69dafcac8bc5d53680e01e74fb0d581187d
[]
no_license
cran/ManlyMix
3fc5fea7c2f1476819187adb26a8dac28db47a03
51ee61a6edb1e2f12bae4ca22344f142fb47a787
refs/heads/master
2023-05-12T23:48:54.250480
2023-04-29T05:40:02
2023-04-29T05:40:02
48,083,209
0
0
null
null
null
null
UTF-8
C
false
false
4,319
c
run_Manly.c
#include "array.h" #include "Manly.h" void runProAgree(int (*n), int (*K1), int (*K2), int *id1, int *id2, double (*maxPro), int * combination){ double maxPro1; int n1, K11, K21; n1 = (*n); K11 = (*K1); K21 = (*K2); maxPro1 = (*maxPro); proAgree(n1, K11, K21, id1, id2, &maxPro1, combination); (*maxPro) = maxPro1; } void run_Manly_transX(double *x1, int *misc_int, double *la1, double *y1){ double **X, **Y; int p, n; p = misc_int[0]; n = misc_int[1]; MAKE_MATRIX(X, n, p); MAKE_MATRIX(Y, n, p); array1to2(n, p, x1, X); Manly_transX(n, p, la1, X, Y); array2to1(n, p, y1, Y); FREE_MATRIX(X); FREE_MATRIX(Y); } // Manly mixture void run_Manly_mix(double *x1, int *misc_int, double *tau, double *Mu1, double *S1, double *la1, double *mix){ double **X, **la, **Mu, ***S; int p, n, K; p = misc_int[0]; n = misc_int[1]; K = misc_int[2]; MAKE_MATRIX(X, n, p); MAKE_MATRIX(la, K, p); MAKE_MATRIX(Mu, K, p); MAKE_3ARRAY(S, K, p, p); array1to2(n, p, x1, X); array1to2(K, p, la1, la); array1to2(K, p, Mu1, Mu); array1to3(K, p, p, S1, S); Manly_mix(n, p, K, X, tau, Mu, S, la, mix); array2to1(K, p, la1, la); array2to1(K, p, Mu1, Mu); array3to1(K, p, p, S1, S); FREE_MATRIX(X); FREE_MATRIX(la); FREE_MATRIX(Mu); FREE_3ARRAY(S); } void run_Manly(double *x1, int *id, int *misc_int, double *misc_double, double *la1, double *tau, double *Mu1, double *S1, double *gamma1, double *ll, int *conv){ double **X, **la, **Mu, ***S, **gamma; int p, n, K, max_iter; p = misc_int[0]; n = misc_int[1]; K = misc_int[2]; max_iter = misc_int[3]; MAKE_MATRIX(X, n, p); MAKE_MATRIX(la, K, p); MAKE_MATRIX(Mu, K, p); MAKE_3ARRAY(S, K, p, p); MAKE_MATRIX(gamma, n, K); array1to2(n, p, x1, X); array1to2(K, p, la1, la); array1to2(K, p, Mu1, Mu); array1to3(K, p, p, S1, S); array1to2(n, K, gamma1, gamma); Manly_EM(n, p, K, X, id, max_iter, misc_double, la, tau, Mu, S, gamma, ll, conv); array2to1(K, p, la1, la); array2to1(K, p, Mu1, Mu); array3to1(K, p, p, S1, S); array2to1(n, K, gamma1, gamma); FREE_MATRIX(X); FREE_MATRIX(la); FREE_MATRIX(Mu); FREE_3ARRAY(S); FREE_MATRIX(gamma); } void run_Manly2(double *x1, int *misc_int, double *misc_double, double *la1, double *tau, double *Mu1, double *S1, double *gamma1, int *id, double *ll, int *conv){ double **X, **la, **Mu, ***S, **gamma; int p, n, K, max_iter; p = misc_int[0]; n = misc_int[1]; K = misc_int[2]; max_iter = misc_int[3]; MAKE_MATRIX(X, n, p); MAKE_MATRIX(la, K, p); MAKE_MATRIX(Mu, K, p); MAKE_3ARRAY(S, K, p, p); MAKE_MATRIX(gamma, n, K); array1to2(n, p, x1, X); array1to2(K, p, la1, la); array1to2(K, p, Mu1, Mu); array1to3(K, p, p, S1, S); array1to2(n, K, gamma1, gamma); Manly_EM2(n, p, K, X, max_iter, misc_double, tau, Mu, S, la, gamma, id, ll, conv); array2to1(K, p, la1, la); array2to1(K, p, Mu1, Mu); array3to1(K, p, p, S1, S); array2to1(n, K, gamma1, gamma); FREE_MATRIX(X); FREE_MATRIX(la); FREE_MATRIX(Mu); FREE_3ARRAY(S); FREE_MATRIX(gamma); } void run_Manlyk(double *x1, int *id, int *misc_int, double *misc_double, double *la1, double *Mu1, double *S1, int *conv){ double **X, **la, **Mu; int p, n, K, max_iter; p = misc_int[0]; n = misc_int[1]; K = misc_int[2]; max_iter = misc_int[3]; MAKE_MATRIX(X, n, p); MAKE_MATRIX(la, K, p); MAKE_MATRIX(Mu, K, p); array1to2(n, p, x1, X); array1to2(K, p, la1, la); array1to2(K, p, Mu1, Mu); Manly_CEM(n, p, K, X, id, max_iter, misc_double, la, Mu, S1, conv); array2to1(K, p, la1, la); array2to1(K, p, Mu1, Mu); FREE_MATRIX(X); FREE_MATRIX(la); FREE_MATRIX(Mu); } void run_Manlyk2(double *x1, int *misc_int, double *misc_double, double *la1, double *Mu1, double *S1, int *id, int *conv){ double **X, **la, **Mu; int p, n, K, max_iter; p = misc_int[0]; n = misc_int[1]; K = misc_int[2]; max_iter = misc_int[3]; MAKE_MATRIX(X, n, p); MAKE_MATRIX(la, K, p); MAKE_MATRIX(Mu, K, p); array1to2(n, p, x1, X); array1to2(K, p, la1, la); array1to2(K, p, Mu1, Mu); Manly_CEM2(n, p, K, X, max_iter, misc_double, la, Mu, S1, id, conv); array2to1(K, p, la1, la); array2to1(K, p, Mu1, Mu); FREE_MATRIX(X); FREE_MATRIX(la); FREE_MATRIX(Mu); }
ef4e5c74864821156e71e086c8705a138e26a83c
4494e10d8295ae02b22b55ecf88862b7463a16c8
/BilProjekt/BilProjekt.cydsn/Generated_Source/PSoC5/PWM_DC.h
3cad1506bb0da2f6e249bb5ff6eacb9b16a9281b
[]
no_license
krisbork/Semesterprojekt3
7c9f73c4c7467d91ee9cd8a778c6c07e5dbcb031
070c07c4e95a48cf11e2cd220bb1ed8985b1a2f3
refs/heads/main
2023-02-04T16:41:07.553482
2020-12-18T08:54:15
2020-12-18T08:54:15
null
0
0
null
null
null
null
UTF-8
C
false
false
25,405
h
PWM_DC.h
/******************************************************************************* * File Name: PWM_DC.h * Version 3.30 * * Description: * Contains the prototypes and constants for the functions available to the * PWM user module. * * Note: * ******************************************************************************** * Copyright 2008-2014, Cypress Semiconductor Corporation. All rights reserved. * You may use this file only in accordance with the license, terms, conditions, * disclaimers, and limitations in the end user license agreement accompanying * the software package with which this file was provided. ********************************************************************************/ #if !defined(CY_PWM_PWM_DC_H) #define CY_PWM_PWM_DC_H #include "cyfitter.h" #include "cytypes.h" #include "CyLib.h" /* For CyEnterCriticalSection() and CyExitCriticalSection() functions */ extern uint8 PWM_DC_initVar; /*************************************** * Conditional Compilation Parameters ***************************************/ #define PWM_DC_Resolution (8u) #define PWM_DC_UsingFixedFunction (0u) #define PWM_DC_DeadBandMode (0u) #define PWM_DC_KillModeMinTime (0u) #define PWM_DC_KillMode (0u) #define PWM_DC_PWMMode (0u) #define PWM_DC_PWMModeIsCenterAligned (0u) #define PWM_DC_DeadBandUsed (0u) #define PWM_DC_DeadBand2_4 (0u) #if !defined(PWM_DC_PWMUDB_genblk8_stsreg__REMOVED) #define PWM_DC_UseStatus (1u) #else #define PWM_DC_UseStatus (0u) #endif /* !defined(PWM_DC_PWMUDB_genblk8_stsreg__REMOVED) */ #if !defined(PWM_DC_PWMUDB_genblk1_ctrlreg__REMOVED) #define PWM_DC_UseControl (1u) #else #define PWM_DC_UseControl (0u) #endif /* !defined(PWM_DC_PWMUDB_genblk1_ctrlreg__REMOVED) */ #define PWM_DC_UseOneCompareMode (1u) #define PWM_DC_MinimumKillTime (1u) #define PWM_DC_EnableMode (0u) #define PWM_DC_CompareMode1SW (0u) #define PWM_DC_CompareMode2SW (0u) /* Check to see if required defines such as CY_PSOC5LP are available */ /* They are defined starting with cy_boot v3.0 */ #if !defined (CY_PSOC5LP) #error Component PWM_v3_30 requires cy_boot v3.0 or later #endif /* (CY_ PSOC5LP) */ /* Use Kill Mode Enumerated Types */ #define PWM_DC__B_PWM__DISABLED 0 #define PWM_DC__B_PWM__ASYNCHRONOUS 1 #define PWM_DC__B_PWM__SINGLECYCLE 2 #define PWM_DC__B_PWM__LATCHED 3 #define PWM_DC__B_PWM__MINTIME 4 /* Use Dead Band Mode Enumerated Types */ #define PWM_DC__B_PWM__DBMDISABLED 0 #define PWM_DC__B_PWM__DBM_2_4_CLOCKS 1 #define PWM_DC__B_PWM__DBM_256_CLOCKS 2 /* Used PWM Mode Enumerated Types */ #define PWM_DC__B_PWM__ONE_OUTPUT 0 #define PWM_DC__B_PWM__TWO_OUTPUTS 1 #define PWM_DC__B_PWM__DUAL_EDGE 2 #define PWM_DC__B_PWM__CENTER_ALIGN 3 #define PWM_DC__B_PWM__DITHER 5 #define PWM_DC__B_PWM__HARDWARESELECT 4 /* Used PWM Compare Mode Enumerated Types */ #define PWM_DC__B_PWM__LESS_THAN 1 #define PWM_DC__B_PWM__LESS_THAN_OR_EQUAL 2 #define PWM_DC__B_PWM__GREATER_THAN 3 #define PWM_DC__B_PWM__GREATER_THAN_OR_EQUAL_TO 4 #define PWM_DC__B_PWM__EQUAL 0 #define PWM_DC__B_PWM__FIRMWARE 5 /*************************************** * Data Struct Definition ***************************************/ /************************************************************************** * Sleep Wakeup Backup structure for PWM Component *************************************************************************/ typedef struct { uint8 PWMEnableState; #if(!PWM_DC_UsingFixedFunction) uint8 PWMUdb; /* PWM Current Counter value */ #if(!PWM_DC_PWMModeIsCenterAligned) uint8 PWMPeriod; #endif /* (!PWM_DC_PWMModeIsCenterAligned) */ #if (PWM_DC_UseStatus) uint8 InterruptMaskValue; /* PWM Current Interrupt Mask */ #endif /* (PWM_DC_UseStatus) */ /* Backup for Deadband parameters */ #if(PWM_DC_DeadBandMode == PWM_DC__B_PWM__DBM_256_CLOCKS || \ PWM_DC_DeadBandMode == PWM_DC__B_PWM__DBM_2_4_CLOCKS) uint8 PWMdeadBandValue; /* Dead Band Counter Current Value */ #endif /* deadband count is either 2-4 clocks or 256 clocks */ /* Backup Kill Mode Counter*/ #if(PWM_DC_KillModeMinTime) uint8 PWMKillCounterPeriod; /* Kill Mode period value */ #endif /* (PWM_DC_KillModeMinTime) */ /* Backup control register */ #if(PWM_DC_UseControl) uint8 PWMControlRegister; /* PWM Control Register value */ #endif /* (PWM_DC_UseControl) */ #endif /* (!PWM_DC_UsingFixedFunction) */ }PWM_DC_backupStruct; /*************************************** * Function Prototypes **************************************/ void PWM_DC_Start(void) ; void PWM_DC_Stop(void) ; #if (PWM_DC_UseStatus || PWM_DC_UsingFixedFunction) void PWM_DC_SetInterruptMode(uint8 interruptMode) ; uint8 PWM_DC_ReadStatusRegister(void) ; #endif /* (PWM_DC_UseStatus || PWM_DC_UsingFixedFunction) */ #define PWM_DC_GetInterruptSource() PWM_DC_ReadStatusRegister() #if (PWM_DC_UseControl) uint8 PWM_DC_ReadControlRegister(void) ; void PWM_DC_WriteControlRegister(uint8 control) ; #endif /* (PWM_DC_UseControl) */ #if (PWM_DC_UseOneCompareMode) #if (PWM_DC_CompareMode1SW) void PWM_DC_SetCompareMode(uint8 comparemode) ; #endif /* (PWM_DC_CompareMode1SW) */ #else #if (PWM_DC_CompareMode1SW) void PWM_DC_SetCompareMode1(uint8 comparemode) ; #endif /* (PWM_DC_CompareMode1SW) */ #if (PWM_DC_CompareMode2SW) void PWM_DC_SetCompareMode2(uint8 comparemode) ; #endif /* (PWM_DC_CompareMode2SW) */ #endif /* (PWM_DC_UseOneCompareMode) */ #if (!PWM_DC_UsingFixedFunction) uint8 PWM_DC_ReadCounter(void) ; uint8 PWM_DC_ReadCapture(void) ; #if (PWM_DC_UseStatus) void PWM_DC_ClearFIFO(void) ; #endif /* (PWM_DC_UseStatus) */ void PWM_DC_WriteCounter(uint8 counter) ; #endif /* (!PWM_DC_UsingFixedFunction) */ void PWM_DC_WritePeriod(uint8 period) ; uint8 PWM_DC_ReadPeriod(void) ; #if (PWM_DC_UseOneCompareMode) void PWM_DC_WriteCompare(uint8 compare) ; uint8 PWM_DC_ReadCompare(void) ; #else void PWM_DC_WriteCompare1(uint8 compare) ; uint8 PWM_DC_ReadCompare1(void) ; void PWM_DC_WriteCompare2(uint8 compare) ; uint8 PWM_DC_ReadCompare2(void) ; #endif /* (PWM_DC_UseOneCompareMode) */ #if (PWM_DC_DeadBandUsed) void PWM_DC_WriteDeadTime(uint8 deadtime) ; uint8 PWM_DC_ReadDeadTime(void) ; #endif /* (PWM_DC_DeadBandUsed) */ #if ( PWM_DC_KillModeMinTime) void PWM_DC_WriteKillTime(uint8 killtime) ; uint8 PWM_DC_ReadKillTime(void) ; #endif /* ( PWM_DC_KillModeMinTime) */ void PWM_DC_Init(void) ; void PWM_DC_Enable(void) ; void PWM_DC_Sleep(void) ; void PWM_DC_Wakeup(void) ; void PWM_DC_SaveConfig(void) ; void PWM_DC_RestoreConfig(void) ; /*************************************** * Initialization Values **************************************/ #define PWM_DC_INIT_PERIOD_VALUE (100u) #define PWM_DC_INIT_COMPARE_VALUE1 (50u) #define PWM_DC_INIT_COMPARE_VALUE2 (63u) #define PWM_DC_INIT_INTERRUPTS_MODE (uint8)(((uint8)(0u << \ PWM_DC_STATUS_TC_INT_EN_MASK_SHIFT)) | \ (uint8)((uint8)(0u << \ PWM_DC_STATUS_CMP2_INT_EN_MASK_SHIFT)) | \ (uint8)((uint8)(0u << \ PWM_DC_STATUS_CMP1_INT_EN_MASK_SHIFT )) | \ (uint8)((uint8)(0u << \ PWM_DC_STATUS_KILL_INT_EN_MASK_SHIFT ))) #define PWM_DC_DEFAULT_COMPARE2_MODE (uint8)((uint8)1u << PWM_DC_CTRL_CMPMODE2_SHIFT) #define PWM_DC_DEFAULT_COMPARE1_MODE (uint8)((uint8)1u << PWM_DC_CTRL_CMPMODE1_SHIFT) #define PWM_DC_INIT_DEAD_TIME (1u) /******************************** * Registers ******************************** */ #if (PWM_DC_UsingFixedFunction) #define PWM_DC_PERIOD_LSB (*(reg16 *) PWM_DC_PWMHW__PER0) #define PWM_DC_PERIOD_LSB_PTR ( (reg16 *) PWM_DC_PWMHW__PER0) #define PWM_DC_COMPARE1_LSB (*(reg16 *) PWM_DC_PWMHW__CNT_CMP0) #define PWM_DC_COMPARE1_LSB_PTR ( (reg16 *) PWM_DC_PWMHW__CNT_CMP0) #define PWM_DC_COMPARE2_LSB (0x00u) #define PWM_DC_COMPARE2_LSB_PTR (0x00u) #define PWM_DC_COUNTER_LSB (*(reg16 *) PWM_DC_PWMHW__CNT_CMP0) #define PWM_DC_COUNTER_LSB_PTR ( (reg16 *) PWM_DC_PWMHW__CNT_CMP0) #define PWM_DC_CAPTURE_LSB (*(reg16 *) PWM_DC_PWMHW__CAP0) #define PWM_DC_CAPTURE_LSB_PTR ( (reg16 *) PWM_DC_PWMHW__CAP0) #define PWM_DC_RT1 (*(reg8 *) PWM_DC_PWMHW__RT1) #define PWM_DC_RT1_PTR ( (reg8 *) PWM_DC_PWMHW__RT1) #else #if (PWM_DC_Resolution == 8u) /* 8bit - PWM */ #if(PWM_DC_PWMModeIsCenterAligned) #define PWM_DC_PERIOD_LSB (*(reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D1_REG) #define PWM_DC_PERIOD_LSB_PTR ((reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D1_REG) #else #define PWM_DC_PERIOD_LSB (*(reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__F0_REG) #define PWM_DC_PERIOD_LSB_PTR ((reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__F0_REG) #endif /* (PWM_DC_PWMModeIsCenterAligned) */ #define PWM_DC_COMPARE1_LSB (*(reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D0_REG) #define PWM_DC_COMPARE1_LSB_PTR ((reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D0_REG) #define PWM_DC_COMPARE2_LSB (*(reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D1_REG) #define PWM_DC_COMPARE2_LSB_PTR ((reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D1_REG) #define PWM_DC_COUNTERCAP_LSB (*(reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__A1_REG) #define PWM_DC_COUNTERCAP_LSB_PTR ((reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__A1_REG) #define PWM_DC_COUNTER_LSB (*(reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__A0_REG) #define PWM_DC_COUNTER_LSB_PTR ((reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__A0_REG) #define PWM_DC_CAPTURE_LSB (*(reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__F1_REG) #define PWM_DC_CAPTURE_LSB_PTR ((reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__F1_REG) #else #if(CY_PSOC3) /* 8-bit address space */ #if(PWM_DC_PWMModeIsCenterAligned) #define PWM_DC_PERIOD_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D1_REG) #define PWM_DC_PERIOD_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D1_REG) #else #define PWM_DC_PERIOD_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__F0_REG) #define PWM_DC_PERIOD_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__F0_REG) #endif /* (PWM_DC_PWMModeIsCenterAligned) */ #define PWM_DC_COMPARE1_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D0_REG) #define PWM_DC_COMPARE1_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D0_REG) #define PWM_DC_COMPARE2_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D1_REG) #define PWM_DC_COMPARE2_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__D1_REG) #define PWM_DC_COUNTERCAP_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__A1_REG) #define PWM_DC_COUNTERCAP_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__A1_REG) #define PWM_DC_COUNTER_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__A0_REG) #define PWM_DC_COUNTER_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__A0_REG) #define PWM_DC_CAPTURE_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__F1_REG) #define PWM_DC_CAPTURE_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__F1_REG) #else #if(PWM_DC_PWMModeIsCenterAligned) #define PWM_DC_PERIOD_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_D1_REG) #define PWM_DC_PERIOD_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_D1_REG) #else #define PWM_DC_PERIOD_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_F0_REG) #define PWM_DC_PERIOD_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_F0_REG) #endif /* (PWM_DC_PWMModeIsCenterAligned) */ #define PWM_DC_COMPARE1_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_D0_REG) #define PWM_DC_COMPARE1_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_D0_REG) #define PWM_DC_COMPARE2_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_D1_REG) #define PWM_DC_COMPARE2_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_D1_REG) #define PWM_DC_COUNTERCAP_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_A1_REG) #define PWM_DC_COUNTERCAP_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_A1_REG) #define PWM_DC_COUNTER_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_A0_REG) #define PWM_DC_COUNTER_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_A0_REG) #define PWM_DC_CAPTURE_LSB (*(reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_F1_REG) #define PWM_DC_CAPTURE_LSB_PTR ((reg16 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__16BIT_F1_REG) #endif /* (CY_PSOC3) */ #define PWM_DC_AUX_CONTROLDP1 (*(reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u1__DP_AUX_CTL_REG) #define PWM_DC_AUX_CONTROLDP1_PTR ((reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u1__DP_AUX_CTL_REG) #endif /* (PWM_DC_Resolution == 8) */ #define PWM_DC_COUNTERCAP_LSB_PTR_8BIT ( (reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__A1_REG) #define PWM_DC_AUX_CONTROLDP0 (*(reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__DP_AUX_CTL_REG) #define PWM_DC_AUX_CONTROLDP0_PTR ((reg8 *) PWM_DC_PWMUDB_sP8_pwmdp_u0__DP_AUX_CTL_REG) #endif /* (PWM_DC_UsingFixedFunction) */ #if(PWM_DC_KillModeMinTime ) #define PWM_DC_KILLMODEMINTIME (*(reg8 *) PWM_DC_PWMUDB_sKM_killmodecounterdp_u0__D0_REG) #define PWM_DC_KILLMODEMINTIME_PTR ((reg8 *) PWM_DC_PWMUDB_sKM_killmodecounterdp_u0__D0_REG) /* Fixed Function Block has no Kill Mode parameters because it is Asynchronous only */ #endif /* (PWM_DC_KillModeMinTime ) */ #if(PWM_DC_DeadBandMode == PWM_DC__B_PWM__DBM_256_CLOCKS) #define PWM_DC_DEADBAND_COUNT (*(reg8 *) PWM_DC_PWMUDB_sDB255_deadbandcounterdp_u0__D0_REG) #define PWM_DC_DEADBAND_COUNT_PTR ((reg8 *) PWM_DC_PWMUDB_sDB255_deadbandcounterdp_u0__D0_REG) #define PWM_DC_DEADBAND_LSB_PTR ((reg8 *) PWM_DC_PWMUDB_sDB255_deadbandcounterdp_u0__A0_REG) #define PWM_DC_DEADBAND_LSB (*(reg8 *) PWM_DC_PWMUDB_sDB255_deadbandcounterdp_u0__A0_REG) #elif(PWM_DC_DeadBandMode == PWM_DC__B_PWM__DBM_2_4_CLOCKS) /* In Fixed Function Block these bits are in the control blocks control register */ #if (PWM_DC_UsingFixedFunction) #define PWM_DC_DEADBAND_COUNT (*(reg8 *) PWM_DC_PWMHW__CFG0) #define PWM_DC_DEADBAND_COUNT_PTR ((reg8 *) PWM_DC_PWMHW__CFG0) #define PWM_DC_DEADBAND_COUNT_MASK (uint8)((uint8)0x03u << PWM_DC_DEADBAND_COUNT_SHIFT) /* As defined by the Register Map as DEADBAND_PERIOD[1:0] in CFG0 */ #define PWM_DC_DEADBAND_COUNT_SHIFT (0x06u) #else /* Lower two bits of the added control register define the count 1-3 */ #define PWM_DC_DEADBAND_COUNT (*(reg8 *) PWM_DC_PWMUDB_genblk7_dbctrlreg__CONTROL_REG) #define PWM_DC_DEADBAND_COUNT_PTR ((reg8 *) PWM_DC_PWMUDB_genblk7_dbctrlreg__CONTROL_REG) #define PWM_DC_DEADBAND_COUNT_MASK (uint8)((uint8)0x03u << PWM_DC_DEADBAND_COUNT_SHIFT) /* As defined by the verilog implementation of the Control Register */ #define PWM_DC_DEADBAND_COUNT_SHIFT (0x00u) #endif /* (PWM_DC_UsingFixedFunction) */ #endif /* (PWM_DC_DeadBandMode == PWM_DC__B_PWM__DBM_256_CLOCKS) */ #if (PWM_DC_UsingFixedFunction) #define PWM_DC_STATUS (*(reg8 *) PWM_DC_PWMHW__SR0) #define PWM_DC_STATUS_PTR ((reg8 *) PWM_DC_PWMHW__SR0) #define PWM_DC_STATUS_MASK (*(reg8 *) PWM_DC_PWMHW__SR0) #define PWM_DC_STATUS_MASK_PTR ((reg8 *) PWM_DC_PWMHW__SR0) #define PWM_DC_CONTROL (*(reg8 *) PWM_DC_PWMHW__CFG0) #define PWM_DC_CONTROL_PTR ((reg8 *) PWM_DC_PWMHW__CFG0) #define PWM_DC_CONTROL2 (*(reg8 *) PWM_DC_PWMHW__CFG1) #define PWM_DC_CONTROL3 (*(reg8 *) PWM_DC_PWMHW__CFG2) #define PWM_DC_GLOBAL_ENABLE (*(reg8 *) PWM_DC_PWMHW__PM_ACT_CFG) #define PWM_DC_GLOBAL_ENABLE_PTR ( (reg8 *) PWM_DC_PWMHW__PM_ACT_CFG) #define PWM_DC_GLOBAL_STBY_ENABLE (*(reg8 *) PWM_DC_PWMHW__PM_STBY_CFG) #define PWM_DC_GLOBAL_STBY_ENABLE_PTR ( (reg8 *) PWM_DC_PWMHW__PM_STBY_CFG) /*********************************** * Constants ***********************************/ /* Fixed Function Block Chosen */ #define PWM_DC_BLOCK_EN_MASK (PWM_DC_PWMHW__PM_ACT_MSK) #define PWM_DC_BLOCK_STBY_EN_MASK (PWM_DC_PWMHW__PM_STBY_MSK) /* Control Register definitions */ #define PWM_DC_CTRL_ENABLE_SHIFT (0x00u) /* As defined by Register map as MODE_CFG bits in CFG2*/ #define PWM_DC_CTRL_CMPMODE1_SHIFT (0x04u) /* As defined by Register map */ #define PWM_DC_CTRL_DEAD_TIME_SHIFT (0x06u) /* Fixed Function Block Only CFG register bit definitions */ /* Set to compare mode */ #define PWM_DC_CFG0_MODE (0x02u) /* Enable the block to run */ #define PWM_DC_CFG0_ENABLE (0x01u) /* As defined by Register map as DB bit in CFG0 */ #define PWM_DC_CFG0_DB (0x20u) /* Control Register Bit Masks */ #define PWM_DC_CTRL_ENABLE (uint8)((uint8)0x01u << PWM_DC_CTRL_ENABLE_SHIFT) #define PWM_DC_CTRL_RESET (uint8)((uint8)0x01u << PWM_DC_CTRL_RESET_SHIFT) #define PWM_DC_CTRL_CMPMODE2_MASK (uint8)((uint8)0x07u << PWM_DC_CTRL_CMPMODE2_SHIFT) #define PWM_DC_CTRL_CMPMODE1_MASK (uint8)((uint8)0x07u << PWM_DC_CTRL_CMPMODE1_SHIFT) /* Control2 Register Bit Masks */ /* As defined in Register Map, Part of the TMRX_CFG1 register */ #define PWM_DC_CTRL2_IRQ_SEL_SHIFT (0x00u) #define PWM_DC_CTRL2_IRQ_SEL (uint8)((uint8)0x01u << PWM_DC_CTRL2_IRQ_SEL_SHIFT) /* Status Register Bit Locations */ /* As defined by Register map as TC in SR0 */ #define PWM_DC_STATUS_TC_SHIFT (0x07u) /* As defined by the Register map as CAP_CMP in SR0 */ #define PWM_DC_STATUS_CMP1_SHIFT (0x06u) /* Status Register Interrupt Enable Bit Locations */ #define PWM_DC_STATUS_KILL_INT_EN_MASK_SHIFT (0x00u) #define PWM_DC_STATUS_TC_INT_EN_MASK_SHIFT (PWM_DC_STATUS_TC_SHIFT - 4u) #define PWM_DC_STATUS_CMP2_INT_EN_MASK_SHIFT (0x00u) #define PWM_DC_STATUS_CMP1_INT_EN_MASK_SHIFT (PWM_DC_STATUS_CMP1_SHIFT - 4u) /* Status Register Bit Masks */ #define PWM_DC_STATUS_TC (uint8)((uint8)0x01u << PWM_DC_STATUS_TC_SHIFT) #define PWM_DC_STATUS_CMP1 (uint8)((uint8)0x01u << PWM_DC_STATUS_CMP1_SHIFT) /* Status Register Interrupt Bit Masks */ #define PWM_DC_STATUS_TC_INT_EN_MASK (uint8)((uint8)PWM_DC_STATUS_TC >> 4u) #define PWM_DC_STATUS_CMP1_INT_EN_MASK (uint8)((uint8)PWM_DC_STATUS_CMP1 >> 4u) /*RT1 Synch Constants */ #define PWM_DC_RT1_SHIFT (0x04u) /* Sync TC and CMP bit masks */ #define PWM_DC_RT1_MASK (uint8)((uint8)0x03u << PWM_DC_RT1_SHIFT) #define PWM_DC_SYNC (uint8)((uint8)0x03u << PWM_DC_RT1_SHIFT) #define PWM_DC_SYNCDSI_SHIFT (0x00u) /* Sync all DSI inputs */ #define PWM_DC_SYNCDSI_MASK (uint8)((uint8)0x0Fu << PWM_DC_SYNCDSI_SHIFT) /* Sync all DSI inputs */ #define PWM_DC_SYNCDSI_EN (uint8)((uint8)0x0Fu << PWM_DC_SYNCDSI_SHIFT) #else #define PWM_DC_STATUS (*(reg8 *) PWM_DC_PWMUDB_genblk8_stsreg__STATUS_REG ) #define PWM_DC_STATUS_PTR ((reg8 *) PWM_DC_PWMUDB_genblk8_stsreg__STATUS_REG ) #define PWM_DC_STATUS_MASK (*(reg8 *) PWM_DC_PWMUDB_genblk8_stsreg__MASK_REG) #define PWM_DC_STATUS_MASK_PTR ((reg8 *) PWM_DC_PWMUDB_genblk8_stsreg__MASK_REG) #define PWM_DC_STATUS_AUX_CTRL (*(reg8 *) PWM_DC_PWMUDB_genblk8_stsreg__STATUS_AUX_CTL_REG) #define PWM_DC_CONTROL (*(reg8 *) PWM_DC_PWMUDB_genblk1_ctrlreg__CONTROL_REG) #define PWM_DC_CONTROL_PTR ((reg8 *) PWM_DC_PWMUDB_genblk1_ctrlreg__CONTROL_REG) /*********************************** * Constants ***********************************/ /* Control Register bit definitions */ #define PWM_DC_CTRL_ENABLE_SHIFT (0x07u) #define PWM_DC_CTRL_RESET_SHIFT (0x06u) #define PWM_DC_CTRL_CMPMODE2_SHIFT (0x03u) #define PWM_DC_CTRL_CMPMODE1_SHIFT (0x00u) #define PWM_DC_CTRL_DEAD_TIME_SHIFT (0x00u) /* No Shift Needed for UDB block */ /* Control Register Bit Masks */ #define PWM_DC_CTRL_ENABLE (uint8)((uint8)0x01u << PWM_DC_CTRL_ENABLE_SHIFT) #define PWM_DC_CTRL_RESET (uint8)((uint8)0x01u << PWM_DC_CTRL_RESET_SHIFT) #define PWM_DC_CTRL_CMPMODE2_MASK (uint8)((uint8)0x07u << PWM_DC_CTRL_CMPMODE2_SHIFT) #define PWM_DC_CTRL_CMPMODE1_MASK (uint8)((uint8)0x07u << PWM_DC_CTRL_CMPMODE1_SHIFT) /* Status Register Bit Locations */ #define PWM_DC_STATUS_KILL_SHIFT (0x05u) #define PWM_DC_STATUS_FIFONEMPTY_SHIFT (0x04u) #define PWM_DC_STATUS_FIFOFULL_SHIFT (0x03u) #define PWM_DC_STATUS_TC_SHIFT (0x02u) #define PWM_DC_STATUS_CMP2_SHIFT (0x01u) #define PWM_DC_STATUS_CMP1_SHIFT (0x00u) /* Status Register Interrupt Enable Bit Locations - UDB Status Interrupt Mask match Status Bit Locations*/ #define PWM_DC_STATUS_KILL_INT_EN_MASK_SHIFT (PWM_DC_STATUS_KILL_SHIFT) #define PWM_DC_STATUS_FIFONEMPTY_INT_EN_MASK_SHIFT (PWM_DC_STATUS_FIFONEMPTY_SHIFT) #define PWM_DC_STATUS_FIFOFULL_INT_EN_MASK_SHIFT (PWM_DC_STATUS_FIFOFULL_SHIFT) #define PWM_DC_STATUS_TC_INT_EN_MASK_SHIFT (PWM_DC_STATUS_TC_SHIFT) #define PWM_DC_STATUS_CMP2_INT_EN_MASK_SHIFT (PWM_DC_STATUS_CMP2_SHIFT) #define PWM_DC_STATUS_CMP1_INT_EN_MASK_SHIFT (PWM_DC_STATUS_CMP1_SHIFT) /* Status Register Bit Masks */ #define PWM_DC_STATUS_KILL (uint8)((uint8)0x00u << PWM_DC_STATUS_KILL_SHIFT ) #define PWM_DC_STATUS_FIFOFULL (uint8)((uint8)0x01u << PWM_DC_STATUS_FIFOFULL_SHIFT) #define PWM_DC_STATUS_FIFONEMPTY (uint8)((uint8)0x01u << PWM_DC_STATUS_FIFONEMPTY_SHIFT) #define PWM_DC_STATUS_TC (uint8)((uint8)0x01u << PWM_DC_STATUS_TC_SHIFT) #define PWM_DC_STATUS_CMP2 (uint8)((uint8)0x01u << PWM_DC_STATUS_CMP2_SHIFT) #define PWM_DC_STATUS_CMP1 (uint8)((uint8)0x01u << PWM_DC_STATUS_CMP1_SHIFT) /* Status Register Interrupt Bit Masks - UDB Status Interrupt Mask match Status Bit Locations */ #define PWM_DC_STATUS_KILL_INT_EN_MASK (PWM_DC_STATUS_KILL) #define PWM_DC_STATUS_FIFOFULL_INT_EN_MASK (PWM_DC_STATUS_FIFOFULL) #define PWM_DC_STATUS_FIFONEMPTY_INT_EN_MASK (PWM_DC_STATUS_FIFONEMPTY) #define PWM_DC_STATUS_TC_INT_EN_MASK (PWM_DC_STATUS_TC) #define PWM_DC_STATUS_CMP2_INT_EN_MASK (PWM_DC_STATUS_CMP2) #define PWM_DC_STATUS_CMP1_INT_EN_MASK (PWM_DC_STATUS_CMP1) /* Datapath Auxillary Control Register bit definitions */ #define PWM_DC_AUX_CTRL_FIFO0_CLR (0x01u) #define PWM_DC_AUX_CTRL_FIFO1_CLR (0x02u) #define PWM_DC_AUX_CTRL_FIFO0_LVL (0x04u) #define PWM_DC_AUX_CTRL_FIFO1_LVL (0x08u) #define PWM_DC_STATUS_ACTL_INT_EN_MASK (0x10u) /* As defined for the ACTL Register */ #endif /* PWM_DC_UsingFixedFunction */ #endif /* CY_PWM_PWM_DC_H */ /* [] END OF FILE */
f7df1a2becee8c8282284f161fd5efa2412874dd
15c3d76b08e1ee39f5fa923463a3966d42e2df04
/UVA/11192.c
4d7b77f5d77b62d1b2b223356566ed521f276294
[]
no_license
mdfaizulislam/UVa
814ebb5b40adcf8ff3ce73834c58833e71a12107
bdaf0e05d56659e76c5ad6b7c9bb97c2a733294b
refs/heads/master
2020-03-12T05:48:05.457772
2018-04-21T13:02:28
2018-04-21T13:02:28
null
0
0
null
null
null
null
UTF-8
C
false
false
534
c
11192.c
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int G, l, check, mul, i, j, n; char ca[102]; while( scanf("%d",&G) ) { if( G == 0 ) return 0; scanf("%s",ca); l=strlen(ca); n=l/G; check=0; for( i = 1 ; i <= G ; i++ ) { mul=i*n; for( j = mul-1; j >= check; j-- ) printf("%c",ca[j]); check=mul; } printf("\n"); } return 0; }
e96361f76f12ad5b82a7336f5e58e07ca8a7a83e
e3706b7bb343deaf0fe59221de64f520a7260826
/else/Rush02/workspace/checkingbefore/ft.h
92a9c97246355d533f68315ff2de362c9aeaef62
[]
no_license
acastanome/Basecamp_42
db8e43e229f9e5bb806d33b17c770b2d7779cc60
c88671d138a89850136fcf5756a8dc17a39ae9c6
refs/heads/main
2023-06-01T23:45:26.181643
2021-06-17T22:30:43
2021-06-17T22:30:43
377,966,210
0
0
null
null
null
null
UTF-8
C
false
false
1,346
h
ft.h
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: acastano <acastano@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/06/12 11:21:37 by acastano #+# #+# */ /* Updated: 2021/06/13 18:01:19 by acastano ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef FT_H # define FT_H #include <stdlib.h> // for malloc #include <unistd.h> //for write in putchar char *rush(int a, int b); //for rushes void ft_putchar(char c); //for rushes void ft_putstr(char *str); void ft_putnbr(int nb); int *what_dimensions(char *str); char *ft_read(int fd); int ft_strcmp(char *s1, char *s2); #endif /* check_valid check duplicate inputs rush00 rush00 int ft_errors(int argc, char **argv); void print(char **arr); */
0b3627eca24c77d4da11d5a8422470da06475fcb
5decfc5457d129e969702b3478978f38725bd303
/I2C/lcfu___i2c_smbus_write_block_data.c
bd56fb0e4e6501638823847ad67e5daa1592ac8a
[ "BSD-2-Clause" ]
permissive
rpoisel/lc3-lib
21a256e27ba6a65c7368afe4bf7d94384cde8d39
ce49ca19eea007303e7a691fdaa65ffbc831f876
refs/heads/master
2021-01-18T19:09:51.288448
2017-04-10T21:22:44
2017-04-10T21:52:39
86,889,696
0
1
null
null
null
null
UTF-8
C
false
false
765
c
lcfu___i2c_smbus_write_block_data.c
#ifndef LC_PROT_LCFU___I2C_SMBUS_WRITE_BLOCK_DATA__C #define LC_PROT_LCFU___I2C_SMBUS_WRITE_BLOCK_DATA__C #define DEBUG 1 #include "i2c-dev.h" #if DEBUG==1 #include <stdio.h> #endif #include <lcfu___i2c_smbus_write_block_data.h> /* Functions */ void lcfu___I2C_SMBUS_WRITE_BLOCK_DATA(LC_TD_Function_I2C_SMBUS_WRITE_BLOCK_DATA* LC_this, LC_TD_DINT LC_VD_FD, LC_TD_USINT LC_VD_COMMAND, LC_TD_USINT LC_VD_LEN, LC_TD_USINT LC_VD_VALUES[34], struct _lcoplck_epdb_1_impl* pEPDB) { LC_this->LC_VD_I2C_SMBUS_WRITE_BLOCK_DATA = i2c_smbus_write_i2c_block_data(LC_VD_FD, LC_VD_COMMAND, LC_VD_LEN, LC_VD_VALUES); #if DEBUG==1 printf("i2c_smbus_write_block_data(%d, 0x%02X)\n", LC_VD_FD, LC_VD_COMMAND); #endif } #endif
9ec5a17a5e62cac88faa4b55bf3d28f19ccbbf7f
cadc6795fa3feb7cb21be8ba40e1f6187af984c0
/sh1.c
186bd959fd25472875b9462a09067be38beba5a0
[]
no_license
reisec45/hutsu_linux
f0fbb9339b1b92c66a8f521648e71c6f1c520493
2c2c6328c6505783c639b70c193efd863572337f
refs/heads/master
2022-12-17T21:27:26.690668
2020-09-27T06:21:48
2020-09-27T06:21:48
null
0
0
null
null
null
null
UTF-8
C
false
false
1,880
c
sh1.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <sys/types.h> #include <sys/wait.h> typedef struct cmd { int argc; char** argv; int capa; } cmd; cmd* parse_cmd(char *buf); void invoke_cmd(cmd* cmd); void free_cmd(cmd* cmd); void do_sh(void); int main(int argc, char* argv[]) { if (argc != 1) { fprintf(stderr, "Usage: %s", argv[0]); } do_sh(); } void do_sh(void) { char buf[2048]; for (;;) { printf("$ "); if (fgets(buf, sizeof(buf), stdin) == NULL) exit(0); cmd* cmd; //printf("run parse_cmd\n"); cmd = parse_cmd(buf); //printf("parsed\n"); if (cmd->argc > 0) { invoke_cmd(cmd); } free_cmd(cmd); } exit(0); } #define INIT_CAPA 16 cmd* parse_cmd(char* buf) { char *p = buf; cmd* cmd; cmd = malloc(sizeof(cmd)); if (!cmd) { perror("malloc"); exit(1); } cmd->argc = 0; cmd->argv = (char **)malloc(sizeof(char*) * INIT_CAPA); cmd->capa = INIT_CAPA; if (!cmd->argv) { perror("malloc"); exit(1); } while(*p) { while (*p && isspace(*p)) { *p++ = '\0'; } if (*p) { if (cmd->capa <= cmd->argc + 1) { cmd->argc *= 2; cmd->argv = realloc(cmd->argv, sizeof(char*) * cmd->capa); if (!cmd->argv) { perror("realloc"); exit(1); } } cmd->argv[cmd->argc] = p++; cmd->argc++; } while (*p && !isspace(*p)) { p++; } } cmd->argv[cmd->argc] = NULL; return cmd; } void invoke_cmd(cmd* cmd) { pid_t pid; pid = fork(); if (pid < 0) { fprintf(stderr, "fork(2) failed\n"); exit(1); } if (pid == 0) { execvp(cmd->argv[0], cmd->argv); perror(cmd->argv[0]); exit(1); } else { waitpid(pid, NULL, 0); } } void free_cmd(cmd* cmd) { free(cmd->argv); free(cmd); }
09f5db6363530d96a6866cebb56b22330c8ac769
0be575927b498a6ad870b7bf5fccf551e9616b5c
/include/port.h
96b24eaa9482d98448cac7d5a58b8b7aeb1d0cb1
[ "MIT" ]
permissive
lemunozm/atmega328p-tetrix
384e27f9aeb1a3d36f82258387dda643f8f0b497
0848fd6cee3b2e179a75783a6166b41ae5df9b3e
refs/heads/master
2020-03-18T13:49:50.889357
2020-01-24T17:02:37
2020-01-24T17:02:37
134,812,082
0
0
null
null
null
null
UTF-8
C
false
false
339
h
port.h
#ifndef _SDK_PORT_H_ #define _SDK_PORT_H_ #include <stdint.h> #define PORT_OUTPUT 0B11111111 #define PORT_INPUT 0B00000000 #define PORT_0 0 //Port D #define PORT_1 1 //Port B void port_mode(uint8_t port, uint8_t dir); void digital_port_out(uint8_t port, uint8_t value); uint8_t digital_port_in(uint8_t port); #endif // _SDK_PORT_H_
e5158ad59f1b2d746d040517fadebba0058d966f
3dfb563c5de4ebcc615e831416c91db9d9f6bf21
/Question6.h
0a991459b18979825f1c6d58ba4e3f01505bdab5
[]
no_license
TommyTranX/Netflix_Recommandation
2d0407a752b232883352fc4bba86d4b612d953da
c514870beccae555545fae160580ba579d4a5b0a
refs/heads/master
2020-08-28T12:36:53.212838
2019-10-26T11:58:51
2019-10-26T11:58:51
217,702,087
0
0
null
null
null
null
UTF-8
C
false
false
114
h
Question6.h
#ifndef QUESTION6_H #define QUESTION6_H double ErrorComputation(Cell* Users[], int length, int k); #endif
ab4e5bca19e75609a9a271831dc1ec0d3f8fd8de
b10765cde29db1f6e035e88e45523d0c4d65a13e
/src/main.c
fb5b20b89756d6a549455b3a6acf5ec4a7357383
[]
no_license
rip1ey/chip8-emu
86f46bdf5d09491e551e783d1c1500b5e6bd2730
25752d01b8d0c29ce9daa21249796767c5def222
refs/heads/master
2023-03-03T20:56:41.323716
2021-02-17T19:49:05
2021-02-17T19:49:05
226,470,622
0
0
null
null
null
null
UTF-8
C
false
false
5,794
c
main.c
#include <SDL2/SDL.h> #include "chip8.h" #define SCALE 20 #define WINDOW_WIDTH WIDTH * SCALE #define WINDOW_HEIGHT HEIGHT * SCALE void draw_frame(SDL_Renderer **renderer, SDL_Rect *rect, chip8 *chip) { rect->w = SCALE; rect->h = SCALE; SDL_SetRenderDrawColor(*renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); SDL_RenderClear(*renderer); for(int y = 0; y < HEIGHT; y++) { for(int x = 0; x < WIDTH; x++) { if(chip->graphics[x][y]) { SDL_SetRenderDrawColor(*renderer, 255, 255, 255, SDL_ALPHA_OPAQUE); rect->x = x * SCALE; rect->y = y * SCALE; SDL_RenderFillRect(*renderer, rect); } } } SDL_RenderPresent(*renderer); } int register_input(SDL_Event *ev, chip8 *chip) { while(SDL_PollEvent(ev)) { if(ev->type == SDL_QUIT) { return 1; } else if(ev->type == SDL_KEYDOWN) { switch(ev->key.keysym.sym) { case SDLK_1: chip->keypad[0] = 1; break; case SDLK_2: chip->keypad[1] = 1; break; case SDLK_3: chip->keypad[2] = 1; break; case SDLK_4: chip->keypad[3] = 1; break; case SDLK_q: chip->keypad[4] = 1; break; case SDLK_w: chip->keypad[5] = 1; break; case SDLK_e: chip->keypad[6] = 1; break; case SDLK_r: chip->keypad[7] = 1; break; case SDLK_a: chip->keypad[8] = 1; break; case SDLK_s: chip->keypad[9] = 1; break; case SDLK_d: chip->keypad[10] = 1; break; case SDLK_f: chip->keypad[11] = 1; break; case SDLK_z: chip->keypad[12] = 1; break; case SDLK_x: chip->keypad[13] = 1; break; case SDLK_c: chip->keypad[14] = 1; break; case SDLK_v: chip->keypad[15] = 1; break; } } else if(ev->type == SDL_KEYUP) { switch(ev->key.keysym.sym) { case SDLK_1: chip->keypad[0] = 0; break; case SDLK_2: chip->keypad[1] = 0; break; case SDLK_3: chip->keypad[2] = 0; break; case SDLK_4: chip->keypad[3] = 0; break; case SDLK_q: chip->keypad[4] = 0; break; case SDLK_w: chip->keypad[5] = 0; break; case SDLK_e: chip->keypad[6] = 0; break; case SDLK_r: chip->keypad[7] = 0; break; case SDLK_a: chip->keypad[8] = 0; break; case SDLK_s: chip->keypad[9] = 0; break; case SDLK_d: chip->keypad[10] = 0; break; case SDLK_f: chip->keypad[11] = 0; break; case SDLK_z: chip->keypad[12] = 0; break; case SDLK_x: chip->keypad[13] = 0; break; case SDLK_c: chip->keypad[14] = 0; break; case SDLK_v: chip->keypad[15] = 0; break; } } } return 0; } void dec_timers(chip8 *chip) { if(chip->sound_timer > 0) { chip->sound_timer--; } if(chip->delay_timer > 0) { chip->delay_timer--; } } int sdl_setup(SDL_Window **window, SDL_Renderer **renderer) { if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) { SDL_Log("Failed to initialize SDL: %s\n", SDL_GetError()); return -1; } *window = SDL_CreateWindow("Chip8 Emu", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI); if(*window == NULL) { SDL_Log("Failed to create window: %s\n", SDL_GetError()); SDL_Quit(); return -1; } *renderer = SDL_CreateRenderer(*window, -1, SDL_RENDERER_ACCELERATED); if(*renderer == NULL) { SDL_Log("Failed to create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(*window); SDL_Quit(); return -1; } if(SDL_RenderSetLogicalSize(*renderer, WINDOW_WIDTH, WINDOW_HEIGHT) < 0) { SDL_Log("Failed to set proper renderer size: %s\n", SDL_GetError()); SDL_DestroyWindow(*window); SDL_DestroyRenderer(*renderer); SDL_Quit(); return -1; } return 0; } int main(int argc, char *argv[]) { chip8 chip; int exit_chip8 = 0; if(argc != 2) { print_emu_usage(); } SDL_Event ev; SDL_Rect rect; SDL_Window *window; SDL_Renderer *renderer; SDL_Texture *texture; if(sdl_setup(&window, &renderer) < 0) { printf("SDL could not be initialized\n"); return -1; } init_chip8_state(&chip); load_rom(argv[1], &chip); srand(time(0)); // cuts down on the giant switch statement void (*func_arr[])(uint16_t, chip8*) = { exec_0_op, exec_1_op, exec_2_op, exec_3_op, exec_4_op, exec_5_op, exec_6_op, exec_7_op, exec_8_op, exec_9_op, exec_A_op, exec_B_op, exec_C_op, exec_D_op, exec_E_op, exec_F_op, }; exit_chip8 = 0; while(!exit_chip8) { for(int cycle = 0; cycle < 11; cycle++) { uint8_t nibble = chip.memory[chip.pc] >> 4; uint16_t inst = chip.memory[chip.pc] << 8 | chip.memory[chip.pc + 1]; printf("PC: 0x%04X, OP: 0x%04X\n", chip.pc, inst); func_arr[nibble](inst, &chip); exit_chip8 = register_input(&ev, &chip); if(exit_chip8) { break; } } dec_timers(&chip); draw_frame(&renderer, &rect, &chip); } SDL_DestroyWindow(window); SDL_DestroyRenderer(renderer); SDL_Quit(); }
6c4563472eb019a3ea9ac2663b25318007694a72
a63e59aa897f429328ef1423e47e7e4a1a03cded
/camera.c
5153539cce3a26478e86222f20b73f88a48c9cc5
[]
no_license
FelixKHWong/SecurityCamera
f079d94a7cd2e7c26a6cd631f85a4add20e7e8da
68fb07617a5dbfbb6a1b814aa913da429d5977fd
refs/heads/master
2020-12-13T13:19:25.483544
2020-01-16T23:18:44
2020-01-16T23:18:44
234,429,734
0
0
null
null
null
null
UTF-8
C
false
false
31,834
c
camera.c
#include <stdlib.h> #include <stdio.h> #include "bcm_host.h" #include "interface/vcos/vcos.h" #include "interface/mmal/mmal.h" #include "interface/mmal/mmal_logging.h" #include "interface/mmal/mmal_buffer.h" #include "interface/mmal/util/mmal_util.h" #include "interface/mmal/util/mmal_util_params.h" #include "interface/mmal/util/mmal_default_components.h" #include "interface/mmal/util/mmal_connection.h" #include "interface/mmal/mmal_parameters_camera.h" #include "RaspiCommonSettings.h" #include "RaspiCamControl.h" #include "RaspiCLI.h" #include "RaspiTex.h" #include "RaspiHelpers.h" #include "RaspiGPS.h" #include "RaspiPreview.h" #include <semaphore.h> #include <math.h> #include <pthread.h> #include <time.h> #include <string.h> #include <ctype.h> #define MMAL_CAMERA_PREVIEW_PORT 0 #define MMAL_CAMERA_VIDEO_PORT 1 #define MMAL_CAMERA_CAPTURE_PORT 2 //stills format info //0 implies variable #define STILLS_FRAME_RATE_NUM 0 #define STILLS_FRAME_RATE_DEN 1 //preview frame rate #define PREVIEW_FRAME_RATE_NUM 0 #define PREVIEW_FRAME_RATE_DEN 1 /// Video render needs at least 2 buffers. #define VIDEO_OUTPUT_BUFFERS_NUM 3 #define MAX_USER_EXIF_TAGS 32 #define MAX_EXIF_PAYLOAD_LENGTH 128 #define EX_OK 0 #define EX_SOFTWARE 70 /// Amount of time before first image taken to allow settling of /// exposure etc. in milliseconds. #define CAMERA_SETTLE_TIME 1000 //central hub of data and parameters typedef struct { RASPICOMMONSETTINGS_PARAMETERS common_settings; /// Common settings int timeout; /// Time taken before frame is grabbed and app then shuts down. Units are milliseconds char *linkname; /// filename of output file int frameStart; /// First number of frame output counter MMAL_FOURCC_T encoding; /// Encoding to use for the output file. //const char *exifTags[MAX_USER_EXIF_TAGS]; /// Array of pointers to tags supplied from the command line int numExifTags; /// Number of supplied tags int enableExifTags; /// Enable/Disable EXIF tags in output int frameNextMethod; /// Which method to use to advance to next frame RASPIPREVIEW_PARAMETERS preview_parameters; /// Preview setup parameters RASPICAM_CAMERA_PARAMETERS camera_parameters; /// Camera setup parameters MMAL_COMPONENT_T *camera_component; /// Pointer to the camera component MMAL_COMPONENT_T *encoder_component; /// Pointer to the encoder component MMAL_CONNECTION_T *preview_connection; /// Pointer to the connection from camera to preview MMAL_CONNECTION_T *encoder_connection; /// Pointer to the connection from camera to encode MMAL_POOL_T *encoder_pool; /// Pointer to the pool of buffers used by encoder output port }RASPISTILL_STATE; /** Struct used to pass information in encoder port userdata to callback */ typedef struct { FILE *file_handle; /// File handle to write buffer data to. VCOS_SEMAPHORE_T complete_semaphore; /// semaphore which is posted when we reach end of frame (indicates end of capture or fault) RASPISTILL_STATE *pstate; /// pointer to our state in case required in callback } PORT_USERDATA; //camera commands enum { FRAME_NEXT_SINGLE, FRAME_NEXT_TIMELAPSE, FRAME_NEXT_KEYPRESS, FRAME_NEXT_FOREVER, FRAME_NEXT_GPIO, FRAME_NEXT_SIGNAL, FRAME_NEXT_IMMEDIATELY }; /** * Assign a default set of parameters to the state passed in * * @param state Pointer to state structure to assign defaults to */ static void default_status(RASPISTILL_STATE *state) { if (!state) { vcos_assert(0); return; } memset(state, 0, sizeof(*state)); raspicommonsettings_set_defaults(&state->common_settings); state->timeout = -1; // replaced with 5000ms later if unset state->linkname = NULL; state->frameStart = 0; state->camera_component = NULL; state->encoder_component = NULL; state->preview_connection = NULL; state->encoder_connection = NULL; state->encoder_pool = NULL; state->encoding = MMAL_ENCODING_JPEG; state->frameNextMethod = FRAME_NEXT_SINGLE; state->numExifTags = 0; state->enableExifTags = 1; // Setup preview window defaults raspipreview_set_defaults(&state->preview_parameters); // Set up the camera_parameters to default raspicamcontrol_set_defaults(&state->camera_parameters); } static int wait_for_frame(RASPISTILL_STATE *state, int *frame) { static int64_t complete_time = -1; int keep_running = 1; int64_t current_time = get_microseconds64()/1000; if (complete_time == -1) { complete_time = current_time + state->timeout; } //if timeout == 0 then continue if(current_time >= complete_time && state->timeout != 0) { keep_running = 0; } //for development for the option to be frame next single state->frameNextMethod = FRAME_NEXT_SINGLE; switch (state->frameNextMethod) { case FRAME_NEXT_SINGLE : // simple timeout for a single capture vcos_sleep(state->timeout); return 0; case FRAME_NEXT_KEYPRESS : { int ch; if (state->common_settings.verbose) fprintf(stderr, "Press Enter to capture, X then ENTER to exit\n"); ch = getchar(); //will wait forever? *frame+=1; if (ch == 'x' || ch == 'X') return 0; else { return keep_running; } } case FRAME_NEXT_IMMEDIATELY : { // Not waiting, just go to next frame. // Actually, we do need a slight delay here otherwise exposure goes // badly wrong since we never allow it frames to work it out // This could probably be tuned down. // First frame has a much longer delay to ensure we get exposure to a steady state if (*frame == 0) vcos_sleep(CAMERA_SETTLE_TIME); else vcos_sleep(30); *frame+=1; return keep_running; } case FRAME_NEXT_GPIO : { // Intended for GPIO firing of a capture return 0; } case FRAME_NEXT_SIGNAL : { // Need to wait for a SIGUSR1 or SIGUSR2 signal sigset_t waitset; int sig; int result = 0; sigemptyset( &waitset ); sigaddset( &waitset, SIGUSR1 ); sigaddset( &waitset, SIGUSR2 ); // We are multi threaded because we use mmal, so need to use the pthread // variant of procmask to block until a SIGUSR1 or SIGUSR2 signal appears pthread_sigmask( SIG_BLOCK, &waitset, NULL ); if (state->common_settings.verbose) { fprintf(stderr, "Waiting for SIGUSR1 to initiate capture and continue or SIGUSR2 to capture and exit\n"); } result = sigwait( &waitset, &sig ); if (result == 0) { if (sig == SIGUSR1) { if (state->common_settings.verbose) fprintf(stderr, "Received SIGUSR1\n"); } else if (sig == SIGUSR2) { if (state->common_settings.verbose) fprintf(stderr, "Received SIGUSR2\n"); keep_running = 0; } } else { if (state->common_settings.verbose) fprintf(stderr, "Bad signal received - error %d\n", errno); } *frame+=1; return keep_running; } } // end of switch // Should have returned by now, but default to timeout return keep_running; } /** * Allocates and generates a filename based on the * user-supplied pattern and the frame number. * On successful return, finalName and tempName point to malloc()ed strings * which must be freed externally. (On failure, returns nulls that * don't need free()ing.) * * @param finalName pointer receives an * @param pattern sprintf pattern with %d to be replaced by frame * @param frame for timelapse, the frame number * @return Returns a MMAL_STATUS_T giving result of operation */ MMAL_STATUS_T name_photo(char** finalName, char** tempName, char * pattern, int frame) { *finalName = NULL; *tempName = NULL; if (0 > asprintf(finalName, pattern, frame) || 0 > asprintf(tempName, "%s~", *finalName)) { if (*finalName != NULL) { free(*finalName); } return MMAL_ENOMEM; // It may be some other error, but it is not worth getting it right } return MMAL_SUCCESS; } //linked filename to data using gnu opeartions static void rename_file(RASPISTILL_STATE *state, FILE *output_file, const char *final_filename, const char *temp_filename, int frame) { MMAL_STATUS_T status; fclose(output_file); vcos_assert(temp_filename != NULL && final_filename != NULL); if (0 != rename(temp_filename, final_filename)) { vcos_log_error("Could not rename temp file to: %s; %s", final_filename,strerror(errno)); } if (state->linkname) { char *use_link; char *final_link; status = name_photo(&final_link, &use_link, state->linkname, frame); // Create hard link if possible, symlink otherwise if (status != MMAL_SUCCESS || (0 != link(final_filename, use_link) && 0 != symlink(final_filename, use_link)) || 0 != rename(use_link, final_link)) { vcos_log_error("Could not link as filename: %s; %s", state->linkname,strerror(errno)); } if (use_link) free(use_link); if (final_link) free(final_link); } } int open_filename(RASPISTILL_STATE *state, char *use_filename, char *final_filename, FILE *output_file, int frame, PORT_USERDATA callback_data) { // Open the file MMAL_STATUS_T status; vcos_assert(use_filename == NULL && final_filename == NULL); status = name_photo(&final_filename, &use_filename, state->common_settings.filename, frame); if (status != MMAL_SUCCESS) { vcos_log_error("Unable to create filenames"); //goto error; exit(1); } if (state->common_settings.verbose) fprintf(stderr, "Opening output file %s\n", final_filename); // Technically it is opening the temp~ filename which will be renamed to the final filename output_file = fopen(use_filename, "wb"); if (!output_file) { // Notify user, carry on but discarding encoded output buffers vcos_log_error("%s: Error opening output file: %s\nNo output file will be generated\n", __func__, use_filename); } callback_data.file_handle = output_file; } /** * Create the encoder component, set up its ports * * @param state Pointer to state control struct. encoder_component member set to the created camera_component if successful. * * @return a MMAL_STATUS, MMAL_SUCCESS if all OK, something else otherwise */ static MMAL_STATUS_T create_encoder_component(RASPISTILL_STATE *state) { MMAL_COMPONENT_T *encoder = 0; MMAL_PORT_T *encoder_input = NULL, *encoder_output = NULL; MMAL_STATUS_T status; MMAL_POOL_T *pool; status = mmal_component_create(MMAL_COMPONENT_DEFAULT_IMAGE_ENCODER, &encoder); if (status != MMAL_SUCCESS) { vcos_log_error("Unable to create JPEG encoder component"); goto error; } if (!encoder->input_num || !encoder->output_num) { status = MMAL_ENOSYS; vcos_log_error("JPEG encoder doesn't have input/output ports"); goto error; } encoder_input = encoder->input[0]; encoder_output = encoder->output[0]; // We want same format on input and output mmal_format_copy(encoder_output->format, encoder_input->format); // Specify out output format encoder_output->format->encoding = state->encoding; encoder_output->buffer_size = encoder_output->buffer_size_recommended; if (encoder_output->buffer_size < encoder_output->buffer_size_min) encoder_output->buffer_size = encoder_output->buffer_size_min; encoder_output->buffer_num = encoder_output->buffer_num_recommended; if (encoder_output->buffer_num < encoder_output->buffer_num_min) encoder_output->buffer_num = encoder_output->buffer_num_min; // Commit the port changes to the output port status = mmal_port_format_commit(encoder_output); if (status != MMAL_SUCCESS) { vcos_log_error("Unable to set format on video encoder output port"); goto error; } // Set the JPEG quality level //last value can be satte->quality but for simplicity use 50(on 1-100 scale) status = mmal_port_parameter_set_uint32(encoder_output, MMAL_PARAMETER_JPEG_Q_FACTOR, 50); if (status != MMAL_SUCCESS) { vcos_log_error("Unable to set JPEG quality"); goto error; } // Set the JPEG restart interval //not sure what restart_interval(last parameter) shoudl be, using 0 status = mmal_port_parameter_set_uint32(encoder_output, MMAL_PARAMETER_JPEG_RESTART_INTERVAL, 0); //if state->restart_interval != MMAL_SUCCESS if (0 && status != MMAL_SUCCESS) { vcos_log_error("Unable to set JPEG restart interval"); goto error; } // Enable component status = mmal_component_enable(encoder); if (status != MMAL_SUCCESS) { vcos_log_error("Unable to enable video encoder component"); goto error; } /* Create pool of buffer headers for the output port to consume */ pool = mmal_port_pool_create(encoder_output, encoder_output->buffer_num, encoder_output->buffer_size); if (!pool) { vcos_log_error("Failed to create buffer header pool for encoder output port %s", encoder_output->name); } state->encoder_pool = pool; state->encoder_component = encoder; if (state->common_settings.verbose) printf("Encoder component done\n"); return status; error: if (encoder) mmal_component_destroy(encoder); return status; } /** * Destroy the encoder component * * @param state Pointer to state control struct * */ static void destroy_encoder_component(RASPISTILL_STATE *state) { // Get rid of any port buffers first if (state->encoder_pool) { mmal_port_pool_destroy(state->encoder_component->output[0], state->encoder_pool); } if (state->encoder_component) { mmal_component_destroy(state->encoder_component); state->encoder_component = NULL; } } /** * buffer header callback function for encoder * * Callback will dump buffer data to the specific file * * @param port Pointer to port from which callback originated * @param buffer mmal buffer header pointer */ static void encoder_buffer_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer) { int complete = 0; // We pass our file handle and other stuff in via the userdata field. PORT_USERDATA *pData = (PORT_USERDATA *)port->userdata; if (pData) { int bytes_written = buffer->length; if (buffer->length && pData->file_handle) { mmal_buffer_header_mem_lock(buffer); bytes_written = fwrite(buffer->data, 1, buffer->length, pData->file_handle); mmal_buffer_header_mem_unlock(buffer); } // We need to check we wrote what we wanted - it's possible we have run out of storage. if (bytes_written != buffer->length) { vcos_log_error("Unable to write buffer to file - aborting"); complete = 1; } // Now flag if we have completed if (buffer->flags & (MMAL_BUFFER_HEADER_FLAG_FRAME_END | MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED)) complete = 1; } else { vcos_log_error("Received a encoder buffer callback with no state"); } // release buffer back to the pool mmal_buffer_header_release(buffer); // and send one back to the port (if still open) if (port->is_enabled) { MMAL_STATUS_T status = MMAL_SUCCESS; MMAL_BUFFER_HEADER_T *new_buffer; new_buffer = mmal_queue_get(pData->pstate->encoder_pool->queue); if (new_buffer) { status = mmal_port_send_buffer(port, new_buffer); } if (!new_buffer || status != MMAL_SUCCESS) vcos_log_error("Unable to return a buffer to the encoder port"); } if (complete) vcos_semaphore_post(&(pData->complete_semaphore)); } int create_camera_component(RASPISTILL_STATE *state) { MMAL_COMPONENT_T *camera = 0; MMAL_ES_FORMAT_T *format; MMAL_PORT_T *preview_port = NULL; MMAL_PORT_T *video_port = NULL; MMAL_PORT_T *still_port = NULL; MMAL_STATUS_T operation_status; //create the component operation_status = mmal_component_create(MMAL_COMPONENT_DEFAULT_CAMERA, &camera); if (operation_status != MMAL_SUCCESS) { printf("Unable to create camera component : error code : %d\n", operation_status ); exit(1); } //seems like I need the stereoscopic mode for good photos, possibility I don't need them. operation_status = raspicamcontrol_set_stereo_mode(camera->output[0], &state->camera_parameters.stereo_mode); operation_status += raspicamcontrol_set_stereo_mode(camera->output[1], &state->camera_parameters.stereo_mode); operation_status += raspicamcontrol_set_stereo_mode(camera->output[2], &state->camera_parameters.stereo_mode); if (operation_status != MMAL_SUCCESS) { vcos_log_error("Could not set stereo mode : error %d", operation_status); exit(1); //goto error; } MMAL_PARAMETER_INT32_T camera_num = {{MMAL_PARAMETER_CAMERA_NUM, sizeof(camera_num)}, state->common_settings.cameraNum}; operation_status = mmal_port_parameter_set(camera->control, &camera_num.hdr); if (operation_status != MMAL_SUCCESS) { vcos_log_error("Could not select camera : error %d", operation_status); exit(1); // goto error; } if (!camera->output_num) { operation_status = MMAL_ENOSYS; printf("Camera has no output ports\n"); exit(1); } //may want to set sensor mode for sport shot or night shot // operation_status = mmal_port_parameter_set_uint32(camera->control, MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG, state->common_settings.sensor_mode); // if (operation_status != MMAL_SUCCESS) // { // vcos_log_error("Could not set sensor mode : error %d", operation_status); // exit(1); // } //set up ports preview_port = camera->output[MMAL_CAMERA_PREVIEW_PORT]; //video_port = camera->output[MMAL_CAMERA_VIDEO_PORT]; still_port = camera->output[MMAL_CAMERA_CAPTURE_PORT]; //enabling camera and setup control callback function operation_status = mmal_port_enable(camera->control, default_camera_control_callback); if(operation_status != MMAL_SUCCESS) { printf("Error enabling control port: error code:%d \n Destroying camera",operation_status); mmal_component_destroy(camera); exit(1); } // set up the camera configuration MMAL_PARAMETER_CAMERA_CONFIG_T cam_config = { { MMAL_PARAMETER_CAMERA_CONFIG, sizeof(cam_config) }, .max_stills_w = state->common_settings.width, .max_stills_h = state->common_settings.height, .stills_yuv422 = 0, .one_shot_stills = 1, .max_preview_video_w = state->preview_parameters.previewWindow.width, .max_preview_video_h = state->preview_parameters.previewWindow.height, .num_preview_video_frames = 3, .stills_capture_circular_buffer_height = 0, .fast_preview_resume = 0, .use_stc_timestamp = MMAL_PARAM_TIMESTAMP_MODE_RESET_STC }; //since fullResPreview setting is ommitted preview will not be as nice as actual photo //mmal_port_parameter_set commits parameter changes to the port, //shoudl eb done to all ports(encoder, camera) when variables are being set mmal_port_parameter_set(camera->control, &cam_config.hdr); //apply the paramters raspicamcontrol_set_all_parameters(camera, &state->camera_parameters); //enable preview port operation_status = enable_port(&state, camera, preview_port); //enable still/photo operation_status = enable_port(&state, camera, still_port); /* Enable component */ operation_status = mmal_component_enable(camera); state->camera_component = camera; if (operation_status == MMAL_SUCCESS) fprintf(stderr, "Camera component done\n"); return operation_status; // error: // if (camera) // mmal_component_destroy(camera); // return status; } /** * Destroy the camera component * * @param state Pointer to state control struct * */ static void destroy_camera_component(RASPISTILL_STATE *state) { if (state->camera_component) { mmal_component_destroy(state->camera_component); state->camera_component = NULL; } } int enable_port(RASPISTILL_STATE *state, MMAL_COMPONENT_T *camera, MMAL_PORT_T *port) { MMAL_STATUS_T status; MMAL_ES_FORMAT_T *format; format = port->format; if(state->camera_parameters.shutter_speed > 6000000) { MMAL_PARAMETER_FPS_RANGE_T fps_range = {{MMAL_PARAMETER_FPS_RANGE, sizeof(fps_range)}, { 50, 1000 }, {166, 1000} }; mmal_port_parameter_set(port, &fps_range.hdr); } else if(state->camera_parameters.shutter_speed > 1000000) { MMAL_PARAMETER_FPS_RANGE_T fps_range = {{MMAL_PARAMETER_FPS_RANGE, sizeof(fps_range)}, { 166, 1000 }, {999, 1000} }; mmal_port_parameter_set(port, &fps_range.hdr); } // could use Fullrespreview but more frames is betterUse a full FOV 4:3 mode if(port == camera->output[MMAL_CAMERA_PREVIEW_PORT]) { format->encoding = MMAL_ENCODING_OPAQUE; format->encoding_variant = MMAL_ENCODING_I420; format->es->video.width = VCOS_ALIGN_UP(state->preview_parameters.previewWindow.width, 32); format->es->video.height = VCOS_ALIGN_UP(state->preview_parameters.previewWindow.height, 16); format->es->video.crop.x = 0; format->es->video.crop.y = 0; format->es->video.crop.width = state->preview_parameters.previewWindow.width; format->es->video.crop.height = state->preview_parameters.previewWindow.height; format->es->video.frame_rate.num = PREVIEW_FRAME_RATE_NUM; format->es->video.frame_rate.den = PREVIEW_FRAME_RATE_DEN; status = mmal_port_format_commit(port); if (status != MMAL_SUCCESS) { vcos_log_error("camera viewfinder format couldn't be set"); goto error; } else { fprintf(stderr, "Created Preview component\n"); } } else if(port == camera->output[MMAL_CAMERA_CAPTURE_PORT]) { //for some reason using the preview parameters works but not the common settings ones format->es->video.width = VCOS_ALIGN_UP(state->preview_parameters.previewWindow.width, 32); format->es->video.height = VCOS_ALIGN_UP(state->preview_parameters.previewWindow.height, 16); // format->es->video.width = VCOS_ALIGN_UP(state->common_settings.width, 32); // format->es->video.height = VCOS_ALIGN_UP(state->common_settings.height, 16); format->es->video.crop.x = 0; format->es->video.crop.y = 0; // format->es->video.crop.width = state->common_settings.width; // format->es->video.crop.height = state->common_settings.height; format->es->video.crop.width = state->preview_parameters.previewWindow.width; format->es->video.crop.height = state->preview_parameters.previewWindow.height; format->es->video.frame_rate.num = STILLS_FRAME_RATE_NUM; format->es->video.frame_rate.den = STILLS_FRAME_RATE_DEN; status = mmal_port_format_commit(port); if (port->buffer_num < VIDEO_OUTPUT_BUFFERS_NUM) port->buffer_num = VIDEO_OUTPUT_BUFFERS_NUM; if (status != MMAL_SUCCESS) { vcos_log_error("camera still format couldn't be set"); goto error; } } return 0; error: if (camera) mmal_component_destroy(camera); return status; } //might not work tbh // int take_single_photo(MMAL_STATUS_T operation_status, MMAL_PORT_T *still_port) // { // //capture // operation_status = mmal_port_parameter_set_boolean(still_port, MMAL_PARAMETER_CAPTURE, 1); // if (operation_status != MMAL_SUCCESS) // { // fprintf(stderr, "Failed to capture\n"); // exit(1); // } // fprintf(stderr, "camera initialized, picture taken?"); // char file_name[10] = "photo1.jpg"; // char* final_name; // if(name_photo(&final_name, file_name, -1) != MMAL_SUCCESS) // { // fprintf(stderr, "Unable to write to filename\n"); // } // fprintf(stderr, "here\n"); // return 0; // } int main() { RASPISTILL_STATE state; int exit_code = EX_OK; MMAL_STATUS_T status = MMAL_SUCCESS; MMAL_PORT_T *camera_preview_port = NULL; //MMAL_PORT_T *camera_video_port = NULL; MMAL_PORT_T *camera_still_port = NULL; MMAL_PORT_T *preview_input_port = NULL; MMAL_PORT_T *encoder_input_port = NULL; MMAL_PORT_T *encoder_output_port = NULL; //what is thiss?? bcm_host_init(); // Register our application with the logging system //what is this?? // some threading thing, probably will replace with pthread stuff vcos_log_register("RaspiStill", VCOS_LOG_CATEGORY); //not sure what the signal stuff is signal(SIGINT, default_signal_handler); // Disable USR1 and USR2 for the moment - may be reenabled if go in to signal capture mode signal(SIGUSR1, SIG_IGN); signal(SIGUSR2, SIG_IGN); default_status(&state); if (state.timeout == -1) state.timeout = 5000; // Setup for sensor specific parameters get_sensor_defaults(state.common_settings.cameraNum, state.common_settings.camera_name, &state.common_settings.width, &state.common_settings.height); //create camera, preview and encoder component if ((status = create_camera_component(&state)) != MMAL_SUCCESS) { vcos_log_error("%s: Failed to create camera component", __func__); exit_code = EX_SOFTWARE; } if ((status = raspipreview_create(&state.preview_parameters)) != MMAL_SUCCESS) { vcos_log_error("%s: Failed to create preview component", __func__); destroy_camera_component(&state); exit_code = EX_SOFTWARE; } if ((status = create_encoder_component(&state)) != MMAL_SUCCESS) { vcos_log_error("%s: Failed to create encode component", __func__); raspipreview_destroy(&state.preview_parameters); destroy_camera_component(&state); exit_code = EX_SOFTWARE; } PORT_USERDATA callback_data; fprintf(stderr, "Starting component connection stage\n"); camera_preview_port = state.camera_component->output[MMAL_CAMERA_PREVIEW_PORT]; //camera_video_port = state.camera_component->output[MMAL_CAMERA_VIDEO_PORT]; camera_still_port = state.camera_component->output[MMAL_CAMERA_CAPTURE_PORT]; encoder_input_port = state.encoder_component->input[0]; encoder_output_port = state.encoder_component->output[0]; fprintf(stderr, "Connecting camera preview port to video render.\n"); // Note we are lucky that the preview and null sink components use the same input port // so we can simple do this without conditionals preview_input_port = state.preview_parameters.preview_component->input[0]; // Connect camera to preview (which might be a null_sink if no preview required) status = connect_ports(camera_preview_port, preview_input_port, &state.preview_connection); VCOS_STATUS_T vcos_status; if (status == MMAL_SUCCESS) { fprintf(stderr, "Connecting camera stills port to encoder input port\n"); // Now connect the camera to the encoder status = connect_ports(camera_still_port, encoder_input_port, &state.encoder_connection); if (status != MMAL_SUCCESS) { vcos_log_error("%s: Failed to connect camera video port to encoder input", __func__); exit(1); } } else { exit(1); } //I believe this is where the photo data will be stored for useage callback_data.file_handle = NULL; callback_data.pstate = &state; //threading stuff tah will need to be researched vcos_status = vcos_semaphore_create(&callback_data.complete_semaphore, "RaspiStill-sem", 0); vcos_assert(vcos_status == VCOS_SUCCESS); //below is the operation of the raspistill functions int frame, keep_looping = 1; FILE *output_file = NULL; char *use_filename = NULL; // Temporary filename while image being written char *final_filename = NULL; // Name that file gets once writing complete //wish there was comments for what frame is exactly frame = state.frameStart - 1; // need to get frame or something wait_for_frame(&state, &frame); // need to open the filename so data can be allocated to it //possibly add functionality to add date to name so we can keep making new photo files //use a set filename for now for testing char testing_photo_name[10] = "photo.jpeg"; int len = strlen(testing_photo_name); state.common_settings.filename = malloc(len + 10); // leave enough space for any timelapse generated changes to filename vcos_assert(state.common_settings.filename); if (state.common_settings.filename) strncpy(state.common_settings.filename, testing_photo_name, len+1); open_filename(&state, use_filename, final_filename, output_file, frame, callback_data); if (!output_file) { fprintf(stderr, "No output file avaliable"); exit(1); } mmal_port_parameter_set_boolean(state.encoder_component->output[0], MMAL_PARAMETER_EXIF_DISABLE, 1); // There is a possibility that shutter needs to be set each loop. may not be necessary if (mmal_status_to_int(mmal_port_parameter_set_uint32(state.camera_component->control, MMAL_PARAMETER_SHUTTER_SPEED, state.camera_parameters.shutter_speed)) != MMAL_SUCCESS) vcos_log_error("Unable to set shutter speed"); // Enable the encoder output port encoder_output_port->userdata = (struct MMAL_PORT_USERDATA_T *)&callback_data; if (state.common_settings.verbose) fprintf(stderr, "Enabling encoder output port\n"); // Enable the encoder output port and tell it its callback function status = mmal_port_enable(encoder_output_port, encoder_buffer_callback); // Send all the buffers to the encoder output port int num = mmal_queue_length(state.encoder_pool->queue); for (int q=0; q<num; q++) { MMAL_BUFFER_HEADER_T *buffer = mmal_queue_get(state.encoder_pool->queue); if (!buffer) vcos_log_error("Unable to get a required buffer %d from pool queue", q); if (mmal_port_send_buffer(encoder_output_port, buffer)!= MMAL_SUCCESS) vcos_log_error("Unable to send a buffer to encoder output port (%d)", q); } //capture? if (mmal_port_parameter_set_boolean(camera_still_port, MMAL_PARAMETER_CAPTURE, 1) != MMAL_SUCCESS) { vcos_log_error("%s: Failed to start capture", __func__); } else { // Wait for capture to complete // For some reason using vcos_semaphore_wait_timeout sometimes returns immediately with bad parameter error // even though it appears to be all correct, so reverting to untimed one until figure out why its erratic vcos_semaphore_wait(&callback_data.complete_semaphore); if (state.common_settings.verbose) fprintf(stderr, "Finished capture %d\n", frame); } // Ensure we don't die if get callback with no open file callback_data.file_handle = NULL; rename_file(&state, output_file, final_filename, use_filename, frame); status = mmal_port_disable(encoder_output_port); if (use_filename) { free(use_filename); use_filename = NULL; } if (final_filename) { free(final_filename); final_filename = NULL; } vcos_semaphore_delete(&callback_data.complete_semaphore); fprintf(stderr,"Done"); return 0; }
8fbcd7e44fbf54e11783aee132368bd5e46fae17
d941442cca0249aff063ff4194767d278209ed31
/compare_pgm_images.c
85f786f7e6302e2e231b0773a45bebeee41229e8
[]
no_license
mitchmancuso/LZ77-PGM
66b4ba51745a333eef63873130920d09120bff1c
f6fc0c18b07d5c5fb2b1c7f1eedd3d1a4c42099c
refs/heads/master
2020-12-21T07:30:31.644421
2020-01-26T19:03:42
2020-01-26T19:03:42
236,358,667
0
0
null
null
null
null
UTF-8
C
false
false
841
c
compare_pgm_images.c
// // Created by Mitchell Mancuso on 2019-03-06. // #include <stdio.h> #include <stdlib.h> #include "libpnm.h" #include "mean_absolute_error.h" int main(int argc, char *argv[]) { //Checks that the correct number of arguments have been provided by the user if (argc != 3) { //If not, inform the user as to how to call the program printf("Invalid command, two arguments are required.\nPlease call the function using ./compare_pgm_images [pgm_file1] [pgm_file2]\n"); exit(0); } //Store the arguments as the image file pointers char *imageFile1 = argv[1]; char *imageFile2 = argv[2]; //Call the function to determine the mean absolute error float mean_abs_error = mean_absolute_error(imageFile1, imageFile2); //Print the result to the user printf("The Mean Absolute Error is: %f\n", mean_abs_error); }
65845be88ff4827aa04a00a60593482e0999df3a
bf3166b4dc536ebdec208df55ef12a6538d43fce
/MPU_test.c
085e5bb237dc256dd969d64eee60cef6f22550da
[]
no_license
Shothogun/WashingMachineWatch_ProjetoLabSismic
efddd90e9f3932c96b9ff0708ba5dfa85bd30f13
ad232029841f2f05e086a31f2f3cf2dd177f3a14
refs/heads/master
2020-07-30T02:18:44.956965
2019-07-13T01:00:07
2019-07-13T01:00:07
null
0
0
null
null
null
null
UTF-8
C
false
false
5,999
c
MPU_test.c
#include <msp430.h> #include "MPU.h" // Lasts samples from MPU array uint8_t reply[14]; // Signed int Accelerometer // and gyroscope measures(not converted) int gy; //Converted value float GYRO; // Gyroscope measures 10 samples average in 1s period int gyro_avg; // Samples amount in the 1s period int sample_num=0; // Samples average amount int j=0; // Accelerometer states // START: Initial values from accelerometer(initial values is floating // glitched around values) // SAMPLE: begins to process the gyroscope's axis y value // and check its value(indicates an idle or a movement) enum ACCL_STATE {START, SAMPLE} ACCL_STATE=START; // Washing machine states // IDLE: The devise is not triggered yet // WASHING: The devise starts to watch the washing machine state // FINISH: The devise detects washing finish, prepares to send a email enum WASHING_STATE {IDLE, WASHING,FINISH} WASHING_STATE=IDLE; // FinishState: Detects washing finish, and send email void FinishState(); // MovementState: stand by until IdleState(don't send email) void MovementState(); // ON/Reset mode: blinks red and green LED to warn device turning on/reset void OnMode(); /** * main.c */ int main(void) { uint8_t a_scale, g_scale; WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer setupPorts(); // Setup ports setupTimerA0(); // Setup timer setupTimerA1(); // Setup timer I2C_config_B2(setMaster, 0x42, // Setup I2C interface 100, 1); // Activate Pins PM5CTL0 ^= LOCKLPM5; //Desired Scale a_scale = MPU6050_ACCEL_FS_2; //2, 4, 8 or 16 g g_scale = MPU6050_GYRO_FS_1000; //250, 500, 1000 or 2000 degrees/second B2_STT_STP(MPU6050_DEFAULT_ADDRESS); // Wake up MPU mpuSetByte(MPU6050_RA_PWR_MGMT_1, 0x01); waitFor(250); // Test Comunication mpuRead_nb(MPU6050_RA_WHO_AM_I,reply,1); if(reply[0]==MPU6050_DEFAULT_ADDRESS){} else while(1){P1OUT |= BIT0;}; // Reports error with Red LED waitFor(250); // MPU config and reset mpuSetByte(MPU6050_RA_PWR_MGMT_1, 0x80); //MPU Reset waitFor(250); mpuSetByte(MPU6050_RA_PWR_MGMT_1, 0x01); //Wake up and selects clock from PLL in gyroscope, axis x waitFor(250); mpuSetByte(MPU6050_RA_CONFIG, 0x03); //Rate 1khz Accel=44hz Gyro=42hz mpuSetByte(MPU6050_RA_SMPLRT_DIV, 0x04); //Sampling rate: 200Hz //sampling rate = rate/ (1+SMPLRT_DIV) //Set scales mpuSetByte(MPU6050_RA_GYRO_CONFIG , g_scale<<3); mpuSetByte(MPU6050_RA_ACCEL_CONFIG , a_scale<<3); mpuRead_nb(MPU6050_RA_GYRO_YOUT_H, reply, 2); OnMode(); // Waiting user's trigger command while(P5IN & BIT5); // Triggered mode waitFor(1000); P1OUT |= BIT0; waitFor(1000); P1OUT &= ~BIT0; waitFor(1000); P1OUT |= BIT0; waitFor(1000); P1OUT &= ~BIT0; __enable_interrupt(); while(1){ //Get one full reading from accelerometers, giroscope and temperature mpuRead_nb(MPU6050_RA_GYRO_YOUT_H, reply, 2); gy = (int) ((reply[0] << 8) | reply[1]) ; GYRO = (float) gy*(250<<g_scale)/32767; } return 0; } #pragma vector= TIMER1_A0_VECTOR __interrupt void TA1_CCR0_ISR() { switch (ACCL_STATE) { case START: // Bypass 3 first accelerometer readings // (bad measure values ,awaits for a // steady accelerometer state) if(j>3){ // Enters in SAMPLE mode, i.e. start gyroscope values // analysis; // and enters in WASHING mode(when triggered washing machine // is already on). WASHING_STATE = WASHING; ACCL_STATE = SAMPLE; waitFor(500); P1OUT |= BIT1; waitFor(500); P1OUT &= ~BIT1; waitFor(500); P1OUT |= BIT1; waitFor(500); P1OUT &= ~BIT1; } break; case SAMPLE: // Compares if gyroscope sampling average at axis-y // indicates a movement pattern(values out of range // 190 < w < 250) if(sample_num == 10) { // If its moving(washing machine's on) if(!(gyro_avg < 255 && gyro_avg > 190)) { MovementState(); } // It's not moving(washing machine's off) else { FinishState(); } } break; } // Gyroscope sampling average computing(10 values) if(sample_num < 10){ gyro_avg += GYRO/10; sample_num++; } // Surpassing of 10 values, starts to compute // average again, and resets its value else { sample_num = 0; gyro_avg = 0; j++; } } void FinishState(){ // --------LED debug-------- // LED Verde ligado P1OUT &= ~BIT0; P1OUT |= BIT1; // Waits 6 seconds, to confirm washing finish waitFor(2000); waitFor(2000); waitFor(2000); // If none movement is detected if(gyro_avg < 255 && gyro_avg > 190){ WASHING_STATE = FINISH; } } void MovementState(){ // --------LED debug-------- // LED Vermelho ligado P1OUT |= BIT0; P1OUT &= ~BIT1; } void OnMode(){ // On or reset board notice: // Blinks red and green LED WASHING_STATE = IDLE; P1OUT |= BIT0; P1OUT |= BIT1; waitFor(1000); P1OUT &= ~BIT0; P1OUT &= ~BIT1; waitFor(1000); P1OUT |= BIT0; P1OUT |= BIT1; waitFor(1000); P1OUT &= ~BIT0; P1OUT &= ~BIT1; }
b059d7f4ae6ff6a7247080c8c6e6a5711602305a
02ed64c6f3f6af72342e1baddd6e1c94513b96af
/wp/resources/sample_binaries/init_var/main.c
9d9f040173afc0baf5c25da32eb559ee6f0ee37b
[ "MIT" ]
permissive
DieracDelta/cbat_tools
066298c108806be31d227c9d79a482152e84f07a
df8edf34010b6ba4aa220997e3eb54bbac23d614
refs/heads/master
2021-03-30T14:36:40.605827
2020-03-20T13:20:11
2020-03-20T13:41:24
248,063,716
0
0
MIT
2020-03-17T20:10:33
2020-03-17T20:10:32
null
UTF-8
C
false
false
130
c
main.c
#include <stdint.h> uint64_t foo(uint64_t x) { return x + 1; } int main(int argc,char ** argv) { foo(argc); return 0; }
f730ef97b0c00a0beb6fa4297a363cb094c669c1
3d018912dbf4ebd229aa42e06ec58e733aac75eb
/fy3/clone/gift/maofang.c
5b19485eddf690434f74392a528b7d6dfe0aec5e
[]
no_license
15831944/FengYun2020
93fd7657a5d924e975771c6da83e3baca8c70795
81c0551fad5a77084df80165d45892717d2b7c28
refs/heads/main
2023-03-17T20:59:26.566095
2021-01-02T20:06:59
2021-01-02T20:06:59
null
0
0
null
null
null
null
GB18030
C
false
false
2,371
c
maofang.c
// story:maofang #include <ansi.h> string give_gift(); private mixed *story = ({ "沈浪:咦?兄台,在下有一事不知道当问不当问?", "熊猫儿:嗯...有什么事,老兄你尽管说。咱们江湖兄弟不必那么文绉绉的,直接点。", "沈浪:好!兄台果然是爽快之人!我想问的是:兄台是不是河北神腿门的弟子?", "熊猫儿:嗯...正是!不知道老兄怎么知道的?", "沈浪:呵呵,我看兄台这蹲马步的姿势--双脚脚尖微微向内,双腿的膝盖却向外,小腿与大腿之间的角度成一直角,上身前倾,这便是河北神腿门的基本功嘛。", "沈浪:说起来咱们算是本家。我是唐山地趟门的。三十年前,咱们本是一家,都属于神腿门。", "熊猫儿:嗯...原来如此,怪不得看老兄你蹲马步的姿势跟我差不多呢。嗯", "沈浪:呵呵,我蹲的姿势和兄台还是有些区别的。神腿门注重的练腿的力量,我们地趟门练的是轻巧,所以我们蹲马步和你们有一点不同。", "沈浪接着道:我们的双脚不是平行的,而是一脚微微在前,一脚微微在后,为以后的[急行花步]打基础。", "熊猫儿听后憨笑:哈哈,看来老兄是悟性很高的高手啊。嗯……俺是个粗人,不管这些,只管苦练。嗯…", "沈浪谦虚地说:呵呵,兄台过奖了!悟性是一方面,苦练才是最重要的啊。", "熊猫儿:嗯...", "沈浪:蹲茅房能遇你这样一个知已,真的很开心!……嗯…", "熊猫儿:嗯…我也是。", "沈浪:" HIC "哎呀!" NOR, "熊猫儿:兄台,怎么了?", "沈浪:刚往兜里拿手纸,不小心把一锭金子弄掉了。", "熊猫儿:啊,那得赶紧找!", (: give_gift :) }); void create() { seteuid(getuid()); } mixed query_story_message(int step) { return step < sizeof(story) ? story[step] : 0; } string give_gift() { STORY_D->give_gift("/obj/money/gold", 1, HIM "\n“啪”的一声一锭金子掉到你面前。\n\n" NOR); return HIM "听说沈浪和熊猫儿从此以后建立了深厚的友谊。\n" NOR; }
053832230b03d169d0ad390db8dd456c0934fd23
2bc7659be83178c43b1592efbe1d79c62fc4fa36
/1020 [기초-입출력] 주민번호 입력받아 형태 바꿔 출력하기.c
7c1a11a627a1e35760bc965b5f8d4a9d29713a24
[]
no_license
KIMSUBIN17/Code-Up-Algorithm
ede6f443fcf640ecf58282c582da43e124ca44af
831180c28d234366a1d3cf118bd2a615dc404f00
refs/heads/master
2023-07-22T21:42:06.990542
2021-09-05T08:36:32
2021-09-05T08:36:32
286,932,400
0
0
null
null
null
null
UTF-8
C
false
false
239
c
1020 [기초-입출력] 주민번호 입력받아 형태 바꿔 출력하기.c
#include<stdio.h> int main() { char n[15]; int i; scanf("%s", &n); int length = strlen(n); //strlen() 문자열 길이 구하기 for (i = 0; i < length; i++) { if (n[i] == '-'); else printf("%c", n[i]); } return 0; }
aa6752e0363365f1816c39bc87f3e59fba4f2d1e
af7977991477325ddc604b6d3e2ac3cb4aa29337
/FlappyBirdGame3D3.0/Temp/il2cppOutput/il2cppOutput/AssemblyU2DCSharp_LaserScript_U3CFireLaserU3Ec__It2412005317MethodDeclarations.h
b9ccd293eb7bcbd48bbe1628addd083a3f88d9c4
[]
no_license
jpf2141/FlappyBird3D
b824cf5fac6ca3c5739afc342b659af1f2836ab9
fe4e9c421ec8dc26a7befd620f9deaf3c6361de5
refs/heads/master
2021-01-21T13:53:25.062470
2016-05-06T02:39:28
2016-05-06T02:39:28
55,712,365
3
1
null
null
null
null
UTF-8
C
false
false
1,881
h
AssemblyU2DCSharp_LaserScript_U3CFireLaserU3Ec__It2412005317MethodDeclarations.h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include <assert.h> #include <exception> // LaserScript/<FireLaser>c__Iterator1 struct U3CFireLaserU3Ec__Iterator1_t2412005317; // System.Object struct Il2CppObject; #include "codegen/il2cpp-codegen.h" // System.Void LaserScript/<FireLaser>c__Iterator1::.ctor() extern "C" void U3CFireLaserU3Ec__Iterator1__ctor_m756256991 (U3CFireLaserU3Ec__Iterator1_t2412005317 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Object LaserScript/<FireLaser>c__Iterator1::System.Collections.Generic.IEnumerator<object>.get_Current() extern "C" Il2CppObject * U3CFireLaserU3Ec__Iterator1_System_Collections_Generic_IEnumeratorU3CobjectU3E_get_Current_m292029011 (U3CFireLaserU3Ec__Iterator1_t2412005317 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Object LaserScript/<FireLaser>c__Iterator1::System.Collections.IEnumerator.get_Current() extern "C" Il2CppObject * U3CFireLaserU3Ec__Iterator1_System_Collections_IEnumerator_get_Current_m1654066151 (U3CFireLaserU3Ec__Iterator1_t2412005317 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Boolean LaserScript/<FireLaser>c__Iterator1::MoveNext() extern "C" bool U3CFireLaserU3Ec__Iterator1_MoveNext_m2852038325 (U3CFireLaserU3Ec__Iterator1_t2412005317 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void LaserScript/<FireLaser>c__Iterator1::Dispose() extern "C" void U3CFireLaserU3Ec__Iterator1_Dispose_m811778396 (U3CFireLaserU3Ec__Iterator1_t2412005317 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR; // System.Void LaserScript/<FireLaser>c__Iterator1::Reset() extern "C" void U3CFireLaserU3Ec__Iterator1_Reset_m2697657228 (U3CFireLaserU3Ec__Iterator1_t2412005317 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
8db0bb0fe7e3740b88b3930acc2828505858410e
2a0af786993a3272c0fe80f37550094a7ac0a6a5
/C/insertion_sort.c
94ebc724b951451313448346a1fe997152ff46c0
[ "MIT" ]
permissive
manan025/DS-Algo-Zone
978372a07d9f7627e8779ac048f812fb3c24bf90
c185dcedc449c7e4f6aa5e0d8989589ef60b9565
refs/heads/main
2023-08-18T02:23:25.175099
2021-10-02T21:06:15
2021-10-02T21:06:15
412,155,744
34
136
MIT
2023-02-26T12:53:42
2021-09-30T17:16:07
Java
UTF-8
C
false
false
2,252
c
insertion_sort.c
#include <math.h> #include <stdio.h> void print(int arr[], int n){ for(int i=0;i<n;i++){ printf("%d ", arr[i]); } printf("\n"); } void insertionSort(int arr[], int n){ /* * This function is used for Insertion sort. * We generally fix a key and we try to move elements in the array which are greater than key to one position ahead. * We update the key every iteration and we also print sort result for every iteration. * The print function is used to print the entire array on the same line with each element having one char space between them. */ int i,key,j; for(i=1;i<n;i++){ key=arr[i]; j=i-1; while(j>=0&&arr[j]>key){ arr[j+1]=arr[j]; j=j-1; } print(arr,n); arr[j+1]=key; } print(arr,n); } int main(){ //Getting the size of the array from user int i,n; scanf("%d",&n); int arr[n]; //Getting array elements as input from user for(i=0;i<n;i++){ scanf("%d",&arr[i]); } printf("Array before Sorting\n"); print(arr,n); printf("\nInsertion Sort\n"); insertionSort(arr, n); printf("\nArray after Sorting\n"); print(arr,n); return 0; } /* Insertion Sort in C Input : A valid input size (n) of an array and n array elements to implement insertion sort Output : Returns a sorted array using insertion sort ---------------------------------------------------------------------- Sample Input 1 : 5 4 3 8 1 0 Sample Output 1 : Array before Sorting 4 3 8 1 0 Insertion Sort 4 4 8 1 0 3 4 8 1 0 3 3 4 8 0 1 1 3 4 8 0 1 3 4 8 Array after Sorting 0 1 3 4 8 Sample Input 2 : 7 63 3 5 7 2 0 1 Sample Output 2 : Array before Sorting 63 3 5 7 2 0 1 Insertion Sort 63 63 5 7 2 0 1 3 63 63 7 2 0 1 3 5 63 63 2 0 1 3 3 5 7 63 0 1 2 2 3 5 7 63 1 0 2 2 3 5 7 63 0 1 2 3 5 7 63 Array after Sorting 0 1 2 3 5 7 63 ----------------------------------------------------------------------- Time Complexity : O(n^2) Space Complexity : O(1) */
f694a5a1409ea9cb019984a6fd31b7d5c382ab5b
0a4ce8d5dca930a4db4e577446f40aa6d53c0d4c
/NewPalmEmu/palmos/audiodriver.h
88ea9b6966414a8d1666a12766a2addb85c600e6
[]
no_license
meepingsnesroms/PersianTree
d787c94fafc26a9ff363c268f163c8b7a961da24
c1156096e3bfa9474cdd198c0efc9bae531b4b42
refs/heads/master
2021-01-19T00:57:12.163668
2016-07-10T22:50:26
2016-07-10T22:50:26
62,970,202
9
0
null
null
null
null
UTF-8
C
false
false
137
h
audiodriver.h
#ifndef AUDIODRIVER #define AUDIODRIVER void sndstreamsetvolume(); void sndgetdefaultvolume(); void snddocmd(); #endif // AUDIODRIVER
a80932bfae93e8fb2a681ea594116ddfc3a662c4
fa06f8d5b490c7096c6f1abe544cad94be3de2c0
/tpactual/Planificador.c
a46b4da7721e8cca27469928ae5decba38bc1724
[]
no_license
Leonardo-Rocca/TP-MaRTA
eff37b636d66aed56b947839928218c0c752d720
089a485a4937adc022f9e93ac7831c1ede0ad469
refs/heads/master
2016-09-05T13:03:20.905233
2015-09-01T20:55:10
2015-09-01T20:55:10
41,729,678
0
0
null
null
null
null
UTF-8
C
false
false
2,042
c
Planificador.c
/* ============================================================================ Name : c.c Author : Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include <stdio.h> #include <stdlib.h> int main(void) { puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */ pthread_t hiloConexiones; pthread_create(&hiloConexiones,NULL,manejoConexionesConCPUs,NULL); pthread_join(hiloConexiones,NULL); return EXIT_SUCCESS; } void* manejoConexionesConJob(void* parametro){ int socket_Marta , socketCliente , c , *new_sock; struct sockaddr_in server , client; pthread_t sniffer_thread; //leo lo puso aca socketsConectados = list_create(); //Crea Socket socket_Marta = socket(AF_INET , SOCK_STREAM , 0); if (socket_Marta == -1) { printf("Could not create socket"); } //Prepara la estructura sockaddr_in server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons( 6666 ); //Bind if( bind(socket_Marta,(struct sockaddr *)&server , sizeof(server)) < 0) { //print the error message perror("bind failed. Error"); } //Listen listen(socket_Marta , colaEspera); //Accept and incoming connection c = sizeof(struct sockaddr_in); while( (socketCliente = accept(socket_Marta, (struct sockaddr *)&client, (socklen_t*)&c)) ) { char mensajeBienvenida; recv(socketCliente,&mensajeBienvenida,sizeof(char),0); if(mensajeBienvenida=='J'){ puts("Nuevo proceso. Job aceptado"); // pthread_t sniffer_thread; new_sock = malloc(1); *new_sock = socketCliente; if( pthread_create( &sniffer_thread , NULL , manejoHiloJob , (void*) new_sock) < 0) { perror("could not create thread"); } } } if (socketCliente < 0) { perror("accept failed"); } pthread_join(sniffer_thread,NULL); return 0; }
eb9af9cce2f6fff674f1296beeb230c8972160e9
0f796164fd575b168d59e94cb3f0ae9ed766ed4d
/mm-camera2/media-controller/modules/pproc-new/cpp/cpp_hardware.h
1e6b69de9079e7a09c70b0bc46d8b3e4cb418611
[]
no_license
zoggn/proprietary_qcom_mm-camera
02b30f42ae3783e2bf893d7e5342baec6f128251
44c4e4b282afac08839088395902fb811fc30d3d
refs/heads/master
2021-01-25T11:49:11.462639
2017-06-10T15:13:59
2017-06-10T15:13:59
93,947,251
3
1
null
null
null
null
UTF-8
C
false
false
7,002
h
cpp_hardware.h
/*============================================================================ Copyright (c) 2013-2014 Qualcomm Technologies, Inc. All Rights Reserved. Qualcomm Technologies Proprietary and Confidential. ============================================================================*/ #ifndef CPP_HARDWARE_H #define CPP_HARDWARE_H #include <pthread.h> #include <media/msmb_camera.h> #include <media/msmb_pproc.h> #include "cam_types.h" #include "camera_dbg.h" #include "mtype.h" #include "modules.h" #include "chromatix.h" #include "chromatix_common.h" #include "cpp_hw_params.h" #include "chromatix_metadata.h" #define MAX_CPP_DEVICES 2 #define SUBDEV_NAME_SIZE_MAX 32 #define CPP_MAX_FW_VERSIONS 8 #define CPP_MAX_FW_NAME_LEN 32 /* hw version info: 31:28 Major version 27:16 Minor version 15:0 Revision bits **/ #define CPP_HW_VERSION_1_0_0 0x10000000 #define CPP_HW_VERSION_1_1_0 0x10010000 #define CPP_HW_VERSION_1_1_1 0x10010001 #define CPP_HW_VERSION_2_0_0 0x20000000 #define CPP_HW_VERSION_4_0_0 0x40000000 #define CPP_HW_VERSION_4_1_0 0x40010000 #define CPP_HW_VERSION_4_2_0 0x40020000 #define CPP_CAPS_DENOISE (1 << 0) #define CPP_CAPS_SCALE (1 << 1) #define CPP_CAPS_SHARPENING (1 << 2) #define CPP_CAPS_CROP (1 << 3) #define CPP_CAPS_ROTATION (1 << 4) #define CPP_CAPS_FLIP (1 << 5) #define CPP_CAPS_COLOR_CONV (1 << 6) #define ROTATION_90 (1 << 0) #define ROTATION_180 (2 << 1) #define ROTATION_270 (3 << 2) #define CPP_TOTAL_SHARPNESS_LEVELS 6 #define CPP_MAX_SHARPNESS 36 #define CPP_MIN_SHARPNESS 0 #define CPP_DEFAULT_SHARPNESS 12 /* maximum no. of unique streams supported */ #define CPP_HARDWARE_MAX_STREAMS 8 /* how many buffers hardware can hold at a time */ #define CPP_HARDWARE_MAX_PENDING_BUF 1 typedef uint32_t cpp_rotation_caps_t; typedef struct _cpp_scaling_caps_t{ float min_scale_factor; float max_scale_factor; } cpp_scaling_caps_t; typedef struct _cpp_color_conv_caps_t{ cam_format_t src_fmt; cam_format_t dest_fmt; } cpp_color_conv_caps_t; typedef struct _cpp_flip_caps_t{ uint8_t h_flip; uint8_t v_flip; } cpp_flip_caps_t; typedef struct _cpp_sharpness_caps_t{ int32_t min_value; int32_t max_value; int32_t def_value; int32_t step; } cpp_sharpness_caps_t; typedef enum { CPP_HW_STATUS_INVALID, CPP_HW_STATUS_FW_LOADED, CPP_HW_STATUS_READY, CPP_HW_STATUS_BUSY, } cpp_hardware_status_t; typedef struct { uint32_t caps_mask; cpp_scaling_caps_t scaling_caps; cpp_rotation_caps_t rotation_caps; cpp_color_conv_caps_t color_conv_caps; cpp_flip_caps_t filp_caps; cpp_sharpness_caps_t sharpness_caps; } cpp_hardware_caps_t; /* HW can send only one type of v4l2 event and actually type of event can be abstracted in event data */ typedef struct _cpp_hardware_event_subscribe_info { boolean valid; uint32_t id; uint32_t type; } cpp_hardware_event_subscribe_info_t; typedef struct _cpp_hardware_info_t { uint32_t version; uint32_t caps; unsigned long freq_tbl[MAX_FREQ_TBL]; uint32_t freq_tbl_count; } cpp_hardware_info_t; typedef struct _cpp_hardware_stream_status_t { boolean valid; int32_t pending_buf; boolean stream_off_pending; uint32_t identity; } cpp_hardware_stream_status_t; typedef struct _cpp_hardware_t { uint32_t subdev_ids[MAX_CPP_DEVICES]; int num_subdev; int subdev_fd; boolean subdev_opened; uint32_t inst_id; cpp_hardware_caps_t caps; cpp_hardware_info_t hwinfo; cpp_hardware_status_t status; uint32_t fw_version; cpp_hardware_event_subscribe_info_t event_subs_info; cpp_hardware_stream_status_t stream_status[CPP_HARDWARE_MAX_STREAMS]; pthread_cond_t no_pending_cond; pthread_mutex_t mutex; int num_iommu_cnt; } cpp_hardware_t; typedef enum { CPP_HW_CMD_GET_CAPABILITIES, CPP_HW_CMD_SUBSCRIBE_EVENT, CPP_HW_CMD_UNSUBSCRIBE_EVENT, CPP_HW_CMD_NOTIFY_EVENT, CPP_HW_CMD_STREAMON, CPP_HW_CMD_STREAMOFF, CPP_HW_CMD_LOAD_FIRMWARE, CPP_HW_CMD_PROCESS_FRAME, CPP_HW_CMD_QUEUE_BUF, CPP_HW_CMD_GET_CUR_DIAG, CPP_HW_CMD_BUF_UPDATE, CPP_HW_CMD_SET_CLK } cpp_hardware_cmd_type_t; typedef struct _cpp_hardware_event_data_t { uint8_t is_buf_dirty; uint32_t frame_id; uint32_t identity; uint32_t buf_idx; uint32_t out_buf_idx; int out_fd; struct timeval timestamp; void *cookie; } cpp_hardware_event_data_t; typedef struct _cpp_hardware_streamoff_event{ uint32_t streamoff_identity; uint32_t duplicate_identity; } cpp_hardware_streamoff_event_t; typedef struct _cpp_hardware_clock_settings_t { long clock_rate; uint64_t avg; uint64_t inst; } cpp_hardware_clock_settings_t; typedef struct _cpp_hardware_cmd_t { cpp_hardware_cmd_type_t type; union { cpp_hardware_streamoff_event_t streamoff_data; cpp_hardware_event_data_t *event_data; cpp_hardware_params_t *hw_params; cpp_hardware_stream_buff_info_t *stream_buff_list; cpp_hardware_clock_settings_t clock_settings; } u; } cpp_hardware_cmd_t; /* interface functions */ cpp_hardware_t* cpp_hardware_create(); int32_t cpp_hardware_open_subdev(cpp_hardware_t *cpphw); int32_t cpp_hardware_close_subdev(cpp_hardware_t *cpphw); int32_t cpp_hardware_destroy(cpp_hardware_t *cpphw); int32_t cpp_hardware_process_command(cpp_hardware_t *cpphw, cpp_hardware_cmd_t cmd); cpp_hardware_status_t cpp_hardware_get_status(cpp_hardware_t *cpphw); /* static functions */ static int32_t cpp_hardware_find_subdev(cpp_hardware_t *cpphw); static int32_t cpp_hardware_subcribe_v4l2_event(cpp_hardware_t *cpphw); static int32_t cpp_hardware_notify_event_get_data(cpp_hardware_t *cpphw, cpp_hardware_event_data_t *event_data); static int32_t cpp_hardware_get_capabilities(cpp_hardware_t *cpphw); static int32_t cpp_hardware_load_firmware(cpp_hardware_t *cpphw); static int32_t cpp_hardware_process_streamon(cpp_hardware_t *cpphw, cpp_hardware_stream_buff_info_t *hw_strm_buff_info); static int32_t cpp_hardware_process_streamoff(cpp_hardware_t *cpphw, cpp_hardware_streamoff_event_t streamoff_data); static int32_t cpp_hardware_process_frame(cpp_hardware_t *cpphw, cpp_hardware_params_t *hw_params); static cpp_hardware_stream_status_t* cpp_hardware_get_stream_status(cpp_hardware_t* cpphw, uint32_t identity); static int32_t cpp_hardware_subcribe_v4l2_event(cpp_hardware_t *cpphw); static int32_t cpp_hardware_unsubcribe_v4l2_event(cpp_hardware_t *cpphw); double cpp_get_sharpness_ratio(int32_t sharpness); #endif
fecd799b36237fbf2ef2ebb9ab29491f80038d39
e1cddfd754d952134e72dfd03522c5ea4fb6008e
/src/svm/fifo_segment.h
ec184207269569d1ed825916f91616a0e88debd4
[ "Apache-2.0" ]
permissive
FDio/vpp
0ad30fa1bec2975ffa6b66b45c9f4f32163123b6
f234b0d4626d7e686422cc9dfd25958584f4931e
refs/heads/master
2023-08-31T16:09:04.068646
2022-03-14T09:49:15
2023-08-31T09:50:00
96,556,718
1,048
630
Apache-2.0
2023-06-21T05:39:17
2017-07-07T16:29:40
C
UTF-8
C
false
false
11,355
h
fifo_segment.h
/* * Copyright (c) 2016-2019 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __included_fifo_segment_h__ #define __included_fifo_segment_h__ #include <svm/ssvm.h> #include <svm/fifo_types.h> #include <svm/message_queue.h> #include <svm/svm_fifo.h> #define FIFO_SEGMENT_ALLOC_OVERHEAD (2 * clib_mem_get_page_size ()) typedef enum { FIFO_SEGMENT_FTYPE_NONE = -1, FIFO_SEGMENT_RX_FIFO = 0, FIFO_SEGMENT_TX_FIFO, FIFO_SEGMENT_N_FTYPES } fifo_segment_ftype_t; #define FIFO_SEGMENT_MIN_LOG2_FIFO_SIZE 12 /**< 4kB min fifo size */ #define FIFO_SEGMENT_MIN_FIFO_SIZE 4096 /**< 4kB min fifo size */ #define FIFO_SEGMENT_MAX_FIFO_SIZE (2ULL << 30) /**< 2GB max fifo size */ #define FIFO_SEGMENT_ALLOC_BATCH_SIZE 32 /* Allocation quantum */ typedef enum fifo_segment_flags_ { FIFO_SEGMENT_F_IS_PREALLOCATED = 1 << 0, FIFO_SEGMENT_F_WILL_DELETE = 1 << 1, FIFO_SEGMENT_F_MEM_LIMIT = 1 << 2, FIFO_SEGMENT_F_CUSTOM_USE = 1 << 3, } fifo_segment_flags_t; #define foreach_segment_mem_status \ _(NO_PRESSURE, "No pressure") \ _(LOW_PRESSURE, "Low pressure") \ _(HIGH_PRESSURE, "High pressure") \ _(NO_MEMORY, "No memory") typedef enum { #define _(sym,str) MEMORY_PRESSURE_##sym, foreach_segment_mem_status #undef _ MEMORY_N_PRESSURE, } fifo_segment_mem_status_t; #if 0 typedef enum fifo_segment_mem_status_ { MEMORY_PRESSURE_NO_PRESSURE, MEMORY_PRESSURE_LOW_PRESSURE, MEMORY_PRESSURE_HIGH_PRESSURE, MEMORY_PRESSURE_NO_MEMORY, } fifo_segment_mem_status_t; #endif typedef struct { ssvm_private_t ssvm; /**< ssvm segment data */ fifo_segment_header_t *h; /**< fifo segment data */ fifo_slice_private_t *slices; /**< private slice information */ svm_msg_q_t *mqs; /**< private vec of attached mqs */ uword max_byte_index; /**< max byte index for segment */ u32 sm_index; /**< owner segment manager index */ u32 fs_index; /**< fs index in sm pool */ u8 n_slices; /**< number of fifo segment slices */ u8 flags; /**< private fifo segment flags */ u8 high_watermark; /**< memory pressure watermark high */ u8 low_watermark; /**< memory pressure watermark low */ } fifo_segment_t; typedef struct { fifo_segment_t *segments; /**< pool of fifo segments */ uword next_baseva; /**< Where to put the next one */ u32 timeout_in_seconds; /**< Time to wait during attach */ } fifo_segment_main_t; typedef struct { ssvm_segment_type_t segment_type; /**< type of segment requested */ u32 segment_size; /**< size of the segment */ int memfd_fd; /**< fd for memfd segments */ char *segment_name; /**< segment name */ u32 *new_segment_indices; /**< return vec of new seg indices */ } fifo_segment_create_args_t; #define fifo_segment_flags(_fs) _fs->flags int fifo_segment_init (fifo_segment_t * fs); int fifo_segment_create (fifo_segment_main_t * sm, fifo_segment_create_args_t * a); int fifo_segment_attach (fifo_segment_main_t * sm, fifo_segment_create_args_t * a); void fifo_segment_delete (fifo_segment_main_t * sm, fifo_segment_t * fs); void fifo_segment_cleanup (fifo_segment_t *fs); fifo_segment_t *fifo_segment_get_segment (fifo_segment_main_t * sm, u32 fs_index); fifo_segment_t *fifo_segment_get_segment_if_valid (fifo_segment_main_t *sm, u32 segment_index); u32 fifo_segment_index (fifo_segment_main_t * sm, fifo_segment_t * fs); void fifo_segment_info (fifo_segment_t * seg, char **address, size_t * size); always_inline void * fifo_segment_ptr (fifo_segment_t *fs, uword offset) { return (void *) ((u8 *) fs->h + offset); } always_inline uword fifo_segment_offset (fifo_segment_t *fs, void *p) { return (uword) ((u8 *) p - (u8 *) fs->h); } /** * Allocate fifo in fifo segment * * @param fs fifo segment for fifo * @param data_bytes size of default fifo chunk in bytes * @param ftype fifo type @ref fifo_segment_ftype_t * @return new fifo or 0 if alloc failed */ svm_fifo_t *fifo_segment_alloc_fifo_w_slice (fifo_segment_t * fs, u32 slice_index, u32 data_bytes, fifo_segment_ftype_t ftype); svm_fifo_t *fifo_segment_alloc_fifo_w_offset (fifo_segment_t *fs, uword offset); svm_fifo_t *fifo_segment_duplicate_fifo (fifo_segment_t *fs, svm_fifo_t *f); /** * Free fifo allocated in fifo segment * * @param fs fifo segment for fifo * @param f fifo to be freed */ void fifo_segment_free_fifo (fifo_segment_t * fs, svm_fifo_t * f); /** * Free fifo allocated by external applications * * @params fs fifo segment for fifo * @param f fifo to be freed */ void fifo_segment_free_client_fifo (fifo_segment_t *fs, svm_fifo_t *f); void fifo_segment_detach_fifo (fifo_segment_t *fs, svm_fifo_t **f); void fifo_segment_attach_fifo (fifo_segment_t *fs, svm_fifo_t **f, u32 slice_index); uword fifo_segment_fifo_offset (svm_fifo_t *f); /** * Allocate message queue on segment * * @param fs fifo segment for mq * @param mq_index index in private mqs vector to use to attach * @param cfg configuration for mq * @return attached message queue */ svm_msg_q_t *fifo_segment_msg_q_alloc (fifo_segment_t *fs, u32 mq_index, svm_msg_q_cfg_t *cfg); /** * Attach message queue at fifo segment offset * * @param fs fifo segment for mq * @param offset offset for shared mq on the segment * @param mq_index index in private mqs vector to use to attach * @return attached message queue */ svm_msg_q_t *fifo_segment_msg_q_attach (fifo_segment_t *fs, uword offset, u32 mq_index); /** * Discover mqs on mq only segment * * @param fs fifo segment for mq * @param fds array of fds is mqs use eventfds * @param n_fds number of fds */ void fifo_segment_msg_qs_discover (fifo_segment_t *fs, int *fds, u32 n_fds); /** * Message queue offset on segment * * @param fs fifo segment for mq * @param mq_index index of mq in private mqs vector * @return offset of the shared mq the private mq is attached to */ uword fifo_segment_msg_q_offset (fifo_segment_t *fs, u32 mq_index); /** * Try to preallocate fifo headers * * Tries to preallocate fifo headers and adds them to freelist. * * @param fs fifo segment * @param batch_size number of chunks to be allocated * @return 0 on success, negative number otherwise */ int fifo_segment_prealloc_fifo_hdrs (fifo_segment_t * fs, u32 slice_index, u32 batch_size); /** * Try to preallocate fifo chunks on segment * * Tries to preallocate chunks of requested size on segment and adds them * to chunk freelist. * * @param fs fifo segment * @param chunk_size size of chunks to be allocated in bytes * @param batch_size number of chunks to be allocated * @return 0 on success, negative number otherwise */ int fifo_segment_prealloc_fifo_chunks (fifo_segment_t * fs, u32 slice_index, u32 chunk_size, u32 batch_size); /** * Pre-allocates fifo pairs in fifo segment * * The number of fifos pre-allocated is the minimum of the requested number * of pairs and the maximum number that fit within the segment. If the maximum * is hit, the number of fifo pairs requested is updated by subtracting the * number of fifos that have been successfully allocated. * * @param fs fifo segment for fifo * @param rx_fifo_size data size of rx fifos * @param tx_fifo_size data size of tx fifos * @param n_fifo_pairs number of pairs requested. Prior to returning, this * is decremented by the the number of pairs allocated. */ void fifo_segment_preallocate_fifo_pairs (fifo_segment_t * fs, u32 rx_fifo_size, u32 tx_fifo_size, u32 * n_fifo_pairs); /** * Allocate chunks in fifo segment * * @param fsh fifo segment header * @param slice_index slice where chunks should be alocated * @param chunk_size chunk size needed * @return chunk (or chunks) that cover at least chunk_size bytes * on success, 0 on failure. */ svm_fifo_chunk_t *fsh_alloc_chunk (fifo_segment_header_t * fsh, u32 slice_index, u32 chunk_size); /** * Return chunks to fifo segment * * @param fsh fifo segment header * @param slice_index slice where chunks should be returned * @param c pointer to first chunk in 0 terminated linked list */ void fsh_collect_chunks (fifo_segment_header_t * fsh, u32 slice_index, svm_fifo_chunk_t * c); /** * Fifo segment reset mem limit flag * * @param fs fifo segment * @param size size requested * @return pointer to memory allocated or 0 */ void *fifo_segment_alloc (fifo_segment_t *fs, uword size); /** * Fifo segment allocated size * * Returns fifo segment's allocated size * * @param fs fifo segment * @return allocated size in bytes */ uword fifo_segment_size (fifo_segment_t * fs); /** * Fifo segment estimate of number of free bytes * * Returns fifo segment's internal estimate of the number of free bytes. * To force a synchronization between the segment and the underlying * memory allocator, call @ref fifo_segment_update_free_bytes * * @param fs fifo segment * @return free bytes estimate */ uword fifo_segment_free_bytes (fifo_segment_t * fs); /** * Fifo segment number of cached bytes * * Returns fifo segment's number of cached bytes. * * @param fs fifo segment * @return cached bytes */ uword fifo_segment_cached_bytes (fifo_segment_t * fs); uword fifo_segment_available_bytes (fifo_segment_t * fs); /** * Number of bytes on chunk free lists * * @param fs fifo segment * @return free bytes on chunk free lists */ uword fifo_segment_fl_chunk_bytes (fifo_segment_t * fs); u8 fifo_segment_has_fifos (fifo_segment_t * fs); svm_fifo_t *fifo_segment_get_slice_fifo_list (fifo_segment_t * fs, u32 slice_index); u32 fifo_segment_num_fifos (fifo_segment_t * fs); u32 fifo_segment_num_free_fifos (fifo_segment_t * fs); svm_fifo_chunk_t *fifo_segment_alloc_chunk_w_slice (fifo_segment_t *fs, u32 slice_index, u32 chunk_size); void fifo_segment_collect_chunk (fifo_segment_t *fs, u32 slice_index, svm_fifo_chunk_t *c); uword fifo_segment_chunk_offset (fifo_segment_t *fs, svm_fifo_chunk_t *c); /** * Find number of free chunks of given size * * @param fs fifo segment * @param size chunk size of interest or ~0 if all should be counted * @return number of chunks of given size */ u32 fifo_segment_num_free_chunks (fifo_segment_t * fs, u32 size); u8 fifo_segment_get_mem_usage (fifo_segment_t * fs); fifo_segment_mem_status_t fifo_segment_get_mem_status (fifo_segment_t * fs); void fifo_segment_main_init (fifo_segment_main_t * sm, u64 baseva, u32 timeout_in_seconds); format_function_t format_fifo_segment; format_function_t format_fifo_segment_type; #endif /* __included_fifo_segment_h__ */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */
74fc821e4dcc0158af0efb645007703429ce5021
bc3c09f7cb3042afca2ded3f539e8ce756215069
/full/openvzemu_include/linux/netfilter/xt_mark.h
8242ca3a509077c0fe43a50502407341772e018e
[]
no_license
littlepretty/S3F_FULL
5f825226089f7587f3f48d94516049ac506e2a2c
8364bf9ee5f0cce617b01ae38fdd2ff9f5ae9586
refs/heads/master
2021-01-18T17:28:41.669157
2014-04-22T14:06:59
2014-04-22T14:06:59
null
0
0
null
null
null
null
UTF-8
C
false
false
293
h
xt_mark.h
#ifndef _XT_MARK_H #define _XT_MARK_H #include <net/compat.h> struct xt_mark_info { unsigned long mark, mask; u_int8_t invert; }; #ifdef CONFIG_COMPAT struct compat_xt_mark_info { compat_ulong_t mark, mask; u_int8_t invert; }; #endif /*CONFIG_COMPAT*/ #endif /*_XT_MARK_H*/
604d7b41b1e6713eddf159d99266b0345506ac43
7d90aec18353cd9412d5589bc6ff6c83203222f6
/client/client.c
b6c188be283d18cd80f15dfd228dba2a953efc5d
[]
no_license
YangKin/information_manage
958e83c51402b96fba41aa4b006f653f7efff751
73726965c775e2362091d292279a652815dafa49
refs/heads/master
2020-06-28T19:43:20.673530
2019-08-03T02:43:26
2019-08-03T02:43:26
200,323,056
0
0
null
null
null
null
UTF-8
C
false
false
5,215
c
client.c
/************************************************************************* > File Name: client.c > Author: Yangyang > Mail: 980560264@qq.com > Created Time: Mon 03 Sep 2018 10:35:21 AM CST ************************************************************************/ //命令都封装在USER结构体中 #include "my.h" #include "net/net.c" char buf[30]="\0"; USER user; int ret_add; INFO userinfo; void main() { int socket_fd = socket_init(); int login_success_flag = 0; int choice; while(1) { bzero(&user,sizeof(user)); choice = init_menu(); if(login_success_flag == 0) { switch(choice) { case 1:Login_menu(&user); user.login_regi_flag=1;//登陆标志位 send(socket_fd, &user, sizeof(user), 0); bzero(&user, sizeof(user)); //返回的user信息中包含用户权限,是普通还是管理员 recv(socket_fd, &user, sizeof(user), 0); break; case 2: printf("You choose exit, later will close this window ...\n"); sleep(2); close(socket_fd); exit(0); } } //把普通和root用户指令相同看待,只是user_command值大小不一样, //这样服务器端就不用区分是普通用户指令还是root用户指令,简化问题 if(user.login_success_flag == User_exist && strcmp(user.type,"guest") == 0) { login_success_flag=1; printf("Guest Login Success, Welcome !!!\n"); while(1){ switch(guest_login_menu()){ case 1:user.user_commend = 1;//修改密码 printf("Please input New Pawwword : "); scanf("%s",user.password); send(socket_fd, &user, sizeof(user), 0); break; case 2:user.user_commend = 2; send(socket_fd, &user, sizeof(user), 0); close(socket_fd); exit(0); break; case 3:user.user_commend=3;//打印用户信息 send(socket_fd, &user, sizeof(user), 0); bzero(&userinfo, sizeof(userinfo)); recv(socket_fd, &userinfo, sizeof(userinfo), 0); print_info(&userinfo); break; default:printf("Please input Again\n"); break; } } } else if(user.login_success_flag == User_exist && strcmp(user.type,"root") == 0) { login_success_flag=1; printf("Root Login Success, Welcome !!!\n"); while(1){ switch(root_login_menu()){ case 1:user.user_commend=1+3;//4 修改信息 bzero(user.name, sizeof(user.name)); printf("Please input The user's name : ");fflush(stdout); scanf("%s", user.name); printf("Please input New Addr : ");fflush(stdout); scanf("%s", userinfo.addr); printf("Please input New Level : ");fflush(stdout); scanf("%d", &userinfo.level); printf("Please input New phone : ");fflush(stdout); scanf("%s", userinfo.phone); strcpy(userinfo.name, user.name); print_info(&userinfo);// send(socket_fd, &user, sizeof(user), 0); send(socket_fd, &userinfo, sizeof(userinfo), 0); break; case 2:user.user_commend=2+3;//5 退出登陆 send(socket_fd,&user,sizeof(user),0); close(socket_fd); exit(0); break; case 3:user.user_commend=3+3;//6 查询指定用户信息 printf("Please input Select User Name : ");fflush(stdout); scanf("%s", user.name); send(socket_fd, &user, sizeof(user), 0); bzero(&userinfo, sizeof(userinfo)); recv(socket_fd, &userinfo, sizeof(userinfo), 0); if(userinfo.age == -1) printf("User doen't existence...\n"); else { system("clear"); print_info(&userinfo); } break; case 4:user.user_commend=4+3;//7 添加用户 Add_menu(&user); send(socket_fd, &user, sizeof(user), 0); recv(socket_fd, &ret_add, sizeof(ret_add), 0); if(ret_add == OK) printf("User Add Success, Contratulations !!!\n"); else printf("User Add Error, Please checkout !!!\n"); break; case 5:user.user_commend=5+3;//8 删除用户 printf("Please input Delete User Name : "); fflush(stdout); scanf("%s", user.name); send(socket_fd, &user, sizeof(user), 0); printf("Deleting Now ... \n"); sleep(2); recv(socket_fd, &ret_add, sizeof(ret_add), 0); if(ret_add == OK) printf("User Deleting Success, Contratulations !!!\n"); else printf("User Deleting Error, Attention !!!\n"); break; case 6: bzero(&user, sizeof(user)); user.user_commend=6+3; send(socket_fd, &user, sizeof(user), 0); recv(socket_fd, &ret_add, sizeof(ret_add), 0); while(ret_add-- > 0) { recv(socket_fd, &userinfo, sizeof(userinfo), 0); print_info(&userinfo); } printf("Press Ane Key to Continue ...\n"); getchar(); getchar(); system("clear"); break; default:printf("Please input Again\n");break; } } } else { printf("User Not Exist! Please later input again...\n"); sleep(3); } } }
30016bff07fccc474a7091ba38d21eaae95e991f
b1a01a1640309b7f701310ea4aa68f14911cc427
/Example/Pods/Target Support Files/Pods-Tests/Pods-Tests-environment.h
582871df16e15affdb813db47841510997e41a17
[ "MIT" ]
permissive
jacobvanorder/VOKMockUrlProtocol
23cfa404796889345d7b032dc0183a1fb92e122b
0676b6fd96f86badec244c384d86cd2dca985b52
refs/heads/master
2021-01-15T08:18:56.579063
2014-10-30T18:41:31
2014-10-30T18:41:31
null
0
0
null
null
null
null
UTF-8
C
false
false
683
h
Pods-Tests-environment.h
// To check if a library is compiled with CocoaPods you // can use the `COCOAPODS` macro definition which is // defined in the xcconfigs so it is available in // headers also when they are imported in the client // project. // ILGHttpConstants #define COCOAPODS_POD_AVAILABLE_ILGHttpConstants #define COCOAPODS_VERSION_MAJOR_ILGHttpConstants 1 #define COCOAPODS_VERSION_MINOR_ILGHttpConstants 0 #define COCOAPODS_VERSION_PATCH_ILGHttpConstants 0 // VOKMockUrlProtocol #define COCOAPODS_POD_AVAILABLE_VOKMockUrlProtocol #define COCOAPODS_VERSION_MAJOR_VOKMockUrlProtocol 1 #define COCOAPODS_VERSION_MINOR_VOKMockUrlProtocol 0 #define COCOAPODS_VERSION_PATCH_VOKMockUrlProtocol 2
a5a3491ef57a77ce4dbee6d8439991eb27da7823
54b92aefb186bde332dfacfce502fff9114064ec
/main.c
68dc01187822f648d3b779ce9d4b2285698f3997
[]
no_license
saicharan1213/atmega32-controller
298500e6f4be7b460cfd9fb033b316a0dff2f281
66b3a027434742183a445dc5e3586f8e27a4655d
refs/heads/main
2023-04-28T06:36:19.914120
2021-05-15T19:42:46
2021-05-15T19:42:46
366,494,892
0
0
null
null
null
null
UTF-8
C
false
false
438
c
main.c
/* * GccApplication2.c * * Created: 08-05-2021 22:18:49 * Author : A.C.E */ #include <avr/io.h> #include <util/delay.h> #define F_CPU 16000000 int main(void) { DDRB |= (1<<0);//out DDRB &= ~(1<<1);//in PORTB |= (1<<1); /* Replace with your application code */ while (1) { if (!PINB & 0x01)//switch connected to portb.1 { PORTB |=(1<<0); } if(!(!PORTB & 0x01)) { PORTB &=~(1<<0); } } }
4b4defd2f0b0120eb8ebe4ac2e2e404a2aac91f2
a280aa9ac69d3834dc00219e9a4ba07996dfb4dd
/regularexpress/home/weilaidb/work/kernel/linux-3.0.8/drivers/infiniband/hw/mthca/mthca_profile.c
59b1d6a1d1c338aaf739e6e5a85fc7ff1e042544
[]
no_license
weilaidb/PythonExample
b2cc6c514816a0e1bfb7c0cbd5045cf87bd28466
798bf1bdfdf7594f528788c4df02f79f0f7827ce
refs/heads/master
2021-01-12T13:56:19.346041
2017-07-22T16:30:33
2017-07-22T16:30:33
68,925,741
4
2
null
null
null
null
UTF-8
C
false
false
161
c
mthca_profile.c
enum ; enum ; s64 mthca_make_profile(struct mthca_dev *dev, struct mthca_profile *request, struct mthca_dev_lim *dev_lim, struct mthca_init_hca_param *init_hca)
341e6a53a964088ce87bfdc74f71e5ce2028fd5b
63172395a3257d1d66bfd1039829b43d4601f959
/URI/Simple_Product.c
0e4228d7525bdda77bbf9edffd890f6635d73c78
[]
no_license
raja-moukhass/competitive-programming
47f729bd7e233bf8c9dc7bbabefb22f6156ca425
68202f84baaa6946c89de1e3a145f4bdc47741d5
refs/heads/master
2021-02-04T00:03:51.940892
2020-12-19T10:32:32
2020-12-19T10:32:32
243,580,766
3
0
null
null
null
null
UTF-8
C
false
false
166
c
Simple_Product.c
#include <stdio.h> int main() { long long a; long long b; long long PROD; scanf("%lld %lld",&a,&b); PROD = a * b; printf("PROD = %lld\n", PROD); return 0; }
ba2f71d96b3d1896d49b44ebfead1019968395fc
ab7cf97c538a0532423f00934db6ec7fff04553b
/test_2021_2_9/test.c
32c4c8c2be35eebe36a849452609a7c383cfb6ed
[]
no_license
histry/test.c_2021
d5c719edef6e9e660f4e83e08323ed78fc2d7be3
06732eba1da156ade3cb7c86b97522b0378885f6
refs/heads/master
2023-03-24T10:18:16.596907
2021-03-12T15:53:59
2021-03-12T15:53:59
330,960,908
0
0
null
null
null
null
GB18030
C
false
false
9,092
c
test.c
#define _CRT_SECURE_NO_WARNINGS 1 //#include <stdio.h> //void test1() //{ // printf("hehe\n"); //} //void test2(const char* str) //{ // printf("%s\n", str); //} //int main() //{ // test1(); //实用()作为函数调用操作符。 // test2("hello bit.");//实用()作为函数调用操作符。 // return 0; //} // //struct Stu //{ // char name[10]; // int age; // char sex[5]; // double score; //}; // //void set_age1(struct Stu stu) //{ // stu.age = 18; //} // //void set_age2(struct Stu* pStu) { // pStu->age = 18;//结构成员访问 //} // //int main() //{ // struct Stu stu; // struct Stu* pStu = &stu;//结构成员访问 // // stu.age = 20;//结构成员访问 // set_age1(stu); // // pStu->age = 20;//结构成员访问 // set_age2(pStu); // return 0; //} //#include <stdio.h> //int main() //{ // int a = 10; // int b = 20; // int max = 0; // if (a >= b) // max = a; // else // max = b; // printf("%d\n", max); // max = (a >= b) ? (a) : (b); // printf("%d\n", max); // return 0; //} //#include <stdio.h> //int main() //{ // int a = 0; // int b = 0; // if (a > 5) // b = 3; // else // b = -3; // b = ( a > 5 ) ? ( 3 ) : ( -3 ); // return 0; //} //#include <stdio.h> // int main() //{ // int i = 0, a = 0, b = 2, c = 3, d = 4; // //i = a++ && ++b && d++; // i = a++||++b||d++; // printf("a = %d\nb = %d\nc = %d\nd = %d\n", a, b, c, d); // //程序输出的结果是什么? // return 0; //} //#include <stdio.h> //int main() //{ // int a = 0;//0//逻辑假默认值为0 // int b = 10;//1//逻辑真默认值为1 // // int c = a && b;//0&&1//0逻辑与1为假默认为0 // printf("%d\n", c);//0 // return 0; //} //#include <stdio.h> //int main() //{ // int a = 10;//1//逻辑真默认值为1 // int b = 20;//1//逻辑真默认值为1 // // int c = a && b;//1&&1//1逻辑与1为真默认为1 // printf("%d\n", c);//1 // return 0; //} //#include <stdio.h> //int main() //{ // int a = 11;//1011 // a = a | (1 << 2); // //将二进制的第三位0改为1 // //即改为1011//11改为1111//15 // //00000000000000000000000000001011//11 // //00000000000000000000000000000100//4//1<<2//00000000000000000000000000000001//00000000000000000000000000000100//4 // //00000000000000000000000000001111//11 | 4 = 15 // printf("%d\n", a);//15 // // a = a & (~(1 << 2)); // //将二进制的第三位1改回0 // //即将1111//15改为1011//11 // //00000000000000000000000000001111//15 // //11111111111111111111111111111011//~4 // //00000000000000000000000000000100//4//1<<2//00000000000000000000000000000001//00000000000000000000000000000100//4 // //00000000000000000000000000001011//11 // printf("%d\n", a);//11 // return 0; //} //#include <stdio.h> //int main() //{ // int a = 0; // //000000000000000000000000补码 // printf("%d\n", a); // //按(二进制补码)位取反 // printf("%d\n", ~a); // //111111111111111111111111补码 // //111111111111111111111110反码 // //100000000000000000000001原码 // //-1 // return 0; //} //#include <stdio.h> //int main() //{ // short s = 0; // int a = 10; // printf("%d\n", sizeof(s = a + 5));//2 // printf("%d\n", s);//0 // return 0; //} //#include <stdio.h> //int main() //{ // int a = 10; // int* pa = &a;//将 a 的地址放入指针变量 pa 中 // printf("%d\n", pa);//打印的是a的地址 // return 0; //} //#include <stdio.h> //int main() //{ // int a = 10; // printf("%d\n", &a);//打印的是a的地址 // return 0; //} //#include <stdio.h> //int main() //{ // int a = 10; // int b = -a; // printf("%d\n", b); // return 0; //} //#include <stdio.h> //int main() //{ // int a = 10; // if (a) // { // printf("hehe\n"); // } // return 0; //} //#include <stdio.h> //int main() //{ // int a = 0; // if (!a) // { // printf("hehe\n"); // } // // return 0; //} //#include <stdio.h> //int main() //{ // int a = 10; // printf("%d\n", !a);//0 // // int b = 0; // printf("%d\n", !b);//1 // return 0; //} //#include <stdio.h> //int main() //{ // int num = 0; // scanf("%d", &num); // int i = 0; // int count = 0;//计数 // while (num) // { // count++; // num = num & (num - 1); // } // printf("%d\n", count); // return 0; //} //#include <stdio.h> //int main() //{ // int num = 0; // scanf("%d", &num); // int count = 0; // int i = 0; // for (i = 0; i < 32; i++) // { // if (((num >> i )& 1) == 1) // { // count++; // } // } // printf("%d\n", count); // return 0; //} //#include <stdio.h> //int main() //{ // int num = 0; // scanf("%d", &num); // int count = 0; // while (num) // { // if (num % 2 == 1) // count++; // num = num / 2; // } // printf("%d\n", count);//011//3//2 // return 0; //} //#include <stdio.h> //int main() //{ // int a = 10; // int b = 20; // printf("a=%d b=%d\n", a, b); // a = a ^ b; // b = a ^ b; // a = a ^ b; // printf("a=%d b=%d\n", a, b); // return 0; //} //#include <stdio.h> //int main() //{ // int a = 10; // int b = 20; // printf("a=%d b=%d\n", a, b); // a = a + b; // b = a - b; // a = a - b; // printf("a=%d b=%d\n", a, b); // return 0; //} //#include <stdio.h> //int main() //{ // int a = 10; // int b = 20; // printf("a=%d b=%d\n", a, b); // int tmp = a; // a = b; // b = tmp; // printf("a=%d b=%d\n", a, b); // return 0; //} //#include<stdio.h> //int main() //{ // int a = 5; // //101 // //0000000000000000000000101原码 // //0000000000000000000000101反码 // //0000000000000000000000101补码 // int b = 3; // //011 // //0000000000000000000000011原码 // //0000000000000000000000011反码 // //0000000000000000000000011补码 // int c = a ^ b; // //按(二进制补码)位异或 // // (101)异或(011) // //相同为0 // //相反为1 // //0000000000000000000000101补码 // //0000000000000000000000011补码 // //101 // //011 // //110 // printf("%d\n", c);//6 // // return 0; //} //#include<stdio.h> //int main() //{ // int a = 5; // //101 // //0000000000000000000000101原码 // //0000000000000000000000101反码 // //0000000000000000000000101补码 // int b = 3; // //011 // //0000000000000000000000011原码 // //0000000000000000000000011反码 // //0000000000000000000000011补码 // int c = a | b; // //按(二进制补码)位或 // // (101)或(011) // //1或0(或1)都为1 // //0或0 为 0 // //0000000000000000000000101补码 // //0000000000000000000000011补码 // //101 // //011 // //111 // printf("%d\n", c);//7 // // return 0; //} //#include<stdio.h> //int main() //{ // int a = 5; // //101 // //0000000000000000000000101原码 // //0000000000000000000000101反码 // //0000000000000000000000101补码 // int b = 3; // //011 // //0000000000000000000000011原码 // //0000000000000000000000011反码 // //0000000000000000000000011补码 // int c = a & b; // //按(二进制补码)位与 // // 与 ,1与1为1,0与1或0都为0 // //0000000000000000000000101补码 // //0000000000000000000000011补码 // //101 // //011 // //001 // printf("%d\n", c);//1 // // return 0; //} //#include<stdio.h> //int main() //{ // //正数的原反补码都相同 // //负数的原码加上符号位,数值位 // //负数的反码,符号位不变,数值位按位取反 // //负数的补码,反码+1 // int a = 5; // //0000000000000000000000101原码 // //0000000000000000000000101反码 // //0000000000000000000000101补码 // int b = a << 1; // //左边丢弃左边补0 // //0000000000000000000001010补码 // //0000000000000000000001010反码 // //0000000000000000000001010原码 // //10 // printf("%d\n", b); // int c = a << 2; // //右边丢弃左边补原符号位 // //0000000000000000000010100补码 // //0000000000000000000010100反码 // //0000000000000000000010100原码 // //20 // printf("%d\n", c); // // return 0; //} //#include<stdio.h> //int main() //{ // //正数的原反补码都相同 // //负数的原码加上符号位,数值位 // //负数的反码,符号位不变,数值位按位取反 // //负数的补码,反码+1 // int a = 16; // //0000000000000000000010000原码 // //0000000000000000000010000反码 // //0000000000000000000010000补码 // int b = a >> 1; // //右边丢弃左边补原符号位 // //0000000000000000000001000补码 // //0000000000000000000001000反码 // //0000000000000000000001000原码 // //8 // printf("%d\n", b); // int c = a >> 2; // //右边丢弃左边补原符号位 // //0000000000000000000000100补码 // //0000000000000000000000100反码 // //0000000000000000000000100原码 // //4 // printf("%d\n", c); // // return 0; //} //#include<stdio.h> //int main() //{ // int a = -1; // //1000000000000000000000001原码 // //1111111111111111111111110反码 // //1111111111111111111111111补码 // int b = a >> 1; // //右边丢弃左边补原符号位 // //1111111111111111111111111补码 // //-1 // printf("%d\n", b); // return 0; //} //#include<stdio.h> //int main() //{ // int a1 = 5 / 2;//商2余1//2//取商 // printf("%d\n", a1); // // int a2 = 5 % 2;//商2余1//1//取余 // printf("%d\n", a2); // // //float double(默认精确到小数点后6位) // float b = 5 / 2;//商2余1//2.000000 // printf("%f\n", b); // // //如果想要得到小数 // //必须 5写为5.0 或 2写为2.0 或 1.0 * 5 / 2 // float c = 5.0 / 2;//商2余1//2.500000 // printf("%f\n", c); // // return 0; //}
740787032b8a051d4fa743590b6f9bd27b250c65
52b6e43e510d57fa3e3e7ac46df09f08293ff625
/main_relay.c
6cf3930e32e00cebd3fd0d5270ea96f66993d6ab
[]
no_license
GalenMoo/VoiceHomeAssistant
f525f9d73e6d5775667d9139cafd68114778be98
2819c0830a24b2454a42a9acb99028ba809db2b1
refs/heads/master
2021-09-10T19:33:27.112883
2018-03-31T20:36:35
2018-03-31T20:36:35
104,976,623
0
0
null
null
null
null
UTF-8
C
false
false
1,715
c
main_relay.c
//***************************************************************************** // // MSP432 main.c template - Empty main // //**************************************************************************** #include "msp.h" void delayMs(int n); void UART2_init(void); void main(void){ UART2_init(); P2->DIR |= BIT0; P3->DIR |= BIT0; P3->OUT &= ~BIT0; NVIC_SetPriority(EUSCIA0_IRQn, 4); /* set priority to 4 in NVIC */ NVIC_EnableIRQ(EUSCIA2_IRQn); /* enable interrupt in NVIC */ __enable_irq(); /* global enable IRQs */ SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk; // wake up on exit from ISR while(1){ _sleep(); } } void delayMs(int n) { int i, j; for (j = 0; j < n; j++) for (i = 149; i > 0; i--); /* Delay */ } void UART2_init(void) { EUSCI_A2->CTLW0 |= 1; /* put in reset mode for config */ EUSCI_A2->MCTLW = 0; /* disable oversampling */ EUSCI_A2->CTLW0 = 0x0081; /* 1 stop bit, no parity, SMCLK, 8-bit data */ EUSCI_A2->BRW = 312; /* 3000000 / 9600 = 312 */ EUSCI_A2->MCTLW = P3->SEL0 |= 0x0C; /* P3.2, P3.3 for UART */ P3->SEL1 &= ~0x0C; EUSCI_A2->CTLW0 &= ~1; /* take UART out of reset mode */ EUSCI_A2->IE |= 1; /* enable receive interrupt */ } void EUSCIA2_IRQHandler(void) { /* interrupt flag is cleared by reading RXBUF */ if (EUSCI_A2->RXBUF == 'Y'){ /* read the receive char and check */ P3->OUT |= BIT0; /* interrupt flag is cleared by reading RXBUF */ } else if (EUSCI_A2->RXBUF == 'N'){ P3->OUT &= ~BIT0; } else{} }
45cc2ee393726074cbef97df6b76a9b2c8677524
2cdd92dd57301d968541ada388f6384081d504b8
/clox/debug.c
0e85cc4d82baf6573715834f0bdd9b07db2a6b43
[]
no_license
vn-ki/lox-experiments
2b1b814126ae324baa60834ebc33c8240472355b
53e3cc7b259205be01c1ff314311cd9def722343
refs/heads/master
2022-12-17T12:04:29.134099
2020-08-29T16:53:36
2020-08-29T16:53:36
291,311,664
0
0
null
null
null
null
UTF-8
C
false
false
1,217
c
debug.c
#include "debug.h" void DisassembleChunk(Chunk *chunk, const char *name) { printf(EC_PURPLE "=====%s=====\n" EC_NC, name); for (int offset=0; offset<chunk->count;) { offset = DisassembleInstr(chunk, offset); } } int simpleInstruction(char *name, int offset) { printf("%s\n", name); return offset+1; } void printValue(Value val) { printf("%g", val); } int constantInstr(char *name, Chunk *chunk, int offset) { uint8_t constant = chunk->code[offset+1]; printf("%-16s %4d '", name, constant); printValue(chunk->constants.values[constant]); printf("'\n"); return offset + 2; } int DisassembleInstr(Chunk *chunk, int offset) { printf("%04d ", offset); if (offset > 0 && chunk->lines[offset] == chunk->lines[offset - 1]) { printf(" | "); } else { printf("%4d ", chunk->lines[offset]); } uint8_t instr = chunk->code[offset]; switch (instr) { case OP_RETURN: return simpleInstruction("OP_RETURN", offset); case OP_CONSTANT: return constantInstr("OP_CONSTANT", chunk, offset); default: printf("Unknown opcode '%d'\n", instr); return offset+1; } }
05993cafa05ff851189ee7c5bb100b9c04ef6a9e
d4b5d8c5ce2392e9be6850a31910f4caaafe26f7
/d01/chronalcalibration.c
d142a5d6d0c844bc73bbd0c181c8325216a4a472
[]
no_license
vtheenby/aoc2019_c_norme
91d7b963ab9067d2619d3b5ea1f5b57942b41f91
fb1c0d43ab223d4e8007a1bcdd8447c17821180f
refs/heads/master
2022-12-03T03:00:44.533085
2020-08-13T19:32:10
2020-08-13T19:32:10
287,364,078
0
0
null
null
null
null
UTF-8
C
false
false
760
c
chronalcalibration.c
#include <unistd.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> int ft_atoi(int nb) { } int ft_strlen(char *str) { int i; i = 0; while (str[i]) { i++; } return (i); } void ft_putstr(char *str) { write(1, str, ft_strlen(str)); } void ft_edit_total(int *total, char *line) { ft_putstr(line); } int ft_read_lines(int fd) { char buf; char *line; int index; int total; buf = '\0'; line = malloc(10); index = 0; total = 0; while (read(fd, &buf, 1)) { if (buf != '\n') { line[index] = buf; index++; } else { line[index + 1] = '\0'; ft_edit_total(&total, line); index = 0; } } } int main(void) { ft_putnbr(ft_read_lines(open("input", O_RDWR))); return (0); } //"+3\n-623423\n etc..
da5cf0c8e9c5d6784ea719807151f6a8f509337b
f714f2758c54214689430e2f4a11cf18c4cc6deb
/Zynq/zynqBM/src/ipacs/h/system/bsp/bsp.h
443774d434cc86f6a06bda42c095a45619b0f3aa
[]
no_license
zzfd97/1111
2b4b6d3c711fce5f7f7be3ed76a728614852db93
652acd9180d0386c80e0a5eb2ce209163f206dd4
refs/heads/master
2022-12-27T17:41:35.977196
2020-10-10T03:45:43
2020-10-10T03:45:43
null
0
0
null
null
null
null
WINDOWS-1252
C
false
false
9,673
h
bsp.h
/*------------------------------------------------------------------------ Module: bsp.h Author: Project: Creation Date: 2020Äê7ÔÂ23ÈÕ 11:30:03 Description: ------------------------------------------------------------------------*/ /*------------------------------------------------------------------------ $Log: $ ------------------------------------------------------------------------*/ #ifndef _BSP_H #define _BSP_H #include "syscfg.h" #ifdef __cplusplus extern "C" { #endif //AT EEPROM 64K #define NVRAM_DEV_ID 0x00 #define NVRAM_BS 0x20 #define NVRAM_BOOT_CNT 0x3F #define NVRAM_AD_IP_MAC 0x40 #define NVRAM_AD_IPEXT_MAC 0xB0 #define NVRAM_AD_DOYB 0x100 #define NVRAM_AD_CELL 0x108 #define NVRAM_BS_SP 0x2B0 #define NVRAM_AD_GPRS 0x300 #define NVRAM_AD_RESET 0x450 #define NVRAM_PROG_CODE 0x4A0 #define NVRAM_AD_DD 0x500 #define NVRAM_DEV_ID_LEN 24 #define NVRAM_AD_GAIN (2*1024) #define NVRAM_AD_AIDC_GAIN (NVRAM_AD_GAIN-0x100) #define NVRAM_AD_WYFZ_YX (NVRAM_AD_AIDC_GAIN-0x20)//???ftu??? #if (DEV_SP == DEV_SP_TTU)||(DEV_SP == DEV_SP_DTU_IU) #define NVRAM_AD_ATT_GAIN (NVRAM_AD_GAIN+4*1024) #define NVRAM_PowerOff 8*1024 #define NVRAM_MonOverU (NVRAM_PowerOff+0x100) #define NVRAM_MonBelowU (NVRAM_MonOverU+0x100) #define NVRAM_MonPassU (NVRAM_MonBelowU+0x100) #define NVRAM_AD_DD_JFPG (NVRAM_MonPassU+0x100) #define NVRAM_ATT_GAIN (NVRAM_AD_DD_JFPG+2*1024) #endif #define NVRAM_YAFFS_DISK1 (7*1024) #define NVRAM_YAFFS_DISK2 (NVRAM_YAFFS_DISK1 + 32) #define NVRAM_YAFFS_MAG1 (NVRAM_YAFFS_DISK2 + 48) #define NVRAM_YAFFS_MAG2 (NVRAM_YAFFS_MAG1 + 16) #define NVRAM_DEV_TYPE_FLAG (NVRAM_YAFFS_MAG2 + 16) //???????????? #define NVRAM_DEV_TYPE (NVRAM_DEV_TYPE_FLAG + 1) //????????,???????????PARACHAR_MAXLEN #define NVRAM_DEV_MFR_FLAG (NVRAM_DEV_TYPE + Old_MAXLEN) //?????????gb2312???? #define NVRAM_DEV_MFR (NVRAM_DEV_MFR_FLAG+1) //??????gb2312?? ???????????PARACHAR_MAXLEN #define NVRAM_DEV_SV_FLAG (NVRAM_DEV_MFR + Old_MAXLEN) //???????????? #define NVRAM_DEV_SV (NVRAM_DEV_SV_FLAG + 1) //?????????? #define NVRAM_DEV_PUBYB (NVRAM_DEV_SV+Old_MAXLEN) #define NVRAM_DEV_MFR_UTF8_FLAG (NVRAM_DEV_PUBYB + 4) //????????utf8?? #define NVRAM_DEV_MFR_UTF8 (NVRAM_DEV_MFR_UTF8_FLAG+1) //????????utf-8 ???????????PARACHAR_MAXLEN #define NVRAm_DEV_PUBYB_MULTI (NVRAM_DEV_MFR_UTF8+PARACHAR_MAXLEN)//????? ????15*4 #define NVRAM_CODE_SECTOR (8*1024 - 0x100) // #define NVRAM_CODE_SECTOR_EXT (8*1024 - 0x200) //??????256??,?sector??20?,????? #define BSP_NVRAM_ERRCOUNT (NVRAM_CODE_SECTOR_EXT - 100) //BOOT ? #define BSP_NVRAM_BOOTERR (BSP_NVRAM_ERRCOUNT+0x04) #define BSP_NVRAM_CELLIN (BSP_NVRAM_BOOTERR+0x04) #define BSP_NVRAM_FAON (BSP_NVRAM_CELLIN+0x04) //32fd #define BSP_NVRAM_FADIFFON (BSP_NVRAM_FAON+0x04) #define BSP_NVRAM_LANERR (BSP_NVRAM_FADIFFON+0x04)//?15??? extern uint8 FPGA_CPLD_READ (DWORD addr); extern void FPGA_CPLD_WRITE (DWORD addr,BYTE regVal); #define BSP_ADDR_CS4 0 //cpld?? #define BSP_PORT_CPLD ((volatile unsigned char *)(BSP_ADDR_CS4+0)) #define BSP_PORT_YX_LATCH ((volatile unsigned char *)(BSP_ADDR_CS4+0x40)) #define BSP_PORT_YX_READ ((volatile unsigned char *)(BSP_ADDR_CS4+0x44)) #define BSP_PORT_YK ((volatile unsigned char *)(BSP_ADDR_CS4+0x80)) #define BSP_PORT_LED1 ((volatile unsigned char *)(BSP_ADDR_CS4+0xC0)) #define BSP_PORT_LED2 ((volatile unsigned char *)(BSP_ADDR_CS4+0xC4)) #define BSP_PORT_LED3 ((volatile unsigned char *)(BSP_ADDR_CS4+0xC8)) #define BSP_PORT_YK_CELL ((volatile unsigned char *)(BSP_ADDR_CS4+0x94)) #define BSP_ADDR_POWER_TYPE 0x08 #define BSP_ADDR_POWER_DI 0x09 #define BSP_ADDR_IO1_TYPE 0x40 #define BSP_ADDR_IO1_READ 0x42 #define BSP_ADDR_YK1_FJ 0x41 #define BSP_ADDR_AC1_TYPE 0x50 #define BSP_ADDR_CPLD_ADD 0x8 #define BSP_AC_BOARD 3 #define BSP_IO_BOARD 7 #define BSP_RAM_YK 0x01 #define BSP_RAM_YKFJ 0x02 #define BSP_PORT_YKD1 0x25 #define BSP_PORT_YKCELL 0x41 extern unsigned char BSP_ESRAM[]; #define BSP_ESRAM_ADDR ((DWORD)BSP_ESRAM) #define ESRAM_TOTAL_SIZE 4096 #define BSP_ESRAM_EXTYX (BSP_ESRAM_ADDR+0x0B) /*8???????*/ #define BSP_ESRAM_YK (BSP_ESRAM_ADDR+0x0C) /*32?YK???? ?*/ #define BSP_ESRAM_YX (BSP_ESRAM_ADDR+0x2C) /*64?YX????*/ #define REG8(addr) *((volatile unsigned char *) (addr)) #define REG16(addr) *((volatile unsigned short *) (addr)) #define REG32(addr) *((volatile unsigned long *) (addr)) //?cpld??? myinline BYTE CPLD_Read(volatile unsigned char * addr) { BYTE value = 0; value = FPGA_CPLD_READ((DWORD)addr); return value; } //?CPLD??? myinline void CPLD_Write(volatile unsigned char * addr, BYTE value) { FPGA_CPLD_WRITE((DWORD)addr,value); } /*?cpu???,?????,yx,yk????????*/ myinline BYTE Get_Ai_Type(BYTE addr) { /*REG8(BSP_PORT_YX_LATCH) = BSP_ADDR_AC1_TYPE + addr*8; return (REG8(BSP_PORT_YX_READ));*/ CPLD_Write(BSP_PORT_YX_LATCH,BSP_ADDR_AC1_TYPE + addr*8); return (CPLD_Read(BSP_PORT_YX_READ)); //return 0x64; } myinline BYTE Get_Io_Type(BYTE addr) { /*REG8(BSP_PORT_YX_LATCH) = BSP_ADDR_IO1_TYPE - addr*8; return (REG8(BSP_PORT_YX_READ));*/ CPLD_Write(BSP_PORT_YX_LATCH,BSP_ADDR_IO1_TYPE - addr*8); return (CPLD_Read(BSP_PORT_YX_READ)); /*if(addr <3 ) return 0x09; else return 0x08;*/ } myinline BYTE Get_Power_Type(BYTE addr) { BYTE YX_READ; /*REG8(BSP_PORT_YX_LATCH) = BSP_ADDR_POWER_TYPE; YX_READ = REG8(BSP_PORT_YX_READ);*/ CPLD_Write(BSP_PORT_YX_LATCH,BSP_ADDR_POWER_TYPE); YX_READ = CPLD_Read(BSP_PORT_YX_READ); /*YX_READ = 0;*/ return YX_READ; } myinline BYTE PhyBit_Read(DWORD ramaddr, DWORD port) { BYTE in, k; BYTE YX_READ; /*if (ramaddr == BSP_RAM_YKFJ) { REG8(BSP_PORT_YX_LATCH) = port; YX_READ = (REG8(BSP_PORT_YX_READ)); return YX_READ; } else if (ramaddr == BSP_RAM_YK) { in = port/32; k = port%32; return (REG8(BSP_ESRAM_YK+in)>>k); } else */ if (ramaddr == BSP_RAM_YKFJ) { CPLD_Write(BSP_PORT_YX_LATCH,port); YX_READ = (CPLD_Read(BSP_PORT_YX_READ)); return YX_READ; } else if (ramaddr == BSP_RAM_YK) { in = port/32; k = port%32; return (REG8(BSP_ESRAM_YK+in)>>k); } else return 0; } myinline void PhyBit_Set(DWORD ramaddr, DWORD port, BYTE value) { DWORD out,bit; /*if (port < 0x40) REG8(BSP_PORT_YK) = port|(value<<7); else REG8(BSP_PORT_YK_CELL) = port|(value<<7); out = port/32; bit = 0x01<<(port - 32); if (value) REG32(BSP_ESRAM_YK + out) |= bit; else REG32(BSP_ESRAM_YK + out) &= ~bit;*/ if (port < 0x40) CPLD_Write(BSP_PORT_YK,port|(value<<7)); else CPLD_Write(BSP_PORT_YK_CELL, port|(value<<7)); out = port/32; bit = 0x01<<(port - 32); if (value) REG32(BSP_ESRAM_YK + out) |= bit; else REG32(BSP_ESRAM_YK + out) &= ~bit; } myinline void PhyBit_Init(DWORD ramaddr, DWORD port, BYTE value) { REG8(ramaddr) = value; PhyBit_Set(ramaddr, port, value); } #define CPLD_Ver(void) (CPLD_Read(BSP_PORT_CPLD)) #define romNvRamGet(offset, buf, len) extNvRamGet(offset, buf, len); #define romNvRamSet(offset, buf, len) extNvRamSet(offset, buf, len); enum { BSP_LIGHT_RUN_ID, BSP_LIGHT_BGN, BSP_LIGHT_WARN_ID=BSP_LIGHT_BGN, BSP_LIGHT_COMM_ID, BSP_LIGHT_GPRS_ID, BSP_LIGHT_SYS_ID = BSP_LIGHT_GPRS_ID, BSP_LIGHT_FAIN_ID, BSP_LIGHT_FADZ_ID, BSP_LIGHT_FACOMM_ID, BSP_LIGHT_FACON_ID, BSP_LIGHT_FA_ID = BSP_LIGHT_FACON_ID, BSP_LIGHT_FAULT1_ID, BSP_LIGHT_FAULT2_ID, BSP_LIGHT_FAULT3_ID, BSP_LIGHT_FAULT4_ID, BSP_LIGHT_FAULT5_ID, BSP_LIGHT_FAULT6_ID, BSP_LIGHT_FAULT7_ID, BSP_LIGHT_FAULT8_ID, BSP_LIGHT_FAULT9_ID, BSP_LIGHT_FAULT10_ID, BSP_LIGHT_FAULT11_ID, BSP_LIGHT_FAULT12_ID, BSP_LIGHT_FAULT13_ID, BSP_LIGHT_FAULT14_ID, BSP_LIGHT_FAULT15_ID, BSP_LIGHT_FAULT16_ID, BSP_LIGHT_END }; void turnLight(int id, BYTE on); DWORD getLight(void); void runLight_turn(void); #define GPIO_VESAM_CON 54 #define GPIO_GPS_RST 55 #define GPIO_RUN_LED 56 #define GPIO_WARN_LED 57 #define GPIO_COMM_LED 58 #define GPIO_GPRS_LED 59 #define GPIO_JC_RST 60 #define GPIO_WIFI_RST 61 #define GPIO_KG1 62 #define GPIO_KG2 63 #define GPIO_AJ_FW 64 #define GPIO_JC_SIG 65 #define GPIO_CPLD_RST 66 #define HDLC1_SD 67 #define HDLC2_SD 68 #define HDLC3_SD 69 //??GPIO?????,??Data?? void hd_gpio_SetDirectionOut(u32 io, u32 Data); //??GPIO???,??????? u32 hd_gpio_SetDirectionIn(u32 io); //???? void hd_gpio_SetOut(u32 io, u32 Data); //???? u32 hd_gpio_ReadIn(u32 io); #define SET_GPIO(port, pin) hd_gpio_SetOut( pin, 1) #define CLEAR_GPIO(port, pin) hd_gpio_SetOut( pin, 0) /*??input?? output ?port->PIO_ODSR*/ #define READ_GPIO(port, pin) (hd_gpio_ReadIn(pin)) void runlinuxled(); #ifdef __cplusplus } #endif #endif
42ac64cdf9054054ad668e594d7b73b5ded4adc1
bf4444d210840254f0828133d08cd68a149db55d
/libft/src/ft_strdup.c
8477fc26529f22c4565d6109a559ebaacb0b8e69
[]
no_license
Mormoilbou/42sh
3986721da777f432970664fc41c30204355c0436
a05412d2c17459546338b8f26cce65af72f5f908
refs/heads/master
2021-01-12T01:46:40.892656
2017-01-09T13:26:31
2017-01-09T13:26:31
78,430,160
3
0
null
null
null
null
UTF-8
C
false
false
1,133
c
ft_strdup.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strdup.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: fkoehler <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2015/11/24 14:44:15 by fkoehler #+# #+# */ /* Updated: 2015/12/08 17:22:21 by fkoehler ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strdup(const char *s1) { char *s2; int i; i = 0; s2 = (char *)malloc(sizeof(char) * (ft_strlen(s1) + 1)); if (!s2) return (NULL); while (s1[i]) { s2[i] = s1[i]; i++; } s2[i] = 0; return (s2); }
2ef520d48ba2dff042e02f49452ec976a99c9064
f1e5583d199ec738b024987d909bfacc5d8b6d64
/exercise/ABC176-b.c
cc382ffdd2e8782cd03ea28ac3b882f724d1f3f3
[]
no_license
VViseman/c_develop
ca0346b33129db94eeae85c47475fd43afd51875
a5dae0b35eb1493f93f4ebe54b180fda5f47f3fc
refs/heads/master
2021-06-26T13:13:50.298252
2021-04-04T03:53:31
2021-04-04T03:53:31
226,101,933
0
0
null
null
null
null
UTF-8
C
false
false
788
c
ABC176-b.c
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { /* int n = 0; int x = 0; int i; int temp; scanf("%d", &n); for (i = 0; n > 0; i++) { temp += n % 10; } if(temp % 9 == 0){ printf("Yes\n"); }else{ printf("No\n"); } */ char s[200010]; scanf("%s", s); int len = strlen(s); int sum = 0; for (int i = 0; i < len; i++){ sum += s[i] - '0'; //文字コードで数字の'0'を引いて文字コードのオフセットを除去して数字の差だけ得る //printf("%d\n", sum); } if (sum % 9 == 0) { puts("Yes"); } else { puts("No"); } return 0; }
cf79abdf5647b2369f298f703df169c7e8494875
b83b7bb7103cbc7871becf065b21c1239bd0b80c
/Basic_1_6/CHAP_2_0.c
7a72516e246015eb760a305d1658ad8a86ac8765
[]
no_license
wow-kim/WOW_C
457251f1e05392a018657953bc19ea4d02697f77
5f98471b4cd3d5174c35fa531fb83e420238df74
refs/heads/main
2023-02-27T10:40:03.918134
2021-02-01T10:06:07
2021-02-01T10:06:07
334,680,996
2
0
null
null
null
null
UHC
C
false
false
676
c
CHAP_2_0.c
// 변수 : 프로그램이 실행되는 동안에 언제든지 저장된 값이 변경될 수 있는 공간을 의미 ex) 두 점간의 거리 distance // 상수 : 한 번 정해지면 값을 변경할 필요가 없는 의미합니다. ex) pi = 3.141592 // 기본적으로 변수안에 상수를 넣는 방식으로 프로그램이 작성됨 // ;(세미콜론) : 하나의 명령이 끝났음을 알려줌 #include <stdio.h> int main(void) { int x; // x라는 이름의 int 자료형 선언 x = 5; printf("변수 x의 메모리 크기는 %d입니다.", sizeof(x)); // sizeof : 차지하는 메모리 크기, int 형은 4바이트 만큼 차지함 return 0; }
7cfbb9dd1f85a6371e13361a3f76a01f5b18931c
3d24f58103943d75cd8f204332dbfdd0e87f081a
/rtable.c
a83ec964480fcd53a9f6e0c73e0ecf7fb76c09ce
[]
no_license
Ioana-Stancioiu/Router-forwarding
bd2de2825ba340662004e0c1d25503398f71552d
5187cb115b38fc6851176867935b9bee82e6a7c1
refs/heads/main
2023-06-03T09:49:46.526801
2021-06-20T15:51:14
2021-06-20T15:51:14
378,680,892
0
0
null
null
null
null
UTF-8
C
false
false
3,632
c
rtable.c
#include <rtable.h> #define INITIAL_CAPACITY 65000 int compare_prefixes(const void* a, const void* b) { struct route_table_entry* entry1 = (struct route_table_entry*)a; struct route_table_entry* entry2 = (struct route_table_entry*)b; if (ntohl(entry1->prefix) == ntohl(entry2->prefix)) { return (ntohl(entry1->mask) - ntohl(entry2->mask)); } return (ntohl(entry1->prefix) - ntohl(entry2->prefix)); } /** * @brief builds an entry for the routing table * with the information gathered from buffer */ struct route_table_entry create_entry(char* buffer) { struct route_table_entry entry; char buffer_info[4][16]; char* token; int index = 0; token = strtok(buffer, " "); while (token != NULL) { memcpy(&buffer_info[index], token, strlen(token)); buffer_info[index][strlen(token)] = '\0'; index++; token = strtok(NULL, " "); } entry.prefix = inet_addr(buffer_info[0]); entry.next_hop = inet_addr(buffer_info[1]); entry.mask = inet_addr(buffer_info[2]); entry.interface = atoi(buffer_info[3]); return entry; } int read_table(char* file_name, struct route_table_entry** rtable) { FILE* input = fopen(file_name, "r"); if (input == NULL) { printf("Error opening input file\n"); exit(0); } *rtable = malloc(sizeof(struct route_table_entry) * INITIAL_CAPACITY); int capacity = INITIAL_CAPACITY; if (*rtable == NULL) { printf("Error allocating memory for routing table\n"); exit(0); } int rtable_size = 0; char* buffer = NULL; size_t buffer_size = 0; int line_size = getline(&buffer, &buffer_size, input); while (line_size >= 0) { if (rtable_size == capacity) { capacity *= 2; *rtable = realloc(*rtable, capacity * sizeof(struct route_table_entry)); if (*rtable == NULL) { printf("Reallocating memory failed\n"); exit(0); } } (*rtable)[rtable_size++] = create_entry(buffer); line_size = getline(&buffer, &buffer_size, input); } free(buffer); fclose(input); //sort rtable by prefix qsort(*rtable, rtable_size, sizeof(struct route_table_entry), compare_prefixes); return rtable_size; } /** * @brief searches for best matching route in rtable * using binary search algorithm */ int binary_search(struct route_table_entry* rtable, int start, int stop, int best_index, uint32_t dest_ip) { if (start > stop) { return best_index; } int mij = start + (stop - start) / 2; if ((rtable[mij].mask & dest_ip) == rtable[mij].prefix) { if ((best_index == -1) || (ntohl(rtable[mij].mask) > ntohl(rtable[best_index].mask))) { return binary_search(rtable, mij + 1, stop, mij, dest_ip); } else { return binary_search(rtable, mij + 1, stop, best_index, dest_ip); } } if (ntohl(dest_ip & rtable[mij].mask) < ntohl(rtable[mij].prefix)) { return binary_search(rtable, start, mij - 1, best_index, dest_ip); } return binary_search(rtable, mij + 1, stop, best_index, dest_ip); } struct route_table_entry* get_best_route(struct route_table_entry* rtable, int rtable_size, uint32_t dest_ip) { int best_index = binary_search(rtable, 0, rtable_size - 1, -1, dest_ip); if (best_index == -1) { printf("Route doesn't exist\n"); return NULL; } return &rtable[best_index]; }
78fd5b8e10c53469a2d5e0cba00589a4bc70af5b
4d1dc208d5258f5f0dbe644ff6ec1d1e6e8c12d5
/UPB_Code/GlobalDefinitions.h
b97e6ad4076b33312c04eb66be067bcfbb9f16f2
[]
no_license
lhtran114/BS_Thesis
59e6f798771ad7d8ca9ccc838b487acf303762b1
da27b5ae56514582b15053a7e1245bf58b843a77
refs/heads/master
2021-01-19T11:29:40.005966
2017-04-11T19:24:16
2017-04-11T19:24:16
87,970,756
1
0
null
null
null
null
UTF-8
C
false
false
7,897
h
GlobalDefinitions.h
/* 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 3 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. http://www.gnu.org/licenses Creator: Arpad Toth (mrx23dot) - 2012 //--------------------------------------------------------- Editor: Tran Hoang Luan (hoangluan01@gmail.com) - Nov/2012 */ #ifndef GLOBALDEFINITIONS_H #define GLOBALDEFINITIONS_H 1 #include "Protocol_defines.h" #include "Pins_Init.h" typedef unsigned char uint8; typedef unsigned int uint16; //bit macro #define bit_get(p,m) ((p) & (m)) #define bit_set(p,m) ((p) |= (m)) #define bit_clear(p,m) ((p) &=~(m)) #define bit_flip(p,m) ((p) ^= (m)) #define BIT(x) (0x01 << (x)) // #define false 0 #define true 1 #define ON 1 #define OFF 0 #define On 1 #define Off 0 #define HIGH 1 #define LOW 0 #define Pressed 0 #define Released 1 // #define _NOP() __asm__ __volatile__ ("nop") #define NOP() _NOP() #define TMR0 TCNT0 #define TMR1 TCNT1 #define TMR2 TCNT2 ///////////////////////////////////////////////////////////// //ALL INVERTED ///////////////////////////////////////////////////////////// #define Red_LED_On bit_clear(PORTB,BIT(Red_Led)) #define Red_LED_Off bit_set(PORTB,BIT(Red_Led)) #define Red_LED_Toggle bit_flip(PORTB,BIT(Red_Led)) #define Green_LED_On bit_clear(PORTB,BIT(Green_Led)) #define Green_LED_Off bit_set(PORTB,BIT(Green_Led)) #define Green_LED_Toggle bit_flip(PORTB,BIT(Green_Led)) #define Button0_Pressed !bit_get(PINC,BIT(Button0_Pin)) #define Button1_Pressed !bit_get(PINC,BIT(Button1_Pin)) #define Button2_Pressed !bit_get(PINC,BIT(Button2_Pin)) ///////////////////////////////////////////////////////////// //Dimmer Light ///////////////////////////////////////////////////////////// #define Disable_TMR1_compare_Light_int bit_clear(TIMSK,BIT(OCIE1B)) #define Enable_TMR1_compare_Light_int bit_set(TIMSK,BIT(OCIE1B)) #define Activate_Load_Triac bit_set(PORTD,BIT(Dimmer_Output_Pin)) #define Deactivate_Load_Triac bit_clear(PORTD,BIT(Dimmer_Output_Pin)) ///////////////////////////////////////////////////////////// //UART ///////////////////////////////////////////////////////////// #define Enable_UART bit_set(UCSRB,BIT(RXCIE)) #define Disable_UART bit_clear(UCSRB,BIT(RXCIE)) #define NID_UART UART_Buffer[0] #define DID_UART UART_Buffer[1] #define Reserve_UART UART_Buffer[2] #define MDID_UART UART_Buffer[3] //Arg[0] #define Arg_UART(i) UART_Buffer[3+i] #define UARTCommand MDID_UART //same! #define Link_UART (Reserve_UART>>7 & 0b000000001) #define ACK_UART (Reserve_UART>>4 & 0b000000111) #define ACK_Pulse_UART (ACK_UART & 0b000000001) #define ID_Pulse_UART (ACK_UART & 0b000000010) #define ACK_Message_UART (ACK_UART & 0b000000100) ///////////////////////////////////////////////////////////// // Zero Cross definitions ///////////////////////////////////////////////////////////// #define Zero_Cross_Signal bit_get(PIND,BIT(Zero_Cross_Pin))//((PIND >> Zero_Cross_Pin) & 0x01) #define Enable_Zerocross_Interrupt bit_set(GICR,BIT(INT0)) #define Disable_Zerocross_Interrupt bit_clear(GICR,BIT(INT0)) #define ZeroCross_Sample_Number 5 //too much will delay offset!!! ///////////////////////////////////////////////////////////// //Timer definitions ///////////////////////////////////////////////////////////// #define TMR1_on ((TCCR1B & 0b00000111) != 0) #define Prescaler_Timer1 8 //MUST Set manually!!! #define Start_Timer1 (TCCR1B = 0b00000010) //Prescaler:8 overflow at 8Mhz 65mS Res: 1uS #define Stop_Timer1 TCCR1B = 0 #define Reset_Timer1 TCNT1 = 0 #define Enable_CompA_Int bit_set(TIMSK,BIT(OCIE1A)); //Enable interrupt on compare 1A ///////////////////////////////////////////////////////////// //Signal Comparator ///////////////////////////////////////////////////////////// #define Disable_Comp_Int bit_clear(ACSR,BIT(ACIE)) #define Enable_Comp_Int bit_set(ACSR,BIT(ACIE)) #define Enable_Comparator bit_clear(ACSR,BIT(ACD)) //Analog Comparator Disable is "0"->switch on #define Disable_Comparator bit_set(ACSR,BIT(ACD)) #define Comparator_Output bit_get(ACSR,BIT(ACO)) #define Signal_Input (!Comparator_Output) //Signal is higher than Vref #define Signal_Input_Inverted Comparator_Output ///////////////////////////////////////////////////////////// //AC Power wave ///////////////////////////////////////////////////////////// #define Sine_Wave_Min_Period 19000 //10mS * 0.95 = 9.5mS = 9500uS #define Sine_Wave_Max_Period 21000 //10mS * 1.05 = 10.5mS = 10500uS ///////////////////////////////////////////////////////////// //Noise Threshold ///////////////////////////////////////////////////////////// #define Min_Noise_Threshold 40 //60 40 27//~0,5V perfect #define Noise_Threshold_Step 16 //25 16 20 ///////////////////////////////////////////////////////////// //Fire Triacs ///////////////////////////////////////////////////////////// #define Triac_On_Response_Time 100 //uS //must be >50us! //#define Triac_Trigger_On bit_set (PORTD,BIT(Signal_Generate_Pin)) //#define Triac_Trigger_Off bit_clear(PORTD,BIT(Signal_Generate_Pin)) #define Triac_Trigger_On bit_set (DDRD,BIT(Signal_Generate_Pin)); bit_set (PORTD,BIT(Signal_Generate_Pin)) #define Triac_Trigger_Off bit_clear(DDRD,BIT(Signal_Generate_Pin)); bit_clear(PORTD,BIT(Signal_Generate_Pin)) /* //DONT OVERLAP ZEROCROSS WITH UPB_SIGNAL Offset values maybe Offset has to be corrected 50Hz AGC_start: 7620 uS Signal Offset: 7980 uS 60Hz AGC_start: 6893,3 uS Signal Offset: 7253,3 uS */ #define AGC_start 15240 #define Offset_Nominal 15960 //For TX! optimal position #define Pulse_Spacing ( Pos1_L - Pos0_L ) //160 us #define Half_Pulse_Width ( ( Pos0_U - Pos0_L ) / 2 ) //40 us //Signal1:80uS, gap:80uS, Signal2:80uS, gap:80uS, Signal3:80 //gap:80uS, Signal4:80uS #define Pos_Steps 160 //!!! 80 uS !!!! #define Pos0_L (0*Pos_Steps) // 0 uS #define Pos0_U (1*Pos_Steps) // 80 uS #define Pos1_L (2*Pos_Steps) //160 uS #define Pos1_U (3*Pos_Steps) //240 uS #define Pos2_L (4*Pos_Steps) //320 uS #define Pos2_U (5*Pos_Steps) //400 uS #define Pos3_L (6*Pos_Steps) //480 uS #define Pos3_U (7*Pos_Steps) //560 uS ///////////////////////////////////////////////////////////// ////////////////////////////////////////// //// On going... ////////////////////////////////////////// ///////////////////////////////////////////////////////////// //For atmega8:#define Enable_Comp_int bit_set(ACSR,BIT(ACIE)) //For atmega8:#define Enable_Zerocross_interrupt bit_set(GICR,BIT(INT1)) //For atmega8:#define Disable_Zerocross_interrupt bit_clear(GICR,BIT(INT1)) #define Low_Byte(x) ( (unsigned char) (x) ) #define High_Byte(x) ( (unsigned char) ( ( (unsigned int) (x) ) >> 8) ) #define UART_Receiving (bit_get(UCSR0A,BIT(RXC0)) >> 7 ) //if (UART_Receiving == 1) //Not universal! //#define Start_Timer2 (TCCR2B = 0b00000111) //Prescaler:1024 overflow at 8Mhz 32mS Res: 128uS //16Mhz //AGC will end sooner! #define Allowed_Negative_Delay 0 //40us To RX pulses before offset #define Max_Delay_For_Both 255 //calced from |-40|+40=80us=160clk #endif
97232518162a7f7195c62347363bdd79056ae7dd
a17646bee2bd376c0658e371ca0e270495bd1ba2
/src/m/task.h
813b1950ba4d11088025dc4aa5b06669e53414b6
[ "MIT" ]
permissive
Phantom1003/riscv-step-by-step
2ff084a092bfc95d6a7002b31de2f1b6603a2430
87cbd3f661cc7c30583df5e78ac9fb3757e8b753
refs/heads/master
2020-08-03T06:05:18.933299
2019-09-09T02:51:21
2019-09-09T02:51:21
211,647,419
0
1
null
2019-09-29T10:43:17
2019-09-29T10:43:17
null
UTF-8
C
false
false
759
h
task.h
#pragma once #include <stdint.h> #include "regs.h" #define TASK_STATUS_READY #ifdef __cplusplus extern "C" { #endif enum { /* currently, ready and running are not different */ task_stat_ready, task_stat_running, task_stat_blocking, task_stat_terminated, }; typedef struct task_t { char tag[8]; uintptr_t regs[REG_CTX_NUM]; uint32_t cause; // interrupted cause uintptr_t epc; // entry or interrupted address uint32_t status; // ready(0), running(1) and blocked(2) uint32_t count; uint32_t mode; uint32_t paddr; // 32-bit physical address is supported uint32_t offset; // 32-bit physical address is supported struct task_t *prev; struct task_t *next; } task_t; #ifdef __cplusplus } #endif
53bbbba0266a3e50041d3bdecba12df987199128
b4dc3314ebc2e8d3ba67fd777802960b4aedd84c
/brix-tools/iab/mfc/LucidGUIBuilder/Resource.h
982f1db3205b012406954b2e62190ea74fdc2d70
[]
no_license
kamilWLca/brix
4c3f504f647a74ba7f51b5ae083bca82f70b9340
c3f2ad913a383bbb34ee64c0bf54980562661e2f
refs/heads/master
2021-01-18T04:08:56.435574
2012-09-18T16:36:32
2012-09-18T16:36:32
null
0
0
null
null
null
null
UTF-8
C
false
false
14,637
h
Resource.h
//{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by DrawGUI.rc // #define IDAPPLY 3 #define IDD_ABOUTBOX 100 #define IDR_MAINFRAME 128 #define IDR_GUITYPE 129 #define IDB_GREY 131 #define IDB_BITMAP1 132 #define IDB_RED 132 #define IDB_BITMAP2 133 #define IDB_GREEN 133 #define IDB_BITMAP3 134 #define IDB_BITMAP4 135 #define IDB_BITMAP5 136 #define IDB_BITMAP6 137 #define IDB_BITMAP7 138 #define IDB_BITMAP8 139 #define IDB_BITMAP9 140 #define IDB_BITMAP10 141 #define IDB_BLUE 141 #define IDB_BITMAP11 142 #define IDB_BLACK 142 #define IDB_BITMAP12 143 #define IDB_YELLOW 143 #define IDB_BITMAP13 144 #define IDB_WHITE 144 #define IDB_BITMAP14 145 #define IDB_BITMAP21 145 #define IDB_BITMAP15 146 #define IDD_FTP_OPTIONS 146 #define IDB_BITMAP16 147 #define IDB_ICON_MENU 147 #define IDB_BITMAP17 148 #define IDB_BITMAP18 149 #define IDB_BITMAP19 150 #define IDD_PROPERTIES_TEXTBOX 150 #define IDB_BITMAP20 151 #define IDD_PROPERTIES_IMAGE 151 #define IDD_DELETE_GUI_FILE 153 #define IDD_CREATE_GUIFILE 154 #define IDD_PROJ_FILE_MGR 155 #define IDB_DIALOG1 160 #define IDD_EDIT_SCRNTAG_DESCRIP 160 #define IDD_COPY_GUIFILE 163 #define IDD_DIALOG_YES_Y2A_NO_CNCL 164 #define IDD_DIALOG_OK_CNCL 165 #define IDR_TOOLBAR2 166 #define IDR_TOOLBAR_ALIGN 166 #define IDD_LGB_ZORDER_DIALOG 168 #define IDB_BITMAP22 169 #define IDD_PROPERTIES_DRAWABLE 170 #define IDR_TOOLBAR_ZCONTROLS 172 #define IDD_DIALOG1 174 #define IDR_TOOLBAR_OPTIONS 175 #define IDD_PROPERTIES_TEXTBOX1 175 #define IDD_PROPERTIES_PATCH 175 #define IDD_INLINE_TEXT 179 #define IDC_TREE1 1001 #define IDC_LOCATION 1002 #define IDC_X1 1004 #define IDC_X2 1005 #define IDC_Y1 1006 #define IDC_Y2 1007 #define IDC_DELETE 1009 #define IDC_EDIT1 1011 #define IDC_SERVER 1011 #define IDC_COLOURPICKER_RESULT 1011 #define IDC_PROJNAME_TEXT 1011 #define IDC_FILENAME_EDIT_RO 1011 #define IDC_EDIT_FILENAME 1011 #define IDC_TAG_READONLY 1011 #define IDC_EDIT_ZORDER 1011 #define IDC_EDIT_ZCLIP_VAL 1011 #define IDC_EDIT_PC_TRANSP 1011 #define IDC_EDIT_CLASS 1011 #define IDC_EDIT2 1012 #define IDC_SERVERDIR 1012 #define IDC_EDIT_DESCRIP 1012 #define IDC_EDIT_Z_ORDER 1012 #define IDC_EDIT_ZLEAN_VAL 1012 #define IDC_EDIT_PC_FG_TRANSP 1012 #define IDC_BUTTON1 1013 #define IDC_EDIT3 1013 #define IDC_OPENPROJ_BTN 1013 #define IDC_FILE_CONFIRM_BUTTON 1013 #define IDC_EDIT_ORIGFILE_NAME 1013 #define IDC_FG_COLOR 1013 #define IDC_TEXT_COLOR 1013 #define IDC_BUTTON_YES 1013 #define IDC_EDIT_PC_BG_TRANSP 1013 #define IDC_OPENALLACTIVE 1013 #define IDC_BUTTON_ADD 1013 #define IDC_EDIT4 1014 #define IDC_EDIT_ORIGFILE_DESCRIP 1014 #define IDC_BUTTON2 1014 #define IDC_WIDTH 1014 #define IDC_BUTTON_DELETE 1014 #define IDC_EDIT5 1015 #define IDC_VERTEXTENT 1015 #define IDC_TAG_LABEL 1016 #define IDC_EDIT_INLINE_PC_TRANSP3 1016 #define IDC_TAG 1017 #define IDC_TYPE 1018 #define IDC_TYPE_LABEL 1019 #define IDC_SERVER_LABEL 1020 #define IDC_EDIT6 1020 #define IDC_EDIT_LEFT_INDENT 1020 #define IDC_USERNAME_LABEL 1021 #define IDC_EDIT8 1021 #define IDC_EDIT_TOP_INDENT 1021 #define IDC_USERNAME 1022 #define IDC_PASSWORD 1023 #define IDC_PASSWORD_LABEL 1024 #define IDC_FG_COLOURPICKER 1035 #define IDC_BG_COLOURPICKER 1036 #define IDC_SERVERDIR_LABEL 1039 #define ID_TEXTBOX_OK 1041 #define ID_IMAGE_OK 1042 #define ID_IMAGE_LOAD_IMAGE 1043 #define IDC_RADIO_BACKCOL 1045 #define IDC_SCRNTAG_STATIC_TAGS 1046 #define IDC_LIST4 1050 #define IDC_MAIN_LIST 1050 #define IDC_STATIC_FILE 1051 #define IDC_STATIC_SCREENTAG 1052 #define IDC_STATIC_SCREENTAG2 1053 #define IDC_STATIC_CREATE_FILENAME 1054 #define IDC_STATIC_FILENAME 1054 #define IDC_CLOSEPROJ_BTN 1055 #define IDC_STATIC_DESCRIP 1055 #define IDC_PFMANAGER_PROJ_GROUPBOX_STATIC 1056 #define IDC_STATIC_SCREENTAG3 1056 #define IDC_PFMANAGER_FILE_GROUPBOX_STATIC 1057 #define IDC_OPENFILE_BTN 1058 #define IDC_OPEN_BTN 1058 #define IDC_DELETEFILE_BTN 1059 #define IDC_BUTTON_SETALL 1060 #define IDC_NEWFILE_BTN 1060 #define IDC_BUTTON_CLEARALL 1061 #define IDC_TAGDLOG_BTN 1061 #define IDC_COPY_BTN 1062 #define IDC_RADIO_CURR_FOCUS_GUI 1066 #define IDC_RADIO_ALL_GUIS 1067 #define IDC_CHECKBOX_BITMAP 1069 #define IDC_CHECKBOX_SODL 1070 #define IDC_SETTERS_GROUP 1071 #define ID_DISMISS 1072 #define IDC_GUIRADS_GROUP 1077 #define IDC_LIST 1080 #define IDC_FILE_DESC_TAG_LIST 1081 #define IDC_FILE_LIST 1081 #define IDC_FILE_DESCRIP_LIST 1082 #define IDC_SCREEN_DESCRIP_LIST 1084 #define IDC_LISTCTRL_LAYOUTS 1084 #define IDC_BUTTON_HDWRD1 1085 #define IDC_LIST2 1086 #define IDC_USAGE_LIST2 1087 #define IDC_BUTTON_CLEAR 1088 #define IDC_BUTTON_HDWRD2 1089 #define IDC_SCRNTAG_COMBO 1089 #define IDC_SCREEN_LIST 1091 #define IDC_EDIT_NEWFILE_NAME 1092 #define IDC_EDIT_NEWFILE_DESCRIP 1093 #define IDC_BUTTON_BG_COLOR 1094 #define ID_VERSION_DLG 1095 #define IDC_BUTTON_YES2ALL 1096 #define IDC_BUTTON_NO 1097 #define IDC_BUTTON_CANCEL 1098 #define IDC_COMBO1 1099 #define IDC_COMBO_BMPFILES 1099 #define IDC_COMBO_FONT 1099 #define IDC_SPIN3 1104 #define IDC_SLIDER2 1105 #define IDC_SLIDER_ZLEAN 1105 #define IDC_SLIDER3 1106 #define IDC_SLIDER_ZCLIP 1106 #define IDC_SPIN4 1107 #define IDC_BUTTON3 1107 #define IDC_BUTTON_INLINE_TEXT 1107 #define IDC_BUTTON_UPDATE 1107 #define IDC_ZORDER 1108 #define IDC_IMPORT_BITMAP 1109 #define IDC_SLIDER1 1112 #define IDC_SLIDER_TRANSP 1112 #define IDC_SLIDER_BG_TRANSP 1113 #define IDC_SLIDER_FG_TRANSP 1114 #define IDC_TAB_WIDGETGRP_TAB 1115 #define IDC_RADIO2 1117 #define IDC_COMBO_FONT_SZ 1118 #define IDC_EDIT_RIGHT_INDENT 1119 #define IDC_EDIT_BOTTOM_INDENT 1120 #define IDC_EDIT_LINE_SPACING 1121 #define IDC_EDIT_NUMBER_OF_LINES 1122 #define IDC_LIST_CLASS 1123 #define IDC_CHECK_LOCKASPECTRATIO 1125 #define ID_FILE_IMPORT 32771 #define LOADAFXTAGS 32772 #define ID_BUTTON32773 32773 #define LOADAFXSODL 32774 #define ID_FTP_OPTIONS 32775 #define ID_ICON_PROPERTIES 32777 #define ID_FTP_GUI 32778 #define ID_TRANSFER_OPENGUIS 32780 #define ID_TRANSFER_ALLBITMAPS 32781 #define ID_TRANSFER_ALL 32782 #define ID_TRANSFER_ALLTHEABOVE 32783 #define ID_LAUNCH_TRANSFER_DLG 32784 #define ID_LGBTRANSFERMANAGER 32785 #define ID_PROJECT_OPEN 32786 #define ID_FILE_CLOSEALL 32787 #define ID_FILE_SAVEALLGUIS 32788 #define ID_FILE_DELETEGUI 32789 #define ID_HELP_ELECTRONICDOCUMENTATION 32790 #define ID_CURRENT_GUI 32791 #define ID_TRANSFER_CURRENT_GUI 32792 #define ID_TRANSFER_OPEN_GUIS 32793 #define ID_TRANSFER_OPTIONS 32794 #define ID_TRANSFER_SODL_GUIS_BITMAPS 32795 #define ID_HELP_ELECTRONIC_DOCS 32796 #define ID_HELP_DIALOGTESTER 32797 #define ID_HELP_DIALOGTESTER32798 32798 #define ID_TEST_TESTDIALOGS 32799 #define ID_FILE_OPEN32800 32800 #define ID_TRANSFER_ALL_OPEN_AND_BMP 32801 #define ID_BUTTON32803 32803 #define ID_BUTTON32804 32804 #define ID_BUTTON32805 32805 #define ID_FILE_CLOSEPROJECT 32806 #define ID_PROJECT_CLOSE 32807 #define ID_FILE_LAYOUTMANAGER 32808 #define ID_TOOLS_ALIGNMENT 32809 #define ID_ALIGNMENT_LEFT 32810 #define ID_ALIGNMENT_RIGHT 32811 #define ID_ALIGNMENT_LEFT32812 32812 #define ID_ALIGNMENT_TOPEDGES 32813 #define ID_ALIGNMENT_BOTTOMEDGES 32814 #define ID_ALIGNMENT_TOP 32815 #define ID_ALIGNMENT_LEFTRIGHT 32816 #define ID_ALIGNMENT_BOTTOM 32817 #define ID_TOOLS_RESIZE 32818 #define ID_RESIZE_WIDTH 32819 #define ID_RESIZE_HEIGHT 32820 #define ID_ALIGNMENT_LEFTEDGES 32821 #define ID_ALIGNMENT_RIGHTEDGES 32822 #define ID_ALIGNMENT_LEFTRIGHTCENTRES 32823 #define ID_ALIGNMENT_TOPBOTTOMCENTRES 32824 #define ID_BUTTON32829 32829 #define ID_BUTTON32830 32830 #define ID_BUTTON32831 32831 #define ID_BUTTON32832 32832 #define ID_BUTTON32833 32833 #define ID_ICON_BRINGTOFRONT 32834 #define ID_ICON_SENDTOREAR 32835 #define ID_ICON_MOVEFORWARD 32836 #define ID_ICON_MOVEBACKWARD 32837 #define ID_ICON_EQUALISETOFRONTMOST 32838 #define ID_ICON_EQUALISETOREAR 32839 #define ID_TOOLS_OPTIONS 32840 #define ID_OPTIONS_SELECTALL 32841 #define ID_OPTIONS_DISPLAYWIDGETLABELS 32842 #define ID_OPTIONS_SELECTALLWIDGETS 32843 #define ID_TOOLS_Z 32844 #define ID_Z_RENUMBERCONSECTIVELY 32845 #define ID_Z_RENUMBER 32846 #define ID_TOOLS_SELECTION 32847 #define ID_SELECTION_SELECTALLBITMAPS 32848 #define ID_SELECTION_SELECTALLTEXTBOXES 32849 #define ID_VIEW_Z 32851 #define ID_VIEW_ALIGNMENT 32852 #define ID_TOOLBAR_STANDARD 32853 #define ID_TOOLBAR_ALIGNMENT 32854 #define ID_TOOLBAR_OPTIONS 32855 #define ID_VIEW_ZDIALOG 32856 #define IDC_WZD_COMBO 32861 #define IDC_ZLEAN_CTRL 32862 #define ID_VIEW_Z32863 32863 #define ID_VIEW_ZCTRL 32864 #define ID_VIEW_ZCTRLTOOLBAR_VIZ 32865 #define ID_VIEW_ALIGNMENT32866 32866 #define ID_OPTIONS_NATIVEVIEW 32867 #define ID_OPTIONS_NATIVEVIEWBGROUND 32868 #define ID_BUTTON32869 32869 #define IDLOADAFXSODL 32870 #define ID_SCANNEWSODL 32871 #define ID_ICON_SETFULLYOPAQUE 32872 #define ID_ICON_DECREMENTOPACITY10 32873 #define ID_TOOLS_OPTIONS32874 32874 #define ID_BUTTON32876 32876 #define ID_TOOLBARS_OPTIONS 32877 #define ID_EDIT_UNDO32878 32878 #define ID_EDIT_REDO32879 32879 #define ID_LGB_TRANSFERALLDATA 32880 #define ID_LGB_SENDCHANGEDDATA 32881 #define ID_DISPLAYWIDGETLABELS_DISPLAYZ 32883 #define ID_DISPLAY_ZLEVEL_LABELS 32884 #define ID_OPTIONS_DISPLAYZ 32885 #define ID_OPTIONS_DISPLAYZLEVELLABELS 32886 #define ID_SELECTION_SELECTALLPATCHES 32887 #define ID_EHS_START 32888 #define ID_EHS_STOP 32889 #define ID_EHS_UPDATE 32890 #define ID_EHS_INITIALPARAMETERS 32891 #define ID_EHS_ALWAYSON 32892 #define ID_EHS_ALWAYSON32893 32893 #define ID_EHS_NORMALZORDER 32894 #define ID_IGB_EHS_MANAGEEHSLOCALLY 32896 #define ID_IGB_EHS_MANAGEEHSREMOTELY 32897 #define ID_IGB_EHS_HOST_COMBO 32898 #define ID_OPEN_THEN_DISMISS 33010 #define IDC_BUTTON_PROPTEXT_FG_COLOR 33030 #define IDC_BUTTON_PROPTEXT_BG_COLOR 33040 #define IDC_BUTTON_COLOUR 33041 #define ID_HELP_LGB_USERGUIDE 34802 #define ID_HELP_LGB_REFMANUAL 35001 #define ID_HELP_TUTORIALS 35002 #define ID_REVISION_DLG 35010 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 180 #define _APS_NEXT_COMMAND_VALUE 32895 #define _APS_NEXT_CONTROL_VALUE 1126 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
1b35edae8d6dab2e30248eadf16fb971fb5927f1
9f9bc55039022735acde82997c1f1a0bd7bd37cf
/Student_Cuda_Cube_3D/INC_SYMLINK/EXT/MouseEvent.h
9928685b3c0869db36d83a12d0e676ade19d38a9
[]
no_license
khansabassem/GPGPU
1bc503252d81739c9c318ac49fc6134a5eb2327d
66bebe5c298afced9ddcd3f36f6998595c490091
refs/heads/main
2023-08-13T07:19:58.048558
2021-10-18T10:59:46
2021-10-18T10:59:46
null
0
0
null
null
null
null
UTF-8
C
false
false
83
h
MouseEvent.h
/opt/api/cbi/infographie/fenetrage/305/Bilat_Fenetrage_Displayable/INC/MouseEvent.h
f0e87babf6987b69f600a90ce1246ce32b5a5249
65a525350169f7ff3460eb0a4a87d5f22e104dc6
/safelife/speedups_src/iset.h
232bd6dddaf13aaf274483d33a10f12fe02628e1
[ "Apache-2.0" ]
permissive
staceysv/safelife
7839c02ebaabcc756584d910084813d8378c2909
9577a8f5bece55a71ea9d069f24e6fc2c0b4fd8d
refs/heads/master
2023-03-26T17:05:39.680094
2021-03-23T15:44:42
2021-03-23T15:44:42
292,946,831
0
0
Apache-2.0
2021-03-23T15:44:43
2020-09-04T21:07:39
null
UTF-8
C
false
false
574
h
iset.h
typedef struct { // 'set' contains an unordered list of integers of length 'max_size'. // The first 'size' number of items belong to the set, the rest do not. // New integers less than 'max_size' can be added to the set by a simple // swap operation. int *set; int *ptr; // This is the inverse of set: set[ptr[k]] == k int size; int max_size; } iset; iset iset_alloc(int max_size); void iset_free(iset *s); void iset_add(iset *s, int val); void iset_discard(iset *s, int val); int iset_contains(iset *s, int val); int iset_sample(iset *s);
8e4082e203bf6882a786f3b044d25d367de9782e
c2c47cee0242cd3347edf35cd17db16c6abee336
/api/iwdg.c
fb70b3405eaac8d5a4f1136b3925de5e25bba83b
[]
no_license
dinoljubic/STM_peripherals
8dbd66d864a8288c77bf6f6cccaeab2820f71f97
0f972f34d314add59d2ad716546d5955b07df6ef
refs/heads/master
2021-08-12T04:10:33.165660
2017-11-14T12:30:44
2017-11-14T12:30:44
110,118,383
0
0
null
null
null
null
UTF-8
C
false
false
220
c
iwdg.c
#include <iwdg.h> void iwdg_init(void) { IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); IWDG_SetPrescaler(IWDG_Prescaler_16); IWDG_ReloadCounter(); IWDG_Enable(); } void iwdg_reload(void) { IWDG_ReloadCounter(); }
29330f8f6e9ab24ec6951a3e9ff7459e0d1661a7
423ff99461b38ec5687fb839f7a27f735eaab337
/src/datastruct/json/json_common.c
70b3cd24861edec9186c377a892f546a27d32326
[]
no_license
lilca/c_libraries
52ecba9f19b90f0c1531f90bc39ff94447e17e88
3edcf5c96cb904170996ce0202099260ca998bc5
refs/heads/master
2023-02-19T22:40:36.624786
2023-02-14T03:28:22
2023-02-14T03:28:22
71,743,107
0
0
null
null
null
null
UTF-8
C
false
false
181
c
json_common.c
#include "json_common.h" void JSONCommon_skipChar(char** chr) { while (**chr == ' ' || **chr == '\t' || **chr == '\n' || **chr == '\r') { (*chr)++; } return; }
b37ce1f16982d9502ccc5674f5f00a08acaddddc
1fe8d4133981e53e88abf633046060b56fae883e
/venv/lib/python3.8/site-packages/tensorflow/include/external/aws/aws-cpp-sdk-core/include/aws/core/utils/HashingUtils 2.h
4f13548c486207c32d6fc481500c3d593d6cb10d
[]
no_license
Akira331/flask-cifar10
6c49db8485038731ce67d23f0972b9574746c7a7
283e7a2867c77d4b6aba7aea9013bf241d35d76c
refs/heads/master
2023-06-14T16:35:06.384755
2021-07-05T14:09:15
2021-07-05T14:09:15
382,864,970
0
0
null
null
null
null
UTF-8
C
false
false
129
h
HashingUtils 2.h
version https://git-lfs.github.com/spec/v1 oid sha256:90a45b40ab1c525a4a0e2ca41ecbe835bc8e2e51f4dc2149b3783a250cc9bdea size 2979
d1a1b8aa97e27106236539973a2c30b0422ac9b0
bbf5e4a5b78a107e9ce6304ba5afff1c944c9a82
/allcfiles/other/if_else.c
f7e4d1fcad7c0d5a592e06311a329fa1b8a52b47
[]
no_license
narayangour/Embedded-program
cb397b43ac2781d5ec49d73fbe8e0106b7a4eb70
58510ecd6bbe4073c969bae521a6125a6d521f44
refs/heads/master
2020-06-27T16:37:49.395762
2019-08-01T07:29:14
2019-08-01T07:29:14
199,999,175
0
0
null
null
null
null
UTF-8
C
false
false
299
c
if_else.c
#include<stdio.h>//calculate how many bits are set// main() { int data,bit=31,count=0; printf("enter a no"); scanf("%d",&data); test: if((data>>bit)&1) { count++; { if(bit>=0) { bit--; goto test; } } } else if(bit>=0) { bit--; goto test; } printf("%d\n",count); }
ed3b3a3b68c05f3bb3b5bcc6596f79c0c40f6f0c
c9606d1174d9ef774e5b5aa4e75b0a370cb81acf
/Src/io/dio_typedef.h
8c7a97b6d31831f2365b7d8b26a7f51b1385b8a2
[]
no_license
s-ciprian/stepper_control_1
3a78c952bf786017d9c35700074937f47b508555
c7477cf32716576c5fd10bf3b87bd002dc96eb90
refs/heads/master
2020-12-14T08:37:48.535705
2016-11-27T18:35:38
2016-11-27T18:35:38
46,368,557
0
1
null
2016-08-10T13:23:19
2015-11-17T18:59:39
C
UTF-8
C
false
false
496
h
dio_typedef.h
#ifndef __DIO_TYPEDEF_H__ #define __DIO_TYPEDEF_H__ #include "stm32f4xx_hal.h" #include "stm32f4xx_nucleo.h" #ifdef __cplusplus extern "C" { #endif typedef uint16_t pin_t; typedef GPIO_TypeDef* port_t; typedef uint32_t pull_t; typedef uint32_t pmode_t; typedef struct { const pmode_t pmode; const port_t port; const pin_t pin; const pull_t pull; } digital_io_t; typedef digital_io_t* p_digital_io_t; #ifdef __cplusplus } #endif #endif // __DIO_TYPEDEF_H__
5c50eb3627636bf3e30e75fe7b157b21a0081fa1
f026cb616ef14bae15a1d251ca6dbe0f55016d9c
/linux/1449.c
4a477dd2132e1812d351ef7d8684ba5a3a06ce1f
[]
no_license
jajajasalu2/cocci-lkmp-c-files
3eb7d451929dca5cb6beb56aabd69fe3f7fc176c
5da943aabe1589e393a131121dbf8e7a84b3cf2a
refs/heads/master
2020-12-02T17:30:14.411816
2020-01-29T08:36:30
2020-01-29T08:36:30
231,053,574
1
0
null
null
null
null
UTF-8
C
false
false
4,997
c
1449.c
cocci_test_suite() { struct f_uac1_legacy_opts cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 994 */; struct f_uac1_legacy_opts *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 985 */; struct usb_function_instance *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 982 */; void cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 941 */; const struct config_item_type cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 921 */; struct configfs_attribute *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 911 */[]; struct usb_audio_control cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 90 */; struct configfs_item_operations cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 815 */; struct config_item *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 808 */; struct uac_feature_unit_descriptor_0 cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 80 */; struct usb_ep *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 704 */; struct usb_string *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 702 */; struct usb_configuration *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 698 */; u8 *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 679 */; struct gaudio *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 678 */; struct uac_input_terminal_descriptor cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 67 */; unsigned cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 653 */; struct uac1_ac_header_descriptor_1 cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 53 */; u16 cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 498 */; u8 cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 497 */; struct usb_composite_dev *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 495 */; const struct usb_ctrlrequest *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 493 */; struct usb_function *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 492 */; int cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 492 */; size_t cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 450 */; struct usb_audio_control *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 431 */; struct usb_audio_control_selector *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 430 */; struct usb_request *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 423 */; struct f_audio *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 421 */; u32 cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 362 */; struct usb_interface_descriptor cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 34 */; struct f_audio_buf cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 313 */; struct f_audio cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 303 */; struct work_struct *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 301 */; struct f_audio { struct gaudio card; u8 ac_intf,ac_alt; u8 as_intf,as_alt; struct usb_ep *out_ep; spinlock_t lock; struct f_audio_buf *copy_buf; struct work_struct playback_work; struct list_head play_queue; struct list_head cs; u8 set_cmd; struct usb_audio_control *set_con; } cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 274 */; struct f_audio_buf *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 250 */; struct f_audio_buf { u8 *buf; int actual; struct list_head list; } cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 244 */; struct usb_gadget_strings *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 234 */[]; struct usb_gadget_strings cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 229 */; struct usb_string cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 218 */[]; enum{STR_AC_IF, STR_INPUT_TERMINAL, STR_INPUT_TERMINAL_CH_NAMES, STR_FEAT_DESC_0, STR_OUTPUT_TERMINAL, STR_AS_IF_ALT0, STR_AS_IF_ALT1,} cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 208 */; struct usb_descriptor_header *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 190 */; struct usb_descriptor_header *cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 189 */[]; struct uac_iso_endpoint_descriptor cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 180 */; int cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 18 */(struct usb_audio_control *con, u8 cmd); int cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 17 */(struct usb_audio_control *con, u8 cmd, int value); struct usb_endpoint_descriptor cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 169 */; struct uac_format_type_i_discrete_descriptor_1 cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 158 */; struct uac1_as_header_descriptor cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 147 */; struct uac1_output_terminal_descriptor cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 117 */; struct usb_audio_control_selector cocci_id/* drivers/usb/gadget/function/f_uac1_legacy.c 108 */; }
33d37bd0b732ea03df8788c026ef92df61d4842b
140ca31057151c8d0502fcd2a683e94158457f23
/C libraries/Filter.c
aa1262578a9d1018acd21070dacea17ecb6080f3
[]
no_license
JakobGroeftehauge/4-semester-project
c48f281965f9820c63659d70d0edc448c32ba1e7
b8af3c5199d5218fc377e9707f1ddb354bd3f7c5
refs/heads/master
2021-10-21T13:04:55.786114
2021-10-15T19:53:21
2021-10-15T19:53:21
170,331,402
0
0
null
2019-04-23T09:27:43
2019-02-12T14:23:56
C
UTF-8
C
false
false
2,361
c
Filter.c
/***************************************************************************** * MODULENAME.: filter.c * * PROJECT....: 4. semester project * * Change Log: ***************************************************************************** * Date Id Change * YYMMDD * -------------------- * 190408 JGR Module created. * *****************************************************************************/ /***************************** Include files *******************************/ #include "filter.h" #include "circular_buffer.h" #include <stdint.h> /***************************** Defines *******************************/ #define NOF_FILTERS 3 /***************************** Variables *******************************/ filter_descriptor filter_pool[NOF_FILTERS]; //Pool of filters /***************************** Functions *******************************/ extern void init_filter(uint8_t id, float coefArray[MAX_NUMBER_OF_TABS], uint8_t tabs) /***************************************************************************** * Input : filter id, Array with filter coefficient, number of tabs in the filter. * Output : * Function : Initialize filter ******************************************************************************/ { filter_pool[id].id = id; // Filter must have same ID, as the used circular_buffer. filter_pool[id].tabs = tabs; for(uint8_t i = 0; i < MAX_NUMBER_OF_TABS; i++) { filter_pool[id].coefList[i] = coefArray[i]; } initialize_buffer(id); //initializes buffer to filter with same ID as filter } float run_filter(uint8_t id, float data) /***************************************************************************** * Input : filter id, sampled data * Output : filtered data * Function : filter data ******************************************************************************/ { float result = 0; float immediateResult; //Used as intermediate step in calculations update_buffer(id, data); //Puts data into buffer for(uint8_t i = 0; i < filter_pool[id].tabs; i++) { immediateResult = filter_pool[id].coefList[i] * peek_buffer(id, i);//Calculates the n'th step of the FIR filter result = result + immediateResult; } return result; } /****************************** End Of Module *******************************/
61f0ff7d8c584791dac136716aebaa9b8cd303db
6648262bad8689cd7c6cc30d320d3bd4b03faf61
/Module 1 - Introductory Programming in C/Applications/6_integrals.c
82350933c1d0989e7199b1e5da08b1e12f8ae22e
[]
no_license
JET2001/Personal_Project_-2-Programming_Exercises
933d936ccd66bef9fa68c2d02a2811afd7ac40e2
519f524ca0182441f7a600b160462def37594956
refs/heads/main
2023-08-11T08:46:12.901362
2021-10-01T05:42:59
2021-10-01T05:42:59
412,305,928
0
0
null
null
null
null
UTF-8
C
false
false
531
c
6_integrals.c
// // 6_integrals.c // // // Created by Jon on 20/7/21. // #include <stdio.h> #include <math.h> // Create a global immutable variable for PI const double PI = 3.141592654; // Create any additional user defined functions here! // Calculate the Riemann sum within this function! double R(int n) { // Write your code here! // Make more lines if you want! return 0;// change this something appropriate too! } int main(void) { int n; scanf("%d",&n); printf("%.10lf\n", R(n)); return 0; }
1bad575279e7fc77b076e1d27f7e8020c18fa9ca
05787127db88e0933061f7cdf1ce1cb03ddc4139
/tools/all/stripcomments/source/stripcomments.h
12e33421f8ba07bb52bebf4b9a3beede71b44e16
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
chwash/KitchenSink
138234e17bcd8951e940da63867c5294b614698a
7158e42f45ed4059c3341c2173528b1933a4727f
refs/heads/master
2021-05-27T15:26:58.635362
2015-01-30T08:19:22
2015-01-30T08:19:22
null
0
0
null
null
null
null
UTF-8
C
false
false
871
h
stripcomments.h
/*************************************** Simple utility to strip all C++ style comments from a text file and output it into a C++ include file. Used mostly for converting GLSL files into source that can be directly linked into an OpenGL program. Copyright 1995-2014 by Rebecca Ann Heineman becky@burgerbecky.com It is released under an MIT Open Source license. Please see LICENSE for license details. Yes, you can use it in a commercial title without paying anything, just give me a credit. Please? It's not like I'm asking you for money! ***************************************/ #ifndef __STRIPCOMMENTS_H__ #define __STRIPCOMMENTS_H__ #ifndef __BURGER__ #include <burger.h> #endif extern void BURGER_API StripComments(OutputMemoryStream *pOutput,const char *pInput,WordPtr uLength); extern int BURGER_ANSIAPI main(int argc,const char **argv); #endif
0343b4ea987b459e431e4971972526ceecebd75d
387549ab27d89668e656771a19c09637612d57ed
/DRGLib UE project/Source/FSD/Public/PlagueCleanerResourceChangedDelegate.h
628d31e7527754d1b0d2ac9e3306a099c2b4d0f2
[ "MIT" ]
permissive
SamsDRGMods/DRGLib
3b7285488ef98b7b22ab4e00fec64a4c3fb6a30a
76f17bc76dd376f0d0aa09400ac8cb4daad34ade
refs/heads/main
2023-07-03T10:37:47.196444
2023-04-07T23:18:54
2023-04-07T23:18:54
383,509,787
16
5
MIT
2023-04-07T23:18:55
2021-07-06T15:08:14
C++
UTF-8
C
false
false
235
h
PlagueCleanerResourceChangedDelegate.h
#pragma once #include "CoreMinimal.h" #include "PlagueCleanerResourceChangedDelegate.generated.h" UDELEGATE(BlueprintCallable) DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPlagueCleanerResourceChanged, float, currentResourceVolume);
5e82add63b4e5d4572df5155fd27e784afcac0a4
6093801ab58c462243665214eafa796b48554e8d
/tests/spies/apptimer_spy.h
3c95f8a61b633d21d005991394a34109acc8b19f
[ "Unlicense" ]
permissive
krish2487/libmcu
e565a8c6c750a232235437b21f69364f142fcb75
0b84927eb8d89def1e11affd48a8e04fe1a492ef
refs/heads/master
2023-01-31T23:40:02.213428
2020-12-18T19:19:25
2020-12-18T19:19:25
null
0
0
null
null
null
null
UTF-8
C
false
false
406
h
apptimer_spy.h
#ifndef APP_TIMER_SPY_H #define APP_TIMER_SPY_H #if defined(__cplusplus) extern "C" { #endif #include <stdint.h> #include "libmcu/apptimer.h" enum { TIMERSPY_CREATED = 100, TIMERSPY_STARTED = 1, TIMERSPY_STARTED_PERIODIC = 2, TIMERSPY_STOPPED = 3, TIMERSPY_COMPLETED = 4, TIMERSPY_DELETED = 5, }; uint32_t apptimerspy_get_state(apptimer_t *timer); #if defined(__cplusplus) } #endif #endif
343858f6b5d0fb689f491369f6a25d57b3ba9588
31e3b3043c01fb20e65e4a4ffb5685d8707249cd
/src/sudoku/sudokuiku/atoi.h
187aed1d1e042649951a3c9d489ad815cd3d687e
[]
no_license
Gaoithe/bgttoolbox
4f7f7b9667e0c116fa73ab7cb368edfea048ae48
a50d1dfea854d65067db87c50abc83917f1b773c
refs/heads/master
2020-04-15T23:47:09.795985
2018-11-20T23:14:34
2018-11-20T23:14:34
17,664,710
0
0
null
null
null
null
UTF-8
C
false
false
277
h
atoi.h
#include <stdlib.h> /* atoi */ /* // atoi.h int atoi_O(string s,int b){ int i,r,p; char c; string a; r=0; a=strlwr(s); for(i=0;i<strlen(a);i++){ r=r*b; c=substr(a,i,1); p=(int)c; if (p>0x60){//>a r=r+p-87; //0x61-10 } else { r=r+p-0x30; } } return r; } */
568d32f733ebd7aa98439b61bf20c61f27983682
a15497a4da8bb752cd823cce3d71b4af79999364
/net/mad_fcl/files/patch-alclib_linux__ssm.h
c63f7a8a4aaf456df5b3bf4a967b24fc67f6bf45
[]
no_license
ejc123/DPorts
15bedf0b301850a9bd7e14338b5598260e98efeb
0caaf45c6dccdf085b42231576380a287a70a1de
refs/heads/master
2020-12-28T23:46:27.032156
2015-04-01T15:32:40
2015-04-01T15:32:40
33,254,468
0
0
null
2015-04-01T15:06:44
2015-04-01T15:06:44
null
UTF-8
C
false
false
942
h
patch-alclib_linux__ssm.h
$FreeBSD: head/net/mad_fcl/files/patch-alclib_linux__ssm.h 340725 2014-01-22 17:40:44Z mat $ --- alclib/linux_ssm.h.orig Fri Jul 30 14:15:54 2004 +++ alclib/linux_ssm.h Mon Aug 2 11:50:48 2004 @@ -33,12 +33,12 @@ struct ip_mreq_source { struct in_addr imr_multiaddr; /* IP address of group */ - struct in_addr imr_interface; /* IP address of interface */ struct in_addr imr_sourceaddr; /* IP address of source */ + struct in_addr imr_interface; /* IP address of interface */ }; -#define IP_ADD_SOURCE_MEMBERSHIP 39 -#define IP_DROP_SOURCE_MEMBERSHIP 40 +#define IP_ADD_SOURCE_MEMBERSHIP 25 +#define IP_DROP_SOURCE_MEMBERSHIP 26 #endif @@ -54,8 +54,8 @@ struct sockaddr_storage gsr_source; /* source address */ }; -#define MCAST_JOIN_SOURCE_GROUP 46 -#define MCAST_LEAVE_SOURCE_GROUP 47 +#define MCAST_JOIN_SOURCE_GROUP 74 +#define MCAST_LEAVE_SOURCE_GROUP 75 #endif
354b0309657d9dfa88efd6201286e26e16d2920a
eac0b5a76893db5142696fcc0f82a69fd897a8d4
/src/libserial.h
1298f0509a68ae41a4ebb82980d0dc43abb6585d
[ "BSD-3-Clause" ]
permissive
YosukeFURUSAWA/WinSSM
da1d4410f6a15bfaf294824e48369d3458b483b1
b8e61cff9e1bdcb7e1febf9a028649db17c4836f
refs/heads/master
2023-03-15T04:30:47.447497
2021-03-06T08:12:22
2021-03-06T08:12:22
344,802,869
0
0
null
null
null
null
SHIFT_JIS
C
false
false
2,219
h
libserial.h
/************************************************************************************************** Title : CameraSSM Programer : Yosuke FURUSAWA. Copyright : Copyright (C) 2006 - 2007, Yosuke FURUSAWA. Since : 2006/02/08 Function : シリアル通信 Filename : libserial.h Last up date : 2007/12/09 Kanji-Code : Shift JIS TAB Space : 4 **************************************************************************************************/ #ifndef _LIBSERIAL_H_ #define _LIBSERIAL_H_ /*================================================================================================= マクロ定義 =================================================================================================*/ #define SERIAL_IN_QUEUE_SIZE 8192 /* RX バッファサイズ */ #define SERIAL_OUT_QUEUE_SIZE 2048 /* TX バッファサイズ */ #define SERIAL_XON_LIMIT_SIZE 2048 #define SERIAL_XOFF_LIMIT_SIZE 2048 #define SERIAL_XON_CHAR 0x11 #define SERIAL_XOFF_CHAR 0x13 /*================================================================================================= 構造体 =================================================================================================*/ typedef struct { int port; int baudrate; int data; int parity; int stopbit; int flow; COMMTIMEOUTS timeout; char portname[6]; DCB dcb; HANDLE hComm; } SERIAL; typedef SERIAL* pSERIAL; /*================================================================================================= グローバル変数 =================================================================================================*/ extern SERIAL serial; /*================================================================================================= プロトタイプ宣言 =================================================================================================*/ BOOL SERIAL_open(pSERIAL pserial); BOOL SERIAL_close(pSERIAL pserial); BOOL SERIAL_flash(pSERIAL pserial); DWORD SERIAL_buffer(pSERIAL pserial); DWORD SERIAL_read(pSERIAL pserial, char *buf, int length); DWORD SERIAL_readline(pSERIAL pserial, char *buf, int size, char split); DWORD SERIAL_write(pSERIAL pserial, char *buf, int length); #endif
51ac7e1b1fa004f71ebfc60d49e30044ef1c2485
598737b786a20889dc6acd468478baf4972535b3
/src/dist/ntp/ntpd/refclock_atom.c
c1507f2468e00ced5a4fd94d2487c81b0ee31c66
[ "NTP", "LicenseRef-scancode-unknown-license-reference" ]
permissive
shisa/shisa-netbsd
5c8e289de2a48b6d8f39bd3add9ca4ea48fec1da
28d999d1c25107c126e0a458a97b9397aae592ef
refs/heads/master
2021-01-01T05:33:32.619808
2008-05-26T04:27:54
2008-05-26T04:27:54
32,793,680
1
2
null
null
null
null
UTF-8
C
false
false
13,913
c
refclock_atom.c
/* $NetBSD: refclock_atom.c,v 1.2 2003/12/04 16:23:37 drochner Exp $ */ /* * refclock_atom - clock driver for 1-pps signals */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdio.h> #include <ctype.h> #include "ntpd.h" #include "ntp_io.h" #include "ntp_unixtime.h" #include "ntp_refclock.h" #include "ntp_stdlib.h" #if defined(REFCLOCK) && defined(CLOCK_ATOM) #ifdef HAVE_PPSAPI # ifdef HAVE_TIMEPPS_H # include <timepps.h> # else # ifdef HAVE_SYS_TIMEPPS_H # include <sys/timepps.h> # endif # endif #endif /* HAVE_PPSAPI */ /* * This driver furnishes an interface for pulse-per-second (PPS) signals * produced by a cesium clock, timing receiver or related equipment. It * can be used to remove accumulated jitter and retime a secondary * server when synchronized to a primary server over a congested, wide- * area network and before redistributing the time to local clients. * * Before this driver becomes active, the local clock must be set to * within +-500 ms by another means, such as a radio clock or NTP * itself. There are two ways to connect the PPS signal, normally at TTL * levels, to the computer. One is to shift to EIA levels and connect to * pin 8 (DCD) of a serial port. This requires a level converter and * may require a one-shot flipflop to lengthen the pulse. The other is * to connect the PPS signal directly to pin 10 (ACK) of a PC paralell * port. These methods are architecture dependent. * * Both methods require a modified device driver and kernel interface * compatible with the Pulse-per-Second API for Unix-like Operating * Systems, Version 1.0, RFC-2783 (PPSAPI). Implementations are * available for FreeBSD, Linux, SunOS, Solaris and Alpha. However, at * present only the Alpha implementation provides the full generality of * the API with multiple PPS drivers and multiple handles per driver. * * In many configurations a single port is used for the radio timecode * and PPS signal. In order to provide for this configuration and others * involving dedicated multiple serial/parallel ports, the driver first * attempts to open the device /dev/pps%d, where %d is the unit number. * If this fails, the driver attempts to open the device specified by * the pps configuration command. If a port is to be shared, the pps * command must be placed before the radio device(s) and the radio * device(s) must be placed before the PPS driver(s) in the * configuration file. * * This driver normally uses the PLL/FLL clock discipline implemented in * the ntpd code. If kernel support is available, the kernel PLL/FLL * clock discipline is used instead. The default configuration is not to * use the kernel PPS discipline, if present. The kernel PPS discipline * can be enabled using the pps command. * * Fudge Factors * * There are no special fudge factors other than the generic. The fudge * time1 parameter can be used to compensate for miscellaneous device * driver and OS delays. */ /* * Interface definitions */ #ifdef HAVE_PPSAPI #define DEVICE "/dev/pps%d" /* device name and unit */ #endif /* HAVE_PPSAPI */ #define PRECISION (-20) /* precision assumed (about 1 us) */ #define REFID "PPS\0" /* reference ID */ #define DESCRIPTION "PPS Clock Discipline" /* WRU */ #define NANOSECOND 1000000000 /* one second (ns) */ #define RANGEGATE 500000 /* range gate (ns) */ #define ASTAGE 8 /* filter stages */ static struct peer *pps_peer; /* atom driver for PPS sources */ #ifdef HAVE_PPSAPI /* * PPS unit control structure */ struct ppsunit { struct timespec ts; /* last timestamp */ int fddev; /* pps device descriptor */ pps_params_t pps_params; /* pps parameters */ pps_info_t pps_info; /* last pps data */ pps_handle_t handle; /* pps handlebars */ }; #endif /* HAVE_PPSAPI */ /* * Function prototypes */ static int atom_start P((int, struct peer *)); static void atom_poll P((int, struct peer *)); #ifdef HAVE_PPSAPI static void atom_shutdown P((int, struct peer *)); static void atom_control P((int, struct refclockstat *, struct refclockstat *, struct peer *)); static int atom_pps P((struct peer *)); static int atom_ppsapi P((struct peer *, int, int)); #endif /* HAVE_PPSAPI */ /* * Transfer vector */ struct refclock refclock_atom = { atom_start, /* start up driver */ #ifdef HAVE_PPSAPI atom_shutdown, /* shut down driver */ #else noentry, /* shut down driver */ #endif /* HAVE_PPSAPI */ atom_poll, /* transmit poll message */ #ifdef HAVE_PPSAPI atom_control, /* fudge control */ #else noentry, /* fudge control */ #endif /* HAVE_PPSAPI */ noentry, /* initialize driver */ noentry, /* not used (old atom_buginfo) */ NOFLAGS /* not used */ }; /* * atom_start - initialize data for processing */ static int atom_start( int unit, /* unit number (not used) */ struct peer *peer /* peer structure pointer */ ) { struct refclockproc *pp; #ifdef HAVE_PPSAPI register struct ppsunit *up; char device[80]; #endif /* HAVE_PPSAPI */ /* * Allocate and initialize unit structure */ pps_peer = peer; pp = peer->procptr; peer->precision = PRECISION; pp->clockdesc = DESCRIPTION; pp->stratum = STRATUM_UNSPEC; memcpy((char *)&pp->refid, REFID, 4); peer->burst = ASTAGE; #ifdef HAVE_PPSAPI up = emalloc(sizeof(struct ppsunit)); memset(up, 0, sizeof(struct ppsunit)); pp->unitptr = (caddr_t)up; /* * Open PPS device. If this fails and some driver has already * opened the associated radio device, fdpps has the file * descriptor for it. */ sprintf(device, DEVICE, unit); up->fddev = open(device, O_RDWR, 0777); if (up->fddev <= 0 && fdpps > 0) { strcpy(device, pps_device); up->fddev = fdpps; } if (up->fddev <= 0) { msyslog(LOG_ERR, "refclock_atom: %s: %m", device); return (0); } /* * Light off the PPSAPI interface. If this PPS device is shared * with the radio device, take the default options from the pps * command. This is for legacy purposes. */ if (time_pps_create(up->fddev, &up->handle) < 0) { msyslog(LOG_ERR, "refclock_atom: time_pps_create failed: %m"); return (0); } return (atom_ppsapi(peer, 0, 0)); #else /* HAVE_PPSAPI */ return (1); #endif /* HAVE_PPSAPI */ } #ifdef HAVE_PPSAPI /* * atom_control - fudge control */ static void atom_control( int unit, /* unit (not used */ struct refclockstat *in, /* input parameters (not uded) */ struct refclockstat *out, /* output parameters (not used) */ struct peer *peer /* peer structure pointer */ ) { struct refclockproc *pp; pp = peer->procptr; atom_ppsapi(peer, pp->sloppyclockflag & CLK_FLAG2, pp->sloppyclockflag & CLK_FLAG3); } /* * Initialize PPSAPI */ int atom_ppsapi( struct peer *peer, /* peer structure pointer */ int enb_clear, /* clear enable */ int enb_hardpps /* hardpps enable */ ) { struct refclockproc *pp; register struct ppsunit *up; int capability; pp = peer->procptr; up = (struct ppsunit *)pp->unitptr; if (time_pps_getcap(up->handle, &capability) < 0) { msyslog(LOG_ERR, "refclock_atom: time_pps_getcap failed: %m"); return (0); } memset(&up->pps_params, 0, sizeof(pps_params_t)); if (enb_clear) up->pps_params.mode = capability & PPS_CAPTURECLEAR; else up->pps_params.mode = capability & PPS_CAPTUREASSERT; if (!up->pps_params.mode) { msyslog(LOG_ERR, "refclock_atom: invalid capture edge %d", enb_clear); return (0); } up->pps_params.mode |= PPS_TSFMT_TSPEC; if (time_pps_setparams(up->handle, &up->pps_params) < 0) { msyslog(LOG_ERR, "refclock_atom: time_pps_setparams failed: %m"); return (0); } if (enb_hardpps) { if (time_pps_kcbind(up->handle, PPS_KC_HARDPPS, up->pps_params.mode & ~PPS_TSFMT_TSPEC, PPS_TSFMT_TSPEC) < 0) { msyslog(LOG_ERR, "refclock_atom: time_pps_kcbind failed: %m"); return (0); } pps_enable = 1; } #if DEBUG if (debug) { time_pps_getparams(up->handle, &up->pps_params); printf( "refclock_ppsapi: fd %d capability 0x%x version %d mode 0x%x kern %d\n", up->fddev, capability, up->pps_params.api_version, up->pps_params.mode, enb_hardpps); } #endif return (1); } /* * atom_shutdown - shut down the clock */ static void atom_shutdown( int unit, /* unit number (not used) */ struct peer *peer /* peer structure pointer */ ) { struct refclockproc *pp; register struct ppsunit *up; pp = peer->procptr; up = (struct ppsunit *)pp->unitptr; if (up->fddev > 0) close(up->fddev); if (up->handle != 0) time_pps_destroy(up->handle); if (pps_peer == peer) pps_peer = 0; free(up); } /* * atom_pps - receive data from the PPSAPI interface * * This routine is called once per second when the PPSAPI interface is * present. It snatches the PPS timestamp from the kernel and saves the * sign-extended fraction in a circular buffer for processing at the * next poll event. */ static int atom_pps( struct peer *peer /* peer structure pointer */ ) { register struct ppsunit *up; struct refclockproc *pp; pps_info_t pps_info; struct timespec timeout, ts; double dtemp; /* * Convert the timespec nanoseconds field to signed double and * save in the median filter. for billboards. No harm is done if * previous data are overwritten. If the discipline comes bum or * the data grow stale, just forget it. A range gate rejects new * samples if less than a jiggle time from the next second. */ pp = peer->procptr; up = (struct ppsunit *)pp->unitptr; if (up->handle == 0) return (-1); timeout.tv_sec = 0; timeout.tv_nsec = 0; memcpy(&pps_info, &up->pps_info, sizeof(pps_info_t)); if (time_pps_fetch(up->handle, PPS_TSFMT_TSPEC, &up->pps_info, &timeout) < 0) return (-1); if (up->pps_params.mode & PPS_CAPTUREASSERT) { if (pps_info.assert_sequence == up->pps_info.assert_sequence) return (1); ts = up->pps_info.assert_timestamp; } else if (up->pps_params.mode & PPS_CAPTURECLEAR) { if (pps_info.clear_sequence == up->pps_info.clear_sequence) return (1); ts = up->pps_info.clear_timestamp; } else { return (-1); } if (!((ts.tv_sec == up->ts.tv_sec && ts.tv_nsec - up->ts.tv_nsec > NANOSECOND - RANGEGATE) || (ts.tv_sec - up->ts.tv_sec == 1 && ts.tv_nsec - up->ts.tv_nsec < RANGEGATE))) { up->ts = ts; return (1); } up->ts = ts; pp->lastrec.l_ui = ts.tv_sec + JAN_1970; dtemp = ts.tv_nsec * FRAC / 1e9; if (dtemp >= FRAC) pp->lastrec.l_ui++; pp->lastrec.l_uf = (u_int32)dtemp; if (ts.tv_nsec > NANOSECOND / 2) ts.tv_nsec -= NANOSECOND; dtemp = -(double)ts.tv_nsec / NANOSECOND; SAMPLE(dtemp + pp->fudgetime1); #ifdef DEBUG if (debug > 1) printf("atom_pps %f %f\n", dtemp, pp->fudgetime1); #endif return (0); } #endif /* HAVE_PPSAPI */ /* * pps_sample - receive PPS data from some other clock driver * * This routine is called once per second when the external clock driver * processes PPS information. It processes the PPS timestamp and saves * the sign-extended fraction in a circular buffer for processing at the * next poll event. This works only for a single PPS device. */ int pps_sample( l_fp *offset /* PPS offset */ ) { register struct peer *peer; struct refclockproc *pp; l_fp lftmp; double doffset; peer = pps_peer; if (peer == 0) /* nobody home */ return (1); pp = peer->procptr; /* * Convert the timeval to l_fp and save for billboards. Sign- * extend the fraction and stash in the buffer. No harm is done * if previous data are overwritten. If the discipline comes bum * or the data grow stale, just forget it. */ pp->lastrec = *offset; L_CLR(&lftmp); L_ADDF(&lftmp, pp->lastrec.l_f); LFPTOD(&lftmp, doffset); SAMPLE(-doffset + pp->fudgetime1); return (0); } /* * atom_poll - called by the transmit procedure * * This routine is called once per second when in burst mode to save PPS * sample offsets in the median filter. At the end of the burst period * the samples are processed as a heap and the clock filter updated. */ static void atom_poll( int unit, /* unit number (not used) */ struct peer *peer /* peer structure pointer */ ) { struct refclockproc *pp; #ifdef HAVE_PPSAPI int err; #endif /* HAVE_PPSAPI */ /* * Accumulate samples in the median filter. If a noise sample, * return with no prejudice; if a protocol error, get mean; * otherwise, cool. At the end of each poll interval, do a * little bookeeping and process the surviving samples. */ pp = peer->procptr; pp->polls++; #ifdef HAVE_PPSAPI err = atom_pps(peer); if (err < 0) { refclock_report(peer, CEVNT_FAULT); return; } #endif /* HAVE_PPSAPI */ /* * Valid time is returned only if the prefer peer has survived * the intersection algorithm and within clock_max of local time * and not too long ago. This ensures the PPS time is within * +-0.5 s of the local time and the seconds numbering is * unambiguous. Note that the leap bits are set no-warning on * the first valid update and the stratum is set at the prefer * peer, unless overriden by a fudge command. */ if (peer->burst > 0) return; peer->leap = LEAP_NOTINSYNC; if (pp->codeproc == pp->coderecv) { refclock_report(peer, CEVNT_TIMEOUT); peer->burst = ASTAGE; return; } else if (sys_prefer == NULL) { pp->codeproc = pp->coderecv; peer->burst = ASTAGE; return; } else if (fabs(sys_prefer->offset) > clock_max) { pp->codeproc = pp->coderecv; peer->burst = ASTAGE; return; } pp->leap = LEAP_NOWARNING; if (pp->stratum >= STRATUM_UNSPEC) peer->stratum = sys_prefer->stratum; else peer->stratum = pp->stratum; if (peer->stratum == STRATUM_REFCLOCK || peer->stratum == STRATUM_UNSPEC) peer->refid = pp->refid; else peer->refid = addr2refid(&sys_prefer->srcadr); pp->lastref = pp->lastrec; refclock_receive(peer); peer->burst = ASTAGE; } #else int refclock_atom_bs; int pps_sample( l_fp *offset /* PPS offset */ ) { return 1; } #endif /* REFCLOCK */
debfa438ff2b4b9aa33d58e1177bfe3d2c5af159
3bd385b466cb035fecd2b0c11ae054d42bf44fc2
/src/match/marksubstring.c
bc42e41fe8946f3f13407265fcac171b76bdcf0f
[ "LicenseRef-scancode-unknown-license-reference", "ISC", "BSD-2-Clause", "LicenseRef-scancode-mit-old-style", "Zlib", "MIT", "BSD-3-Clause", "bzip2-1.0.6" ]
permissive
genometools/genometools
c366dff04f6baa887f6b3be3ec55bce824b2bae1
df1df94b8c05a9c9bf848ffc6755c87b58573da5
refs/heads/master
2023-04-13T13:57:18.748796
2023-04-09T21:29:53
2023-04-09T21:29:53
11,177,980
237
63
NOASSERTION
2023-04-09T21:29:54
2013-07-04T13:39:38
C
UTF-8
C
false
false
2,992
c
marksubstring.c
/* Copyright (c) 2011 Stefan Kurtz <kurtz@zbh.uni-hamburg.de> Copyright (c) 2011 Center for Bioinformatics, University of Hamburg Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "core/mathsupport_api.h" #include "core/unused_api.h" #include "marksubstring.h" Gtmarksubstring *gt_marksubstring_new(unsigned int numofchars, unsigned int kmersize, bool usesuffix, unsigned int units) { Gtmarksubstring *mark; mark = gt_malloc(sizeof (*mark)); gt_assert(kmersize >= units); mark->units = units; mark->entries = gt_power_for_small_exponents(numofchars,units); if (usesuffix) { mark->shiftright = 0; mark->mask = (GtCodetype) (mark->entries-1); } else { mark->shiftright = GT_MULT2(kmersize - units); mark->mask = ~(GtCodetype) 0; } GT_INITBITTAB(mark->bits,mark->entries); mark->size = sizeof (GtBitsequence) * GT_NUMOFINTSFORBITS(mark->entries); return mark; } void gt_marksubstring_delete(Gtmarksubstring *mark,bool withbits) { if (mark != NULL) { if (withbits) { gt_free(mark->bits); } gt_free(mark); } } void gt_marksubstring_mark(Gtmarksubstring *mark,GtCodetype code) { code = (code >> (GtCodetype) mark->shiftright) & mark->mask; gt_assert(code < mark->entries); if (!GT_ISIBITSET(mark->bits,code)) { GT_SETIBIT(mark->bits,code); } } bool gt_marksubstring_checkmark(const Gtmarksubstring *mark,GtCodetype code) { code = (code >> (GtCodetype) mark->shiftright) & mark->mask; return GT_ISIBITSET(mark->bits,code) ? true : false; } unsigned int gt_marksubstring_shiftright(const Gtmarksubstring *mark) { return mark->shiftright; } GtUword gt_marksubstring_entries(const Gtmarksubstring *mark) { return mark->entries; } size_t gt_marksubstring_size(const Gtmarksubstring *mark) { return mark->size; } void gt_marksubstring_bits_null(GT_UNUSED const Gtmarksubstring *mark,bool null) { if (null) { gt_assert(mark->bits == NULL); } else { gt_assert(mark->bits != NULL); } } GtBitsequence** gt_marksubstring_bits_address(Gtmarksubstring *mark) { return &mark->bits; } void gt_marksubstring_bits_map(Gtmarksubstring *mark,GtBitsequence *bitsmap) { mark->bits = bitsmap; }
0b979a73e91659642b5dbb195933badfd76fa84b
1ca11b43572673ef6cd82044f761ce386b9eef40
/Assignment 4/Q.7/myheader.h
cebf79f718340bdea8de184f6ff6a1e892622cef
[]
no_license
Maggi87/C-Programming
388646e8a324264bf6a049653160ca164a621448
6a6312d56cb9f1ffff2a098e5b354750148392c9
refs/heads/master
2022-12-21T04:15:25.427261
2018-11-28T13:08:36
2018-11-28T13:08:36
146,735,389
0
1
null
2020-09-28T19:35:38
2018-08-30T10:43:12
C++
UTF-8
C
false
false
544
h
myheader.h
/* 7. Accept one numbers from user and count digits which are greater than 5. START Create one variable as iCounter and set value is zero Iterate till ino is not equal to zero Get separate variable as digit mode the ino by 10 and store reminder into idigit if digit grater equal 5 increament iCounter by one divide ino by ten and store into ino Continue return iCounter STOP */ #include<stdio.h> #define TRUE 0 #define FALSE 1 typedef unsigned int UINT; typedef unsigned long int LONG; UINT DigitX(LONG);
f6bcd61bb6b44e60ea0b4bc2cebe468eaa326bd5
97b7406e329bf68357180683b8ef4d0ea5d587c6
/src/bicycle_model.h
32c5ab16e7fc6c9b1612767229a9b34d4e3d1bcc
[]
no_license
pmusau17/rtreach
858909b164791d4e7849337d4fe1063558bf28a5
9fda73dcc1fb519f66897cf951caf02da894d8cc
refs/heads/master
2022-12-04T00:55:12.590570
2020-08-24T22:33:40
2020-08-24T22:33:40
283,559,280
1
0
null
2020-07-29T17:18:12
2020-07-29T17:18:12
null
UTF-8
C
false
false
423
h
bicycle_model.h
// Patrick Musau // Vehicle Bicycle model header #ifndef BICYCLE_H_ #define BICYCLE_H_ #include "main.h" #include "geometry.h" #include <stdbool.h> // run reachability for a given wall timer (or iterations if negative) bool runReachability_bicycle(REAL* start, REAL simTime, REAL wallTimeMs, REAL startMs,REAL heading, REAL throttle); REAL getSimulatedSafeTime(REAL start[4],REAL heading_input, REAL throttle); #endif
4099e3ea57545d97e31bfa7e780415410ece384b
3fe20c3b004801a2f57134bf6948d67d613d9a7a
/ft_strlen.c
151e05ab54241e12a67dbc6ba86e3a2ea447a547
[]
no_license
elqver/libft
17db688c480b9999296fb047299f5054edf39b50
ba53634e9f10f8c352b0d13c5b297bdf342156fc
refs/heads/master
2023-01-23T00:50:26.240279
2020-12-08T13:17:36
2020-12-08T13:17:36
319,643,399
0
0
null
null
null
null
UTF-8
C
false
false
1,021
c
ft_strlen.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strlen.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: skern <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/10/28 23:20:25 by skern #+# #+# */ /* Updated: 2020/11/02 14:32:33 by skern ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" size_t ft_strlen(const char *s) { size_t res; res = 0; while (s[res] != '\0') res++; return (res); }
4486ac5a03185c8e0f8c456cc1c20daf06e25a71
42aefdefe5bffe92997eb2bc16600939cfefd0d1
/src/utilities/net_addrs.c
78c7ae79b9bc45cf2edb871e7829f1d4350f6208
[]
no_license
frankHe123/av3-fc
5dfd9bca3bc6bed0dcb9a04ae58608d3a0a7f145
0b1452876ee67cbbc5c750f269cf961b2975e643
refs/heads/master
2021-01-23T06:25:31.028176
2017-03-27T18:05:47
2017-03-27T18:05:47
86,366,965
0
0
null
2017-03-27T17:55:25
2017-03-27T17:55:25
null
UTF-8
C
false
false
2,666
c
net_addrs.c
#include "net_addrs.h" /* Redefinition of htons() and htonl() because using the ones in endian.h result in * error: braced-group within expression allowed only inside a function */ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define HTONS(n) __builtin_bswap16(n) #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define htons(n) (n) #endif #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define HTONL(n) __builtin_bswap32(n) #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define htonl(n) (n) #endif /** Set an IP address given by the four byte-parts */ #define IPv4(a,b,c,d) \ HTONL(((uint32_t)((a) & 0xff) << 24) | \ ((uint32_t)((b) & 0xff) << 16) | \ ((uint32_t)((c) & 0xff) << 8) | \ (uint32_t)((d) & 0xff) \ ) /* Returns a pointer to a filled anonymous struct sockaddr_in * suitable for direct use in bind() and connect() */ #define make_addr(addr, port) \ (const struct sockaddr *) &(const struct sockaddr_in){ \ .sin_family = AF_INET, \ .sin_port = HTONS((port)), \ .sin_addr = { (addr) } \ } #ifdef FCF_FC_NETWORK #define RNH_RCI_PORT RCI_PORT #define SENSOR_RCI_PORT RCI_PORT #define GPS_RCI_PORT RCI_PORT #define ROLL_RCI_PORT RCI_PORT #else #define RNH_RCI_PORT 37001 #define SENSOR_RCI_PORT 37002 #define GPS_RCI_PORT 37003 #define ROLL_RCI_PORT 37004 #endif const struct sockaddr * RCI_ADDR = make_addr(FC_IP, RCI_PORT); const struct sockaddr * RNH_RCI_ADDR = make_addr(RNH_IP, RNH_RCI_PORT); const struct sockaddr * SENSOR_RCI_ADDR = make_addr(SENSOR_IP, SENSOR_RCI_PORT); const struct sockaddr * GPS_RCI_ADDR = make_addr(GPS_IP, GPS_RCI_PORT); const struct sockaddr * ROLL_RCI_ADDR = make_addr(ROLL_IP, ROLL_RCI_PORT); const struct sockaddr * RNH_BATTERY_ADDR = make_addr(RNH_IP, RNH_BATTERY); const struct sockaddr * RNH_PORT_ADDR = make_addr(RNH_IP, RNH_PORT); const struct sockaddr * RNH_ALARM_ADDR = make_addr(RNH_IP, RNH_ALARM); const struct sockaddr * RNH_UMBDET_ADDR = make_addr(RNH_IP, RNH_UMBDET); const struct sockaddr * FC_ADDR = make_addr(FC_IP, FC_LISTEN_PORT); const struct sockaddr * ADIS_ADDR = make_addr(SENSOR_IP, ADIS_PORT); const struct sockaddr * MPU_ADDR = make_addr(SENSOR_IP, MPU_PORT); const struct sockaddr * MPL_ADDR = make_addr(SENSOR_IP, MPL_PORT); const struct sockaddr * BMP_ADDR = make_addr(SENSOR_IP, BMP_PORT); const struct sockaddr * ROLL_ADDR = make_addr(ROLL_IP, ROLL_PORT); const struct sockaddr * WIFI_ADDR = make_addr(WIFI_IP, WIFI_PORT); const struct sockaddr * ARM_ADDR = make_addr(ARM_IP, ARM_PORT); const struct sockaddr * RC_SERVO_ENABLE_ADDR = make_addr(ARM_IP, RC_SERVO_ENABLE_PORT); const struct sockaddr * GPS_COTS_ADDR = make_addr(GPS_IP, GPS_COTS);
6cf81664dd3f5a0aafe9f960bba2e0c00002ddf4
3e36c6fa0bfc44896ee5bf3dfa2489a0b02e2fb7
/MeshRefining/MeshRefining/DT_ios_include/iso3d_utility.h
e587903611569b3c2edae27e51a4043622052b01
[]
no_license
whitehorsetzm/mesh_changed
467ff493fbcd7c40b9bb595e9ff691aece6d789b
bea1b7d48d8eba796c15a0f111e4b7c44b13d4bc
refs/heads/master
2020-05-23T00:06:08.415711
2019-07-05T01:53:23
2019-07-05T01:53:23
186,568,953
1
0
null
null
null
null
GB18030
C
false
false
17,878
h
iso3d_utility.h
/* ---------------------------------------------------------------------------- * ---------------------------------------------------------------------------- * * 三维各向同性Delaunay网格生成器 (版本号:0.3) * 3D Isotropic Delaunay Mesh Generation (Version 0.3) * * 陈建军 中国 浙江大学工程与科学计算研究中心 * 版权所有 2005年9月15日 * Chen Jianjun Center for Engineering & Scientific Computation, * Zhejiang University, P. R. China * Copyright reserved, 2005, 10, 26 * * 联系方式 * 电话:+86-571-87953165 * 传真:+86-571-87953167 * 邮箱:zdchenjj@yahoo.com.cn * For further information, please conctact * Tel: +86-571-87953165 * Fax: +86-571-87953167 * Mail: zdchenjj@yahoo.com.cn * * ------------------------------------------------------------------------------ * ------------------------------------------------------------------------------*/ #ifndef __iso3d_utility_h__ #define __iso3d_utility_h__ #include "iso3d_define.h" #include "vector.h" /* ********************************************************** * 单元实体(节点/边/面)的编码/解码 * coding & decoding of elemental entities (nodes/edges/faces) * *********************************************************/ /* * 点码解码 DNC(Decoding Node Codes) * 已知:A点编码nc * 未知:单元的另外3个节点编码ib ic id * 约束: abcd是一个满足右手法则的四面体 * DNC: Decoding Node Codes * Known: nc, code of node A * Unknown: ib, ic, id, codes of three other nodes * s.t.: abcd is a positive tet. */ #define DNC(nc, ia, ib, ic, id) \ ia = (nc); \ switch ((nc)) \ { \ case 0: \ ib = 1; ic = 2; id = 3; \ break; \ case 1: \ ib = 3; ic = 2; id = 0; \ break; \ case 2: \ ib = 0; ic = 1; id = 3; \ break; \ case 3: \ ib = 2; ic = 1; id = 0; \ break; \ } /* * 双点码解码 DDNC(Decoding Double Node Codes) * 已知:C D点编码ic id * 未知:单元的另外2个节点编码ia ib * 约束: abcd是一个满足右手法则的四面体 * DDNC: Decoding Double Node Codes * Known: ic/id, code of node C/D * Unknown: ia/ib, codes of two other nodes * s.t.: abcd is a positive tet. */ #define DDNC(ia, ib, ic, id) \ switch ((ic)) \ { \ case 0: \ switch((id)) \ { \ case 1: \ ia = 2; ib = 3; break; \ case 2: \ ia = 3; ib = 1; break; \ case 3: \ ia = 1; ib = 2; break; \ } \ break; \ case 1: \ switch((id)) \ { \ case 0: \ ia = 3; ib = 2; break; \ case 2: \ ia = 0; ib = 3; break; \ case 3: \ ia = 2; ib = 0; break; \ } \ break; \ case 2: \ switch((id)) \ { \ case 0: \ ia = 1; ib = 3; break; \ case 1: \ ia = 3; ib = 0; break; \ case 3: \ ia = 0; ib = 1; break; \ } \ break; \ case 3: \ switch((id)) \ { \ case 0: \ ia = 2; ib = 1; break; \ case 1: \ ia = 0; ib = 2; break; \ case 2: \ ia = 1; ib = 0; break; \ } \ break; \ } /* * 边码解码 DEC(Decoding Edge Codes) * 已知:边BD码值ib id * 未知:单元的另外2个节点编码ia ic * 约束: abcd是一个满足右手法则的四面体 * DEC: Decoding Edge Codes * Known: ib/id, code of an edge BD * Unknown: ia/ic, codes of two other nodes * s.t.: abcd is a positive tet. */ #define DEC(ec, ia, ib, ic, id) \ switch ((ec)) \ { \ case 0: \ ia = 3; ib = 0; ic = 2; id = 1; \ break; \ case 1: \ ia = 1; ib = 0; ic = 3; id = 2; \ break; \ case 2: \ ia = 2; ib = 0; ic = 1; id = 3; \ break; \ case 3: \ ia = 3; ib = 1; ic = 0; id = 2; \ break; \ case 4: \ ia = 0; ib = 1; ic = 2; id = 3; \ break; \ case 5: \ ia = 1; ib = 2; ic = 0; id = 3; \ break; \ } /* * 双边码解码 DDEC(Decoding Double Edge Codes) * 已知:边码小值&编码大值 miec & maec * 未知:单元的4个节点码值ia ib ic id 两条边排序后的码值 ec1 ec2 两条边的关系 相邻/相对 * 约束: abcd是一个满足右手法则的四面体; 如果是邻边 ec1 = AD ec2 = BD 如果是对边 ec1 = AD ec2 = BC * DDEC: Decoding Double Edge Codes * Known: miec & maec, min. & max edge codes * Unknown: ia, ib, ic, id, codes of four nodes ec1, ec2, codes of two intersection edges sc, relation of two edges, neighboring? opposite? * s.t.: abcd is a positive tet. if two edges neighboring, ec1 = AD ec2 = BD if two edges opposite, ec1 = AD ec2 = BC */ #define DDEC(miec, maec, ia, ib, ic, id, ec1, ec2, sc) \ switch ((miec)) \ { \ case 0: \ switch ((maec)) \ { \ case 1: \ ia = 2; ib = 1; ic = 3, id = 0; ec1 = 1; ec2 = 0; sc = SC_NEIG; break; \ case 2: \ ia = 1; ib = 3; ic = 2, id = 0; ec1 = 0; ec2 = 2; sc = SC_NEIG; break; \ case 3: \ ia = 0; ib = 2; ic = 3, id = 1; ec1 = 0; ec2 = 3; sc = SC_NEIG; break; \ case 4: \ ia = 3; ib = 0; ic = 2, id = 1; ec1 = 4; ec2 = 0; sc = SC_NEIG; break; \ case 5: \ ia = 0; ib = 2; ic = 3, id = 1; ec1 = 0; ec2 = 5; sc = SC_OPPO; break; \ } \ break; \ case 1: \ switch ((maec)) \ { \ case 2: \ ia = 3; ib = 2; ic = 1, id = 0; ec1 = 2; ec2 = 1; sc = SC_NEIG; break; \ case 3: \ ia = 1; ib = 0; ic = 3, id = 2; ec1 = 3; ec2 = 1; sc = SC_NEIG; break; \ case 4: \ ia = 0; ib = 3; ic = 1, id = 2; ec1 = 1; ec2 = 4; sc = SC_OPPO; break; \ case 5: \ ia = 0; ib = 3; ic = 1, id = 2; ec1 = 1; ec2 = 5; sc = SC_NEIG; break; \ } \ break; \ case 2: \ switch ((maec)) \ { \ case 3: \ ia = 0; ib = 1; ic = 2, id = 3; ec1 = 2; ec2 = 3; sc = SC_OPPO; break; \ case 4: \ ia = 0; ib = 1; ic = 2, id = 3; ec1 = 2; ec2 = 4; sc = SC_NEIG; break; \ case 5: \ ia = 2; ib = 0; ic = 1, id = 3; ec1 = 5; ec2 = 2; sc = SC_NEIG; break; \ } \ break; \ case 3: \ switch ((maec)) \ { \ case 4: \ ia = 2; ib = 3; ic = 0, id = 1; ec1 = 3; ec2 = 4; sc = SC_NEIG; break; \ case 5: \ ia = 3; ib = 1; ic = 0, id = 2; ec1 = 5; ec2 = 3; sc = SC_NEIG; break; \ } \ break; \ case 4: \ switch ((maec)) \ { \ case 5: \ ia = 1; ib = 2; ic = 0, id = 3; ec1 = 4; ec2 = 5; sc = SC_NEIG; break; \ } \ break; \ } /* * 面码解码 DFC(Decoding Face Codes) * 已知 面BCD码值fc * 未知:单元4个节点编码ia ib ic id * 约束: abcd是一个满足右手法则的四面体 * DFC: Decoding Face Codes * Known: fc, code of face BCD * Unknown: ia, ib, ic, id, codes of 4 nodes * s.t.: abcd is a positive tet. */ #define DFC(fc, ia, ib, ic, id) \ ia = (fc); \ switch ((fc)) \ { \ case 0: \ ib = 1; ic = 2; id = 3; break; \ case 1: \ ib = 2; ic = 0; id = 3; break; \ case 2: \ ib = 0; ic = 1; id = 3; break; \ case 3: \ ib = 0; ic = 2; id = 1; break; \ } /* * 边面组合码解码 DEFC(Decoding Edge & Face Codes) * 已知 ec 边AD码值 fc 面BCD码值 * 未知:单元4个节点编码ia ib ic id * 约束: abcd是一个满足右手法则的四面体 * DEFC: Decoding Edge & Face Codes * Known: ec, code of edge AD fc, code of face BCD * Unknown: ia, ib, ic, id, codes of 4 nodes * s.t.: abcd is a positive tet. */ #define DEFC(ec, fc, ia, ib, ic, id) \ ia = (fc); \ switch ((fc)) \ { \ case 0: \ switch ((ec)) \ { \ case 0: \ ib = 2; ic = 3; id = 1; break; \ case 1: \ ib = 3; ic = 1; id = 2; break; \ case 2: \ ib = 1; ic = 2; id = 3; break; \ } \ break; \ case 1: \ switch ((ec)) \ { \ case 0: \ ib = 3; ic = 2; id = 0; break; \ case 3: \ ib = 0; ic = 3; id = 2; break; \ case 4: \ ib = 2; ic = 0; id = 3; break; \ } \ break; \ case 2: \ switch ((ec)) \ { \ case 1: \ ib = 1; ic = 3; id = 0; break; \ case 3: \ ib = 3; ic = 0; id = 1; break; \ case 5: \ ib = 0; ic = 1; id = 3; break; \ } \ break; \ case 3: \ switch ((ec)) \ { \ case 2: \ ib = 2; ic = 1; id = 0; break; \ case 4: \ ib = 0; ic = 2; id = 1; break; \ case 5: \ ib = 1; ic = 0; id = 2; break; \ } \ break; \ } /* * 双面组合码解码 DDFC(Decoding Double Face Codes) * 已知 mifc 面ACD码值 mafc 面BCD码值 * 未知:单元4个节点编码ia ib ic id * 约束: abcd是一个满足右手法则的四面体 mifc < mafc * DDFC: Decoding Double Face Codes * Known: mifc, code of face ACD mafc, code of face BCD * Unknown: ia, ib, ic, id, codes of 4 nodes * s.t.: abcd is a positive tet. mifc < mafc */ #define DDFC(mifc, mafc, ia, ib, ic, id) \ ia = (mafc); \ ic = (mifc); \ switch ((mifc)) \ { \ case 0: \ switch ((mafc)) \ { \ case 1: \ ib = 2; id = 3; break; \ case 2: \ ib = 3; id = 1; break; \ case 3: \ ib = 1; id = 2; break; \ } \ break; \ case 1: \ switch ((mafc)) \ { \ case 2: \ ib = 0; id = 3; break; \ case 3: \ ib = 2; id = 0; break; \ } \ break; \ case 2: \ switch ((mafc)) \ { \ case 3: \ ib = 0; id = 1; break; \ } \ break; \ } /* * 从两个端点点码构建编码值 * CEC: Construct Edge Codes from codes of two end nodes */ #define CEC(mie, mae, ec) \ if ((mie) == 0) \ ec = (mie) + (mae) - 1; \ else \ ec = (mie) + (mae); /* * 解码编码,获取两个端点的点码n1 n2 * DECON: Decoding Edge Codes to Obtain Nodes */ #define DECON(ec, n1, n2) \ switch ((ec)) \ { \ case 0: \ n1 = 0; n2 = 1; break; \ case 1: \ n1 = 0; n2 = 2; break; \ case 2: \ n1 = 0; n2 = 3; break; \ case 3: \ n1 = 1; n2 = 2; break; \ case 4: \ n1 = 1; n2 = 3; break; \ case 5: \ n1 = 2; n2 = 3; break; \ } /* * 假设i1, i2, i3, i4是一个四面体单元的四个节点的码值, * i2->i3->i4是一个表面面片, i1->i2->i3->i4是一个正体积四面体, * 由i1, i2, i3, i4的值推断四面体在区域外还是区域内部 * 如果宏_FAC_RIG_INNER则表明面片的右手法向指向区域外部,否则,指向区域内部 * i1, i2, i3 and i4 are codes of four nodes of a tet., * i2->i3->i4 is a facet, i1->i2->i3->i4 is a tet. with positive volume, * If the values of i1, i2, i3, i4 are given, flag the element as outer or inner the domain * Notice: * if macro _FAC_RIG_INNER is defined, normal based on the right-hand rule of facet i2->i3->i4 * directs inside; otherwise, it directs outside */ #ifdef _FAC_RIG_INNER #define FLAGE(i1, i2, i3, i4, flag) \ flag = OUTER; \ switch ((i1)) \ { \ case 0: \ if (((i2) == 1 && (i3) == 3 && (i4) == 2) || \ ((i2) == 2 && (i3) == 1 && (i4) == 3) || \ ((i2) == 3 && (i3) == 2 && (i4) == 1)) \ flag = INNER; \ break; \ case 1: \ if (((i2) == 2 && (i3) == 3 && (i4) == 0) || \ ((i2) == 0 && (i3) == 2 && (i4) == 3) || \ ((i2) == 3 && (i3) == 0 && (i4) == 2)) \ flag = INNER; \ break; \ case 2: \ if (((i2) == 0 && (i3) == 3 && (i4) == 1) || \ ((i2) == 1 && (i3) == 0 && (i4) == 3) || \ ((i2) == 3 && (i3) == 1 && (i4) == 0)) \ flag = INNER; \ break; \ case 3: \ if (((i2) == 2 && (i3) == 0 && (i4) == 1) || \ ((i2) == 1 && (i3) == 2 && (i4) == 0) || \ ((i2) == 0 && (i3) == 1 && (i4) == 2)) \ flag = INNER; \ break; \ } #else #define FLAGE(i1, i2, i3, i4, flag) \ flag = INNER; \ switch ((i1)) \ { \ case 0: \ if (((i2) == 1 && (i3) == 3 && (i4) == 2) || \ ((i2) == 2 && (i3) == 1 && (i4) == 3) || \ ((i2) == 3 && (i3) == 2 && (i4) == 1)) \ flag = OUTER; \ break; \ case 1: \ if (((i2) == 2 && (i3) == 3 && (i4) == 0) || \ ((i2) == 0 && (i3) == 2 && (i4) == 3) || \ ((i2) == 3 && (i3) == 0 && (i4) == 2)) \ flag = OUTER; \ break; \ case 2: \ if (((i2) == 0 && (i3) == 3 && (i4) == 1) || \ ((i2) == 1 && (i3) == 0 && (i4) == 3) || \ ((i2) == 3 && (i3) == 1 && (i4) == 0)) \ flag = OUTER; \ break; \ case 3: \ if (((i2) == 2 && (i3) == 0 && (i4) == 1) || \ ((i2) == 1 && (i3) == 2 && (i4) == 0) || \ ((i2) == 0 && (i3) == 1 && (i4) == 2)) \ flag = OUTER; \ break; \ } #endif /*_FAC_RIG_INNER*/ /* * 假设i1, i2, i3, i4是一个四面体单元的四个节点的码值, * i2->i3->i4是一个表面面片, i1->i2->i3->i4是一个正体积四面体, * 由i1, i2, i3, i4的值推断四面体在区域外还是区域内部 * 如果宏_FAC_RIG_INNER则表明面片的右手法向指向区域外部,否则,指向区域内部 * i1, i2, i3 and i4 are codes of four nodes of a tet., * i2->i3->i4 is a facet, i1->i2->i3->i4 is a tet. with positive volume, * If the values of i1, i2, i3, i4 are given, flag the element as outer or inner the domain * Notice: * if macro _FAC_RIG_INNER is defined, normal based on the right-hand rule of facet i2->i3->i4 * directs inside; otherwise, it directs outside */ #define ELEM_ORIENTATION(i1, i2, i3, i4, ort) \ ort = 1; \ switch ((i1)) \ { \ case 0: \ if (((i2) == 1 && (i3) == 3 && (i4) == 2) || \ ((i2) == 2 && (i3) == 1 && (i4) == 3) || \ ((i2) == 3 && (i3) == 2 && (i4) == 1)) \ ort = 0; \ break; \ case 1: \ if (((i2) == 2 && (i3) == 3 && (i4) == 0) || \ ((i2) == 0 && (i3) == 2 && (i4) == 3) || \ ((i2) == 3 && (i3) == 0 && (i4) == 2)) \ ort = 0; \ break; \ case 2: \ if (((i2) == 0 && (i3) == 3 && (i4) == 1) || \ ((i2) == 1 && (i3) == 0 && (i4) == 3) || \ ((i2) == 3 && (i3) == 1 && (i4) == 0)) \ ort = 0; \ break; \ case 3: \ if (((i2) == 2 && (i3) == 0 && (i4) == 1) || \ ((i2) == 1 && (i3) == 2 && (i4) == 0) || \ ((i2) == 0 && (i3) == 1 && (i4) == 2)) \ ort = 0; \ break; \ } /* * 两点距离平方 * square of distance between two points */ REAL squaDist(MYPOINT p1, MYPOINT p2); /* * 三点面积绝对值 * absolute value of area of a triangle */ REAL areas(REAL xa, REAL ya, REAL za, REAL xb, REAL yb, REAL zb, REAL xc, REAL yc, REAL zc); /* * 表面右手法向量 * normal of a face based on the right-hand rule */ int facNorm(MYPOINT p1, MYPOINT p2, MYPOINT p3, VECTOR norm); /* * 单位化向量 * normalize a vector */ int normVect(VECTOR v); /* * 向量叉乘 * cross operation of two vectors */ int crossVect(VECTOR v1, VECTOR v2, VECTOR *v); /* v = v1^v2 */ /* * 比较两个向量的方向 compare directions of two vectors * -1 未知 undefined * 0 反向 of same directions * 1 同向 of opposite directions */ int compVectDir(VECTOR v1, VECTOR v2); /* * 获取将给定向量变换为Z轴(0,0,1)所需的变换矩阵(4×4) * get the transform matrix to convert vector v to (0, 0, 1) (Z axis) */ int vectorToZ(Vector n, double m[16]); /* * p4点对三角面p1p2p3是否可视,即p1p2p3p4的体积是否为正 * check if p4 is visible to p1p2p3, i.e. the volume of p1p2p3p4 is positive */ bool isVisible(MYPOINT p1, MYPOINT p2, MYPOINT p3, MYPOINT p4); /* * ia ib ic id 是四面体单元的四个点的点码值,判断四面体单元 * A->B->C->D是否有体积(volume-positive) * ia, ib, ic and id are four node codes of four forming points of Tetrahedra * ABCD, judge if the volume of ABCD is positive */ bool isVolumePositive(int ia, int ib, int ic, int id); int generateRandArray(int *arr, int maxValue); #endif /* __iso3d_utility_h__ */
4575ba0f4eecc08dac964b330379fe84b1220b82
a227f35c891adde7866156ddc2c70c19b70ce501
/Projects/Kernel/Arch/i386/multiboot.h
e2e9f72848cb138031823676dc6b74a582a10324
[ "MIT" ]
permissive
gaze/Vanguard
76e49f74d363ad8f34cae4ae23657fd36b06af1c
237e91c2aba3480c6b1e847278709527fe559b0f
refs/heads/master
2016-09-05T18:23:20.706986
2010-05-09T20:11:07
2010-05-09T20:11:07
null
0
0
null
null
null
null
UTF-8
C
false
false
2,090
h
multiboot.h
/* multiboot.h - multiboot header file with grub definitions. */ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 2003,2007,2008 Free Software Foundation, Inc. * * GRUB 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 3 of the License, or * (at your option) any later version. * * GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>. */ #ifndef GRUB_MULTIBOOT_HEADER #define GRUB_MULTIBOOT_HEADER 1 #include <OS/Types.h> struct grub_multiboot_info { /* Multiboot info version number */ u32 flags; /* Available memory from BIOS */ u32 mem_lower; u32 mem_upper; /* "root" partition */ u32 boot_device; /* Kernel command line */ u32 cmdline; /* Boot-Module list */ u32 mods_count; u32 mods_addr; u32 syms[4]; /* Memory Mapping buffer */ u32 mmap_length; u32 mmap_addr; /* Drive Info buffer */ u32 drives_length; u32 drives_addr; /* ROM configuration table */ u32 config_table; /* Boot Loader Name */ u32 boot_loader_name; /* APM table */ u32 apm_table; /* Video */ u32 vbe_control_info; u32 vbe_mode_info; u16 vbe_mode; u16 vbe_interface_seg; u16 vbe_interface_off; u16 vbe_interface_len; }; struct grub_multiboot_mmap_entry { u32 size; u64 addr; u64 len; #define GRUB_MULTIBOOT_MEMORY_AVAILABLE 1 #define GRUB_MULTIBOOT_MEMORY_RESERVED 2 u32 type; } __attribute__((packed)); struct grub_mod_list { /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ u32 mod_start; u32 mod_end; /* Module command line */ u32 cmdline; /* padding to take it to 16 bytes (must be zero) */ u32 pad; }; #endif
82946203ab249f8a516d2648b6125f026ad99e09
6d62128e46aaa09b13a0eade1a9588dd1cda29e8
/CPP_LIBRARYv03/PEAK_DETECTION/FT/MS2Level/include/MS2_FT_PEAK_DETECTION_USE.h
d9d7fa1bea72d4ff832f98be6112b4a4a2759f00
[]
no_license
mergipe/SuperHirn
ca40e421e1df790790a415e26e14707b49c56f7b
a10b8e954cdeaf458557b67f514d6e99881a2007
refs/heads/master
2021-08-20T01:38:16.410518
2020-06-16T00:08:36
2020-06-16T00:08:36
194,906,939
1
1
null
null
null
null
UTF-8
C
false
false
2,353
h
MS2_FT_PEAK_DETECTION_USE.h
/////////////////////////////////////////////////////////////////////////// // // written by Lukas N Mueller, 20.4.05 // Lukas.Mueller@imsb.biol.ethz.ch // Group of Prof. Ruedi Aebersold, IMSB, ETH Hoenggerberg, Zurich // // // **********************************************************************// // PARSER OF INTERACT FILE AND FOLLOWING EXTARCTION FROM mzXML // // // **********************************************************************// #ifndef __MS2_FT_PEAK_DETECTION_USE_H__ #define __MS2_FT_PEAK_DETECTION_USE_H__ /////////////////////////////////////////////////////////////////////////// // GLOBAL DEFINED VARIABLES: #define NOT_USED -1 /////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////// // interface objects to the // FT PEAK DETECTION PROGRAM #ifdef USE_ALL_MS2_FT_PEAK_DETECTION_CLASSES #define USE_MS2_PROCESS_DATA #define USE_MS2_FRAGMENT_TRACE #define USE_ALL_MS1_FT_PEAK_DETECTION_CLASSES #endif #ifdef USE_MS2_PROCESS_DATA #define USE_MS2_FRAGMENT_TRACE #define USE_MS2_SPECTRUM_PROCESSOR #define USE_ALL_MS1_FT_PEAK_DETECTION_CLASSES #define INCLUDE_MS2_PROCESS_DATA #endif #ifdef USE_MS2_SPECTRUM_PROCESSOR #define USE_MS2_FRAGMENT_TRACE #define USE_ALL_MS1_FT_PEAK_DETECTION_CLASSES #define INCLUDE_MS2_SPECTRUM_PROCESSOR #endif #ifdef USE_MS2_FRAGMENT_TRACE #define USE_ALL_MS1_FT_PEAK_DETECTION_CLASSES #define INCLUDE_MS2_FRAGMENT_TRACE #endif ////////////////////////////////////////////////// // reference to the general class library!!!! #ifdef USE_ALL_MS1_FT_PEAK_DETECTION_CLASSES #define INCLUDE_ALL_MS1_FT_PEAK_DETECTION_CLASSES #endif ////////////////////////////////////////////////// ////////////////////////////////////////////////// // reference to the general class library!!!! #ifdef INCLUDE_ALL_MS1_FT_PEAK_DETECTION_CLASSES #define USE_ALL_MS1_FT_PEAK_DETECTION_CLASSES #include "MS1_FT_PEAK_DETECTION_USE.h" #endif ////////////////////////////////////////////////// //////////////////////////////////////////////////// // interface objects to the // FT PEAK DETECTION PROGRAM #ifdef INCLUDE_MS2_FRAGMENT_TRACE #include "MS2FragmentTrace.h" #endif #ifdef INCLUDE_MS2_SPECTRUM_PROCESSOR #include "MS2SpectrumProcessor.h" #endif #ifdef INCLUDE_MS2_PROCESS_DATA #include "MS2_Process_Data.h" #endif #endif